<jupyter_start><jupyter_text>Welcome to Python FundamentalsIn this module, we are going to establish or review our skills in Python programming. In this notebook we are going to cover:* Variables and Data Types * Operations* Input and Output Operations* Logic Control* Iterables* Functions<jupyter_code><jupyter_output><empty_output><jupyter_text>Variable and Data Types Variables are used as a container of values that can be named and assigned multiple times within a program. It is a memory location that can be changed in the future depending on specifications. These variables include several data types such as numerics, sequence type, boolean, sets, and dictionary<jupyter_code>y = 10
a,b = 4, -17
y
type(y)
x = 1.0
type (x)
y = float (y)
y
x = float (x)
type (x)
l,r,b = "3",'1', 'one'
type (b)
r_int = int(r)
type (r)<jupyter_output><empty_output><jupyter_text>Operations Operators allows performing operations among values and variables. This section is divided into four categories namely Arithmetic, Assignment Operations, Comparators, and Logical Operations.   Arithmetic Arithmetic Operators are used to perform basic mathematical functions such as Addition, Subtraction, Multiplication, and Division. But, for Python program, additional tools has been added such as Floor Division, Exponentiation, and Modulus.<jupyter_code>a, b, c, d = 3.0, -0.5, 0, -38
### Addition
s = a+b
s
### Subtraction
D = b-d
D
### Multiplication
P = a*d
P
### Division
Q= c/a
Q<jupyter_output><empty_output><jupyter_text>**Additional Operations**<jupyter_code>### Floor Division
Fq = d//b
Fq<jupyter_output><empty_output><jupyter_text>**Floor Division** is same with the normal process of division but the difference is that the code allows the user to round up the quotient to the nearest whole number.<jupyter_code>### Exponentiation
E = a**b
E<jupyter_output><empty_output><jupyter_text>**Exponentiation** refers to the process of having an exponent to the assigned values.<jupyter_code>### Modulo
mod = d%a
mod<jupyter_output><empty_output><jupyter_text>**Modulo** refers to the process of calculating the remainder of the divident and divisor represented by the symbol % (percentage sign) Modulo calculates the remainder of dividing two values. This operator is represented by the percentage sign (%). The syntax for the modulo operator is: number1 % number2. The first number is divided by the second then the remainder is returned.  Assignment Operations Based on its name, assignment operations are used to assign values and perform algebraic equations.<jupyter_code>G, H, J, K = 0, 100, 2, 2
G += a
G
H -= d
H
J *= 3
J
K **= 2
K<jupyter_output><empty_output><jupyter_text>Comparators **Comparators** are used to compare values depending if they are equal, Not equal, Greater than, Less than, Greater than or equal to, and	Less than or equal to.<jupyter_code>res_1, res_2, res_3 = 1, 2.0, "1"
true_val = 1.0
## Equality
res_2 == true_val
## Non-equality
res_3 != true_val
## Inequality
t1 = res_1 > res_2
t2 = res_1 < res_2/2
t3 = res_1 >= res_2/2
t4 = res_1 <= res_2
t4<jupyter_output><empty_output><jupyter_text>Logical **Logical** operators are designed to make or combine conditional statements such as and, or, and not which results to a code result of True or False.<jupyter_code>res_1 == true_val
res_1 is true_val
res_1 is not true_val
p, q = True, False
conj = p and q
conj
p, q = False, False
disj = p or q
disj
p, q = True, False
e = not (q)
e
p, q = True, False
xor = (not p and q) or (p and not q)
xor<jupyter_output><empty_output><jupyter_text>Input and Output Operations The input operation uses input() function to present the input of the program, whereas the output operation uses print() function to show the output of a program.  For input, it takes input from the user, evaluates it (only accepts valid python expressions), and converts it into a string format.  For output, it evaluates the expression first before printing a complete line. Moreover, a comma is used in order to print more than one item on a single line.<jupyter_code>print("Hello World")
cnt = 1
string = "Hello World"
print(string, " , Current run count is:", cnt)
cnt += 4
print(f"{string}, Current count is: {cnt}")
sem_grade = 85
name = "hakdog"
print("Hello {}, your semestral grade is: {}".format(name, sem_grade))
w_pg, w_mg, w_fg = 0.3, 0.3, 0.4
print("The weights of your semestral grades are:\
\n\t{:.2%} for Prelims\
\n\t{:.2%} for Midterms, and\
\n\t{:.2%} for Finals.".format(w_pg, w_mg, w_fg))
x = input("enter a number: ")
x
name = input("yagi cutie: ")
pg = input("Enter prelim grade: ")
mg = input("Enter midterm grade: ")
fg = input("Enter finals grade: ")
sem_grade = None
print("Hello {}, your semestral grade is {}".format(name, sem_grade))<jupyter_output>yagi cutie: yago
Enter prelim grade: 90
Enter midterm grade: 97
Enter finals grade: 99
Hello yago, your semestral grade is None<jupyter_text>Looping Statements ``` This is formatted as code```**Loop** is a command used to perform series of statements to be executed repeatedly until a specified condition is obtained. This section is divided into two types which the While loop and For loop.   While A while loop repeats a block of code as long as a certain condition is true. Using while loops lets your program run as long as your users want them to.<jupyter_code>## while loops
i, j = 0, 10
while (i<=j):
  print(f"{i}\t|\t{j}")
  i+=1<jupyter_output>0	|	10
1	|	10
2	|	10
3	|	10
4	|	10
5	|	10
6	|	10
7	|	10
8	|	10
9	|	10
10	|	10<jupyter_text>For *for* loop executes a sequence of statements multiple times and abbreviates the code that manages the loop variable.<jupyter_code># for(int i=0; i<10; i++){
# printf(i)
# }

i=0
for i in range(10):
    print(i)
playlist = ["All too well", "traitor","Crazier"]
print('Now playing:\n')
for song in playlist:
    print(song)<jupyter_output>Now playing:

All too well
traitor
Crazier<jupyter_text>Flow Control Control flow is the sequence in which the code in the program is executed. This is controlled using conditional statements, loops, and function calls.   Conditional Statements Python uses logical conditions from mathematics. These conditions can be used in the following:*   if keyword for if statements*   elif keyword used for "if the previous conditions were not true, then try this condition"*   else keyword for anything that is not under the preceding conditions.<jupyter_code>numeral1, numeral2 = 12, 14
if(numeral1 == numeral2):
  print("yah")
elif(numeral1>numeral2):
    print("aww")
else: 
      print("hays")<jupyter_output>hays<jupyter_text>Functions Function breaks programs into smaller ones by reusing codes, making it easier to understand and troubleshoot the program. It only runs when it is activated, and can even return data as a result.<jupyter_code># void DeleteUser(int userid){
# delete(userid);
#}

def delete_user (userid):
    print("Successfully deleted user: {}".format(userid))

def delete_all_users ():
  print("Hala bakit ka namatay")
userid = "Yagi"
delete_user("Yagi")
delete_all_users()
def add(addend1, addend2):
    return addend1 + addend2

def power_of_base2(exponent):
    return 2**exponent
#addend1, addend2 = 4, 10
#add(addend1, addend2)

exponent = 17
power_of_base2(exponent)<jupyter_output><empty_output><jupyter_text>CALCULATOR<jupyter_code>print("Hello student! Please fill out the necessary information needed below.")
name = input("Name of Student(SURNAME, First Name): ")
course = input("Course: ")
pg = input("Enter prelim grade: ")
mg = input("Enter midterm grade: ")
fg = input("Enter finals grade: ")
pg=float(pg)
mg=float(mg)
fg=float(fg)
prelims= pg*0.30
midterms= mg*0.30
finals= fg*0.40
sem = (prelims+midterms+finals)
grade = sem/100
passing= 0.70
if (grade > passing):
  print('\nGreetings, {} of {}! Your calculated semestral grade is:{: .2%} \U0001F600 Thank you and Have a good day!' .format(name, course, grade))
elif(grade == passing):
  print('\nGreetings, {} of {}! Your calculated semestral grade is :{: .2%} \U0001F606 Thank you and Have a good day!' .format(name, course, grade))
else:
  print('\nGreetings, {} of {}! Your calculated semestral grade is :{: .2%} \U0001F62D Thank you and Have a good day!' .format(name, course, grade))<jupyter_output>Hello student! Please fill out the necessary information needed below.
Name of Student(SURNAME, First Name): Chiu, <NAME>
Course: BS Psychology
Enter prelim grade: 85.65
Enter midterm grade: 84.623
Enter finals grade: 90

Greetings, Chiu, <NAME> of BS Psychology! Your calculated semestral grade is: 87.08% 😀 Thank you and Have a good day!
{'fraction_non_alphanumeric': 0.10147966911336363, 'fraction_numerical': 0.02295234766398695, 'mean_word_length': 5.11831789023521, 'pattern_counts': {'":': 0, '<': 62, '<?xml version=': 0, '>': 62, 'https://': 0, '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': '15', 'dir': 'jupyter-structured-clean-dedup', 'id': '637909', 'license': 'Apache-2.0', 'n_tokens_mistral': 2885, 'n_tokens_neox': 2737, 'n_words': 1124, 'path': 'Activity_1_Python_Fundamentals.ipynb', 'repo_name': 'arbeecvam/Linear-Algebra-2nd-Sem', 'size': '8589'}