#๐ python while and for loops help
46 messages ยท Page 1 of 1 (latest)
@nimble trout
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
unreadable
im sorry ๐ญ
What do you need help with?
temp = float(input("What is the current temperature?: "))
Looks good to me
what's wrong with this line?
Yes
he's on call getting help
I need to use while loops
but for context
we did not do functions
temp = float(input("What is the current temperature?: "))
while True:
\n
print("The temperature is too high! Turn down the vat's temperature, wait 5 minutes, and check
print("The temperature is too high! \n Turn down the vat's temperature, wait 5 minutes, and check")
text
text
text
"""
print(a)```
print("The temperature is too high! Turn down the vat's temperature, wait 5 minutes, and check"
"
World""")
while True:
temp = float(input("What is the current temperature?: "))
if temp <= 102.5:
continue
elif temp > 102.5:
print("""The temperature is too high! Turn down the vat's temperature,
wait 5 minutes, and then check the temperature again.""")
temp = float(input("What is the current temperature?: ")
if temp < 102.5:
continue
elif temp > 102.5:
temp = float(input("What is the current temperature?: "))
else:
continue
while True:
temp = float(input("What is the current temperature?: "))
if temp <= 102.5:
print("This temperature is alright. Check back in 15 minutes")
continue
elif temp > 102.5:
print("""The temperature is too high! Turn down the vat's temperature,
wait 5 minutes, and then check the temperature again.""")
temp = float(input("What is the current temperature?: ")
if temp < 102.5:
continue
elif temp > 102.5:
temp = float(input("What is the current temperature?: "))
else:
continue
while True:
temp = float(input("What is the current temperature?: "))
if temp <= 102.5:
print("This temperature is alright. Check back in 15 minutes")
continue
elif temp > 102.5:
print("""The temperature is too high! Turn down the vat's temperature,
wait 5 minutes, and then check the temperature again.""")
temp = float(input("What is the current temperature?: "))
if temp < 102.5:
continue
elif temp > 102.5:
temp = float(input("What is the current temperature?: "))
else:
continue
while True:
temp = float(input("What is the current temperature?: "))
if temp <= 102.5:
print("This temperature is alright. Check back in 15 minutes")
continue
elif temp > 102.5:
print("""The temperature is too high! Turn down the vat's temperature,
wait 5 minutes, and then check the temperature again.""")
temp = float(input("What is the current temperature?: "))
if temp <= 102.5:
continue
elif temp > 102.5:
temp = float(input("What is the current temperature?: "))
else:
continue
After this print
print("""The temperature is too high! Turn down the vat's temperature,
wait 5 minutes, and then check the temperature again.""")
Delete the rest
Then use time.sleep()
I forget if its in seconds or milliseconds
be sure to import time at the top
But whatever its unit is, make sure it is 5 minutes
time.sleep() is seconds. Same as time.time() returns. It accepts floats, so you can sleep for less than a second if required.
We never did this in class ๐ญ
No import, no function
There's an unbounded amount of things you won't yet have done. Same for us.
But if you can't use this for the class, just assume the user using your script will just wait themselves, and only enter a new value at the input() when they're ready.
Then ask your teacher, how to make the script "wait" for 5 or 15 minutes?
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.