Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Python Final Exam (questions with complete solutions) 12, Exams of Nursing

Python Final Exam (questions with complete solutions) 12

Typology: Exams

2023/2024

Available from 10/17/2024

studyclass
studyclass 🇺🇸

1.8K documents

1 / 12

Toggle sidebar

Related documents


Partial preview of the text

Download Python Final Exam (questions with complete solutions) 12 and more Exams Nursing in PDF only on Docsity! Python Final Exam (questions with complete solutions) 12 If I wanted to take a number, say 5, and assign it to a Variable, let's say the letter y, how would I code that? - correct answer ✔✔y = 5 How would I print out the variable y? - correct answer ✔✔print(y) A best practice is to assign variable names that have some sort of meaning - correct answer ✔✔True What would the following code print? print('don't skip the coffee') - correct answer ✔✔SyntaxError: invalid syntax Python understands order of operations but you need to be careful to use python operators. For example, (3+4)2 does not work. (3+4)*2 does work. What are some of the operators we covered? - correct answer ✔✔+ is addition * is multiplication / is division % is modulus The following 4 questions all have a snippet of code, and a comment. The comment following the code in the questions below makes a statement. Which of these statements is correct? - correct answer ✔✔The following is a correct comment: 1 + 1 # evaluates to 2 The following is not a correct comment: 1 + 1 # evaluates to 3 True + 100 #evaluates to 101 - correct answer ✔✔Correct 1 + 1(7) # evaluates to 8 - correct answer ✔✔False print_twice('Hello") #evaluates to 'Hello Hello" - correct answer ✔✔Incorrect The below code is what you see when you open a notebook. if x < 0: print('x is negative') What prints when that notebook cell is run? - correct answer ✔✔an error The below code is what you see when you open a notebook. 'what subset?' [1:2] What prints when that notebook cell is run? - correct answer ✔✔h Complete the following if statement so that when you run it prints "x is even" x = 10 What is the output of the following code? x = 0 while x < 5: x += 1 if x == 3: continue print(x) - correct answer ✔✔1 2 4 5 Within a for loop, which line of code would you use to increase the variable called 'count' within the loop by 2? None of these answers are correct add(count, '2') + '2' count count + '2' number = count + '2' - correct answer ✔✔none of these answers are correct Print statement operator value - correct answer ✔✔An instruction that causes Python interrupter to display a value on the screen A special symbol that represents a simple computation like addition, multiplication, or string concatenation One of the basic units of date like a number or string, that a program manipulates Syntax String Floating-point - correct answer ✔✔The rules that govern the structure of a program A type that represents sequences of characters A type that represents numbers with fractional High-level language Low-level language interpreter - correct answer ✔✔A programming language like Python that is designed to be easy for humans to read and write. A programming language that is designed to be easy for a computer to run; also called "machine language" or "assembly" What is the single most important skill for a computer scientist? - correct answer ✔✔Problem solving What is one of the challenges of getting started with Python? - correct answer ✔✔Installing Python and related software on your computer What are some basic instructions found in most programming languages? - correct answer ✔✔Input What is a program? - correct answer ✔✔A sequence of instructions that specifies how to perform a computation What is a statement in Python? - correct answer ✔✔A unit of code that performs a specific task How is a new variable created in Python? - correct answer ✔✔By using an assignment statment What is a variable? - correct answer ✔✔A name that refers to a value What is an example of a statement in Python? - correct answer ✔✔print('Hello World') What is an if statement used for? - correct answer ✔✔To check a condition, and if the condition is true, a block of code is executed If you used the below range in a for loop and printed every step of the loop, What would the output look like? range(20,0,-10) - correct answer ✔✔20 10 There are several people stuck in Meta's metaverse. The bizarre nature of the metaverse has left them stacked in a pyramid. No one is sure why. But you've decided to calculate just how many people are stacked in the pyramid. You've decided to use a for loop to do the counting. Again...no one is really sure why. What is the MISSING row in the Middle of the for loop? total=0 for metas in range (1,5): MISSING print(total) - correct answer ✔✔total += metas (1) .loc[] is primarily label bsed, but may also be used with a boolean array. (2) using pandas.DataFrame.dypes returns the dtypes in the DataFrame... (3) pandas.DataFrame.to_sql will write records stored in a DataFrame to a SQL Database. The parameter "schema" Specify the schema (if tdatabase flavor supports this). - correct answer ✔✔(1) Boolean Array (2) dtypes (3) Specify the schema (if database flavor supports this). Both pandas and numpy have a 'where' method. It is important if you have both loaded to be clear which 'where' you want. example: np.where() pd.where() - correct answer ✔✔True Spyder is a way of running Python code. It is not found in the Anaconda distribution, and needs to be uploaded separately from the Spyder website. - correct answer ✔✔False Visual Studio code is a way of running python code. It is actually useful for many programming languages. - correct answer ✔✔True Spyder files are all saved as .ipynb as the default. - correct answer ✔✔False. The default is .py np.select allows us to create conditional columns. So for example, I could create a few different conditions and use np.select to create new columns based on those conditions. - correct answer ✔✔True The output of df at the end should indicate that trucks of size .5 can "Tow a little" and trucks of size .75 can "Tow a lot", and others care are not trucks. The code is missing 2 words... add those two words to the spaces available below. - correct answer ✔✔Condition selection When first exploring the "sat.csv" data, what (if anything) do you notice that may indicate a data quality problem in one or more columns? - correct answer ✔✔distance_to_store has unexplainable values If I have a single variable (the number 1.4 for example saved as 'x') which method below will help me understand the variable type? - correct answer ✔✔print(type(x)) What is the mean of the following factors in the sat data set? HOW TO CALCULATE MEAN (MIN, MAX, SD, COUNT, ETC) import pandas as pd so = pd.read_csv("sat.csv") so so.describe(include = 'all') - correct answer ✔✔age = 35 distance_to_store = 14 store_spend = 49 sat_price = 2.3 You decide there is MORE information our there in the world that you can join to your sat database. So you write some nifty code to join it... Which of the following datasets makes the most sense to join this one? information about each dataset is given: name_of_dataset{s=field1_name; field2_name ; field3_name ; ...etc) - correct answer ✔✔Customer Complaints {date of complaint; type of complaint; cust_ID}