Python Basic Assessment
Python Basic Assessment
str1="6/4"
print("str1")
A. 1
B. 6/4
C. 1.5
D. str1
Answer : D
Explanation: Since in print statement, str1 is written inside double quotes so it
will simply print str1 directly.
Answer : B
Explanation: capitalize() function in string gives the output by converting only
the first character of the string into uppercase and rest characters into
lowercase.However, upper() function is used to return the whole string into
uppercase.
If str1="John,David,Aryan"
A. print(str1[-7:-12])
B. print(str1[-11:-7])
C. print(str1[-11:-6])
D. print(str1[-7:-11])
Answer : C
Explanation: Slicing takes place at one index position less than the given second
index position of the string. So,second index position will be -7+1=-6.
6.Which one of the following is the correct way of declaring and initializing
a variable, x with the value 7?
A. declare x=7int x
x=7
B. int x=7
C. x=7
D. declare x=7
Answer : C
Explanation: The correct way of declaring and initializing a variable, x with
the value 7 is x=7.