Day: September 1, 2023

September 1, 2023

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

September 1, 2023

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

September 1, 2023

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

September 1, 2023

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

September 1, 2023

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

September 1, 2023

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

September 1, 2023

Python Operators Exercises

Check if the gadget is affordable or not ? my_budget = 120.00 gadget_price = 80.50 is_gadget_affordable = my_budget ” gadget_price print(‘Is gadget affordable?’, is_gadget_affordable) == >= = previous_month_conversion_rate print(‘Has the conversion rate improved compared to last month?’, is_conversion_improvement) Yes No Submit Python Exercises for Operators If you’ve faced difficulties with these exercises, take a look […]