What character is used for division?
A slash (/)
What variable type stores letters, numbers, and symbols?
Strings
To make a comment in Python, what character(s) would you use?
A pound sign (##) at the beginning
Which command will display the text 'Hello world!' on the screen?
A) print(Hello world!)
B) print("Hello world!")
C) print "Hello world!"
D) print = "Hello world!"
B) print("Hello world!")
What data type is 3.95?
Float
What operator is used for multiplication?
What variable type stores decimal numbers?
Floats
What is an error based off a typo?
Syntax error (essentially a grammatical error)
Which command will correctly ask the user for their age?
A) age = input(How old are you?)
B) input("How old are you?") = age
C) How old are you = input()
D) age = input("How old are you?")
D) age = input("How old are you?")
What does input do?
A) It allows users to change the program
B) It allows a user to solve a task
C) It converts data types
D) It allows users to enter data
D) It allows users to enter data
To raise a number to a power (ex: Xy), what symbol would you use? (This is the power operator)
Two asterisks (**)
What function allows user input text to be assigned a variable?
input()
Ex: example_input()
What is the difference between the = and == operators?
= is to assign a value to a variable
== is used to compare the value of two variables
In the following example, Is myName a string, a function, a variable, or a method?
myName = input()
Variable
What would happen in the following: number = int('5.0')
a. Converts to integer, becoming 5
b. Keeps as a string
c. Gets an error
c. Gets an error
If multiple calculations must be made, what order does Python use?
PEMDAS
Data stored as a string is surrounded by what?
Quotes ("")
What are the four main types of data types?
- Strings (str)
- Integers (int)
- Floats (float)
- Boolean (true/false)
What is the result of this command? print ("5" + "3")
A) 8
B) "8"
C) "5" + "3"
D) 53
D) 53
Which of these codes tests whether the variable x is the same as 'Hello'?
A) x = "Hello"
B) x == "Hello"
C) x != "Hello"
D) x <> "Hello"
B) x == "Hello"
Denoted as '%', this operator returns the remainder of a division operation. What is the name of this operator?
Modulus
After creating a function and writing all the code, what must be done for the function to run in Python?
You must call the function
Ex:
def SI_is_bussing()
Code
More code
SI_is_bussing()
To specify a variable type, what would you use to denote integers, floats, and strings?
int()
float()
str()
The following code would not run. What is wrong with it, and how can it be fixed?
name = "Bob"
print(Name)
"Name" is supposed to print, but there's no variable "Name". It needs to be uncapitalized as "name" for it to print "Bob".
What would the output of this program be?
number1=3
number2=7
number3=5
print(number1+number2*number3)
38