Font size
WorksheetsPython Revision
Total questions: 53
Worksheet time: 41mins
Which of the following is the correct syntax for the input ( ) function in Python?
a) input("Enter your name: ")
b) Input("Enter your name: ")
c) input["Enter your name: "]
d) INPUT("Enter your name: ")
(a) is the correct syntax for the input ( ) function in Python?
What does the print ( ) function do in Python?
a) Accepts user input
b) Displays output to the console
c) Performs mathematical operations
d) Reads data from a file
Which of the following statements is true about the print ( ) function?
a) It returns a value
b) It can only display integers
c) It can display strings and variables
d) It can execute conditional statements
print( ) in Python is a/an..............
a) Identifier
b) function
c) data type
d) None
Commenting in Python can be done by using ...........
a) @
b) DoubleQuotes“”
c) #
d) None
Which of the following are valid Python variable names?
a) total123
b) ca$h
c) abc_abc_
d) If
An identifier in python is the name allocated to any variable.
True
False
Input occurs when the syntax of a statement is wrong.
True
False
turtle.left (angle) turns the pointer left to the given angle.
True
False
print (‘Hello world’) and print (“Hello world”) will give the same output.
True
False
print (‘Hello world’) and print (“Hello world”) will give the same output.
True
False
a*b and a**b give the same output.
True
false
List is a data type in Python that is used to store multiple values in a single item.
True
false
Index is the position of an element in String or List data types.
true
false
Distance can be defined using pixel Python turtle.
True
False
turtle. move(10) is used to move forward.
True
False
… (a) …… represents the index from which the elements are to be accessed.
The print () function in Python is used to … (a) …
Print () in Python is a …………….
(a)
The ……… function, used to find the data type of a variable
type()
print()
if()
pop()
The len( ) function gives the ………….. of the characters present in a String.
count
speech
sound
uncount
The upper( ) function converts all the characters to ………...
title
lowercase
uppercase
max
…….... provides a virtual canvas where you can draw pictures and attractive shapes.
turtle
Birds
lion
flies
The title( ) function converts the …....…… character of each word into uppercase.
last
first
next
second
What are the Reserved words/Keyword?
none of these
Words that have a predefined meaning in a programming language
Words that have a defined meaning
Names that have a predefined meaning
Give an example of the Literal?
(“Enter a number: ”)
"9()"
"(())"
name
What is a Delimiter?
(" ")
None of these
They are symbols performing three special roles in python.
They are elements in python.
Give an example of the identifier?
name=
print ()
type()
if()
What is an Operator?
to perform an operation in a python expression.
(+) Sign
??
@!
Give an example of the symbol used for string concatenation?
the + operator can be used to combine two strings
**
(num1)+str1
//
What do you use to store items in the list?
the **
the ( )
the [ ] brackets
the " "
What is the symbol of the Escape character?
\\
\n
**
%
How can you display a variable value along with a String?
(a)
Write an example of the .count( ) function?
print(phrase. count(“sea”))
print(phrase. pop(“”))
print(phrase. upper())
Print()
Two Python numeric data types are ……… and …………….
a) Int and float.
b) String and Boolean.
c) Even num.
d) An Odd num.
An operator ………. is used for floor division.
a) =
b) //
c) **
d) none
.………… is a decimal number.
a) Integer
b) Bool
c) Float
d) String
…………… is a whole number that can be positive or negative, including zero.
a) Integer
b) Bool
c) Footer
d) All the above
Which of the following options is valid in Python variable names?
a) Student_list
b) happy)
c) “Citations$
d) All the above
…………… are a series or a sequence of alphabetical, numbers, and special character that enclosed in single(‘ ’) or double(“ ”) quotes.
a) Float
b) Bool
c) String
d) none of the above
Which is the correct way of declaring a variable x, and assigning a value 10 to it.
a) int x
x=10
b) int x=10
c) x=10
d) None of the above
What will be the output of the following code snippet?
x = 5
y = "10"
z = x + int(y)
print(z)
a) 510
b) 15
c) "510"
d) Error
Which operator is used for exponentiation in Python?
a) **
b)^
c) "^
d) ^*
A ………… is a collection of items in an ordered and sequenced.
a) Integer
b) List
c) Float
d) String
…….. is the symbol used for String Slicing
x=[2:5:6]
y=456
#
my string = (“Welcome to Python”)
The items in a String can be stored within……........
my string = (“Welcome to Python”)
x=[2:5:6]
y=8,9,0
#
Commenting in Python can be done by using:…
#
%
&
**
Find the mistakes and correct the program given below:
print “Welcome to Python)”
name1 = “Nina”
print (name”
Find the output of the program given below:
Num1=20
Num2=25
print(“printing Num1: ”,num1)
print(“printing Num2: ”,num2)
Look at the String given below:
“it is a Beautiful Day”
In the program, it converts the entire String to capital letters. It uses slicing to separate the String. Write the output .
Program:
my_string="it is a Beautiful Day"
print(my_string.upper())
str=my_string[8:]
print(str.upper())
Look at the String given below:
“It is a beautiful day.”
Find out the output of the String with index values 0, 4, 8, 12.
Program:
strg = "It is a beautiful day."
print(strg[0])
print(strg[4])
print(strg[8])
print(strg[12])
What would happen if a decimal number like 2.9 is converted to an integer?
Write the output of the program.
Code:
x=2.9
y=int(x)
print(y)
(a)
