Answer to Question #143415 in Python for owen weston

Question #143415
3.7 Code Practice
Instructions
When we read code and predict its output, it is called tracing code.

For this lesson, you will come up with your own challenging algorithm for other students to trace. It must contain at least 5 if statements and use at least one AND or OR boolean condition.

Note: Elif or else statements will not count - your statements must be if statements. Each if statement should use a unique variable name.

For this challenge, try reading 3 or 4 of your classmates' code as well. Trace their code and predict what it will output, then check the code by running it to see if you got it right, and submit your work for a grade.
1
Expert's answer
2020-11-10T07:35:18-0500

1.



largest = None

for i in range(0,6):

d = int(input("Enter a number: "))

if not largest or d > largest:

largest = d

print("Largest: " + str(largest)


2.


name = input("What's your name?")

if name == "no" or name == "NO" or name == "name":
print("That's not a name!")
else:
print("Hello " + name)

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

if age < 13:
print("Why are you on the Internet??")
elif age < 18:
print("High school's cool")
else:
print("Wow, a real adult!")


dogs = input("Do you like dogs?")

if dogs == "yes" or dogs == "YES":
fish = input("Do you also like fish?")

if fish == "yes" or fish == "YES":
print("What an animal lover!")
else:
print("Yeah, dogs are great!")
else:
cats = input("What about cats?")

if cats == "no" or cats == "NO":
print("Maybe horses or bunnies?")
else:
print("Cats are cool")​

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS