Here you will get all the assignment and quiz solutions of Python Programming Course by prutor.ai. Prutor is an online smart tutoring platform which provides various MOOC courses for student and organised by by IIT Kharagpur. At the end of each course student gets a certificate for sucessfull completion of each course but throughout the course students have to pass all the weekly assignments and quizes.
[1] What will be the output of the following? a=[1,2,3,4,5,6] b=[q for q in a if q%2==0] print(b)
- (a): 2,4,6
- (b): false
- (c): 1,3,5
- (d): 0
Answer: (a) 2,4,6
[2] What will be the third item in the following? n=[-1,2,3,-4,5,-6] a=[(x, abs(x)) for x in n] print(a)
- (a): (-4,4)
- (b): (3,3)
- (c): (2,2)
- (d): (-1,1)
Answer: (b) (3,3)
[3] If A=set(‘python’) and B=set(‘programming’) What is the output of A-B ?
- (a): {‘m’, ‘r’, ‘i’}
- (b): {‘m’, ‘r’, ‘g’, ‘a’, ‘i’}
- (c): {‘h’, ‘y’, ‘t’}
- (d): {‘y’, ‘h’, ‘t’, ‘a’}
Answer: (c) {‘h’, ‘y’, ‘t’}
[4] What will be the output of the following? a=5 if a=6: print(“Hello!”) else: print(“Hi”)
- (a): HelloHi
- (b): Hello
- (c): Hi
- (d): Error
Answer: (d) Error
[5] If A=set(‘apple’, ‘orange’, ‘pear’) then what is the class of A ?
- (a): list
- (b): tuple
- (c): int
- (d): set
Answer: (d) set
[6] What should be the outcome of the following? count=40 count>=30 and count<39
- (a): True
- (b): False
- (c): Error
- (d): None of above
Answer: (b) False
[7] If names=[‘abhay’, ‘mahesh’, ‘prashant’, ‘sandeep’] , what does the following statement do: ‘rakesh’ in names
- (a): checks if ‘rakesh’ is there in names
- (b): deletes ‘rakesh’ from names
- (c): add ‘raksesh’ to names
- (d): append names with ‘rakesh’
[8] If you want to check if the age is equal to or greater than 18, what should come in the blank: if age___18: print(“You can vote.”)
- (a): <
- (b): >!
- (c): <=
- (d):>=
Answer: (d) >=
[9] If names=[‘monu’,’raman’,’shikhar’] , What will be the outcome of the following? if ‘david’ in names: print (“It’s David”) elif ‘monu’ in names: print (“It’s Monu”) elif ‘shyam’ in names: print(“It’s Shyam”)
- (a): Error
- (b): It’s David
- (c): It’s Monu
- (d): It’s Shyam
Answer:(c) It’s Monu
[10] What will be the output of the following code: a=10 if a%2==0: print (“Even”) else: print (“Odd”)
- (a): None of the following
- (b): Error
- (c): Odd
- (d): Even
Answer: (d) Even
[11] if statement along with an else statement in Python is called ______ statement.
- (a): elif
- (b): elseif
- (c): elsif
- (d): ifelse
Answer: (a) elif
[12] if statements in Python should be:
- (a): maintainable
- (b): readable
- (c): efficient
- (d): all of the above
Answer: (d) all of the above
[13] What will be the output of the following? (3 < 1) and (4/0 > 1)
- (a): False
- (b): True
- (c): Run-time error
- (d): None of the above
Answer: (a) False
[14] In Python ‘And’ and ‘Or’ operators are also called:
- (a): Short circuit operators
- (b): Logical operators
- (c): Both A and B
- (d): None of the above
Answer: (c) Both A and B
[15] In the following statement, which operation will be evaluated first according to the order of precedence of operators in Python? (3*20+5)-16/4
- (a): (3*20+5)
- (b): 16/4
- (c): 20+5
- (d):3*20
Answer: (d) 3*20
If you have any quetions, please comment down below, we will try to answer with in first 24 hour. Hope you liked this content, We will come with another week’s quiz, Thanks for reading. Good Bye.
0 Comments
Don't be a stranger Just say hello, I will be happy to help you.