## Home

### Python Tuples Exercises

What is the output of this program? students = ([“John”, “Doe”], [“Jane”, “Smith”], [“Mike”, “Johnson”]) def print_student_info(students, student_index): print(‘Student name:’, students[student_index][0]) print(‘Student lastname:’, students[student_index][1]) print_student_info(students, 2) Student name: MikeStudent lastname: Johnson Student name: JaneStudent lastname: Smith Submit What is the output of this program? students = ([“John”, “Doe”], [“Jane”, “Smith”], [“Mike”, “Johnson”]) def print_student_info(students, student_index): […]

### Python Tuples Exercises

How do you describe the contents of the students? students = [ (“John”, 20, “Computer Science”), (“Emily”, 22, “Mathematics”), (“Michael”, 21, “Physics”), (“Sarah”, 19, “Biology”) ] A list of tuples A tuple of lists Submit What is the output of this program? students = [ (“John”, 20, “Computer Science”), (“Emily”, 22, “Mathematics”), (“Michael”, 21, “Physics”), […]

### Python Tuples Exercises

What is the type of the play_list ? play_list = [“Song 1”, “Song 2”, “Song 3”, “Song 4”, “Song 5”] It is a Tuple It is a List Submit What is the type of the products ? products = (“Apple”, “Banana”, “Orange”, “Grapes”, “Mango”) It is a List It is a Tuple Submit Retrieve the […]

### Python Loops Exercises

Write a Python program using a for loop to print the numbers from 1 to 5. # Print numbers 1 to 5 using a for loop for num in range(1, 6): print(”) Submit Complete this for loop . for ”(0, 10): print(num) range in num Submit What is the output of this code? for num […]

### Python Lists Exercises

Imagine you have a shopping list for groceries, and you realize that one of the items, ‘Milk’, needs to be updated to ‘Almond milk’. How would you update this item in the list? # Create a list of groceries groceries = [“Apples”, “Bread”, “Milk”, “Eggs”] # Update the item in the list ” print(groceries) = […]

### Python Lists Exercises

Complete the list definition. user_permissions = 2’Read’, ‘Write’, ‘Publish’, ‘Delete’] Submit Display the first permission in the list. user_permissions = [‘Read’, ‘Write’, ‘Publish’, ‘Delete’] first_permission = user_permissions[”] print(first_permission) Submit Display the last permission in the list. user_permissions = [‘Read’, ‘Write’, ‘Publish’, ‘Delete’] last_permission = user_permissions[”] print(last_permission) Submit Find the cheapeast item in the list. item_prices […]

### Python Custom Functions Exercises

Define a function that prints Hello Python! on the console. ” print_hello_python(): print(“Hello Python!”) Submit Call the function. def print_hello_python(): print(“Hello Python!”) ” ( print_hello_python ) : Submit Modify the function that accepts a string and prints it on the console. def print_string(”): print(input_string) print_string(“Hello Python!”) Submit This function takes a number and doubles it. […]

### Python Conditionals Exercises

What will be the value of the letter_grade variable? exam_score = 85 program_of_study = ‘Electrical Engineering’ if program_of_study == ‘Computer Science’: if exam_score >= 90: letter_grade = ‘A’ elif exam_score >= 80: letter_grade = ‘B’ elif exam_score >= 70: letter_grade = ‘C’ elif exam_score >= 60: letter_grade = ‘D’ else: letter_grade = ‘F’ elif program_of_study […]

### Python Conditionals Exercises

What will be the value of the shipping_cost variable? destination_zone = “Zone C” if destination_zone == “Zone A”: shipping_cost = 10.0 elif destination_zone == “Zone B”: shipping_cost = 15.0 elif destination_zone == “Zone C”: shipping_cost = 20.0 else: shipping_cost = 25.0 print(“The shipping cost to”, destination_zone, “is:”, shipping_cost) 20.0 25.0 Submit What will be the […]