<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  Variable and Data TypesVariables and data types are the values that change in Python Fundamentals, as the name implies. A variable is a memory location where you store a value in a programming language, and it is created as soon as you assigned a value to it. Meanwhile, the classification or categorizing of data elements is known as data types. It denotes the kind of value that specifies which operations can be performed on a given set of data. Data types are technically classes, and variables are the objects of these classes.<jupyter_code>x = 1
a, b = 0, -1
b
type(x)
int
y = 1.0
type (y)
x = float(x)
type (x)
s, t, u = "0", '1', 'one'
type (u)
s_int = int(s)
s_int<jupyter_output><empty_output><jupyter_text>Operations  ArithmeticMathematical operations such as addition, subtraction, multiplication, division, floor division, exponentiation and modulo are performed using arithmetic operators.<jupyter_code>a, b, c, d = 2.0, -0.5, 0, -32<jupyter_output><empty_output><jupyter_text>AdditionThis operation denotes (+) which adds values on either side of the operator.<jupyter_code>### Addition
S = a+b
S<jupyter_output><empty_output><jupyter_text>SubtractionRepresented by (-), this operation subtracts right hand operand from left hand operand.<jupyter_code>### Subtraction
D = b-d
D<jupyter_output><empty_output><jupyter_text>MultiplicationUsing the symbol (*), this operation multiplies values on both sides of the operator.<jupyter_code>### Multiplication
P = a*d
P<jupyter_output><empty_output><jupyter_text>DivisionThe division operator in Python is (/). When the first operand is divided by the second, it is utilized to find the quotient.<jupyter_code>### Division
Q = c/a
Q<jupyter_output><empty_output><jupyter_text>Floor DivisionWhen the first operand is divided by the second, floor division is applied to calculate the floor quotient. This is denoted by the operator (//).<jupyter_code>### Floor Division
E = a//b
E<jupyter_output><empty_output><jupyter_text>ExponentiationTo raise the first operand to the second power, exponentiation is performed through the symbol (**).<jupyter_code>### Exponentiation
E = a**b
E<jupyter_output><empty_output><jupyter_text>ModuloModulo or Modulus uses the operator (%) that is responsible for dividing left hand operand by right hand operand and returns the remainder.<jupyter_code>### Modulo
mod = d%a
mod<jupyter_output><empty_output><jupyter_text>Assignment OperationsAssignment operators are used in Python programming to assign values to variables. = The equal operation's role is to "Assign" the value of the right side of the expression to the operand on the left side.<jupyter_code>G, H, J, K = 0, 100, 2, 2<jupyter_output><empty_output><jupyter_text>+="Add and Assign" is designed to add both sides of the operand and the sum will be placed on the left operand.<jupyter_code>G += a
G<jupyter_output><empty_output><jupyter_text>-="Subtract And" conducts subtraction to right operand from left operand. The difference would then be assigned to the left operand.<jupyter_code>H -= d
H<jupyter_output><empty_output><jupyter_text>*="Multiply And" operates multiplication to both operands and then the product would be assigned to the left operand.<jupyter_code>J *= 2
J<jupyter_output><empty_output><jupyter_text>**="Exponent And" calculates the exponent value of the operands which would then be assigned also to the left operand.<jupyter_code>K **= 2
K<jupyter_output><empty_output><jupyter_text>ComparatorsValues are compared using comparison operators. Depending on the condition, it results to either True or False.<jupyter_code>res_1, res_2, res_3 = 1, 2.0, "1"
true_val = 1.0
## Equality
res_2 == true_val
## Non-Equality
res_2 != 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>LogicalLogical operators are comprised of:"AND" - True if both operands are true"OR"  - True if either of the operands is true"NOT" - True if the operand is 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 = True, False
disj = p or q
disj

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>I/OInput and Output operators allow you to insert a value into your program that can be printed.<jupyter_code>print("Hello Mars")
cnt = 1
string = "Hello Mars"
print(string, "Current run count is:", cnt)
cnt += 1
print(f"{string} Current count is: {cnt}")
sem_grade = 82
name = "uge"
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 grade are:\
\n\t{:.2%} for Prelims\
\n\t{:.2%} for Misterms, and\
\n\t{:.2%} for Finals.".format(w_pg, w_mg, w_fg))
x = input("enter a number: ")
x
name = input ("<NAME>: ")
pg = input ("Enter prelim grade: ")
mg = input ("Enter midterm grade: ")
fg = input ("Enter final grade: ")
sem_grade = None
print ("Hello {}, your semestral grade is: {}".format(name, sem_grade))<jupyter_output>Kimi mo nawa: 80
Enter prelim grade: 85
Enter midterm grade: 90
Enter final grade: 75
Hello 80, your semestral grade is: None<jupyter_text>Looping Statements  WhileThe while loop is used to repeatedly execute a set of statements until a condition is met.<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>ForFor Loop is used to perform sequential traversal. It can be used to iterate throughout a set of iterators and a range of values.<jupyter_code>#for(int i=0; i<10; i++){
#print(i)
#}

i = 0
for i in range (10):
      print(i)
playlist = ["Crazier","Happier","Bahay-Kubo"]
print('Now PLaying:\n')
for song in playlist:
      print(song)<jupyter_output>Now PLaying:

Crazier
Happier
Bahay-Kubo<jupyter_text>Flow ControlFlow Control is a conditional statement that handles the presentation and execution of codes in a given program. This allows the software to continue running until specific conditions are met. Condition StatementsIf and Else If statements are used in flow control to perform conditional operation.<jupyter_code>numeral1, numeral2 = 13, 14
if(numeral1 == numeral2):
      print("Yey")
elif(numeral1>numeral2):
      print("Hoho")
else:
      print("Aww")<jupyter_output>Aww<jupyter_text>FunctionsFuctions are blocks of code which only runs when it is called. In python, "def" is used to designate a function.<jupyter_code># void DeleteUser(int userid){
#     delete(userid);
# }

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

def delete_all_users ():
    print("Successfully deleted all users")
userid = "Maica"
delete_user("Maica")
delete_all_users()
def add(addend1, addend2):
    return addend1 + addend2

def power_of_base2(exponent):
    return 5**exponent
#addend1, adddend2 = 14, 18
#add(addend1, addend2)

exponent = 4
power_of_base2(exponent)<jupyter_output><empty_output><jupyter_text>Grade Calculator<jupyter_code>print()
name = input('\tOla! What is your name? ');
course = input('\tWhat is your course? ');
prelim = float(input('\tGive Prelim Grade : '));
midterm = float(input('\tGive Midterm Grade : '));
final = float(input('\tGive Final Grade : '));
grade= (prelim) + (midterm) + (final);
avg= grade/3;

print();
print("\t===== DISPLAYING RESULTS =====");
print();
print("\tHi,", name, "from the course", course, "!");
print();
if avg > 70:
    print("\tYour grade is \U0001F600");
elif avg == 70:
    print("\tYour grade is \U0001F606");
elif avg < 70:
      print("\tYour grade is \U0001F62D");
print();<jupyter_output>Ola! What is your name? Ikay
	What is your course? BS in Chemical Engineering
	Give Prelim Grade : 70
	Give Midterm Grade : 75
	Give Final Grade : 65

	===== DISPLAYING RESULTS =====

	Hi, Ikay from the course BS in Chemical Engineering !

	Your grade is 😆
{'fraction_non_alphanumeric': 0.10756685453891354, 'fraction_numerical': 0.021225566614702002, 'mean_word_length': 5.247191011235955, 'pattern_counts': {'":': 0, '<': 90, '<?xml version=': 0, '>': 89, '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': '22', 'dir': 'jupyter-structured-clean-dedup', 'id': '53372', 'license': 'Apache-2.0', 'n_tokens_mistral': 2917, 'n_tokens_neox': 2782, 'n_words': 1018, 'path': 'Activity_1_Python_Fundamentals_Arocena.ipynb', 'repo_name': 'maicaarocena/Linear-Algebra_2nd-Sem', 'size': '8345'}