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
7abf7b9c
Commit
7abf7b9c
authored
Nov 16, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
if and or dla wartości innych typów
parent
ab422039
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
0 deletions
+39
-0
inne_typy.py
dzien2/teoria_if/inne_typy.py
+39
-0
No files found.
dzien2/teoria_if/inne_typy.py
0 → 100644
View file @
7abf7b9c
# W Pythonie nie tylko wartości True i False typu bool nisą w sobie wartość logiczną,
# ale także wartości innych typów. Mogą one być umieszczone w if (albo while),
# mogą być umieszczanie w spójnikach logicznych and i or.
liczba0
=
0
liczba1
=
1
liczba2
=
-
3.14
napis0
=
''
napis1
=
'Ala ma kota'
napis2
=
' '
lista0
=
[]
lista1
=
[
'Adam'
,
'Ludwik'
,
'Xawery'
]
if
liczba0
:
print
(
'liczba0 true'
)
else
:
print
(
'liczba0 false'
)
if
napis0
:
print
(
'napis0 true'
)
else
:
print
(
'napis0 false'
)
if
napis2
:
print
(
'napis2 true'
)
else
:
print
(
'napis2 false'
)
print
()
# Gdy używamy spójników logicznych and or , to wynikiem jest jeden z przekazanych argumentów (a niekoniczenie wartość True / False)
# and: jeśli jedna z wartości jest fałszywa, to and zwraca pierwszą z takich wartości
# jeśli wszystkie są prawdą, to and zwraca ostatnią rzecz po prawej stronie
print
(
'and:'
,
lista1
and
liczba0
and
liczba1
and
liczba2
)
print
(
'and:'
,
lista1
and
napis1
and
liczba1
and
liczba2
)
# or: jeśli jedna z wartości jest prawdą, to or zwraca pierwszą z takich wartości
# jeśli wszystkie są fałśzem, to or zwraca ostatnią rzecz po prawej stronie
print
(
'or:'
,
liczba0
or
liczba1
or
liczba2
)
print
(
'or:'
,
liczba0
or
napis0
or
liczba2
)
print
(
'or:'
,
liczba0
or
napis0
or
lista0
)
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