Coding Pyhton Coding Test 0% Time Limit 10 minutes Maximum Allowed Time Is over Your Paper Successfully Sent. coding Python 1 / 50 What is the result of bool("False")? True None False 2 / 50 What is the result of 3 > 5 or 5 > 2? None True False 3 / 50 How do you open a file for reading in Python? open(file, "r") open(file, "w") open(file, "a") 4 / 50 What is the correct file extension for Python files? .py .pt .pyth 5 / 50 What is the output of [1, 2, 3][1]? 3 1 2 6 / 50 How do you access an element by key in a dictionary? dict.get("key") dict.key dict["key"] 7 / 50 What is the result of list(range(3, 6))? [1, 2, 3, 4, 5, 6] [3, 6] [3, 4, 5] 8 / 50 How do you get the absolute value of a number? abs(num) absolute(num) abs.value(num) 9 / 50 What is the purpose of the pass statement? To raise an error To do nothing To return a value 10 / 50 How do you create an infinite loop in Python? repeat forever for True: while True: 11 / 50 What is the output of type("123")? <class 'int'> <class 'float'> <class 'str'> 12 / 50 How do you swap two variables in Python? var1 = var2; var2 = var1 temp=var1; var1=var2; var2=temp var1, var2 = var2, var1 13 / 50 What is the keyword used to define a class in Python? def class object 14 / 50 How do you get the length of a dictionary? len(list) len(dict) count(dict) 15 / 50 How do you remove whitespace from the beginning and end of a string? strip(" ") strip() clean() 16 / 50 How do you handle exceptions in Python? if-else try-except try-catch 17 / 50 How do you get the ASCII value of a character? ord.value('A') ascii('A') ord('A') 18 / 50 What is the result of int(5.9)? 5 Error 6 19 / 50 What does continue do in a loop? Restarts the loop Skips the iteration Exits the loop 20 / 50 How do you exit a program with a status code? sys.exit(1) quit(1) exit() 21 / 50 What does type(10.5) return? <class 'float'> <class 'str'> <class 'int'> 22 / 50 What is the result of range(3)? A range object A tuple A list 23 / 50 What is the result of "Python" * 2? PythonPython PythonPython Error 24 / 50 Which module is used for mathematical operations? numbers math calc 25 / 50 Which method adds an element to the end of a list? add() append() push() 26 / 50 How do you terminate a program in Python? stop exit() break 27 / 50 How do you get the first character of a string? string.first() string[0:1] string[0] 28 / 50 How do you get the keys of a dictionary? dict.values() dict.items() dict.keys() 29 / 50 How do you declare a variable in Python? x = 5 declare x = 5 var x = 5 30 / 50 What does break do in a loop? Ends the loop Repeats the loop Skips one iteration 31 / 50 What is the result of bin(10)? 1010 Binary 0b1010 32 / 50 What is the output of not(True)? True False None 33 / 50 How do you handle exceptions in Python? if-else try-except handle 34 / 50 What is the purpose of the elif statement? To define a function To check another condition To end a loop 35 / 50 What is the result of 5 * 2 == 10? Error True False 36 / 50 What is the output of print(type(10))? <class 'str'> <class 'float'> <class 'int'> 37 / 50 How do you iterate over a range in steps of 2? range(0, 10) range(2, step=2) range(0, 10, 2) 38 / 50 What is the result of not True? None True False 39 / 50 What is the result of max([1, 5, 3])? 5 1 3 40 / 50 How do you check the type of a variable? checktype(var) isinstance(var) type(var) 41 / 50 How do you access the value of a key in a dictionary? dict.value(key) dict[key] key.dict() 42 / 50 What is the result of [1, 2, 3] + [4, 5]? [5, 4, 3, 2, 1] [1, 2, 3] [1, 2, 3, 4, 5] 43 / 50 What is the result of "Python"[::-1]? Python Error nohtyP 44 / 50 What does type([]) return? <class 'dict'> <class 'tuple'> <class 'list'> 45 / 50 How do you get the length of a list? size(list) count(list) len(list) 46 / 50 How do you iterate over dictionary keys? dict.keys() dict.values() dict.items() 47 / 50 What is the output of print(2 + 3)? 5 23 5 48 / 50 What is the result of "hello".title()? Hello Hello HELLO 49 / 50 How do you convert a string to an integer? str(int) int(string) convert(string) 50 / 50 What is the result of [1, 2, 3] * 2? [2, 4, 6] [1, 2, 3, 1, 2, 3] Error Your score is LinkedIn Facebook VKontakte 0% Exit