-
What is the output of the round() function?
market_share = 12.03298 rounded_market_share = round(market_share, 2) print(rounded_market_share)
-
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)
-
Find the highest temperature.
daily_temperatures = [25, 28, 29, 26, 30, 27] highest_temperature = ''(daily_temperatures) print(highest_temperature)
-
What is the return type of the input() function?
contact_number = input('Please enter your contact number:')
-
What is type casting in Python?
-
Cast the image_resolution from string to integer.
image_resolution = '72' casted_image_resolution = ''(image_resolution)
-
What is wrong with this code?
message = 'You have ' + 5 + ' new messages.' print(message)
-
Debug this code.
message = 'You are customer number: ' + ''(1005)
-
Complete this code.
item_count = 5 cart_message = 'You have ' + ''(item_count) + ' items in your cart.' print(cart_message)
-
Suppose you are organizing an event. Complete the code to determine the number of chairs needed based on the number of attendees and an additional 10 extra chairs.
attendees = input('How many people are attending the event? ') chairs_needed = ''(attendees) + 10 print('You need ' + str(chairs_needed) + ' chairs for the event.')
-
Complete the program based on the following logic: Imagine you are organizing a school picnic, and you need to determine the total cost of food based on the number of students attending and the cost per meal. * cost_per_meal could be a floating point number
num_students = input('Enter the number of students attending the picnic: ') cost_per_meal = input('Enter the cost per meal: ') total_cost = int(num_students) * ''(cost_per_meal) print('The total cost of food for the picnic is: ' + str(total_cost))
Python Exercises for Data Types
If you’ve faced difficulties with these exercises, take a look at Data Types Module on my Python course.
You can also share ‘Python Data Types’ Exercises on your:
X (Twitter) – Telegram – Linkedin – Facebook – or on your favorite platform…