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
855843f4
Commit
855843f4
authored
Nov 17, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FizzBuzz - list vs set
parent
289fabd4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
0 deletions
+42
-0
fizz_buzz_dalsze_wariacje_lista.py
dzien3/zadania/fizz_buzz_dalsze_wariacje_lista.py
+20
-0
fizz_buzz_dalsze_wariacje_zbior.py
dzien3/zadania/fizz_buzz_dalsze_wariacje_zbior.py
+22
-0
No files found.
dzien3/zadania/fizz_buzz_dalsze_wariacje_lista.py
0 → 100644
View file @
855843f4
limit
=
int
(
input
(
'Podaj limit: '
))
podzielne3
=
[]
podzielne5
=
[]
for
i
in
range
(
1
,
limit
+
1
):
if
i
%
3
==
0
:
podzielne3
.
append
(
i
)
if
i
%
5
==
0
:
podzielne5
.
append
(
i
)
print
(
'Podzielne przez 3:'
,
podzielne3
)
print
(
'Podzielne przez 5:'
,
podzielne5
)
print
(
'Liczba podzielnych przez 3:'
,
len
(
podzielne3
))
print
(
'Liczba podzielnych przez 5:'
,
len
(
podzielne5
))
# źle! Bo w liście będą powtórzenia i liczby takie jak 15 30 zostaną policzone dwukrotnie
print
(
'Liczba podzielnych przez 3 lub 5:'
,
len
(
podzielne3
+
podzielne5
))
print
(
podzielne3
+
podzielne5
)
dzien3/zadania/fizz_buzz_dalsze_wariacje_zbior.py
0 → 100644
View file @
855843f4
limit
=
int
(
input
(
'Podaj limit: '
))
podzielne3
=
set
()
podzielne5
=
set
()
for
i
in
range
(
1
,
limit
+
1
):
if
i
%
3
==
0
:
podzielne3
.
add
(
i
)
if
i
%
5
==
0
:
podzielne5
.
add
(
i
)
print
(
'Podzielne przez 3:'
,
podzielne3
)
print
(
'Podzielne przez 5:'
,
podzielne5
)
print
(
'Liczba podzielnych przez 3:'
,
len
(
podzielne3
))
print
(
'Liczba podzielnych przez 5:'
,
len
(
podzielne5
))
print
(
'
\n
Liczba podzielnych przez 3 lub 5:'
,
len
(
podzielne3
|
podzielne5
))
print
(
podzielne3
|
podzielne5
)
print
(
'
\n
Liczba podzielnych przez 3 i 5 jednocześnie:'
,
len
(
podzielne3
&
podzielne5
))
print
(
podzielne3
&
podzielne5
)
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