Does anyone have the answers to 4.2 code practice question 1 and 2 on edhesive? for computer science
Answers
Answer:
Question 1:
u=float(input("Enter a number"))
c = 1
while (u <= 100):
n = float(input("Enter a number"))
u = u + n
c = c + 1
print ("Sum: " + str (u))
if(u > 100):
print ("Numbers Entered: " + str(c))
Question 2:
pet=input("What pet do you have? ")
c=1
while(pet!="rock"):
print("You have a " + pet + " with a total of " + str(c) + " pet(s)")
pet = input("What pet do you have?")
c = c + 1
Explanation:
hope this helped!! Please tell me if there is anything wrong
Answer: num = float(input("Enter a number"))
c = 1
while (num <= 100):
n = float(input("Enter a number"))
num = num + n
c = c + 1
print ("Sum: " + str (num))
if (num > 100):
print ("Numbers Entered: " + str(c))
2nd:
pet = input("What pet do you have? ")
c=1
while(pet!="rock"):
print("You have a " + pet + " with a total of " + str(c) + " pet(s)")
pet = input("What pet do you have?")
c = c + 1
Explanation: Hope I helped!