PYTHON COURSE
In browser use [Link] for use python and practice python program
[Link]
# IS USED FOR COMMENT
# FIRST PROGRAM IS FOR WELCOME
PRINT(“HI WORLD!”)
Press RUN button on editor to see the result in Console, Short for RUN is -
A. VARIABLES & MULTIPLE ASSIGNMENTS:
EX: age = 20
Here age is variable
Ex Sentence = “My name is Kamal”
# Multiple Variables
Kamal,Harsh, Trupthi = 47,17,22
#here 3 variables are assigned with their age
Ex- name,age = “Kamal”,47
Print(name,age)
B. ARITHEMETIC OPERATORS AND STRINGS
# Arithmetic Operators
# + - * / %
Ex: 2 friends have different age
Age1 = 12
Age2 = 18
Print(age1 + age2)
Result = 30 same way we have do substration, multiply, etc
# Strings
Sent1 = “Today is beautiful day”
Sent2 = “Today is very hot day”
Print(sent1)
Print(Sent1, Sent2)
PYTHON IS SLICING SAVING STRING EACH CHARACTER INDEX BEGIN
FROM 0 (ZERO)
EX: SENT=“KAMAL IS GREAT MAN” - Sent =sentence
SO KAMAL = K=ZERO, A=1, M=2,A=3, L=4
PRINT(SENT[0])
RESULT = K
PRINT(SENT[0:5])
RESULT = KAMAL
C. PLACEHOLDERS IN STRINGS
# Placeholders in strings
#ex- automated email system- personalized emails
# unique messages wouldn’t scale
# placeholders is a marker
Name = jake
Print(name + “ is 15 years old”)
#This is placeholder
# Ex – Sentence = %S %s was president of US”
Print(sentence % (“Barack”, “Obama”))
# %s is string and %d is for integer
# Ex : Sentence = “%s is %d years old”
Print(sentence % (“Kamal”, 47))
#Format Strings or FStrings can also be used
# Ex: name = “kamal”
Print(f”Hello, {name}”)
D. Introduction of Lists
#Ordered Items, have an index, know the order
Ex: Want to make shopping list using python
Item_1 = “Apples”
Item_2=”Oranges”
Item_3 = “Curd”
Shopping_List =[‘Apples’,’Oranges’,’Curd’]
#Index-0 or Zero Index
Print(Shopping_list)
Full list will show, but if it want selected item only then
Print(shooping_List[0])
It will show apples and if it is 1 then Oranges
#Slicing doen’t count your end range
Print(shopping_list[0:2])
# if you want to add one more item in the list
Shopping_list.append(‘Blue Berries’)
# Want to modify any item with other item
Print(shopping_list[0]=’Cherries’])
#now apple changed to Cherries
# Want to Delete any list item
Del shopping_list[3]
#Curd Item deleted
# Want to know how many items in the list then use length function
#length of list
Print(Len(shopping_list))
Multiple items in the list
Print(shopping_list * 2)
List_num =[1,4,7,23,6]
Print(max(list_num))
Print(min(list_num))