Commit d53f54ae authored by Fabian Benc's avatar Fabian Benc
Browse files

Added Elif Exercises solutions.

parent a264a708
"""Create a program that will perform the following operations for the entered two numbers:
addition, subtraction, multiplication and division.
Initially, it is necessary to allow the user to enter two numbers,
then select the operation by selecting the character of that operation (+, -, *, /). """
n = int(input("Enter 1st number: "))
m = int(input("Enter 2nd number: "))
o = input("Enter operation: ")
if o == '+':
print(n + m)
elif o == '-':
print(n - m)
elif o == '*':
print(n * m)
elif o == '/':
print(n / m)
\ No newline at end of file
"""Write a program that will allow the user to enter a desired number. The entered number should be divided by 3.
Then if the remainder of the division with number 3 is:
equal to zero print “blue”, equal to 1, print “red”, equal to 2, print “green”, equal to 3, print “purple”, otherwise print “yellow”."""
n = int(input("Enter a number: "))
if n % 3 == 0:
print("blue")
elif n % 3 == 1:
print("red")
elif n % 3 == 2:
print("green")
elif n % 3 == 3:
print("purple")
else:
print("yellow")
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment