First commit

Eps. 2-5
This commit is contained in:
Steve Dogiakos 2020-05-17 19:32:28 -06:00
parent d0717bb450
commit af8764b2ab
4 changed files with 70 additions and 0 deletions

20
basics.py Normal file
View File

@ -0,0 +1,20 @@
if True:
print 'hello'
print 'asd'
# single-line comment
"""
line 1
line 2
line 3
"""
name = 'snachodog'
num1 = 5; num2 = 8
long_name =\
"something" + \
"something else"
print 'hello world',

24
control_structures.py Normal file
View File

@ -0,0 +1,24 @@
# if/else/elif
age = 18
if age >= 18:
print ('is an adult')
elif age >= 12:
print ("is a young adult")
elif age >= 3:
print ('child')
else:
print ('baby')
# ternary
if age >= 21:
old_enough = True
else:
old_enough = False
old_enough = True if age >= 21 else False
# while
while age < 50:
print("not old enough, current age is " +str(age))
age += 1

1
hello.py Normal file
View File

@ -0,0 +1 @@
print ('hello world')

25
strings.py Normal file
View File

@ -0,0 +1,25 @@
# single line
text = 'hello'
# multi line
multi_line = """line1""" \
"""line2""" \
"""line3"""
#substrings
name = 'engineer man'
first_name = name[0:8]
# integer
num1 = 6
# float
dec1 = 5.4
# conversion to substrings
to_string = str(num1)
# conversion to integer/float
num_string = '5'
to_int = int(num_string)
to_float = float(num_string)