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

Python Revision Tour Imp Question

Uploaded by

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

Python Revision Tour Imp Question

Uploaded by

golamanthan27
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 47

DREAM TECHNOLOGY

Python
Revision
Tour
Important Questions
Important Question of Python Revision
Tour
 Valid / invalid Identifiers.  Concatenation and

 operator Replication(string /list/ tuple)

 Evaluate the expressions


 Mutable and immutable datatype

 Type of tokens
 Error

 Random module
 Output(string /list/ tuple) (inbuilt

function e.g.:-isupper())  Create a Dictionary

 Slicing
State True and False
 “Variable declaration is implicit in python”

 “The extend method extends the 1st list with 2nd list contents”

 “A list is immutable”

 “A string is immutable”

 “A dictionary is immutable”

 “A tuple is an editable data store”

 “Multiple elements can be added at the end of list by the append() ”


Which one is not the feature of Python function

(a) Modularity

(b) Reusability

(c) Simplicity

(d) difficult to find error


State True and False
 The pop() method removes and not displays the last element of a list.

 The method that can be delete a range of values from a list is del.

 Given a dictionary dream. The statement dream.items() displays the keys of the
item only.

 A dictionary is ordered by index.

 Integer is a mutable data type in python

 Digits are one of the character set of python


Valid / invalid Identifiers.

Q Find the valid identifier from the following

1. 2_Myname

2. My name

3. True

4. Myname_2
operator

How a>b>c will be interpreted by python?

1. a>b or a>c

2. a>b not a>c

3. a>b and a>c

4. a>b && a>c


operator

Q. Which of the following operator can be used with string data type?

1. **

2. %

3. +

4. /
Evaluate the expressions
operator

Identify the following operator.

a) **

b) ==

c) is

d)or

e) not in
Evaluate the expressions

Which of the following properly expresses the precedence of


operators (using parentheses) in the following expression: 5*3 > 10
and 4+6==11

1.((5*3) > 10) and ((4+6) == 11)

2.(5*(3 > 10)) and (4 + (6 == 11))

3.((((5*3) > 10) and 4)+6) == 11

4.((5*3) > (10 and (4+6))) == 11


Evaluate the expressions

What will the following expression be evaluated to in Python?

print (15.0/ 4+ (8+ 3.0))

(a) 14.75

(b)14.0

(c) 15

(d) 15.5
Output

What will be the output of the following Python code?

i=1

while True:

if i % 007 == 0:

break

print(i)
Output

What will be the output of the following?

X=5678

while X>0:

print(X)

X=X//10
Output

What will be the output

St=“Dream”

for i in St:

print(i ,” ”,end=“ “)
What is the use of id() function in python?

(a) returns the data type of object

(b) returns the size of the object

(c) returns the identity of object

(d) None of the above


Output
What will be the output

t1= (9,5,4,3)

t2=(7,0,9,8)

t=t1+t2

print(t)
Output

What is the output of following program:

import math

a=math.ceil(20.5)

b=a/5

c=math.floor(b)

print(c)
Output
What will be the output
1. ‘Dream Technology’.count(‘olo’7,16)
2. dic={}
dic[(1,2,3)]=8
dic[(4,2,1)]=10
dic[(1,2)]=24
sum=0
for i in dic:
sum=sum+dic[i]
print(sum)
Output
• What will be the output
print(print(“Dream”))
Output
• Write the output of the following given python code
Msg1="WelcOME"
Msg2="GUESTS“
Msg3="“
for I in range(0,len(Msg2)+1):
if Msg1[1]>="A" and Msg1[1]<="M":
Msg3-Msg3+Msg1[1]
elif Msg1[1]="N" and Msg1[1]<="2":
Msg3-Msg3+Msg2[1]
else:
Msg3-Msg3+"*"print (Msg3)
Output

Predict the output of the following program.

for i in range(1,10):

pass

print(i)
Output

What is the output of following code:

X=(1,)

print(X*2)

y=(1)

print(Y*2)
Output
• Consider the following code.
• x=10
• y=x
• print(x==y)
• print(id(x)==id(y))
Output

Find the output of following code.

dic ={"Nitin": (21. "NIIT"), "Ankit" : (15. "NIIT"))}

print("The original dictionary: ", str(dic))

result [(key. 1, j) for key, (1, j) in dic.items()]

print("The list after conversion: ", str(result))


Output
Output
Given is a Python string declaration:
myexam="@@CBSE Examination 2022@@“
Write the output of
print (myexam [::-2])
Output

Write the output of the code given below:

my_dict = {"name": "Aman", "age": 26}

my_dict['age'] = 27

my_dict['address'] = "Delhi“

print (my_dict.items())
Output
Output
• Predict the output of the Python code given below:
tuple1 = (11, 22, 33, 44, 55,66)
listl =list (tuple1)
new list = []
for i in list1:
if i%2==0:
new_list.append(i)
new_tuple
tuple (new_list) = print (new_tuple)
Output
Output
Output
0o11 is equal to 1⋅8¹ + 1⋅8⁰ = 9

• 0o11 is equal to 1⋅8¹ + 1⋅8⁰ = 9,


Output
Ms. Hetvee is working on a string program. She wants to display last
four characters of a string object named s. Which of the following is
statement is true?

1. s[4:]

2. s[:4]

3. s[-4:]

4. s[:-4]
The append() method adds an element at
1. First
2. Last
3. specified index
4. at any location
Rewrite the following program after removing all error(s), also underline each
correction
N=int(input("Enter any number")
For i in range(1,N)
if N%i==0:
c=c+1
if c=2:
print(Prime)
Else:
print(Not a prime)
Which of the following is invalid data type in python.

1. Set

2. None

3. Integer

4. Real
Given an object obj1=(10,20,30,40,50,60,70,80,90).What will be the
output of print(obj1[3:7:2])?

1. (40,50,60,70,80)

2. (40,50,60,70)

3. (40,50,60)

4. (40,60)
Which of the following is/are not python keyword?

1. True

2. break

3. math

4. for
Consider the given expression:
not True and False or True
Which of the following will be correct output if the given expression
is evaluated?
(a) True
(b) False
(c) NONE
(d) NULL
In complex number a+ib ,b represents as

1. Real number

2. Imaginary part

3. Special part

4. None of these
DREAM
TECNOLOGY

You might also like