You can write and run a small Python script that stores data in variables, converts between types, formats output, and makes decisions with if statements.
Values, types, and variables
Everything in Python is a value with a type. The main starter types are int for whole numbers (42), float for decimals (3.5), str for text ("hello"), and bool for True and False. A variable is just a name you attach to a value with =, as in price = 9.99. The name goes on the left, the value on the right; nothing is copied or reserved in advance.
You can always ask Python what it is holding. type(price) reports <class 'float'>, and print(price) shows the value. Types matter because they decide what operations mean: 3 * 2 is 6, but "ab" * 2 is "abab". When you mix incompatible types, like "Total: " + 9.99, Python raises a TypeError instead of guessing, which is a feature, not an annoyance.
Input, conversion, and f-strings
input() always hands you a string, even when the user types digits. So age = input("Age: ") followed by age + 1 fails. Convert first: age = int(input("Age: ")). Use int() for whole numbers, float() for decimals, and str() to turn a number back into text.
To build readable output, use an f-string: put an f before the quotes and drop expressions in braces. name = "Ana"; total = 12.5; print(f"{name} owes ${total:.2f}") prints Ana owes $12.50. The :.2f part rounds the display to two decimal places, which is exactly what you want for money on screen.
Decisions with if, elif, and else
An if statement runs a block only when a condition is True. Conditions come from comparisons (==, !=, <, >=) and can be combined with and, or, and not. Note the difference between = (assign) and == (compare); mixing them up is the classic first-week bug.
Indentation is the syntax. The lines under an if must be indented consistently, four spaces by convention, and Python uses that indentation to decide what belongs to the block. A chain runs top to bottom and stops at the first match: if score >= 90: grade = "A" then elif score >= 80: grade = "B" then else: grade = "C". Because it stops at the first true branch, order your conditions from strictest to loosest.
Write a script that asks for a meal price and a service rating typed as good, okay, or bad. Tip 20 percent for good, 15 percent for okay, and 10 percent for bad. Print the tip and the total, both formatted to two decimal places, in one sentence.
Hint
Convert the price with float() before doing math, and normalize the rating with .lower().strip() so " Good " still matches. Pick the tip rate with an if/elif/else chain, then compute tip = price * rate.
Solution
price = float(input("Meal price: "))
rating = input("Service (good/okay/bad): ").lower().strip()
if rating == "good":
rate = 0.20
elif rating == "okay":
rate = 0.15
else:
rate = 0.10
tip = price * rate
total = price + tip
print(f"Tip ${tip:.2f} on ${price:.2f} for a total of ${total:.2f}.")
A sample run with 40 and good prints: Tip $8.00 on $40.00 for a total of $48.00. If you want bad input rejected instead of defaulting to 10 percent, add a final else that prints a message and stops.