Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marian Esskaros
Tutoring_28_10_2021_Solutions
Commits
d53f54ae
Commit
d53f54ae
authored
Oct 29, 2021
by
Fabian Benc
Browse files
Added Elif Exercises solutions.
parent
a264a708
Changes
2
Hide whitespace changes
Inline
Side-by-side
Elif_Ex_1.py
0 → 100644
View file @
d53f54ae
"""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
Elif_Ex_2.py
0 → 100644
View file @
d53f54ae
"""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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment