Coding Pyhton Coding Test 0% Time Limit 10 minutes Maximum Allowed Time Is over Your Paper Successfully Sent. coding Python 1 / 50 Which function is used to display output in Python? print() show() output() 2 / 50 How do you call a function my_function in Python? my_function my_function() call my_function 3 / 50 What will range(5) produce? A single number A sequence of numbers A list of letters 4 / 50 How do you add an element to a list? list.add() list.append() list.appendlist() 5 / 50 What is the output of type("123")? <class 'str'> <class 'int'> <class 'float'> 6 / 50 How do you start a comment in Python? // # * 7 / 50 How do you split a string into a list? string.partition() string.split() split(string) 8 / 50 How do you check if a key exists in a dictionary? key in dict.keys() dict.contains(key) key in dict 9 / 50 What is the output of print(2 + 3)? 5 23 5 10 / 50 How do you iterate over a range in steps of 2? range(0, 10, 2) range(0, 10) range(2, step=2) 11 / 50 What is the output of len((1, 2, 3))? 4 2 3 12 / 50 How do you check if a list is empty? len(list) == 0 list.empty() list.isempty() 13 / 50 What is the result of 3 > 5 or 5 > 2? True False None 14 / 50 What is the output of bool(0)? False True 0 15 / 50 How do you get the ASCII value of a character? ascii('A') ord('A') ord.value('A') 16 / 50 What is a dictionary in Python? A key-value pair A list of values A set of numbers 17 / 50 How do you create a lambda function in Python? function(x): x + 1 lambda x: x + 1 lambda x -> x + 1 18 / 50 What does str(123) return? A float An integer A string 19 / 50 What is the result of not True? None True False 20 / 50 What is the result of "apple" * 2? Error ['apple', 'apple'] appleapple 21 / 50 What does isinstance("Python", str) return? False True None 22 / 50 Which method is used to get a value from a dictionary by key? get(key) find(key) search(key) 23 / 50 What is the result of 3 ** 2 in Python? 6 12 9 24 / 50 What keyword is used to define a loop in Python? for iterate repeat 25 / 50 Which method adds an element to the end of a list? append() push() add() 26 / 50 What is the default value of end in a print() function? "n" "," "." 27 / 50 What does the pop() method do in a list? Adds an element Sorts the list Removes the last element 28 / 50 How do you remove whitespace from the beginning and end of a string? clean() strip(" ") strip() 29 / 50 How do you exit a program with a status code? sys.exit(1) exit() quit(1) 30 / 50 What is the output of bool(None)? False Error True 31 / 50 What is the correct way to create a list in Python? (1, 2, 3) {1, 2, 3} [1, 2, 3] 32 / 50 How do you get the length of a list? count(list) size(list) len(list) 33 / 50 What is the output of bool([])? True False None 34 / 50 How do you terminate a program in Python? exit() break stop 35 / 50 How do you concatenate two strings? "concat()" "+" "&" 36 / 50 How do you open a file in write mode? open("file") open("file", "w") open("file", "r") 37 / 50 What is the result of [1, 2, 3] * 2? [1, 2, 3, 1, 2, 3] [2, 4, 6] Error 38 / 50 How do you get the remainder of a division? // divmod() % 39 / 50 How do you iterate over dictionary keys? dict.keys() dict.values() dict.items() 40 / 50 How do you define a function in Python? def func(): function func() def func() 41 / 50 How do you create a set in Python? [1, 2, 3] (1, 2, 3) {1, 2, 3} 42 / 50 What does type([]) return? <class 'dict'> <class 'list'> <class 'tuple'> 43 / 50 What does break do in a loop? Skips one iteration Ends the loop Repeats the loop 44 / 50 Which operator is used to find the remainder of division? / // % 45 / 50 What is the result of "Python".startswith("Py")? True False None 46 / 50 What does isinstance(x, int) check? If x is defined If x is a string If x is an integer 47 / 50 How do you convert a string to an integer? convert(string) str(int) int(string) 48 / 50 How do you round a number to two decimal places? approx(num, 2) num.round(2) round(num, 2) 49 / 50 What is the result of min([3, 1, 2])? 3 2 1 50 / 50 How do you convert a list into a set? list.unique() list.set() set(list) Your score is LinkedIn Facebook VKontakte 0% Exit