Created
May 1, 2020 15:09
-
-
Save tetchel/136551fe29cb31a3097c7773c180144a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# oh god why | |
# https://i.redd.it/azecoqeevyv41.jpg | |
operators = [ "+", "-", "*" ] | |
output = "" | |
output += """#!/usr/bin/env python3 | |
# why is it 'sign' lol what a shit variable name | |
signs = [ "+", "-", "*" ] | |
num1 = input("Enter the first number: ") | |
sign = input("Enter the sign ({}): ".format(", ".join(signs))) | |
if not sign in signs: | |
print("Invalid sign '{}' so the program is exiting cause I don't know how to use loops".format(sign)) | |
quit() | |
num2 = input("Enter the second number: ") | |
num1 = int(num1) | |
num2 = int(num2) | |
""" | |
start = 1 | |
# I tried 32 but then I got a runtime error: RecursionError: maximum recursion depth exceeded during compilation | |
end = 26 | |
first = True | |
for i in range(start, end): | |
for op in operators: | |
for j in range(start, end): | |
cnd = "if" if first else "elif" | |
output += "{} num1 == {} and sign == '{}' and num2 == {}:\n".format(cnd, i, op, j) | |
answer = eval("{} {} {}".format(i, op, j)) | |
output += " print({})\n".format(answer) | |
first = False | |
output += """else: | |
print("Sorry I don't know that one :(") | |
""" | |
print(output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment