NEW
Font size
WorksheetsPython Programming Quiz
Total questions: 60
Worksheet time: 3600secs
Sanya is trying to output the string "May the odds favor you" in Python. How can she do it?
print("May the odds favor you")
echo("May the odds favor you")
System.out("May the odds favor you")
printf("May the odds favor you")
Avni is trying to create a variable in Python with a value 22.6. How should she do it?
int a = 22.6
a = 22.6
Integer a = 22.6
None of the above
Myra is learning Python and wants to know how to add a single-line comment in her code. What should she use?
/* This is a comment */
!! This is a comment
// This is a comment
# This is a comment
Aanya is trying to represent 261500000 as a floating number in Python for her programming assignment. How should she do it?
2.615E8
261500000
261.5E8
2.6
Kabir is learning about complex datatypes in Python. He wants to select the correct example of a complex datatype. Which one should he choose?
3 + 2j
-100j
5j
All of the above are correct
Eshaan is trying to create a multi-line string in Python for his project. What is the correct way of doing it?
str = ""My name is Kevin and I live in New York""
str = """My name is Kevin and I live in New York"""
str = "My name is Kevin and I live in New York"
All of the above
Advait is working on a project in Python and needs to convert the uppercase letters in a string to lowercase. How can he achieve this?
lowercase()
capitalize()
lower()
toLower()
Ananya wants to extract the substring "Kevin" from the following string declaration in Python:
str[11:16]
str(11:16)
str[11][16]
str[11-16]
Aashi is trying to access a specific character from her favorite string in Python. Which of the following is the correct way to access the character "K" from the string?
str(11)
str[11]
str:9
None of the above
Mira is working on a project that requires her to parse dates from various text files. Which Python module should she use to parse dates in almost any string format?
datetime module
time module
calendar module
dateutil module
Shreya is learning about different number systems in her programming class. Which of the following is the correct way to indicate Hexadecimal Notation in Python?
str = '\62'
str = '62'
str = "62"
str = '\x62'
Neha is trying to extract a part of her favorite quote from the end of the string in Python. Which of the following methods should she use?
Indexing
Negative Indexing
Begin with the 0th index
Escape Characters
Arnav wants to fetch characters from a given range in a string in Python. How can he do that?
[:]
in operator
[]
None of the above
Aarav is learning Python and wants to know how to capitalize only the first letter of a sentence. What method should he use?
uppercase() method
capitalize() method
upper() method
None of the above
Akhil is trying to find the maximum score from his test results stored in a tuple. What is the correct way to get the maximum value from the tuple in Python?
print (max(myscores));
print (maximum(myscores));
print (myscores.max());
print (myscores.maximum);
Aarav wants to fetch and display only the keys of his stock portfolio Dictionary in Python. How can he do that?
print(mystock.keys())
print(mystock.key())
print(keys(mystock))
print(key(mystock))
How can Krish align a string centrally in Python while working on his project?
align() method
center() method
fill() method
None of the above
How can Ria access the value for the key "Product" in the following Python Dictionary:
mystock["Product"]
mystock("Product")
mystock[Product]
mystock(Product)
Aashi is working on a Python project and needs to set the tab size to 6 in her strings. How can she achieve this?
expandtabs(6)
tabs(6)
expand(6)
None of the above
Sanya is trying to organize her favorite fruits in Python. She wants to use a collection that uses square brackets for comma-separated values. Which collection should she use? Fill in the blanks with a Python collection.
Lists
Dictionary
Tuples
None of the above
Sneha is trying to find the index of the first occurrence of the letter "i" in the string "This is my website". How can she do that?
str.find("i")
str.find(i)
str.index()
str.index("i")
Viaan is trying to figure out how to display whether the date is AM/PM in Python. What should he use?
Use the %H format code
Use the %p format code
Use the %y format code
Use the %I format code
In a programming class, Anika is trying to access a specific element from a Multi-Dimensional List. Which of the following is the correct way for her to do this?
list[row_size:column_size]
list[row_size][column_size]
list[(row_size)(column_size)]
None of the above
Asher is working on a programming assignment in Python. He needs to understand which of the following Bitwise operators shifts the left operand value to the right, by the number of bits in the right operand? The rightmost bits while shifting fall off.
Bitwise XOR Operator
Bitwise Right Shift Operator
Bitwise Left Shift Operator
None of the Above
Avni is trying to access specific elements in her tuple named "mytuple". How can she specify a range of index to print elements from it?
print(mytuple[1:4])
print(mytuple[1 to 4])
print(mytuple[1-4])
print(mytuple[].slice[1:4])
Tisha is trying to learn how to correctly create a function in Python. Which of the following is the right way to define a function?
demoFunction()
def demoFunction()
function demoFunction()
void demoFunction()
Myra is trying to declare a variable in Python for her project. Which one of the following is a valid identifier declaration in Python?
str = "demo666"
str = "666"
str = "demo demo2"
str = "$$$666"
Arnav is working on a Python project and needs to ensure that all the characters in his input string are printable. How can he check this?
print() method
printable() method
isprintable() method
echo() method
Aanya has a Dictionary of items she wants to manage. How can she delete an element with the key "Price" from her Dictionary?
del dict['Price']
del.dict['Price']
del dict('Price')
del.dict['Price']
Divya is working on a Python project and needs to swap cases in her text, changing lowercase letters to uppercase and vice versa. How can she achieve this?
casefold() method
swapcase() method
case() method
title() method
Aditi has a Dictionary in Python named "mystock" that contains various stock items. Which of the following is used to empty the Dictionary in Python?
mystock.del()
clear mystock
del mystock
mystock.clear()
Anika wants to know how to display only the day number of years in Python. Can you help her?
date.strftime("%j")
date.strftime("%H")
date.strftime("%I")
date.strftime("%p")
Akhil wants to display only the day number of years in Python. How can he achieve this?
date.strftime("%j")
date.strftime("%H")
date.strftime("%I")
date.strftime("%p")
Aanya is trying to create a function in Python that can handle different numbers of students' scores. What is used in Python functions, if you have no idea about the number of arguments to be passed?
Keyword Arguments
Default Arguments
Required Arguments
Arbitrary Arguments
Avni is trying to create a Dictionary in Python to store her favorite gadgets. What is the correct way for her to do this?
mystock = {"Product": "Earphone", "Price": 800, "Quantity": 50}
mystock = {"Product"- "Earphone", "Price"-800, "Quantity"-50}
mystock = {Product[Earphone], Price[800], Quantity[50]}
None of the above
Aashi is organizing a study group for her Python class. She wants to know what feature allows her classmates to skip certain arguments or pass them in any order when they are calling a function in their code.
Keyword arguments
Default Arguments
Required Arguments
Arbitrary Arguments
In a programming class, Avani is learning how to create a Dictionary of arguments in a Python function. What is to be used to achieve this?
Arbitrary arguments in Python (*args)
Arbitrary keyword arguments in Python (**args)
Keyword Arguments
Default Arguments
Akhil is working on a Python project and needs to convert the lowercase letters in a string to uppercase. What method should he use?
upper()
uppercase()
capitalize()
toUpper()
Kabir is trying to find the minimum score from his list of test results in Python. What is the correct way to get the minimum value from a List in Python?
print (minimum(mylist));
print (min(mylist));
print (mylist.min());
print (mylist.minimum());
Sneha is trying to convert an integer to a float in her Python program. Which of the following correctly converts int to float in Python?
res = float(10)
res = convertToFloat(10)
None of the above
Aisha is trying to determine the type of a variable in her Python program. How can she do this?
print(typeOf(a))
print(typeof(a))
print(type(a))
None of the above
Siya is trying to compare two values in her Python program to check if they are equal. Which operator should she use to perform this comparison?
=
in operator
is operator
== (Answer)
Avani has a tuple of scores from her recent exams. What is the correct way to get the minimum score from her tuple?
print (min(myscores));
print (minimum(myscores));
print (myscores.min());
print (myscores.minimum);
Myra wants to display only the current month's number in Python. How can she do that?
date.strftime("%H")
date.strftime("%I")
date.strftime("%p")
date.strftime("%m")
Nikita and Vanya are working on a project where they need to determine if two variables point to the same object in memory. How can they compare the two objects to check whether they have the same memory locations?
is operator
in operator
**
Bitwise operators
How to fetch and display only the values of a Dictionary in Python?
print(mystock.value())
print(mystock.values())
print(values(mystock))
print(value(mystock))
Which operator is used in Python to raise numbers to the power?
Bitwise Operators
Exponentiation Operator (**)
Identity Operator (is)
Membership Operators (in)
____________ represents key-value pair in Python?
Tuples
Lists
Dictionary
All the Above
Which of the following Bitwise operators sets each bit to 1, if only one of them is 1, i.e. if only one of the two operands is 1?
Bitwise XOR
Bitwise OR
Bitwise AND
Bitwise NOT
What is the correct way to get the maximum value from a List in Python?
print (maximum(mylist));
print (mylist.max());
print (max(mylist));
print (mylist.maximum());
An example to correctly begin searching from the end range of index in Python Tuples. Let's say our Python Tuple has 4 elements
print(mytuple[-3 to -1])
print(mytuple[3-1])
print(mytuple[].slice[-3:-1])
print(mytuple[-3:-1])
Which of the following Bitwise operators in Python shifts the left operand value to the left, by the number of bits in the right operand? The leftmost bits while shifting fall off.
Bitwise XOR Operator
Bitwise Right Shift Operator
Bitwise Left Shift Operator
None of the Above
How to display only the current month's name in Python?
date.strftime("%H")
date.strftime("%B")
date.strftime("%m")
date.strftime("%d")
___________ uses Parenthesis for comma-separated values in Python? Fill in the blanks with a Python collection?
List
Tuples
None of the above
How to create an empty Tuple in Python?
mytuple = ()
mytuple = (0)
mytuple = 0
mytuple =
How to display only the day number of years in Python?
date.strftime("%j")
date.strftime("%H")
date.strftime("%I")
date.strftime("%p")
Delete multiple elements in a range from a Python List
del mylist[2:4]
del mylist(2:4)
del mylist[2 to 4]
del mylist(2 to 4)
How to fetch the last element from a Python List with negative indexing?
print("Last element = ",mylist[0])
print("Last element = ",mylist[])
print("Last element = ",mylist[-1])
None of the above
What is the correct way to get the length of a List in Python?
mylist.count()
count(mylist)
len(mylist)
length(mylist)
To get today's date, which Python module is to be imported?
calendar module
datetime module
dateutil module
None of the above
