bug: for some reason the binary adition question included the 0b on one occassion, dunno why, must investigate
This commit is contained in:
parent
8c9d854f16
commit
acff092e30
@ -1,6 +1,11 @@
|
||||
print("")
|
||||
import random
|
||||
|
||||
score = 0
|
||||
answered = 0
|
||||
def correct():
|
||||
global score
|
||||
score+=1
|
||||
print("Correct!")
|
||||
while True:
|
||||
'''
|
||||
Conversion ----- 2 -> 10
|
||||
@ -32,7 +37,7 @@ while True:
|
||||
print(start_int+start_frac," exp:", exponent)
|
||||
attempt = input()
|
||||
if float(attempt) == answer:
|
||||
print("Correct")
|
||||
correct()
|
||||
else:
|
||||
print(f"No, the answer was {answer}")
|
||||
if type_int == 1:
|
||||
@ -57,12 +62,12 @@ while True:
|
||||
attempt = input()
|
||||
if answer_in_bin_or_den == 1:
|
||||
if int(attempt) == answer:
|
||||
print("Correct")
|
||||
correct()
|
||||
else:
|
||||
print(f"No, the answer was {answer}")
|
||||
if answer_in_bin_or_den == 0:
|
||||
if str(bin(int(attempt,2)))[2:] == str(bin(answer))[2:]:
|
||||
print("Correct")
|
||||
correct()
|
||||
else:
|
||||
print(f"No, the answer was {bin(answer)}")
|
||||
if type_int == 0:
|
||||
@ -126,18 +131,18 @@ while True:
|
||||
attempt = input()
|
||||
if final_base == 16:
|
||||
if str(hex(int(attempt,16)))[2:] == str(hex(start_number))[2:]:
|
||||
print("Correct")
|
||||
correct()
|
||||
else:
|
||||
print(f"No, the answer was {hex(int(start_number))[2:]}")
|
||||
if final_base == 10:
|
||||
if str(int(attempt)) == str(int(start_number)):
|
||||
print("Correct")
|
||||
correct()
|
||||
else:
|
||||
print(f"No, the answer was {int(start_number)}")
|
||||
if final_base == 2:
|
||||
if str(bin(int(attempt,2)))[2:] == str(bin(start_number))[2:]:
|
||||
print("Correct")
|
||||
correct()
|
||||
else:
|
||||
print(f"No, the answer was {bin(start_number)[2:]}")
|
||||
|
||||
print("\n------------------------------------\n")
|
||||
answered+=1
|
||||
print(f"\nScore: {score}/{answered}\n------------------------------------\n")
|
||||
|
Loading…
x
Reference in New Issue
Block a user