NEW
Font size
WorksheetsPYTHON PROGRAMMING
Total questions: 30
Worksheet time: 30mins
Who developed Python Programming Language?
a) Wick van Rossum
b) Rasmus Lerdorf
c) Guido van Rossum
d) Niene Stom
which type of Programming does Python support?
.
a) object-oriented programming
b) structured programming
c) functional programming
d) all of the mentioned
Is Python case sensitive when dealing with identifiers?
a) no
b) yes
c) machine dependent
d) none of the mentioned
Which of the following is the correct extension of the Python file?
a) .python
b) .pl
c) .py
d) .p
a) .python
b) .pl
c) .py
d) .p
Is Python code compiled or interpreted?
a) Python code is both compiled and interpreted
b) Python code is neither compiled nor interpreted
c) Python code is only compiled
d) Python code is only interpreted
Which of the following is used to define a block of code in Python language?
a) Indentation
b) Key
c) Brackets
d) All of the mentioned
Which keyword is used for function in Python language?
a) Function
b) def
c) Fun
d) Define
Python supports the creation of anonymous functions at runtime, using a construct called __________
a) pi
b) anonymous
c) lambda
d) none of the mentioned
What is the order of precedence in python?
a) Exponential, Parentheses, Multiplication, Division, Addition, Subtraction
b) Exponential, Parentheses, Division, Multiplication, Addition, Subtraction
c) Parentheses, Exponential, Multiplication, Addition, Division, Subtraction
d) Parentheses, Exponential, Multiplication, Division, Addition, Subtraction
What will be the output of the following Python function?
len(["hello",2, 4, 6])
a) Error
b) 6
c) 4
d) 3
Which of the following is a Python tuple?
a) {1, 2, 3}
b) {}
c) [1, 2, 3]
d) (1, 2, 3)
What will be the output of the following Python code?
>>> str1 = 'hello'
>>> str2 = ','
>>> str3 = 'world'
>>> str1[-1:]
a)0olleh
b) hello
c) h
d) o
What will be the output of the following Python code?
>>>str1="helloworld"
>>>str1[::-1]
a) dlrowolleh
b) hello
c) world
d) helloworld
What will be the output of the following Python code snippet?
print('abc'.islower())
a) True
b) False
c) None
d) Error
What is the method inside the class in python language?
a)Object
b)Function
c)Attribute
d) Argument
Python is a:
a)Low-level language
b)High-level language
c)Middle-level language
d)Machine-level language
What will be the output of the following Python code?
x = ['ab', 'cd']
for i in x:
i.upper()
print(x)
a) [‘ab’, ‘cd’]
b) [‘AB’, ‘CD’]
c) [None, None]
d) none of the mentioned
What will be the output of the following Python code?
i = 1
while True:
if i%3 == 0:
break
print(i)
i + = 1
a) 1 2
b) 1 2 3
c) error
d) none of the mentioned
Which one of these is floor division?
a) /
b) //
c) %
d) None of the mentioned
Which of the following data structures is returned by the functions globals() and locals()?
a) list
b) set
c) dictionary
d) tuple
What will be the output of the following Python code?
x=1
def cg():
global x
x=x+1
cg()
x
a) 2
b) 1
c) 0
d) Error
What arithmetic operators cannot be used with strings in Python?
a) *
b) –
c) +
d) All of the mentioned
Which of these in not a core data type?
a) Lists
b) Dictionary
c) Tuples
d) Class
Which of the following is not the correct syntax for creating a set?
a) set([[1,2],[3,4]])
b) set([1,2,2,3,4])
c) set((1,2,3,4))
d) {1,2,3,4}
What does the `range(3)` function return?
a) [0, 1, 2]
b) [1, 2, 3]
c) [0, 1, 2, 3]
d) [3, 2, 1]
What is the correct way to import the `math` module in Python?
a) import math
b) use math
c) from math import *
d) import module math
What does the `isalpha()` method do in Python strings?
A) Checks if all characters in the string are alphabetic
B) Checks if all characters in the string are digits
C) Checks if the string is empty
D) Converts the string to lowercase
What is the output of the following code?
```python
x = 3
y = 2
print(x / y)
```
A) 6
B) 1.5
C) 0.6666666666666666
D) Error
Which of the following data types is mutable in Python?
a) int
b) float
c) tuple
d) list
Which of the following functions is a built-in function in python language?
a)val()
b) print()
c)printf()
d) None of these
