WorksheetsPython Basics 2
Total questions: 36
Worksheet time: 18mins
Integers in Python are designated
the full word integer
num
number
int
Float in Python is designated
The full word float
number
num
flt
Integers are ____________ and floats are _____________
whole numbers and exponents
powers and fractions
fractions and whole numbers
whole numbers and decimal numbers
Which of the following is NOT an example of a float?
7.3
10.0
2.0e2
134
In the following, type(5) , what is (5) called a(n)
statement
variable
argument
opening argument
If you entered type(7.5) the answer output would be
7.5
integer
float
decimal
Using type ahead of a number argument () tells you
whether the number is a float or an integer
what the output will be if you enter an argument
whatever is inside the ()
what type variable you have entered
What is the result in Python when you use the / (division) operation?
A fraction will result no matter what the input
An integer will result no matter what the input
A float will result no matter what the input
Scientific notation will result no matter what the input
Use // in order to yield
A float when doing division with floats
An integer when doing division with integers
A float when doing division with integers
An Integer when doing division with floats
When you use the division operation with 10/3 and you want the remainder, you would use
the symbols //
the symbol /
the symbol /r
the symbol %
When you enter multiple number and operations in one line, Python will
perform operations left to right
perform operations right to left
perform addition and subtraction first
perform order of operations according to PEMDAS
If you wanted to override the automatic application of PEMDAS to your entry of multiple numbers and operations
use {} around all multiplication of division
insert ( ) to prioritize order according to desired order
use [] around any exponents
use [] around all multiplication and division
Which of the following is NOT best practices when designating a variable? in Python
The variable can be a word or words
The variable can be more than one word
Use _ underscore between multiple words
Variables CANNOT be recalled and modified
Create an understandable, relevant name
Once you create the variable age = 18, age operates as a value. If you entered age + 3, it would yield
3
21
ERROR
age
Once you change a variable, such as age = 5, and then enter age + 5, the variable ____________ and when you enter print (age) it would yield __________
remains the same, 5
remains the same, 15
is changed, 10
is changed, 5
Examples of operations where you could use a shortcut to change the variable definition age = 18 (choose all correct answers)
age -= 3 would subtract 3 from 18
age += 3 would add 3 to 18
age *= 3 would multiply 18 by 3
age **= would cube 18
Recall the operation of division using / will return a float whether working with floats or integers. Using // tells Python if there is an integer to yield an integer. However, using // in the shortcut //= with an integer does NOT yield an integer
True
False
Which of the following are Boolean operations in Python (choose all correct answers)
AND
IF
THAN
OR
NOT
NOT is used
if both operands are not true
if any of the operands are true
if any of two operands are not zero
to reverse the logical state of the operand
Which of the following are built in data types in Python
dict
set
tuple
list
all of the above
Which of the following has the most functionality of all of the built in data types in Python
dicts
lists
sets
tuples
Which of the following built in data types is unordered collections of values with no duplicates?
dicts
lists
sets
tuples
When creating a variable list in Python
the comma should be placed before the second/closing ' between list items
the comma should be placed before the first/opening ' in the list item
the comma should be placed after the first/opening ' in the list item
the comma should be placed after the second/closing ' in the list item
Lists use which symbol in Python?
{}
[]
()
||
Sets use which symbol in Python?
||
{}
[]
()
Tuples use which symbol in Python
()
{}
[]
||
An index always begins with
1
i
a
0
The last item in an index will always be
z
aa
2
-1
With regard to an index designation, ___________ is the first location, and the final location is “not including”
length
list
range
set
Remove is used to
remove an entry from a list
delete the contents of a list
remove an entry from a set
delete the contents of a tuple
Append
will remove an entry in a list
will removed an entry from a set
will add an entry to a set
will add an entry to a list
When working with a list, pop will
pop an entry where you have your cursor
remove the first entry in the list
remove the last entry from the list
remove an entry from a set
If you use pop successively on a list
you will get an error message
it will put the entries in a new file
it will eventually remove all items from the list
it will put entries in a set that cannot be changed
What does len tell you when placed in front of your named list?
how many characters are on the line including symbols
how many alpha characters on on the line
how many total list items there are
the length of the name of the list
A list is ____________ a tuple is ____________.
mutable (can be changed once created), immutable (cannot be changed once created)
immutable (can be changed once created), mutable (cannot be changed once created)
Which of the following is NOT true about sets?
Are optimized for testing if a value is a "member"
Are optimized for testing if a value is shared or not shared with another set
Do not contain duplicates
Are in no certain order
Are in alpha numeric order
