Font size
WorksheetsPython Programming
Total questions: 15
Worksheet time: 10mins
Change to upper case
upper = name.upper()
upper = upper(name)
lower = name.lower()
up = name.upr()
Change to capitalize each word
Title = name.Title()
title = name.title()
Title= title(name)
Write the code to get the following output
Hello Grade 5B
(a)
What is type casting ?
Typecasting is a way of changing an object from one number to another.
Typecasting is a way of changing an object from one word to another.
Typecasting is a way of changing an object from one variable to another.
Typecast is a way of changing an object from one data type to another type.
Correct the following line of code so that the variable num1 will store the value as an integer
num1 = input("Enter a number")
num1 = int(input("Enter a number"))
num1 = input("Enter a number").int
num1 = float(input("Enter a number"))
num1 = str(input("Enter a number"))
Predict the output for the following code:
number = 1
while number < 5:
print(number)
number = number + 1
1
3
5
9
2
3
4
2
4
6
8
Error
What will be the output of the following code:
print(10 !=20)
True
False
Syntax Error
What will be the output of the following code:
print(50 ==70)
True
False
Syntax Error
What will be the output of the following code:
print(99>=100)
True
False
Syntax Error
Choose a number that will give you the output as Thank you! for the following code:
num = int(input("Enter a number: ")
if num > 10 :
print("Too high")
else:
print("Thank you! ")
9
9.5
18
3
Would the output of
20//5
and the output of
20%5
be the same?
Yes, they both will give the remainder
No, the first line will give the remainder and the other will give the quotient
Yes, they both will give the quotient
No, the first line will give the quotient and the other will give the remainder
number = random.randint(1,100)
A random number between 1 to 99 will be displayed.
A random number between 1 to 100 will be displayed.
A random number between 0 to 100 will be displayed.
A random number between 1 to 100 will be displayed.
What will be the output of the following code :
num = random.randrange( 0,101,2)
Displays a random number between the range of 0 to 101
Displays a list of even number between the range of 0 to 100
Displays a random odd number between the range of 0 to 100
Displays a random even number between the range of 0 to 101
Choose the correct syntax for creating a list in python
fruit = [Apple, Mango, Grapes]
fruit = ["Apple", "Mango", "Grapes"]
fruit = ("Apple", "Mango", "Grapes")
fruit = ["Apple""Mango""Grapes"]
Choose the correct code to remove the item banana from the following python list:
fruit = ["Apple", "Mango", "Banana", "Grapes"]
fruit.remove()
fruit.remove("Banana")
fruit.remove(Banana)
fruit.remove("Banana")
