This question already has an answer here:
I'm trying to write a program that if a user inputs true, the code will run the set of following if statements for true, and if false skip to the if false statements and run. The program asks the user to input two values and answer a true/false statement, but does recognize when the answer is false.
giga = float(input("Enter CPU gigahertz:\n"))
core_count = int(input("Enter CPU core count:\n"))
hyper = input("Enter CPU hyperthreading (True or False):\n")
if hyper == "true" or "True":
if giga >= 1.9 and giga < 2.4:
if core_count>=2 and core_count :
print("\nThat is a low-performance CPU.")
elif giga >= 2.4 and giga < 2.7:
if core_count>=4 and core_count <6:
print("\nThat is a medium-performance CPU.")
elif 4>core_count>=2:
print("\nThat is a low-performance CPU.")
elif hyper == "false" or "False":
if giga >= 2.4 and giga < 2.8:
if core_count >= 2 and core_count < 6:
print("\nThat is a low-performance CPU.")
The code works for some values but when the user chooses "false" it prints the statements that correspond with the "true" values.
Aucun commentaire:
Enregistrer un commentaire