1/115
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
Text within quotes ““ is known as a?
string
Can strings contain letters, numbers and symbols
Yes
What is the syntax for a newline command?
\n
What is an escape sequence?
Starts with a backslash ex: \\, \t and \n
what does an “=” sign indicate?
Assignment operator
What is an object within parentheses known as?
Arguments
What does the argument end=”” do?
2+ statements in the same string can be put on different lines
What does the float operator do?
represents numbers with decimal components
operations such as +=, -=, /= and *= are used for?
Incrementing
When you perform a math operation with 2 integer values, what data type will your answer be in?
Integer
When you perform a math operation with one integer value and one float value, what data type will your answer be in?
float
Dividing integers gives you which data type as a quotient?
float
What does the % do?
Modulus gives you the remainder after a number is divided
What is // for?
Floor division. Number of times reciprocal can go into divisor
is random.randrange(x,y) inclusive of both x and y?
Only inclusive of x
is random.randint(x,y) inclusive of both x and y?
Yes
How many pathways does 1 bit have?
2
How many pathways does 1 byte (8 bits) have?
256
What are the 3 defining properties of each object in python?
value, type, identification
How do you write 2×10^6 in python?
2.0e6
How do you represent place value after the decimal?
:.xf with x representing the number of digits after the decimal
How do you represent place value before a decimal?
:0xf with x representing the number of digits before the decimal
What is the order of precedence for basic math operators? ( /, *, +, - , etc)
() - parentheses → ** - exponents → - urnary → % * / → + and -
If two operators of equal precedence are included in an equation, (ex: / and *), how do we determine which goes first
Operation is done from left to right
What does the r before a string indicate?
Raw string. All commands such as \n are void and will be displayed as regular text in the string
What is concatenation?
Adding to the very end of an existing list
What is an element?
A value within a list
What is an index?
An integer that specifies the position of an element within a list
What is a list?
mutable ordered collection of items
What does the .pop() function do?
removes the element at specified index
What does the .remove() function do?
removes the first element whose value matches the value specified in your argument
what does the .append() function do?
Adds to end of a list
What does the min() function do?
Finds the smallest value in a list
What does the max() function do?
Finds the largest value in a list
what does the sum() function do?
Finds the sum of all numbers in a list
What is a tuple?
immutable storage of data
What does a dictionary do?
Associates keys with values
What is a key in a dictionary?
term that is located within dictionary
What is a value in a dictionary?
a value that is associated with a key
What type of brackets do tuples use?
Curly brackets { }
What type of brackets do dictionaries use?
parentheses ( )
What type of brackets do lists use?
Square brackets [ ]
What is the command used to delete something in a dictionary?
del dict[k]
What is the order of precedence between basic math operations, greater/less than, not and & or operators?
() → * / % → + - → < <= > >= == != → not → and → or
The built-in Python function that gives an object's identity is:
id()
Assigning a value to a floating point variable that is too large for the computer to represent is a condition called _____ .
overflow
A language is called _____ when upper case letters in identifiers are considered different from lower case letters.
case sensitive
_____ is the process where objects that are no longer needed are deleted.
Garbage collection
Which floating-point literal correctly represents the scientific notation value: 2.3 x 10^7?
2.3e7
What is the value of the name built-in variable in a module that is executed as a script by the programmer?
__main__
The operator *= is called a(n) _____ operator.
compound
Which statement changes the value associated with key "Lemon" to 0.75 in the dictionary fruits_dict?
fruits_dict["Lemon"] = 0.75
Which expression calculates the average of first_num and second_num?
first_num = input('Enter the first number: ')
second_num = input('Enter the second number: ')
(float(first_num) + float(second_num)) / 2
Which of the following expressions causes an implicit conversion between types? Assume variable x is an integer, t is a float, and name is a string.
7.5 + (x / 2)
What is the value of: 1 + int(3.5) / 2?
2.5
Which of the following statements produces an error? Assume string_1 = 'abc' and string_2 = '123'.
string_1[1] = 'B'
Given x = 1, y = 2, and z = 3, how is the expression evaluated? In the choices, items in parentheses are evaluated first.
(x 5) or (y 2) and (z == 5)
False OR (True AND False) --> False OR False --> False
Grover Cleveland served as president of the United States from 1885 to 1889 and from 1893 to 1897. Which expression correctly detects this range?
(1885 <= x <= 1889) or (1893 <= x <= 1897)
Given year is positive, which expressions for XXX, YYY, and ZZZ will output the correct range? Choices are in the form XXX / YYY / ZZZ.
if XXX: Output "1-100"
elif YYY: Output "101-200"
elif ZZZ: Output "201-300"
else: Output "Other"
year < 101 / year < 201 / year < 301
For what values of integer x will Branch 3 execute?
if x < 10 : Branch 1
elif x > 9: Branch 2
else: Branch 3
For no values (never executes)
Which operator is evaluated last in an expression?
or
What is the final value of z?
grades = { 'A': 90, 'B': 80, 'C': 70, 'D': 60 }
my_grade = 70
if my_grade not in grades:
z = 1
else:
z = 2
if 'F' in grades:
z = z + 10
else:
z = z + 20
21
What is wrong with the badly formatted code?
x = input()
if x == 'a':
print('first')
print('second')
The first print() statement must be indented.
What sequence will range(9) give you?
all non-negative integers less than 9 (0-8)
What will the range(X, Y) give you?
All integers >=X and <Y
What will the range(X,Y,Z) give you?
All integers >=X to <Y and incrementing by Z
For the following loop, how many times will the inner loop body execute?
for i in range(2):
for j in range(3): # Inner loop body
6
What is a function with no return statement called?
Void function
What is the word for a function’s behavior of adding together different data types
ex: (‘x’ * 5)
polymorphism
What is Modular Development
dividing a program into separate modules that can be integrated into a single program
def ‘calc_pizza_area():’ is an example of a
function definition
What is a parameter?
function input specified in a function definition
What is an argument?
value provided to a parameter
What are local variables?
variables defined within a function definition
What is a global variable?
A variable defined outside of a function
What data types are immutable?
Strings, integers
What is a keyword argument?
allows argument to map parameters by nam
What does the parameter have in this function definition?
def print_date(day, month, year, style=0):
Default parameter
How can you create a docstring in your code?
by using “““ or ‘‘‘ before and after your text
What is a docstring
a multi-line comment
What does the help() function do?
providing all the docstrings for the intended function, providing a programmer with information on how to call the function
What is the alignment character I use to make my text centre-aligned?
^
What is the alignment character I use to make my text left-aligned?
<
What is the alignment character I use to make my text right-aligned?
>
f"{'Bob':_>5}"What does this code output?
__Bob
using the following string, how can you replace ‘one’ with ‘four’?
phrase = “I want one banana”
phrase.replace(one, four)
How can you use the replace method to replace all instances of a word in a string?
var.replace(old,new) with old being the word you want replaced and new being the word you replaced it with
How can you replace only x occurrences of a word in a string?
.replace(old,new,x)
What method finds the position of where a character is located in a string?
.find(x)
How can find the position of where a character is located in a string if I want to start from the reverse of a string?
.rfind(x)
What method is used to find the number of times x occurs in a string?
.count(x)
Which method returns True if all characters in the string are lowercase or uppercase letters, or the numbers 0-9?
.isalnum()
Which method returns True if all characters are the numbers 0-9?
.isdigit()
Which method returns True if all cased characters are lowercase letters?
.islower()
Which method eturns True if all cased characters are uppercase letters?
.isupper()
Which method returns True if all characters are whitespace?
.isspace()
Which method returns true if the string starts with x
.startswith(x)
Which method returns a copy of the string with only the first letter capitalized?
.capitalize()
Which method returns a copy of a string with all characters lowercased?
.lower()
Which method returns a copy of the string with all characters in uppercase?
.upper()