Category: Code Exercises

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

September 1, 2023

Python Data Types Exercises

What is the output of the round() function? market_share = 12.03298 rounded_market_share = round(market_share, 2) print(rounded_market_share) 12.2 12.03 Submit How many arguments does the round function take in the given code snippet? market_share = 12.03298 rounded_market_share = round(market_share, 2) print(rounded_market_share) Two arguments including market_share and 2 12.03298 Submit Find the lowest price. product_prices = [27.99, […]

September 1, 2023

Python Data Types Exercises

What is the output of this code? hashtag = “#Python” hashtag_length = len(hashtag) print(hashtag_length) 6 7 Submit What is the output of this code? phone_number = ‘555-1234′ phone_number_length = len(phone_number) print(phone_number_length) 8 We can’t use the len function on this variable Submit When using the len() function in Python, does it count spaces as well? […]

September 1, 2023

Python Variable Exercises

Which function in Python is used to ask the user to enter information? input() print() Submit Get an email address from your user and print it. email_address = “”() print(email_address) print input Submit Add a prompt message to the input() function. email_address = input(”) print(email_address) Please enter your email address: ‘Please enter your email address:’ […]