<jupyter_start><jupyter_text>![](https://i.imgur.com/0AUxkXt.png)  Lecture 1 - Basic Python  Markdown Heading 1 Heading 2**Bold***Italic*Learn more [HERE](https://hackmd.io/features?both)!  Variables and data types<jupyter_code># Integer
number_integer = 5

print(number_integer)
type(number_integer)
# Float - number with decimal point
number_float = 1.3

print(number_float)
type(number_float)
# Arithmetic Operations
# Addition
print(1 + 1)

# Subtraction
print(1 - 1)

# Multiplication
print(2 * 5)

# Division
print(7 / 2)

# Floor Division
print(22 // 3)

# Remainder / Modulus
print(22 % 3)
# Strings
my_text = "Data Science's awesome!"
print(my_text)
# Logical / Booleans
is_handsome = False
print(not is_handsome)

# False has the numerical value = 0, True has numerical value = 1
print(False + False)
# Iterators
# Lists
# Lists are collections of Python objects. A list can contain many different data types
lst = [1, 2, 3, 4, 5, 'name', 1.5, True]

print(lst[2:5])

# Dictionaries
# Dictionaries are collections of items, each item has a key and corresponding value
dictionary = {'Name': '<NAME>',
              'Height': 1.65,
              'Cats': ['Uku','Lele']}

print(dictionary['Name'])<jupyter_output>[3, 4, 5]
<NAME><jupyter_text>Functions<jupyter_code># Functions are blocks of code that run when called

# Built-in functions
print("Hi")
round(2.2)

# Creating our own function
def my_function(a, b):
  return a / b
# Calling a function
my_function(2, 3)<jupyter_output><empty_output><jupyter_text>The if-statement<jupyter_code># If-statement
# Perform different actions based on different conditions

x = 1

if x > 5:
  print("Greater than 5")

elif x < 2:
  print("Smaller than 2")

else:
  print(x)


# Notice the code indentation<jupyter_output>Smaller than 2<jupyter_text>The for-loop<jupyter_code># For-loop
# Executing a block of code for a number of times

lst = [1, 2, 3, 4, 5, 'name', 1.5, True]

# For each element (i) in the list lst,...
for i in lst:
  # Print the element (i)
  print(i)
# Another way
# Enumerate function returns a set of index and value instead of just the value

for i, value in enumerate(lst):
  print(i, value)<jupyter_output>0 1
1 2
2 3
3 4
4 5
5 name
6 1.5
7 True<jupyter_text>The while-loop<jupyter_code># While-loop
# Executing a block of code while a condition is True

answer = 5
guess = 5

# While the guess DOES NOT equal the answer,...
while guess != answer:
  # Guess again
  guess = int(input())
  print("Guess:", guess)

# When guess equals the answer, the while-loop stops<jupyter_output><empty_output><jupyter_text>Example: Money exchange<jupyter_code># Can you understand these codes?

money = 2300
origin = money

values = [500, 200, 100, 50, 20, 10, 5, 2, 1]
result = [0, 0, 0, 0, 0, 0, 0, 0, 0]

while (money > 0):
    for index, value in enumerate(values):
        while (money >= value):
            result[index] = result[index] + 1
            money = money - value
            print(result)      
print(money)


print(origin, 'can be exchanged with')
for i in range(len(values)):
    if result[i]>0:
        print(result[i], 'x', values[i],'k')<jupyter_output>[4, 1, 1, 0, 0, 0, 0, 0, 0]
0
2300 can be exchanged with
4 x 500 k
1 x 200 k
1 x 100 k
{'fraction_non_alphanumeric': 0.12248062015503876, 'fraction_numerical': 0.04093023255813953, 'mean_word_length': 3.963076923076923, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 27, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '303765', 'license': 'MIT', 'n_tokens_mistral': 1276, 'n_tokens_neox': 1151, 'n_words': 394, 'path': 'Lecture_1_Basic_Python.ipynb', 'repo_name': 'Bekamtz/numpy-100', 'size': '3229'}