1) Which of the following is a valid variable name in Python? a) 2name b) my_name c) class d) print 2) "What will this code print?  a) HelloWorld b) Hello + World c) Hello World d) Error 3) Which method makes a string all uppercase? a) .upper() b) .capitalize() c) .lower() d) .replace() 4) True or False: A variable name in Python can include spaces. a) TRUE b) FALSE 5) True or False: The len() function can be used to count the number of characters in a string. a) TRUE b) FALSE 6) True or False: Functions in Python must always return a value. a) TRUE b) FALSE 7) "Fill in the blank to get the first character of the string word: a) 0 b) 2 c) 3 d) 1 8) Which of the following is NOT a valid Python data type? a) int b) str c) real d) list 9) "What will this code output? a) ALICE b) alice c) Alice d) Error 10) Which operator is used for exponentiation in Python? a) ^ b) ** c) exp() d) // 11) "What will this code print? a) 2 b) 2.5 c) 3 d) Error 12) True or False: Strings in Python are immutable. a) TRUE b) FALSE 13) Which function is used to find the length of a list or string? a) count() b) size() c) len() d) length() 14) Fill in the blank: The keyword used to return a value from a function is _____. a) return b) yield c) send d) output 15) Which method removes whitespace from both ends of a string? a) strip() b) trim() c) cut() d) split() 16) "What will this code print? a) y b) t c) P d) Error 17) Fill in the blank: To take input from the user, we use the _____ function. a) input() b) read() c) scan() d) ask() 18) "What will this code output? a) 10 b) 55 c) Error 19) Fill in the blank: The built-in function to convert a string to an integer is _____. a) int() b) str() c) float() d) convert() 20) True or False: In Python, you can assign multiple variables in one line. a) TRUE b) FALSE

Variable, Strings, Methods, Functions

Leaderboard

Visual style

Options

Switch template

Continue editing: ?