WorksheetsBasics of Programming
Total questions: 25
Worksheet time: 14mins
What is the output of the following code?
print(type(3))
<class 'int'>
<type 'int'>
int
D) <int>
How do you insert comments in Python code?
# This is a comment
// This is a comment
<!-- This is a comment -->
/* This is a comment */
Which of the following is a valid variable name in Python?
2var
var_1
@var
None
What will the following code output?
print(5 // 2)
2.5
3
2
2.0
What is the output of the following code?
print(bool(""))
True
False
None
Error
What does the following code return?
list1 = [1, 2, 3, 4]
print(list1[-2])
2
3
4
error
Which keyword is used to define a class in Python?
class
def
define
struct
What does the following code return?
list1 = [1, 2, 3, 4]
print(list1[-2])
2
3
4
error
What is the output of the following code?
x = 10
y = 20
x, y = y, x
print(x, y)
10, 10
20,20
10,20
20,10
Which of the following is a Python immutable data type?
List
Set
Dictionary
Tuple
Identify the below expressions which would result in False?
a) False and True b) 1==1 or 2==1
c) 1==1 and 2!=1 d) True and 1==1 e) False or 1>2
c, d
a, e
b, c, d
a, c
what is the output of the below code snippet?
num1=10
num2=7//2
num2*=num1
print(num2)
10
35.0
30
30.0
What is the output of the below code?
num_list = [10.5,30.5,-1.20,10.10]
num_list.insert(-3, -10.5)
num_list.pop(0)
print(num_list[0])
30.5
-10.5
10.1
-1.2
print(~~~~~5)
5
-6
10
-10
Python can be worked on with:
Phones
PCs
Tablets
Laptops
Nintendo Wii
Is Python case sensitive?
Yes
No
Maybe
Depends up on the version of python
Which of the following is the correct extension of the Python file?
.python
.pl
.py
.p
Is Python code compiled or interpreted?
Python code is both compiled and interpreted
Python code is neither compiled nor interpreted
Python code is only compiled
Python code is only interpreted
Which of the following character is used to give single-line comments in Python?
//
#
!
/*
Which of the following functions is a built-in function in python?
fact()
print()
seed()
squareroot()
Which code is correct?
ptinf("Hello World")
print("Helloworld")
printf "hello world"
print (hello world)
Which symbol is used for product calculations?
x
X
*
**
Which one is integer datatype?
w=1
x=10.00
y=010010123459714523697
z=xa
Select the string datatypes.
+91547963
B+ve
1243
5679 22
Which of the following will print the numbers 5,7,9,11,13 in a column
for counter in range(13):
print(counter)
for counter in range(5,13,2):
print(counter)
for counter in range(5,13):
print(counter)
for counter in range(5,14,2):
print(counter)
