My Python First Day Notesbook
My Python First Day Notesbook
print(45*25)
python_with_Ammar
1125
02_operators
In [2]: print(2+2)
print(3-2)
print(6/2)
print(2*3)
print(13%2)
print(6//2)
print(2**3)
print(2**2/2*3/3+6-4)
#PEAMDAS
3.0
4.0
03-Strings
In [3]: print("Hello world")
Hello world
05- Variables
In [4]: # Variables: objects containing specific values
x = 5
print(y)
x = x+10
print(x)
#types of variables
type(x)
print(type(y))
# 4- Do not use Keywords used in functions (break, mean, media, test etc)
fruitbasket= "Mangos"
print(fruitbasket)
15
<class 'str'>
Mangos
06-Input_Variables
In [ ]: #fruit_basket ="Mangos"
#print(fruit_basket)
# print(fruit_basket)
# greetings = "Hello!"
# print(greetings, name)
# print("Hello!", name)
greetings = "Hello!"
07-Conditional_logics
In [ ]: ### Logical Operators mentioned below
### logical operators are either "true or false" or "yes or No" or "0 or 1"
### Equal to ==
### print(4==4)
### hamad_age = 4
### age_at_school = 5
### print(hamad_age==age_at_school)
hamad_age = 4
age_at_school = 5
hamad_age=int(hamad_age)
print(type(hamad_age))
08-Type_conversion
In [ ]: # from unicodedata import name
# x = 10 # integer
# z = "Hello" # string
# x = x+y
# age = int(age)
# print(age, type(float(age)))
# name
print(name,type(str(name)))
09-If_else_elif
In [ ]: requird_age_at_school = 5
hammad_age =2
if hammad_age == requird_age_at_school:
else:
10-Functions
In [ ]: # definig a function
# def print_codanics():
# print_codanics()
# 2
# def print_codanics():
# print(text)
# print(text)
# print(text)
# print_codanics()
# 3
# def print_codanics(text):
# print(text)
# print(text)
# print(text)
# if age == 5:
# else:
# school_calculator(1,"Hammad")
def fg(age):
new_age = age + 20
return new_age
print(new_age)
future_predicted_age= fg(18)
print(future_predicted_age)
11-Loops
In [ ]: # while loops and For loops
# while loops
# x = 0
# while (x<5):
# print(x)
# x = x + 1
# for loop
# for x in range(5,10):
# print(x)
# array
for d in days:
print(d)
12-Import_libraries
In [ ]: #### if you want to print the value of pi
import math
import statistics
x = [150,250,350,450]
print(statistics.mean(x))
13-Trouble_shouting
In [ ]: # if you want to print the value of pi
import math
import statistics
x = [150,250,350,450]
print(statistics.mean(x))