bug: for some reason the binary adition question included the 0b on one occassion, dunno why, must investigate

This commit is contained in:
deadvey 2024-11-15 01:06:56 +00:00
parent 8c9d854f16
commit acff092e30

View File

@ -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")