Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What will be the output of the following snippets of python code? Write down the exact output, including all brackets, parentheses, braces, quotes and commas

What will be the output of the following snippets of python code? Write down the exact output, including all brackets, parentheses, braces, quotes and commas ([], (), {}, '', "", ,) . [3 mark for each Question]

Justify your answer with suitable explanation.

(1)

m=[[x,x+1,x+2]

for x in range(0,3)]

print(m)

(2)

def myfunc(a):

a = a + 2

a = a * 2

return a

print(myfunc(2))

(3)

rec={'Name':'Python', 'Age':20, 'Addr':'SK01', 'Country':'India'}

id1=id(rec)

del rec

rec={'Name':'C++', 'Age':40, 'Addr':'SK02', 'Country':'USA'}

id2=id(rec)

print(id1 == id2)

(4)

def Changer(P, Q=5):

P=P/Q

Q=P%Q

print (P, "#", Q)

return P

A=100

B=10

A=Changer(A, B)

print (A, "$", B)

B=Changer(B)

print (A, "$", B)

(5)

def DISPLAY(mystr):

L = len(mystr)

str2=' '

str3=' '

for i in range(0,L,1):

str2=str2+mystr[i]

for ch in str2:

if ch>='R' and ch<='U':

str3+='@'

elif ch.isupper():

str3+=ch

else:

str3+=ch.lower()

return str3

mystr="FiRST#tERM#ExAM"

mystr=DISPLAY(mystr)

print(mystr)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Administration The Complete Guide To Dba Practices And Procedures

Authors: Craig S. Mullins

2nd Edition

0321822943, 978-0321822949

More Books

Students also viewed these Databases questions

Question

d. How will lack of trust be handled?

Answered: 1 week ago

Question

b. Does senior management trust the team?

Answered: 1 week ago