NEW
Font size
WorksheetsBasic Python
Total questions: 20
Worksheet time: 20mins
In Python, print () by default adds which of the following as an end line argument?
\t
\n
\s
\r
Which of the following is not true about variable names?
The length of the variable name is fixed
Can contain upper case or lowercase letters and digits 0-9
Variable names cannot begin with a digit
Variable names are case sensitive
What does IDE stand for?
Internet Data Evaluation
Integrated Drive Electronics
Integrated Development Enterprises
Integrated Development Environment
In Spyder, the command to clear the console is
%reset
%clear
%del
%delete
Which of the following code cannot be used to initialize multiple variables with a common value?
a, b, c = 55
a, b, c = 55, 55, 55
a = b = c = 55
a = 55; b = a; c = b
What will be the output after executing the given codes?
6
42
3
52
None
Which of the following is true with respect to the below codes?
a = 4**3
b = pow(4,3)
print(a,b)
a = b
a ≠ b
a < b
a > b
What will be the output after executing the given codes?
Syntax error
10
value error
20
Which of the following conversion results in an error?
int('10.8')
float(10)
int(10)
float(10.8)
For which type of error does the interpreter runs the program and does not report an error?
Semantic error
Syntax error
Runtime error
Key error
What will be the output after executing the following codes?
x=27
y=4
print(x//y)
SyntaxError
6.75
3
6
Identify which of the following is not a valid variable name?
X005 =10
A.2 = 10
N_s = 10
r10 = 10
What does the following statements do?
import sys
print(sys.version)
Displays the current Python version
Displays the operating system version
Displays the location of the Python interpreter
All of the above
None of the above
How many operands are there in the following arithmetic expression?
6 * 35 + 8 – (25 / 5)
4
3
5
8
Which is not a valid assignment operator?
**=
+=
//=
%%=
Which of the following command is used to print the output 01-Jan-2020 ?
print('01','Jan', sep=' ', end='-2020')
print('01','Jan', sep='-', end='-2020')
print('01','Jan', sep='-', end='2020')
print('01','Jan','2020', sep='-', end='-2020\n')
What is the correct file extension for Python files?
.pyt
.pyth
.pt
.py
How do you start writing an if statement in Python?
if (x>y)
if (x>y):
if (x,y)
if (x>y) then:
How do you insert COMMENTS in Python code?
/*This is a comment*/
#This is a comment
//This is a comment
Any of the Above
What is a correct syntax to return the first character in a string?
x = "Hello"[0]
x = "Hello".sub(0, 1)
x = sub("Hello", 0, 1)
x = first("Hello")
