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
526d6ae0
Commit
526d6ae0
authored
Nov 30, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
policz_znaki - v2 zagnieżdżenia
parent
3096a300
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
5 deletions
+8
-5
policz_znaki.py
dzien6/przyklady_funkcji/policz_znaki.py
+5
-5
policz_znaki_pytest.py
dzien6/przyklady_funkcji/policz_znaki_pytest.py
+3
-0
No files found.
dzien6/przyklady_funkcji/policz_znaki.py
View file @
526d6ae0
def
policz_znaki
(
napis
):
def
policz_znaki
(
napis
):
wynik
=
0
wynik
=
0
czy_liczyc
=
False
poziom
=
0
for
znak
in
napis
:
for
znak
in
napis
:
if
znak
==
'<'
:
if
znak
==
'<'
:
czy_liczyc
=
True
poziom
+=
1
elif
znak
==
'>'
:
elif
znak
==
'>'
:
czy_liczyc
=
False
poziom
-=
1
el
if
czy_liczyc
:
el
se
:
wynik
+=
1
wynik
+=
poziom
return
wynik
return
wynik
dzien6/przyklady_funkcji/policz_znaki_pytest.py
View file @
526d6ae0
...
@@ -4,5 +4,8 @@ def test_policz_znaki_jeden_tekst():
...
@@ -4,5 +4,8 @@ def test_policz_znaki_jeden_tekst():
wynik
=
policz_znaki
(
'ala ma <kota> a kot ma ale'
)
wynik
=
policz_znaki
(
'ala ma <kota> a kot ma ale'
)
assert
wynik
==
4
assert
wynik
==
4
def
test_policz_znaki_dwa_teksty
():
assert
policz_znaki
(
'Ala ma <kota> a Ola ma <psa>'
)
==
7
def
test_policz_znaki_zagniezdzenie
():
def
test_policz_znaki_zagniezdzenie
():
assert
policz_znaki
(
'a <a<a<aaa>a>>'
)
==
14
assert
policz_znaki
(
'a <a<a<aaa>a>>'
)
==
14
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