HomeCHAPTER CLASS 11 Python Fundamental || Type B || Sumita Arora || Class 11 || Computer science || Information practices || Solution 2 Comments Facebook Twitter Python Fundamental || Type B || Sumita Arora || Class 11 || Computer science || Information practices || Solution Q1. From the following, find out which assignment statement will produce an error. State reason(s) too.(a) x = 55(b) y = 037(c) z = 0o98(d) 56thnumber = 3300(e) length = 450.17(f) !Taylor = 'Instant'(g) this variable = 87.E02(h) float = .17E - 03(i) FLOAT = 0.17E - 03Q2. How will Python evaluate the following expression?(i) 20 + 30 * 40(ii) 20 - 30 + 40(iii) (20 + 30) * 40(iv) 15.0 / 4 + (8 + 3.0)Q3. Find out the error(s) in following code fragments:(i)temperature = 90print temperature(ii)a = 30b= a + bprint (a And b)(iii)a, b, c = 2, 8, 9print (a, b, c)c, b, a = a, b, cprint (a; b; c)(iv)X = 244 = X(v) print ("X="X)(vi)else = 21 - 5Q4. What will be the output produced by following code fragment (s)?(i)X = 10X = X + 10X = X - 5print (X)X, Y = X- 2, 22print (X, Y)(ii)first = 2second = 3third = first + secondprint (first, second, third)first = first + second + thirdthird = second * firstprint (first, second, third)(iii)side = int(input('side')) #side given as 7area = side * sideprint (side, area)Q5. What is the problem with the following fragments?(i)a = 3 print (a)b = 4 print (b)s = a + b print (s)(ii)name = "Prejith"age = 26print ("Your name & age are", name + age)(iii)a = 3s = a + 18a = "New"q = a / 10Q6. Predict the output:(a)x = 40y = x + 1x = 20, y + xprint (x, y)(b)x, y = 20, 60y, x, y = x, y - 10, x + 18print (x, y)(c)a, b = 12, 13c, b = a * 2, a / 2print (a, b, c)(d)a, b= 12, 13print (print(a + b))Q7. Predict the outputa, b, c = 10, 20, 30p, q, r = c-5, a +3, b - 4print ('a, b, c :', a, b, c, end = '')print ('p, q, r : ', p, q, r)Q8. Find the errors in following code fragment:(a)Y = x + 5print (x, Y)(b)print (x = y = 5)(c)a = input ('value')b = a / 2print (a, b)Q9. Find the errors in following code fragment: (The input entered is XI)c = int(input("Enter your class "))print ("Your class is", c)Q10. Consider the following code:name = input('What is your name? ')print ('Hi', name, ',')print ('How are you doing? ')was intended to print output asHi <name>, How are you doing?But it is printing the output as:Hi <name>,How are you doing?What could be the problem? Can you suggest the solution for the same?Q11. Find the errors in following code fragment:c = input( "Enter your class")print ("Last year you were in class") c-1 Q12. What will be returned by Python as result of following statements?(a)>>> type(0)(b)>>>type(int(0))(c)>>>.type(int('0'))(d)>>> type('0')(e)>>>type(1.0)(f)>>>type(int(1.0))(g)>>>type(float(0))(h)>>>type(float(1.0))(i)>>>type(3/2)Match your result after executing above statements.Q13. What will be the output produced by following code?(a)>>> str(print()) + "One"(b) >>> str(print("hello")) + "One" (c)>>> print(print("Hola"))(d)>>>print(print ("Hola", end = ""))Match your result after executing above statements. Can you explain why this result came?Q14. Carefully look at the following code and its execution on Python shell. Why is the last assignment giving error?>>> a = 0o12>>>print(a)10>>> b = 0o13>>> c = 0o78File "<python-input-41-27fbe2fd265f>", line 10078Syntax Error: invalid syntaxQ15. Predict the output:a, b, c = 2, 3, 4a, b, c = a * a, a * b, a * cprint(a, b, c) Q16. The id() can be used to get the memory address of a variable Consider the following code and tell if the id () functions will return the same value or not (as the value to be printed via print()) ? Why?[There are four print() function statements that are printing id of variable num below)num = 13print(id(num))#1num = num +3print( id(num) )#2num = num - 3print( id(num))#3num="Hello"print(id(num))#4Q17. Consider below given two sets of codes, which are nearly identical, along with their execution in Python shell Notice that first code fragment after taking input gives error, while second code-fragment not produce error. Can you tell why?>>> print(num = float(input("value:")) )value:67Traceback (most recent call last):File "ipython-input-56-78b83d911bc6>", line 1, in <modulesprint(num= float (input("value:")))Type Error: 'num is an invalid keyword argument for this function>>>print(float(input("value1 :")))value1:6767.0Q18. Predict the output of the following code:days = int (input("Input days: ")) * 3600 * 24hours = int (input("Input hours: ")) * 3600 minutes = int (input("Input minutes: ")) * 60seconds = int(input("Input seconds: "))time = days + hours + minutes + secondsprint("The amounts of seconds", time)If the input given is in this order: 1, 2, 3, 4 Q19. What will the following code result into?n1, n2 = 5, 7n3 = n1 + n2n4 = n4 + 2print(n1, n2, n3, n4)Q20. Correct the following program so that it displays 33 when 30 is input.val = input("Enter a value")naval = val + 30print (nval)
Writing answers with the questions only can be very convenient but I appreciate the effort. Please keep it up
ReplyDeleteYeah
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )