
IA - 2 - Python
Quiz by Dr. Dishant Pandya
Tag the questions with any skills you have. Your dashboard will track each student's mastery of each skill.
Which of the following is the correct way to create an empty set in Python?
Which method adds an element to a set?
What does the intersection() method do?
How do you access the value associated with a key 'name' in a dictionary my_dict?
Which is a valid way to access the value 'apple' in the following nested structure: data = {'fruits': ['apple', 'banana']}?
What function is used to get user input in Python?
What does the modulo operator (%) do?
Which keyword is used to start a while loop?
Which keyword is used to immediately exit a loop?
What does the continue keyword do in a loop?
A program asks the user for their desired rental car. What data type should store the user's input?
Which code snippet correctly checks if a number num is a multiple of ten?
In a loop asking for pizza toppings, which keyword would allow the user to type "quit" to exit the loop?
What method is used to remove an item from a list at a specific index?
Which method removes all instances of a specific value from a list?
Which keyword is used to define a function?
What are the values passed to a function called?
What is the term for the variables listed in the function definition?
What type of argument is passed with name='value' syntax?
Which of these is an invalid way to call a function greet(name, greeting="Hello")?
What is the purpose of a default value for a parameter?
What happens if you call a function with fewer arguments than required parameters (and no default values)?
A function describe_city(city, country='default_country') is defined. What will happen if you call describe_city('London')?
What should a simple function called display_message() likely do?
What is the primary benefit of using functions in programming?
What is the potential issue with modifying a list directly while iterating over it with a for loop?
What is a recursive function?
Which dictionary method returns a view object containing the keys of the dictionary?
You have a dictionary where keys are strings and values are lists of numbers. You want to calculate the sum of all the numbers across all the lists. Which code snippet accomplishes this correctly?
You want to create a function that can accept a variable number of keyword arguments (kwargs). Which code snippet demonstrates the correct way to do this?