Computer Science, asked by samuelmendiola2004, 7 months ago

4.3 Code Practice: Question 1

Grandma Ester normally gives you hugs for your birthday - one for every year old you are. When you turned 15, she squished you with 15 hugs! This year, she, unfortunately, cannot see you on your birthday, so instead, she wants to send you virtual hugs!

Create a program that prompts the user for how old they are turning and then using a loop, output a virtual hug for every year old they are.

The following prints a single “virtual hug.”

print("**HUG**")

Answers

Answered by apayne
19

Written in Python

age = int(input("How old are you? "))

for i in range(1,age+1):

    print("**HUG**")

Explanation:

The first line prompts the user for age

age = int(input("How old are you? "))

The next line is an iteration that starts from 1 till the user input

for i in range(1,age+1):

The last line prints "**HUG**" while the iteration is true

    print("**HUG**")

Answered by DrizzyJxyy
0

Answer:age = int(input("How old are you? "))

for i in range(1,age+1):

   print("**HUG**")

Explanation:

The first line prompts the user for age

age = int(input("How old are you? "))

The next line is an iteration that starts from 1 till the user input

for i in range(1,age+1):

The last line prints "**HUG**" while the iteration is true

   print("**HUG**")

Explanation:

Similar questions