## Tag: Exercise

### 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 […]

### Python Conditionals Exercises

Write a condition that checks if the item is affordable. item_price = 1900.25 wallet = 2100.50 if ”: print(‘The item is affordable!’) wallet item_price max_file_size: print(‘File size exceeds the maximum allowable limit.’) print(‘Please choose a smaller file.’) Submit Check if the file size exceeds the maximum allowable size for uploading. Otherwise upload the file. file_size […]

### Python Operators Exercises

Suppose to initiate the shipping process for a product, two conditions must be met: The product must be in stock The customer’s shipping address must be within the country Now, determine whether the order should be processed for shipping or not? product_in_stock = True customer_shipping_address_within_country = True is_eligible_for_shipping = product_in_stock and customer_shipping_address_within_country print(‘Is eligible for […]