Python 101..

Back to school!

Mixing Strings with Numbers
my_name = "koray tugay"
my_age = 33
print("Hello, my name is: " + my_name.title() + "and I am " + my_age + " years old.") 
This will actually not work, which I find very strange considering how flexible Python is when it comes to types! When concatenating Numbers with Strings, you must actually tell you want to String representation of your variable! Here is how you can do it:
print("Hello, my name is: " + my_name.title() + "and I am " + str(my_age) + " years old.") 

Working with Lists
my_first_list = ["a", "b", "c"]
print(my_first_list)
## ['a', 'b', 'c']

Looping Lists
my_first_list = ["a", "b", "c"]
for char in my_first_list:
    print(char)
    ## a
    ## b
    ## c

Solving HackerRank Max - Min 
def miniMaxSum(arr):
    arr.sort()
 
    min = 0
    max = 0
 
    for i in range(len(arr) - 1):
        min = min + arr[i+1]
 
    for i in range(len(arr) - 1):
        max = max + arr[i]
 
    print(str(max) + " " + str(min))

My Python List Cheat Sheet
def greet_member(member):
    print("Greetings " + member)
 
 
## Start Here ##
family_members = ["koray", "pinar"]
print(family_members) ## ['koray', 'pinar']
 
## Access using index
print(family_members[0]) ## koray
print(family_members[1]) ## pinar
 
## A very simple loop:
for family_member in family_members:
    greet_member(family_member)
 
## koray
## pinar
 
## Appending to the list
family_members.append("deniz")
family_members.append("toprak")
 
print(family_members) ## ['koray', 'pinar', 'deniz', 'toprak']
 
## length of a list:
number_of_family_members = len(family_members)
print(number_of_family_members) ## 4
 
## Greet new members
for i in range(len(family_members) - 2):
    greet_member(family_members[i + 2])
 
## Greetings deniz
## Greetings toprak
 
## Wrong record in the family list:
family_members.append("alien")
print(family_members)
## ['koray', 'pinar', 'deniz', 'toprak', 'alien']
 
## Remove alien from the list:
del family_members[4]
print(family_members)
## ['koray', 'pinar', 'deniz', 'toprak']
 
## pop by index
got_married = family_members.pop(2)
print(got_married + " got married!") ## deniz got married!
 
## pop default
got_married = family_members.pop() ## pops the last element by default!
print(got_married + " got married!") ## toprak got married!
print(family_members) ## Remaining members: ['koray', 'pinar'] 
 
new_list = ["z", "x", "a", "b", "f"]
## reversing a list:
new_list.reverse()
print(new_list) ## ['f', 'b', 'a', 'x', 'z']
## get the original back
new_list.reverse()
print(new_list) ## ['z', 'x', 'a', 'b', 'f']
 
## sorting a list, not touching the original:
new_list_sorted = sorted(new_list)
print(new_list) ## ['z', 'x', 'a', 'b', 'f']
print(new_list_sorted) ## ['a', 'b', 'f', 'x', 'z']
 
print (new_list == new_list_sorted) ## False
 
## sort the original list
new_list.sort()
print(new_list) ## ['a', 'b', 'f', 'x', 'z']
 
print (new_list == new_list_sorted) ## True