Here’s a simple Python program that accomplishes what you described:
# Ask the user for their age
age = input("Enter your age: ")
# Convert the input to an integer
age = int(age)
# Calculate the number of candles needed
candles_needed = age + 1
# Print the result
print("You will need this many candles for your birthday cake:")
print(candles_needed)
How it works:
- The program prompts the user to enter their age.
- It retrieves the input as a string and converts it to an integer using
int()
. - The program calculates the number of candles needed by adding one to the user's age.
- Finally, it prints the number of candles they’ll need for their birthday cake.
Example usage:
If the user enters 117
, the output will be:
Enter your age: 117
You will need this many candles for your birthday cake:
118
You can run this program in any Python environment, such as an interpreter or an IDE that supports Python.