Twee getallen toevoegen in Python
Leer hoe u twee getallen toevoegt in Python.
Gebruik de +
operator om twee getallen toe te voegen:
Voorbeeld
x = 5
y = 10
print(x + y)
Twee nummers toevoegen met gebruikersinvoer
In dit voorbeeld moet de gebruiker twee cijfers invoeren. Vervolgens drukken we de som af door de twee getallen te berekenen (optellen):
Voorbeeld
x = input("Type a number: ")
y = input("Type another number: ")
sum
= int(x) + int(y)
print("The sum is: ", sum)