Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kurs_alx_pcz
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patryk Czarnik
kurs_alx_pcz
Commits
e39ab026
Commit
e39ab026
authored
Nov 16, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kalkulatory kolejne wersje
parent
c20aeaf2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
0 deletions
+46
-0
kalkulator1.py
dzien2/kalkulator1.py
+8
-0
kalkulator2.py
dzien2/kalkulator2.py
+17
-0
kalkulator3.py
dzien2/kalkulator3.py
+21
-0
No files found.
dzien2/kalkulator1.py
View file @
e39ab026
...
...
@@ -7,3 +7,11 @@ if op == '-': print(x - y)
if
op
==
'*'
:
print
(
x
*
y
)
if
op
==
'/'
:
print
(
x
/
y
)
# w tej wersji, aby sprawdzić, czy użytkownik podał nieznaną operację,
# nie wystarczy dopisać else - bo byłby to else tylko do ostatniego ifa
# if op != '+' and op != '-' and op != '*' and op != '/':
# print('Nieznana operacja')
if
op
not
in
{
'+'
,
'-'
,
'*'
,
'/'
}:
print
(
'Nieznana operacja'
)
dzien2/kalkulator2.py
0 → 100644
View file @
e39ab026
x
=
int
(
input
(
'Podaj pierwszą liczbę: '
))
y
=
int
(
input
(
'Podaj drugą liczbę: '
))
op
=
input
(
'Podaj znak operacji: '
)
if
op
==
'+'
:
print
(
x
+
y
)
elif
op
==
'-'
:
print
(
x
-
y
)
elif
op
==
'*'
:
print
(
x
*
y
)
elif
op
==
'/'
:
if
y
==
0
:
print
(
'Nie wolno dzielić przez zero!'
)
else
:
print
(
x
/
y
)
else
:
print
(
'Nieznana operacja'
)
dzien2/kalkulator3.py
0 → 100644
View file @
e39ab026
x
=
int
(
input
(
'Podaj pierwszą liczbę: '
))
y
=
int
(
input
(
'Podaj drugą liczbę: '
))
op
=
input
(
'Podaj znak operacji: '
)
if
op
==
'+'
:
wynik
=
x
+
y
elif
op
==
'-'
:
wynik
=
x
-
y
elif
op
==
'*'
:
wynik
=
x
*
y
elif
op
==
'/'
:
if
y
==
0
:
wynik
=
'Nie wolno dzielić przez zero!'
else
:
wynik
=
x
/
y
else
:
wynik
=
'Nieznana operacja'
# wpisywanie do tej samej zmiennej czasami liczb, a czasami tekstów jest złym stylem programowania - później zrobimy to lepiej za pomocą wyjątków
print
(
wynik
)
Write
Preview
Markdown
is supported
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