Font size
Worksheets18SE1001 BTech RA Tech. Apt. -Python
Total questions: 50
Worksheet time: 29mins
Code for Hello, World!
print Hello, World!
print("Hello, World!)
print("Hello, World!")
Python is a
text language
database language
programming language
Insert the missing part of the code below to output
_________________ "My name is ".
Which of the following types of computer languages uses binary code to communicate with the computer?
High-level languages
Assembly languages
Machine language
Database languages
What is the name of this symbol (>>>)?
Chevrons
Hash tags
Colon
Semi Colon
What are the names of the two types of mode that are used in Python? Select two.
Interactive mode
Scratch mode
Imperial mode
Script mode
Python is _____ sensitive which means you must use the same indentation every time.
space
colour
code
word
Is python an interpreter or compiler programming language?
Compiler
Interpreter
Python is uses braces to block off code
True
False
Python correct naming convention for constants is?
firstName
First_Name
FIRST_NAME
firstname
Python correct naming convention for variables is?
new_user25
NewUser25
25_new_user
25NewUser
NEWUSER25
print(Hello world!)
print("Hello world!" * 2)
people = ["John", "Rob", "Bob"]
print (people[1])
what would this result be?
people = ["John", "Rob", "Bob"]
print (people[4])
what would this result be?
people = ["John", "Rob", "Bob"]
print (people[-1])
what would this result be?
Which of the following is the correct extension of the Python file?
a) .python
b) .pl
c) .py
d) .p
What will be the value of the following Python expression?
4 + 3 % 5
a) 7
b) 2
c) 4
d) 1
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, Division, Subtraction, Addition
d) Parentheses, Exponential, Multiplication, Division, Addition, Subtraction
Which of the following functions is a built-in function in python?
a) factorial()
b) print()
c) seed()
d) sqrt()
Which of the following is not a core data type in Python programming?
a) Tuples
b) Lists
c) Class
d) Dictionary
To add a new element to a list we use which Python command?
a) list1.addEnd(5)
b) list1.addLast(5)
c) list1.append(5)
d) list1.add(5)
What will be the output of the following Python code?
>>> str1 = 'hello'
>>> str2 = ','
>>> str3 = 'world'
>>> str1[-1:]
a) olleh
b) hello
c) h
d) o
Suppose listExample is [‘h’,’e’,’l’,’l’,’o’], what is len(listExample)?
a) 5
b) 4
c) None
d) Error
What will be the output of the “hello” +1+2+3?
a) hello123
b) hello
c) Error
d) hello6
Suppose list1 is [2445,133,12454,123], what is max(list1)?
a) 2445
b) 133
c) 12454
d) 123
Suppose list1 is [2, 33, 222, 14, 25], What is list1[:-1]?
a) [2, 33, 222, 14]
b) Error
c) 25
d) [25, 14, 222, 33, 2]
If a=(1,2,3,4), a[1:-1] is _________
a) Error, tuple slicing doesn’t exist
b) [2,3]
c) (2,3,4)
d) (2,3)
Which of the following statements create a dictionary?
a) d = {}
b) d = {“john”:40, “peter”:45}
c) d = {40:”john”, 45:”peter”}
d) All of the mentioned
What will be the output of the following Python code snippet?
d = {"john":40, "peter":45}
d["john"]
a) 40
b) 45
c) “john”
d) “peter”
What will be the output of the following Python code?
a={1:"A",2:"B",3:"C"}
b={4:"D",5:"E"}
a.update(b)
print(a)
a) {1: ‘A’, 2: ‘B’, 3: ‘C’}
b) Method update() doesn’t exist for dictionaries
c) {1: ‘A’, 2: ‘B’, 3: ‘C’, 4: ‘D’, 5: ‘E’}
d) {4: ‘D’, 5: ‘E’}
The == operator is a:
function operator
comparison operator
the opposite operator
code operator
TAB=
1 space
2 spaces
3 spaces
4 spaces
