python quiz 2 prutor

Start date- 14-04-2021                                                      End date- 27-04-2021



 

LET'S BEGIN......

________________________________________________________________________________________________________


Q.1. If list=['red' , 'blue' , 'green' , 'yellow'] , what will be the output of :
        list.pop('blue')
        print(list)
1.
2.
3.
4.
ANSWER :- (4) Here it will give an error as the given statement is incorrect,

____________________________________________________________________________________________________


Q:2. Which function will remove an item from a list?
1.
2.
3.
4.
ANSWER :-    (3) in python pop function will delete an item from a list, also it returns last value from the list or the given index value.

____________________________________________________________________________________________________


Q:3. If list=['suzuki', 'subaru', 'honda', 'maruti'] , what will be the output of
        print(list[3])
        after running the code :
        list.sort(reverse=True) ?
1.
2.
3.
4.
ANSWER :- (3)  as here honda is present at third index in list thus it returns honda as output. 

____________________________________________________________________________________________________


Q:4. Which statement is correct?
1.
2.
3.
4.

Q:5. Which method is used to arrange the items of a list in ascending order in python?
1.
2.
3.
4.
Sort() sorts any sequence (list, tuple) and always returns a list with the elements in sorted manner, without modifying the original sequence.

____________________________________________________________________________________________________


Q:6. Which of the following is used for performing repetitive tasks in Python?
1.
2.
3.
4.
ANSWER :- (4) loops are used for performing repetitive tasks in python, with the help of loops we can reduce a long series of repetitive instructions down to one instruction .

____________________________________________________________________________________________________



Q:7. How is a line, or a group of lines, related to the rest of the python program?
1.
2.
3.
4.
ANSWER :- (2) indentation refers to the spaces at the beginning of a code line Python uses indentation to indicate a block of code. and relate a line to entire program. while other languages uses braces to define block of codes.

____________________________________________________________________________________________________


Q:8. If numbers=[1, 2, 3, 4, 5] , then how to get the largest value of this list?
1.
2.
3.
4.
ANSWER :- (2) In Python max() function returns the largest item in an iterable. It can also be used to find the largest item between two or more parameters.

________________________________________________________________________________________________________



Q:9.
 What should come in place of X if we want to print HI! 6 times?
        for i in range(X):
            print('HI!'')
1.
2.
3.
4.
ANSWER :- (4) we use range(last) to create a range of 0 to last where last is the number of times also use loop to iterate through given range.

____________________________________________________________________________________________________


Q:10. Which of the following is a valid singleton tuple?
1.
2.
3.
4.
tuple of one item can be formed by affixing a comma to an expression. an expression by itself does not create a tuple, since parentheses must be usable for grouping of expressions. thus single=1, is correct one.


____________________________________________________________________________________________________


👀👀👀 NEXT QUIZ COMMING SOON STAY UPDATED.......👀👀👀

                                                                                     only at  : -    hi-tutorial.blogspot.com

______________________________________________________________________________________________________


Comments

  1. Thanks for help to complete quiz with correct answers and best reasons..

    ReplyDelete

Post a Comment