Coding Pyhton Coding Test 0% Time Limit 10 minutes Maximum Allowed Time Is over Your Paper Successfully Sent. coding Python 1 / 50 How do you import a module in Python? import math module import math use math 2 / 50 How do you access the value of a key in a dictionary? key.dict() dict.value(key) dict[key] 3 / 50 What is the result of int(5.9)? Error 6 5 4 / 50 What is the output of [1, 2, 3][1]? 2 1 3 5 / 50 How do you handle exceptions in Python? try-catch try-except if-else 6 / 50 What is the result of "apple".replace("a", "o")? opple Error appoe 7 / 50 What is the keyword used to define a class in Python? def object class 8 / 50 Which keyword is used to import all contents of a module? * import_all all 9 / 50 What is the correct file extension for Python files? .pyth .pt .py 10 / 50 What is the output of type("123")? <class 'int'> <class 'str'> <class 'float'> 11 / 50 What is the result of "abc".upper()? Abc abc ABC 12 / 50 How do you raise a number to a power? num**power pow(num, power) num^power 13 / 50 What is the result of bool([1, 2])? None False True 14 / 50 How do you iterate over dictionary keys? dict.items() dict.keys() dict.values() 15 / 50 How do you define a function in Python? def func(): def func() function func() 16 / 50 What does is compare in Python? Object identities Memory usage Values only 17 / 50 How do you delete a key-value pair in a dictionary? pop dict[key] remove dict[key] del dict[key] 18 / 50 What is the result of 3 > 1 and 4 > 5? True False None 19 / 50 How do you exit a program with a status code? sys.exit(1) exit() quit(1) 20 / 50 What is the output of bool(None)? False True Error 21 / 50 How do you concatenate two strings? "+" "concat()" "&" 22 / 50 What is the result of 3 ** 2 in Python? 9 6 12 23 / 50 What is the result of len("Python")? 5 7 6 24 / 50 How do you call a function my_function in Python? my_function() my_function call my_function 25 / 50 What is the output of "hello".count("l")? 1 3 2 26 / 50 How do you start a function with optional arguments? def func(a): def func(a: int): def func(a=1): 27 / 50 What is the result of not True? None True False 28 / 50 What is the purpose of the return keyword? To exit a function To repeat a value To print a value 29 / 50 How do you round a number to two decimal places? approx(num, 2) round(num, 2) num.round(2) 30 / 50 What keyword is used to define a loop in Python? for iterate repeat 31 / 50 What is the output of print(2 ** 3)? 8 9 6 32 / 50 How do you define a constant in Python? const var Use uppercase names define(var) 33 / 50 What is the output of "abc".capitalize()? ABC abc Abc 34 / 50 How do you create a dictionary in Python? {} [] dict() 35 / 50 Which operator is used for equality comparison? == === = 36 / 50 What is the result of "apple" * 2? appleapple ['apple', 'apple'] Error 37 / 50 How do you check if a key exists in a dictionary? dict.exist(key) dict.has_key() key in dict 38 / 50 What is the result of 3 > 5 or 5 > 2? True False None 39 / 50 What is the output of bool(0)? False 0 True 40 / 50 What is the result of "Python" * 2? PythonPython PythonPython Error 41 / 50 What does int("10") return? A string An integer A float 42 / 50 How do you create a set in Python? [1, 2, 3] {1, 2, 3} (1, 2, 3) 43 / 50 What is the result of range(3)? A list A range object A tuple 44 / 50 How do you open a file for reading in Python? open(file, "w") open(file, "a") open(file, "r") 45 / 50 What is the result of bin(10)? 0b1010 Binary 1010 46 / 50 How do you convert a list to a set in Python? {list} set(list) list(set) 47 / 50 What is the result of 10 // 3? 3.33 10 3 48 / 50 How do you swap two variables in Python? temp=var1; var1=var2; var2=temp var1, var2 = var2, var1 var1 = var2; var2 = var1 49 / 50 What is the output of print(3 == 3.0)? False True Error 50 / 50 What is the default value of end in a print() function? "." "," "n" Your score is LinkedIn Facebook VKontakte 0% Exit