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
97c65d7b
Commit
97c65d7b
authored
Dec 01, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
klasy2 - spr pełnoletniości
parent
854fdd7c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
0 deletions
+12
-0
klasy2.py
dzien7/klasy_wprowadzenie/klasy2.py
+12
-0
No files found.
dzien7/klasy_wprowadzenie/klasy2.py
View file @
97c65d7b
...
...
@@ -12,6 +12,9 @@ class Osoba:
def
przedstaw_sie
(
self
):
print
(
f
'Nazywam się {self.imie} {self.nazwisko} i mam {self.wiek} lat'
)
def
jest_pelnoletnia
(
self
):
return
self
.
wiek
>=
18
# W tym przykładzie używamy klasy od razu w tym samym pliku,
# ale w praktyce częściej w jednym pliku definiuje się klasę, a w innym importuje i korzysta.
...
...
@@ -20,6 +23,15 @@ a = Osoba('Ala', 'Kowalska', 30)
b
=
Osoba
(
imie
=
'Bartek'
,
nazwisko
=
'Malinowski'
,
wiek
=
15
)
print
(
a
)
print
(
b
)
print
(
'
\n
Osoby się przedstawiają:'
)
a
.
przedstaw_sie
()
if
a
.
jest_pelnoletnia
():
print
(
f
'{a.imie} jest osobą pełnoletnią'
)
else
:
print
(
f
'{a.imie} jest osobą niepełnoletnią'
)
b
.
przedstaw_sie
()
if
b
.
jest_pelnoletnia
():
print
(
f
'{b.imie} jest osobą pełnoletnią'
)
else
:
print
(
f
'{b.imie} jest osobą niepełnoletnią'
)
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