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
46edaa06
Commit
46edaa06
authored
Nov 30, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
policz_znaki - v3 - inne znaki
parent
526d6ae0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
3 deletions
+8
-3
policz_znaki.py
dzien6/przyklady_funkcji/policz_znaki.py
+3
-3
policz_znaki_print.py
dzien6/przyklady_funkcji/policz_znaki_print.py
+2
-0
policz_znaki_pytest.py
dzien6/przyklady_funkcji/policz_znaki_pytest.py
+3
-0
No files found.
dzien6/przyklady_funkcji/policz_znaki.py
View file @
46edaa06
def
policz_znaki
(
napis
):
def
policz_znaki
(
napis
,
lewy
=
'<'
,
prawy
=
'>'
):
wynik
=
0
poziom
=
0
for
znak
in
napis
:
if
znak
==
'<'
:
if
znak
==
lewy
:
poziom
+=
1
elif
znak
==
'>'
:
elif
znak
==
prawy
:
poziom
-=
1
else
:
wynik
+=
poziom
...
...
dzien6/przyklady_funkcji/policz_znaki_print.py
View file @
46edaa06
...
...
@@ -3,3 +3,4 @@ from policz_znaki import *
print
(
policz_znaki
(
'ala ma <kota> a kot ma ale'
))
print
(
policz_znaki
(
'a <a<a<a>>>'
))
print
(
policz_znaki
(
'a <a<a<aaa>a>>'
))
print
(
policz_znaki
(
'ala [kota [a kot]] ma [ale]'
,
'['
,
']'
))
\ No newline at end of file
dzien6/przyklady_funkcji/policz_znaki_pytest.py
View file @
46edaa06
...
...
@@ -9,3 +9,6 @@ def test_policz_znaki_dwa_teksty():
def
test_policz_znaki_zagniezdzenie
():
assert
policz_znaki
(
'a <a<a<aaa>a>>'
)
==
14
def
test_policz_znaki_inne
():
assert
policz_znaki
(
'ala [kota [a kot]] ma [ale]'
,
'['
,
']'
)
==
18
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