-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy path004_strings.py
58 lines (48 loc) · 1.49 KB
/
004_strings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Video: https://youtu.be/MMxxnj5aP8Y
# String vieme definovat pomocou dvojitych uvodzoviek
string="This is string"
# String, hocijaky datovy typ ale aj premennu vieme vypisat pomocou funkcie print
print(string)
print(1)
print(1.5)
print(True)
jablka = 4
print(jablka)
print("Priamy vypis stringu")
# String vieme definovat aj jednoduchymi uvodzovkami
string='This is string with single quotes'
print(string)
# Takto vieme napisat uvodzovku v stringu definovanom uvodzovkami.
string='This is single quote \' in single quote string'
print(string)
# Takto vieme napisat dvojtu uvodzovku v stringu definovanom uvodzovkami.
string='This is double quote " in single quote'
print(string)
# Takto vieme napisat uvodzovku v stringu definovanom dvojtymi uvodzovkami.
string="This is single quote ' in double quote"
print(string)
# \n je symbol noveho riadku, ktory vidime len pomocou funkcie print
string="This is string with \nnew line"
print(string)
# \t je symbol tabulatoru, ktory vidime len pomocou funkcie print
string="This is string with \n\tnew line and tab"
print(string)
# Co ak nechceme vypisat novy riadok ? Pouzijeme r pred definiciou stringu
tricky_string_path="C:\documents\notes"
print(tricky_string_path)
tricky_string_path_fixed=r"C:\documents\notes"
print(tricky_string_path_fixed)
# String vieme definovat aj na viac riadkov
string="""
This is
multiline
string.
"""
print(string)
# a takto sa zbavime zbytocnych mnovych riadkov
string="""\
This is
multiline
string. Empty lines fixed\
"""
print(string)