Font size
WorksheetsBasics of Python Programming
Total questions: 44
Worksheet time: 25mins
Scholar No.
Name
Contact
College
What is the data type of x after the following statement?
x = ['Today', 'Tomorrow', 'Yesterday']
List
Dictionary
Tuple
String
Output displayed by the print function will add this invisible character at the end of the line by default.
\t
\n
\s
\r
Python files are saved with the extension as?
.python
.pe
.py
.pi
What will be the output after the following statements?
x = True
y = False
print(x or y)
True
False
Not defined
xy
What will be the output after the following statements?
x = 3
y = 7
print(x==y)
y = 7 and x = 3
True
x = 3 and y = 3
False
What will be the output after the following statements?
x = ['Today', 'Tomorrow', 'Yesterday']
y = x[1]
print(y)
x1
Today
Tomorrow
Yesterday
IDLE stands for ... ?
Indigenous Development Lab
Integrated Development Environment
Integrated Developers Local Environment
Integrated Development and Learning Environment
What will be the data type of x after the following statement if input entered is 18 ?
x = input("Enter a number: ")
Float
String
List
Integer
What will be the output after the following statements?
x = 3
y = 2
x += y
print(x)
3
2
5
1
What will be the output after the following statements?
x = [15, 45, 85, 95]
print(x[3]-x[1])
30
40
50
10
Which of the following is used to initialize multiple variables with a common value?
x = y: y = 33
x = y = z = 33
x = z; y = z; x = 33;
x & y & z = 33
What will be the output after the following statements?
x = 46
y = 98
z = y if (y % 2 == 0) else x
print(z)
True
False
46
98
For which type of error does the interpreter halts and reports the error but does not execute the program?
Semantic error
Syntax error
Runtime error
All type of errors
What will be the output after the following statements?
x = [5, 4, 3, 2]
x.insert(1,0)
print(x)
[5, 1, 3, 2, 0]
[5, 0, 4, 3, 2]
[0, 5, 4, 3, 2]
[1, 5, 4, 3, 2]
What will be the output after the following statements?
x = [5, 4, 3, 2]
x.remove(2)
print(x)
[5, 3, 2]
[5, 4, 3]
[5, 4, 2]
[3, 2]
What will be the output after the following statements?
x = ['Sunday', 'Monday', 'Tuesday']
y = x[1] + x[2]
print(y)
MondayTuesday
SundayMonday
SunMonday
Monday Tuesday
What will be the value of x, y and z after the following statement?
x, y, z = 3, 4, 5
All three will have the value of 3
All three will have the value of 345
x will have the value of 3, y will have the value 4 and z will have the value of 5
x and y will have arbitrary values, while z will have the value of 345
What will be the output after the following statements?
x = [25, 35, 45]
y = x[0]
print(y)
x0
25
35
45
What will be the output after the following statements?
x = [[0.0, 1.0, 2.0], [4.0, 5.0, 6.0]]
print(x[1][2])
0.0
1.0
5.0
6.0
What will be the output after the following statements?
x = '24' + '16'
print(x)
40
2416
21
46
What will be the output after the following statements?
x = [[0.0, 1.0, 2.0], [4.0, 5.0, 6.0]]
y = x[0][1] + x[1][0]
print(y)
1.0
4.0
5.0
6.0
What will be the output after the following statements?
x = 8
y = 2
print(x // y)
4.0
4
16
16.0
What will be the output after the following statements?
x = [10, 20, 30]
y = x[1] + x[2]
print(y)
20
30
40
50
For which type of error does the interpreter runs the program and does not report an error?
Semantic error
Syntax error
Runtime error
All type of errors
What will be the output after the following statements?
x = [5, 4, 3, 2]
x.append(1)
print(x)
[5, 4, 3, 2]
5, 4, 3, 2
5432
[5, 4, 3, 2, 1]
User input is read as...?
Floating Decimal
Text String
Boolean Value
Integer
What will be the output after the following statements?
foo = 20>>3
foo <<= 1
foo |= 8
print(foo, type(foo))
4 <class 'int'>
12 <class 'int'>
20 <class 'int'>
None of These
What will be the output after the following statements?
a = '24' + '35'
a /= 5
print(a, type(a))
2435 <class 'int'>
59 <class 'int'>
11.8 <class 'float'>
TypeError
What will be in <put your code here 1, 2, 3> ?
year%400 == 0 ; year%100 == 0 ; year%4 == 0
year%400 == 0 ; year%4 == 0 ; year%100 == 0
year%100 == 0 ; year%400 == 0 ; year%4 == 0
None of These
What will be in <put your code here> ?
beg, ending
beg, ending + 1
0, ending + 1
None of These
Consider a variable job = "chemist". Which of the following expressions will retrieve the last character from the variable value?
job[7]
job[len(job) - 1]
job[5:6]
job[- 1]
All of the above statements are true
Which of the following expressions should be used to assign the variable get_num to get the final print statement output as value 75 from the below tuple?
nst_tup = ("System", (60, 75, 45), (15, 13, 12))
get_num = ..........
print(get_num)
nst_tup[1][2]
nst_tup[1:2][1]
nst_tup[1][1]
nst_tup[1:2](1)
None of the above
What would be the output for the following set of statements?
new_list = [13, 23, 18, 64, 51]
new_list[4] = True
print(new_list)
[13, 23, 18, 64, 51, “True”]
[13, 23, 18, 64, True]
[13, 23, 18, 64, 51, True]
Index Error
What result does the final statement print?
scores = (12, 25, 32, 39, 44)
f_score, *bw_s, l_score = scores
print("Output is :", f_score,"and",bw_s,"and", l_score)
Output is: 12, (25, 32, 39), 44
Output is: 12 and (25, 32, 39) and 44
Output is: 12 and 25 and 39
ValueError: Too many values to unpack
Output is: 12 and [25, 32, 39] and 44
When the following set of instructions are executed, how many times does the vowel “e” appear in the result?
word = "occurence"
for itr in range(len(word)):
if itr%3 == 0:
print(word[itr])
1
“e” is not printed
2
4
None of the above
Consider a dictionary city created with the following keys and values.
city = {'Delhi':3, 'Bengaluru':5, 'Chennai':4, 'Kolkata':6, 'Mumbai':7}
What ways can be used to get the value 5?
city['Bengaluru']
city.get['Bengaluru']
city.values()[1]
list(city.values())[1]
None of the above
Count the number of elements in the below list.
list_tens = [["October", 24, ["2022"]]]
2
1
3
0
None of the above
From the following set of statements, what will be the value of variable y in the final print statement?
y = 1**2**3**2
print(y)
8
9
1
Error
16
What would be the output of the following statements?
log_exp = not not True and False or not False
print(log_exp)
False
True
Not True
None of the above
Consider two answers to a question; answer1 and answer2. What is the output of the following set of statements?
answer1 = True
answer2 = False
print(answer1*answer2)
True
False
0
1
