Python practice: Variables & Data Types
Chapter 2 · 8 questions · free to solve
Question 1 · easy
Store order price
Solve it in your browserCreate a variable
price = 250andquantity = 3. Multiply them to computetotaland printtotal:Question 2 · easy
Inspect data types
Solve it in your browserCreate
units = 15andrate = 45.5. Printtype(units)on the first line andtype(rate)on the second line:Question 3 · easy
Type casting string to integer
Solve it in your browserGiven raw input strings
raw_price = "450"andraw_tax = "81", cast them to integers and print their numeric sum531:Question 4 · easy
Type casting float to string
Solve it in your browserConvert decimal
margin = 0.25into a string usingstr(margin)and printf"Margin: {str(margin)}":Question 5 · easy
Update variable with +=
Solve it in your browserInitialize
balance = 1000. Add250using+=, then add another100using+=. Printbalance:Question 6 · easy
Boolean variable flag
Solve it in your browserCreate a boolean flag
is_delivered = True. Print the variable and its type on separate lines:Question 7 · easy
Snake_case naming convention
Solve it in your browserCreate three variables:
unit_cost = 80,sales_tax = 14, andfinal_price = unit_cost + sales_tax. Printfinal_price:Question 8 · medium
Gross margin calculation
Solve it in your browserGiven
revenue = 50000andcogs = 35000, computegross_profit = revenue - cogsandmargin_pct = gross_profit / revenue. Printmargin_pct:
These questions are free.
Make a free account to solve them, with instant checking and an AI tutor for hints.
Start free