








Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!









โโ What data type is 3.14? Answer: Float โโ What follows the in keyword in a for loop? Answer: Iterable โโ Which loop is used when the number of iterations is known? Answer: for โโ A while loop requires: Answer: Condition + indented block โโ Which keyword exits a loop early? Answer: break โโ In for item in list, item is:
Answer: Value โโ Which structure prevents duplicates? Answer: Set โโ Which is immutable? Answer: Tuple โโ To run Python code from a file: Answer: Save + interpreter โโ Advantage of integrated terminal: Answer: No switching apps โโ Navigate directory command: Answer: cd โโ Interactive Python tool: Answer: Shell โโ Slice last 3 characters: Answer: (-3:)
โโ Default parameter syntax: Answer: name="World" โโ Boolean return: Answer: return number > 0 โโ Discount formula: Answer: price * (1 - percent/100) โโ Password strong condition: Answer: letters + numbers + length โโ Celsius to Fahrenheit: Answer: C * 9/5 + 32 โโ Last character fix: Answer: text(-1) โโ Even number check fix: Answer: return number%2== โโ Larger number logic:
Answer: return larger โโ range(5) produces: Answer: 0- 4 โโ len("hello") = Answer: 5 โโ Index starts at: Answer: 0 โโ Boolean values are: Answer: True/False โโ Function keyword: Answer: def โโ Return keyword does: Answer: exits function with value โโ List index access: Answer: list[0]
โโ type(5) returns: Answer: int โโ Convert string to int: Answer: int() โโ Logical AND operator: Answer: and โโ Logical OR operator: Answer: or โโ What is the operator for logical OR? Answer: B โโ What is the NOT operator? Answer: B โโ What is the equality check operator? Answer: B โโ What is the not equal operator?
Answer: B โโ What does input() return by default? Answer: C. String โโ How do you convert input to an integer? Answer: A. int(input()) โโ Which is a valid variable name? Answer: C. name_ โโ Which keyword defines a class? Answer: C. class โโ Which symbol is used for exponentiation? Answer: B. ** โโ What does // do? Answer: C. Floor division โโ What is the modulus operator? Answer: B. %
โโ What method removes whitespace from a string? Answer: B. strip() โโ How do you split a string into a list? Answer: B. split() โโ How do you join a list into a string? Answer: A. join() โโ What must dictionary keys be? Answer: B. Unique โโ How do you access a dictionary value? Answer: B. dict(key) โโ How do you add a key-value pair to a dictionary? Answer: B. dict(key)=value โโ How do you check if a key exists in a dictionary? Answer: A. key in dict โโ What is None in Python?
Answer: C. Null value โโ Which loop runs at least once? Answer: D. none โโ What does a function without a return give? Answer: C. None โโ What is the default function return type? Answer: C. None โโ Which keyword is for optional loop skip? Answer: C. continue โโ What does pass do? Answer: C. Does nothing โโ How do you create an empty list? Answer: C. Both โโ How do you create an empty dictionary? Answer: C. Both
โโ What is not True? Answer: B. False โโ Which is the correct comparison operator? Answer: B. == โโ What is a function parameter? Answer: A. Input variable โโ What is an argument? Answer: B. Passed value โโ What is the scope of a local variable? Answer: B. Inside function โโ What is the scope of a global variable? Answer: B. Entire program โโ Which keyword modifies a global variable? Answer: A. global โโ What does list slicing (1:3) mean?
Answer: B. index 1- 2 โโ What does (::-1) do? Answer: B. Reverse โโ What is the method to sort a list? Answer: A. sort() โโ How do you copy a list? Answer: A. list.copy() โโ What is the difference between = and copy()? Answer: B. Same object vs new object โโ What is a list comprehension example? Answer: A. (x for x in list) โโ What type of language is Python? Answer: B. Interpreted โโ