0% found this document useful (0 votes)
3 views

Python Unit 2 QB

The document contains a list of answers to questions related to Python programming, including data types, syntax, and functions. It also includes various programming concepts such as debugging, variable assignment, and code execution modes. The answers are categorized by question numbers and are primarily numerical responses.

Uploaded by

joshishiji42
Copyright
© © All Rights Reserved
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Python Unit 2 QB

The document contains a list of answers to questions related to Python programming, including data types, syntax, and functions. It also includes various programming concepts such as debugging, variable assignment, and code execution modes. The answers are categorized by question numbers and are primarily numerical responses.

Uploaded by

joshishiji42
Copyright
© © All Rights Reserved
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
You are on page 1/ 24

Correct

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 ___________

Identify a valid variable given below.

A _______allows us to store a value by assigning it to a name, which can be used later.

x=4
x = "Sally"
print(x),
output for given program
a = 14
A = "Python"
print(a),
output for given program

Which of the following correctly demonstrates the usage of comments in Python?

a = "Python"
b = "programming"
c=a+""+b
print(c),
output is ______

A variable defined inside a function is called__________

Select all options that print.


hello-how-are-you

A _____in Python consists of a series or sequence of characters - letters, numbers, and special characters.

def my_function(fname, lname):


print(fname + " " + lname+" " +20)
my_function("Emil", "Refsnes"),
output is_____

What will be the value of y after the following code snippet is executed? x = 10; y = x * 2;

fruits = ("one", "two", "three")


(green, yellow, red) = fruits
print(red),
output is______

__________ is immutable data type

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?

What is the order of namespaces in which Python looks for an identifier?

What will be the output of the following Python code?


x=12
def f1(a,b=x):
print(a,b)
x=15
f1(4)

Read the following Python code carefully and point out the global variables?
y, z = 1, 2
def f():
global x
x = y+z

Examine the Features and Uses of Python


Describe the interpreter and compiler with an example.
List the various data types in python
Interpreter mode versus script mode execution in Python.

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 ‘ ’)

List the variuous error messages.


Python interpreter and its role in executing Python code.

The significance of debugging in programming and its various techniques


Discuss the basic data types in Python: int, float, boolean, string, and list. Provide examples for each data type.
Illustrate Tuple and Dictionary and list the various operations of both.
Distinction between expressions, statements tuple assignment in Python programming. Illustrate with example
Discuss in detail about various operators used in python programming with example.
Precedence of operators and its impact on evaluating expressions
State algorithm , pseudo code and Flow Chart and a python code for Exchange the values of two variables.
State algorithm , pseudo code and Flow Chart and a python code for Circulate the values of n variables
State algorithm , pseudo code and Flow Chart and a python code for distance between two points.

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

Guido van Rossum Dennis Ritchie


Debugging mode Script mode
11 16
int float
5j -100j
Boolean Sequence

Apple Banana

int complex

Hello World

brand model

5 3

var@ 32var

Variable Value

4 Sally
14 Python

# This is a comment /* This is a comment */

Pythonprogramming Python programming

Global variable Local variable

print(‘hello-‘+‘how-are-you’) print(‘hello’, ‘how’, ‘are’, ‘you’)

Tuple String

Emil Refsnes

20 5

red three

List Set

5 3
banana 1

Integrated Development Learning Interpreted Development Learning Envir

str tuple

5 9

Function String

Quotation line indentation


x=y,y=x x,y =y,x
Python first searches the built-in Python first searches the built-in namespa

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

Bjarne Stroustrup James Gosling


Interactive mode Production mode
13 10
string list
3 + 2j All of the above are correct
Number Directory

Cherry Error

float long

llo Hello,World

Ford Mustang

15 125

Class abc_a_c

Data type Statement

4 error
14 Error

<!-- This is a comment --> * This is a comment *

Python Programming

Constant Data type

print(‘hello’, ‘how’, ‘are’, ‘you’ + ‘-‘ * 4) print(‘hello’ + ‘-‘ + ‘how’ + ‘-‘ + ‘are’ + ‘you’)

Set List

Emil Refsnes Error

"20" None

fruits one

Tuble Dictionary

8 5
0 Error

Interactive Development Learning EnvironmentInternal Development Learning Environment

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

x, y and z Neither x, nor y, nor z


Answer D
A
C
A
C
D
C
B

B
A

C
B

B
C
C

You might also like