Python + Flashcards
(203 cards)
Use _________ to determine which operations are performed first
Parenthesis
Computers can’t store ______ completely accurately, which can lead to bugs.
Floats
How do you include a character that can’t be directly included in a string? Ex: a double quote
Use a backslash
How do you prompt the user for input?
input(‘prompt’)
User input is automatically returned as a ______. (With the contents automatically escaped.)
String
As with integers and floats, _______ in Python can be added, using a process called __________.
strings, concatenation
To add a string that contains a number to an integer you must first __________________.
Convert the string to an integer
You can multiply a string by a float. (T or F)
False
what is the output of this code:
print(3 * ‘7’)
777
How do you convert the string “83” into the integer 83?
int(“83”)
How do you convert the integer 7 into the float 7.0?
float(7)
What is the output of this code and why? \n\n\nint(‘6’+’3’)
63 , because the operation inside the parenthesis is done first and while ‘6’ and ‘3’ are inside the parenthesis they are strings so their sum is ‘63’, which is THEN converted into the integer 63
How do you convert user input (which is automatically a string) into an integer?
int(input(“prompt:”))
Variables can be reassigned as many times as you want. (T or F)
True
You can assign a variable to an integer and then later assign that same variable to a string. (T or F)
True
The only characters allowed in a variable name are:
Letters, Numbers, Underscores
is 13_Hab an acceptable variable name?
No, variable names cannot begin with numbers
Variable names are _____ sensitive.
case
How do you delete a variable?
del variable name
You can also take the value of the variable from user input. (T or F)
True
In–place operators allow you to write code like \n’x = x + 3’ more concisely, as:
x + = 3
What is the output of this code?
x = 3
num = 17
print(num % x)
2 (remainder)
What is the Boolean equal operator in python?
==
What is this Boolean operator? !=
Not equal to