<jupyter_start><jupyter_text>NASA Direct-STEM: Summer Workshop  Author(s): <NAME>, <NAME>  Advisor: Dr. <NAME> - Department: Computer Science   Day 1: Python Basics<img  src="./assets/python.gif"  style="margin-left: 5px; margin-top: 2px; height: 300px; width: 500px"  alt="python-snek"/>   Data Types: Numbers (Integers, Floating-Points), Strings, and Booleans<jupyter_code># Sets random_variable_name to 5
random_variable_name = 5

# Variable name can be whatever you want
# But don't make it confusing like below
six = 5

# We can add the two variables together
random_variable_name + six # expect to get 10
# Sets another_random_variable to 2.5
another_random_variable = 2.5

# Sets one_more_variable to 2
one_more_variable = 2

# We also have other operations like Subtraction, Multiplication, and Division
another_random_variable - one_more_variable<jupyter_output><empty_output><jupyter_text>Math Operations: Addition, Subtraction, Multiplication, and Division<jupyter_code>print(0.7 / 25)
print(10 * 5.4)
print(13 - 23)
print(5 + 6)<jupyter_output>0.027999999999999997
54.0
-10
11<jupyter_text>Other Math Operations: Modulo (mod) and Integer Division<jupyter_code># Modulo gives the remainder
# Ex: 15 % 2 = 1
15 % 2
# So how does it work?
# Let's try:
random_example1 = 19 % 27
random_example2 = 90 % 12
random_example3 = 70 % 7
# Integer Division is the opposite of the mod operation
# Instead the remainder is dropped
# Ex: 5 // 2 = 2 and not 2.5
5 // 2
# So how does it work?
# Let's try:
random_example4 = 20 // 3
random_example5 = 25 // 9
random_example6 = 70 // 36<jupyter_output><empty_output><jupyter_text>Strings and Other String Operations<jupyter_code># Strings can be instantiated with single or double quotes
# No difference it's all preference
one_random_string = "Hello, I am a String constructed with double quotes"
print(one_random_string)
another_random_string = 'Hello, I am a String constructed with single quotes'
print(another_random_string)
# Accessing a character inside a string
# Everything in python is zero indexed
print(one_random_string[0]) # returns H
print(one_random_string[7]) # returns I
# Accessing multiple characters inside a string
# another_random_string[start:end:step]
# by default step is equal to 1
print(another_random_string[0:5]) # returns Hello
print(another_random_string[::2]) # Hlo  maSrn osrce ihsnl uts
# This 5 is an Integer
fiveN = 5
# This 5 is a String
five = '5'
# Here we use Double Equals to compare the two values  
print(five == 5) #Comparing the String 5 with the Integer 5
#They are different types so they are not the same resulting in false 
print(str(fiveN) == five)# Here we use a function named str which turns any Number into a string 
# once our Integer gets turned into a string and we compare it to our string 5 
# We get the result true since both strings contain "5"
7==9
(9%3) == 0
"APPle" == "apple"
2.5 == '2.5'
'2.5' == str(2.5)<jupyter_output><empty_output><jupyter_text>Conditional Statements<jupyter_code>apple = "apple"
if "apple" == apple:
    print("Yay they are both apple")
apples = "apples"
if "apple" != apples:
    print("One says Apples the other says Apple")
boolean1 =  True
boolean2 = False
if boolean1 and boolean2:
    print("They are both true")
else:
    print("One is false")
boolean1 =  True
boolean2 = False
if boolean1 or boolean2:
    print("At least one is true")
boolean1 = True
boolean2 = True
if boolean1 and boolean2:
    print("They are both true")<jupyter_output>They are both true<jupyter_text>Loops<jupyter_code>for i in range(5):
    print(i)
alphabet = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
st = ""
for i in range(9):
    st += alphabet[i] 
print(st)<jupyter_output>abcdefghi<jupyter_text>List Comprehension<jupyter_code>str.lower("APPLE")
# A list of words 
list_a = ["Hello", "World", "In", "Python"]
# This is a list comprehension what this does it applies the function we call to all of the string elements in the list_a
small_list_a = [str.lower() for str in list_a]
# it then saves the results into this new variable
print(small_list_a) # Output: ['hello', 'world', 'in', 'python']
list_a = ["apple", "orange", "apple", "banana"]
list_b = ["apple", "mango", "lemon", "banana"]

common_words = [a for a in list_a for b in list_b if a == b]

print(common_words)
new_list = [2**x for x in range(9)]
new_list<jupyter_output><empty_output><jupyter_text>Dictionary<jupyter_code># Lets say we want some type of key value pair association 
# We can us a dictionary
dictionary = {'apple': 1, 'banana': 2} # this can represent that we have 1 apple and 2 bananas
# one method of getting the value of a key
dictionary.get("apple")
# Second method of getting the value of a key
dictionary["banana"]
# this is how you set a new value to a key the get method doesnt allow for value change
dictionary["apple"] = 9
dictionary["apple"]
#Here we will be printing out the key value pairs that exist in the dictionary
for key, value in dictionary.items():
    print(key, value)
# Lets say we want to add a new key value pair after creation its very easy cause its the same way of changing the value
dictionary["orange"] = 6
#lets print it out again to see oranges added in
for key, value in dictionary.items():
    print(key, value)<jupyter_output>apple 9
banana 2
orange 6
{'fraction_non_alphanumeric': 0.10880538418395962, 'fraction_numerical': 0.028790428117405124, 'mean_word_length': 5.065759637188209, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '414659', 'license': 'bzip2-1.0.6', 'n_tokens_mistral': 1859, 'n_tokens_neox': 1728, 'n_words': 671, 'path': 'files/Python Tutorial.ipynb', 'repo_name': 'imcano/NDS_Summer_Workshop', 'size': '5362'}