Skip to content

Commit

Permalink
Examples in Python for 1st, 2nd and 3rd files (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
anisaAnya authored Feb 10, 2021
1 parent 218110c commit e32fc5c
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Python/1-comments.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# single comment


"""
Multiline comments do not actualy exist in Python
Sometimes you can meet creating of multiline comments by using tripple quotes,
but that is not a comments in general.
Tripple quotes in python treats as regular string and
if it is not assigned to any variable it will be immediately garbage collected
as soon as that code executes. So it doesn't affect execution.
"""
16 changes: 16 additions & 0 deletions Python/2-declaration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#print(a)
#NameError: name 'a' is not defined

a = 5
print(a)
type(a)
#<class 'int'>

b = 5.2

dic = {'d': a, 'c': b}
#obj
print("Dictionary is: ", dic)

dic['c'] = 10
print("Dictionary has been changed: ", dic)
29 changes: 29 additions & 0 deletions Python/3-types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
a = 5
print(type(a))

b = 5.2
print(type(b))
#<class 'float'>

print(type(True))
#<class 'bool'>

print(type(2+3j))
#<class 'complex'>

print(type('hello'))
#<class 'str'>


person = {
'name': 'Rikardo',
'age': 27,
'profession': 'actor'
}

person['age'] = 28
print(person)

array = {a, b, '56'}
print('Arrray ', array)
print(type(array))

0 comments on commit e32fc5c

Please sign in to comment.