Python 21 One Marks
Python 21 One Marks
a) If (x > 5) then:
b) If x > 5:
c) If x > 5 then:
d) If x > 5 then
a) Skip
b) Stop
c) Break
d) Exit
3. What is the output of the following code?
X=3
If x > 5:
Print(“Greater”)
Else:
Print(“Smaller”)
a) Greater
b) Smaller
c) Error
d) None
a) While 0
b) For x in range(0)
c) While True
d) Repeat
a) Catch
b) Except
c) Throw
d) Try
a) HELLO
b) Hello
c) Hello
d) Error
a) Count()
b) Length()
c) Len()
d) Size()
a) Hellohellohello
b) Hello 3
c) Hello, hello, hello
d) Error
a) Replace()
b) Substitute()
c) Swap()
d) Change()
a) Cde
b) Bcde
c) C
d) Error
11. Which of the following methods checks if a string contains only alphabets?
A) Isalpha()
b) Isnum()
c) Isdigit()
d) Isalnum()
a) 1
b) 2
c) 0
d) -1
13. How can you remove whitespace from the beginning and end of a string?
a) Strip()
b) Trim()
c) Clean()
d) Cu
e)
a) List = {1, 2, 3}
b) List = [1, 2, 3]
c) List = (1, 2, 3)
a) 1
b) 2
c) 3
d) Error
a) Add()
b) Append()
c) Insert()
d) Push()
a) [1, 2, 3, 4, 5]
c) [5, 4, 3, 2, 1]
d) Error
b) Pop()
c) Remove()
d) Discard()
a) 4
b) 3
c) 5
d) Error
20. Which method would you use to sort a list in ascending order?
a) Sort()
b) Order()
c) Arrange()
d) Ascend()
21. How can you access the last item in a list my_list?
a) My_list[len(my_list)]
b) My_list[-1]
c) My_list[1]
d) My_list.last()