I am trying to figure out how to run multiple lines of code from python in html
So far i have:
<!DOCTYPE html>
<html>
<py-script>
print()
print("Select The Corresponding Number Or Word For The Operation To Perform:")
print("Type 'quit' To Quit")
print("1. ADD")
operation = input().lower()
# --- ADD --- #
if operation == "1" or operation == "add":
addend1 = float(input("Enter The First Number: "))
addend2 = float(input("Enter The Second Number: "))
print("The Result Is ", str(addend1 + addend2))
<py-script>
</html>
The output is:
print() print("Select The Corresponding Number Or Word For The Operation To Perform:") print("Type 'quit' To Quit") print("1. ADD") print("2. SUBTRACT") print("3. MULTIPLY") print("4. DIVIDE") operation = input().lower() # --- ADD --- # if operation == "1" or operation == "add": addend1 = float(input("Enter The First Number: ")) addend2 = float(input("Enter The Second Number: ")) print("The Result Is ", str(addend1 + addend2)) # --- SUBTRACT --- # elif operation == "2" or operation == "subtract": number1 = int(input("Enter the first number")) number2 = int(input("Enter the second number")) print("The Diffrence Is ", str(number1 - number2)) # --- MULTIPLY --- # elif operation == "3" or operation == "multiply": multiplicand = float(input("Enter The First Number: ")) multiplier = float(input("Enter The Second Number: ")) print("The Product Is ", str(multiplicand * multiplier)) # --- DIVIDE --- # elif operation == "4" or operation == "divide": dividend = float(input("Enter The First Number: ")) divisor = float(input("Enter The Second Number: ")) print("The Result Is ", str(dividend / divisor))
Please note that i copy and pasted the output and it is writen on one line on the website
I don't know what i am doing that well because this is one of my first times using 'pyscript' so if you could explain something that i haven't been able to find i would be great full