CARVIEW |
Python Quiz for Beginners
Question 1
Which of the following methods is used to center a string in a specified width with padding characters?
ljust()
rjust()
center()
capitalize()
Question 2
What will be the result of slicing 'ForGeek'
from index 3 to 12?
GeekFor
ForGeek
For
Geek
Question 3
What does the // operator do in Python?
Exponentiation
Floor division
Modulus
Bitwise AND
Question 5
Which function is used for converting a value to an integer in Python?
int()
float()
str()
bool()
Question 6
What will be the result of the following expression in Python: float("3.14")?
3.14
"3.14"
3
4
Question 7
Which of the following methods is used to find the index of the first occurrence of a substring in a Python string if not found return -1 ?
find()
index()
search()
locate()
Question 8
What does the strip() method do when applied to a Python string?
Removes leading and trailing whitespaces
Converts the string to uppercase
Extracts a substring based on specified indices
Replaces a specified substring with another
Question 9
In Python, variable names are case-sensitive. What does this mean?
Variable names cannot contain uppercase letters.
Variable names must always start with an uppercase letter.
Variable names can be written using a mix of uppercase and lowercase letters, and these are considered distinct.
Variable names must be entirely in uppercase.
Question 10
What is the output of the following code?
print('Python is great'.find('is'))
6
-1
7
None
There are 10 questions to complete.