Float Divisions So 10/5 Is A Float or 2.0
Float Divisions So 10/5 Is A Float or 2.0
QUESTI ON 1
1. a, b = 10,5
2. c = a/b
What is the value assigned to variable ‘c’ after executing the code?
0. ‘2’
0. 2
0. 2.0
0. 5
0. None of the answers above are correct
QUESTION 2
QUESTION 3
a = 50
b = ‘10’ 2 values in the string (1 and 0) ‘ ‘ means string
c = a // len(b) 50//2
for I in range (2) ← the 2 means you have to loop it twice
c %= 9
print (c)
print (bool (“ “) )
QUESTION 5
which python data structure or structures is/are mutable and contain duplicate values?
A. set
B. list
C. tuple
D. set and list
if you change the first one to string, the integer, you can leave number 3 blank as it’s
already a string and then you leave 4 blank too
that’s correct
i am just thinking, you either change one to string and leave the other be, or you rewrite
the second one as string too but it won’t make a big difference as it already is a string
exactly ohhhhhh no no no pardon i see the answers now theres a ) as an answer
ok ok i explain
the general rule is you cannot take the sum of a string and an integer, they all have to
have the same form so integer + integer or string + string or float + float
scroll up if you understood, stay when you are lsot
QUESTION 7
Answer = “False”
if Answer:
print (“The answer is correct.”)
QUESTION 8
so with the numbers of A you make a new list. you start with the 9th index (number 10) and
count back with jumps of 2 to index -8. the minus sign means you stop before the index so
number 2 in this case is not included.
output = 6
second step: you move 8 indexes to know the ending index (ending index is number 2, or
index 1). BUT the ending index is exclusive as the number is negative
step 3: to define our final list_b, we look at the steps. we have to take jumps of 2 indices,
starting at 10 so 10 - 8 - 6 - 4
-> 2 NOT includes as 2 is the ending index that is EXCLUSIVE
so or list_B is [10, 8, 6, 4]
-> the print statement asks the 2 index, the 2 index equals the third number so the answer is
6
list_B = (list_A [9: -8: -2])
QUESTION 9
choose what should be filled out in the empty spaces for the code to give the 4 th, 5th, 6th and
7th line of the .txt file ‘filename’ as output?
A. (1) [4, 5, 6, 7]
(2) += 1
B. (1) (4, 5, 6, 7)
(2) += 1
C. (1) [3, 4, 5, 6]
(2) += 1
D. (1) [4, 5, 6, 7]
(2) *= 1
E. (1) [3, 4, 5, 6]
(2) *= 1
QUESTION 11
1 sentence = ‘as he crossed toward the pharmacy at the corner he
2 involuntarily turned his head because a burst of light that had
3 ricocheted from his temple and saw with that quick smile with which we
4 greet a rainbow or a rose a blindingly white parallelogram of sky being
5 unloaded from the van-a dresser with mirrors across which as across a
6 cinema screen passed a flawlessly clear reflection of boughs sliding
7 and swaying not arboreally but with a human vacillation produced by
8 the nature of those who were carrying this sky these boughs this gliding
9 façade’
10 sentence_list = sentence.split (‘ ’)
how can the code on line 10 be reversed, i.e. how can we turn the value stored in variable
‘sentence_list’ back into the value stored in the variable ‘sentence’?
A. sentence_list.split (‘ ‘)
B. sentence_list.split (‘,’)
C. ‘,’ join (sentence_list)
D. ‘’ join (sentence_list)
E. several of the above answers are correct
QUESTION 12
how can the data in the table above be represented correctly in Python without loss of any
of the information? the potential answers only include an illustrative example, so you may
assume that the structure used for that example can be applied to all data available in the
table above.
A. Houses = {“Avalon”: {“Sale price (100$)”: 2050, “Size (sqft)”: 2650, “Age (years)”: 13},
“Cross Winds”: {…}}
B. Houses = (“Avalon”, 2050, 2650, 13, “Cross Winds”, …)
C. Houses = [{“House”: ”Avalon”, “Sale price (100$)”: 2050, “Size (sqft)”: 2650, “Age
(years)”: 13}, {“House”: “Cross Winds”: …}]
D. Houses = {[“House”: ”Avalon”, “Sale price (100$)”: 2050, “Size (sqft)”: 2650, “Age
(years)”: 13], [“House”: “Cross Winds”: …]}
E. 2 of the answers above are correct
QUESTION 13
x = “ 8 + 5 + 13 + 17 + 3 + 29 + 5 + 31 + 0 + 17 + 29 “
print (Unique_numbers (x))
choose what should be filled out in the empty spaces for the code to give the amount of
unique numbers that are separated from each other with a “+” sign stored in variable “x” as
output.
A. (1) .split(“+”)
(2) len(y)
B. (1) .split(“+”)
(2) len(set(y))
C. (1) .split()
(2) len(set(y))
D. (1) .split()
(2) len(y)
E. none of the answers above are correct
QUESTION 14
Football_data = {
“Goals”: 2,
“Assists”: 4,
“Interceptions”: 22,
“Average performance rating”: “Good”
}
how can we access the value for key “Interceptions” in the following Python Dictionary?
A. Football_data [“Interceptions”]
B. Football_data (“Interceptions”)
C. Football_data [Interceptions]
D. Football_data (Interceptions)
E. Several of the answers above are correct
QUESTION 15
else:
x=6
if x == i:
print (name)
how often will the names “John”, “Jane” and “Doe” be given as output?
A. John: 10 times
Jane: 1 time
Doe: 10 times
B. John: 12 times
Jane: 1 time
Doe: 12 times
C. John: 10 times
Jane: 0 time
Doe: 10 times
D. John: 12 times
Jane: 0 time
Doe: 12 times
E. John: 8 times
Jane: 0 time
Doe: 8 times