Python Unit 2 QB
Python Unit 2 QB
s.no Answer
1 1
2 1
3 1
4 1
5 1
6 1
7 1
8 1
9 1
10 1
11 1
12 1
13 1
14 1
15 1
16 1
17 1
18 1
19 1
20 1
21 1
22 1
23 1
24 1
25 1
26 1
27 1
28 1
29 1
30 1
31 1
32 1
33 1
34 1
35 1
36 4
37 4
38 4
39 4
40 4
41 4
42 4
43 4
44 4
45 4
46 4
47 4
48 4
49 4
50 4
51 4
52 12
53 12
54 12
55 12
56 12
57 12
58 12
59 12
60 12
61 12
62 12
63 12
64 12
Mark
Python was created by ______during 1985- 1990.
Which mode allows users to directly enter and execute Python commands interactively?
What does the following expression evaluate to: 5 + 3 * 2?
Which data type in Python represents a sequence of characters?
Select the correct example of complex data type in Python
_______data type stores Numerical Values
fruits = ["Apple", "Banana", "Cherry"]
x, y, z = fruits
print(y),
output is______
x=5
print(type(x)),
output is______
b = "Hello, World!"
print(b[2:5]),
output is ______
thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
print(thisdict["brand"]),
output is _____
x=5
x **= 3
print(x),
output is ___________
x=4
x = "Sally"
print(x),
output for given program
a = 14
A = "Python"
print(a),
output for given program
a = "Python"
b = "programming"
c=a+""+b
print(c),
output is ______
A _____in Python consists of a series or sequence of characters - letters, numbers, and special characters.
What will be the value of y after the following code snippet is executed? x = 10; y = x * 2;
x=5
x += 3
print(x),
output is _____
x = ["apple", "banana"]
print("banana" in x),
output is _______
IDLE abbreviation_____
fruits= ("apple",)
print(type(fruits)),
output is _____
def my_function(x):
return 5 * x
print(my_function(9)),
output is ____
_______are used to avoid rewriting same code again and again in a program.
______ is a space given to the block of codes for class and function definitions or flow control.
How do you swap the values of two variables in python without using a third variable?
Read the following Python code carefully and point out the global variables?
y, z = 1, 2
def f():
global x
x = y+z
Explain the significance of debugging in Python programming. Provide two common debugging techniques used by Python developers.
In Python, define the int, float, boolean, string, and list data types.
Discuss various operation in Strings
Describe the Experssion and statements in python
Create a program in Python that switches two variables.
Python program to calculate the distance between two points given their coordinates (x1, y1) and (x2, y2).
Develop a Python program that rotates the values of n user-specified variables in a circular manner.
Create a program in Python that switches two variables.
Provide an algorithm to swap two variables.
Draw the flowchart for swap two variables and distance between two points.
Discuss the importance of understanding Python reserved words for Python programmers. Provide examples of Python reserved words.
print (A[i], end ‘ ’)
A programmer mistakenly uses a Python reserved word as a variable name while performing tuple assignment and arithmetic operations i
While debugging a Python script, an error message appears due to incorrect operator precedence in an expression. Analyze how Python e
Question Answer A
Apple Banana
int complex
Hello World
brand model
5 3
var@ 32var
Variable Value
4 Sally
14 Python
Tuple String
Emil Refsnes
20 5
red three
List Set
5 3
banana 1
str tuple
5 9
Function String
Error 12 4
x y and z
operations involving int, float, boolean, and string. Explain the error and suggest a correction.
ow Python evaluates the expression and provide a corrected version.
Answer B Answer C
Cherry Error
float long
llo Hello,World
Ford Mustang
15 125
Class abc_a_c
4 error
14 Error
Python Programming
print(‘hello’, ‘how’, ‘are’, ‘you’ + ‘-‘ * 4) print(‘hello’ + ‘-‘ + ‘how’ + ‘-‘ + ‘are’ + ‘you’)
Set List
"20" None
fruits one
Tuble Dictionary
8 5
0 Error
char list
45 14
Tuple Dictionary
docstring Tuple
temp=x, x=y,y=temp x+y: y=x; x=y
Python first searches the built-in namespace, th Python first searches the global namespace, then the lo
4 12 4 15
B
A
C
B
B
C
C