Get the Python learning content used in our online course here.

Spread the love

Python is easy and fun to learn, so let’s learn python. Are you ready ?!

All the codes shown in the video is available here: 

Python is an interpreted, high-level, general-purpose programming language. Created by Guido van Rossum and first released in 1991, Python’s design philosophy emphasizes code readability with its notable use of significant whitespace.

# Numbers 
# integers 1 2 3 4 5 
# float 1.2 5.6 9.5 10.50 
# complex 5+2j 
print(3 // 2) 
# - * / + ** % 

# variables , a-z , _ , watch , Watch 

Watch_price = 500 
Customer_Name = "karthik" 
Watch1 = Name
1 = 750 
print(Watch_price) 
print(Customer_Name) 

# strings 

word = 'Hi' 
word2 = " my age is 24 , why can't i vote " 
para = """ this is my para """ 
word3 = "hello, world" 

# slicing , length , strip() 

print(word3[-5:-1]) 
print(len(para)) 
print(word2.strip()) 
print(word.lower()) 
print(word.upper()) 
a = 'raj' 
print(a.replace('j', 'ju')) 
print(a.split('a')) 
print("hew" in word3) 
a1 = 'hi' 
a2 = ' karthik' 
print(a1 + a2) 

# Boolean

print(1 == 1) 
# operators 
# arthimetic 
# = 
# > < >= <= 
# and or not 
# is is not
# in not in 
# & | ^ ~ << >> 
number1 = 10 
number1 /= 10 
number2 = number1 + 20 

# casting 

a = float(10) 
b = int(10.10) 
c = str(120) 
print(a, b, c) 

# type 

d = "h3"
print(type(d)) 

# list 

fruits = ['apple', 'orange', 'cherry'] 
fruits[1] = 'banana' 
fruits.append("new") 
print(fruits) 
number = [11, 2, 20, 0] 
number.sort(reverse=True) 
print(number) 
add = fruits + number 
print(add) 

# Tuples 

fruits = ('apple', 'orange', 'cherry') 
print(fruits) 
number = (11, 2, 20, 0) 
print(number) 
add = fruits + number 
print(add) 

# Dictionary , get() 

my_data = { "name": "karthik", "age": "24" } 
# my_data["age"] = "25" 
print(my_data.get("age")) 

# if statements

age = 18 
if age > 18: 
    print("you can vote in election") 
elif age == 18: 
    print("apply for vote id") 
else: 
    print("you have to wait till 18") 
a, b = 10, 20
if a == 10 or b == 20: 
    # and , or nesting of if 
   print("correct") 
   if b == 20: 
         print("hi") 
   else: 
        print("incorrect") 

# functions def 

def addition(a, b): 
    print(a + b) 
def subtraction(a, b): 
    print(a - b) 
def hi(name): 
    print("Hi," + name) 
def fun(a): 
    return a*100 

addition(12, 10) 
addition(100, 300) 
subtraction(50, 25) 
hi("balu") 
print(fun(5)) 

# loops 

name = 'karthik' 
# for loop 
for letters in name: 
    print(letters) 
fruits = ['apple', 'orange', 'banana'] 
for fruit in fruits: 
    print(fruit) 
for i in "hi, welcome": 
    if i == ',': 
# continue 
        print(", is present") 
# break 
    else: 
        print(", is not present") 

#range 5 – 0,1,2,3,4 

for number in range(10, 30, 4): 
    print(number) 
for number in range(5): 
    print(number) 
for i in range(2): 
    print(i) 
else: 
     print('all numbers are finished') 

# loops while 

i = 1 
while i < 5: 
# 5 < 5  
    print(i) i += 1 
else: 
    print("over") 

# Lambda 

add_5 = lambda number: number + 10 
print(add_5(25)) 
print(add_5(120)) 

# simple calculator 

def add(a, b): 
    return a+b 
def sub(a, b): 
    return a-b 
def mul(a, b): 
    return a-b 
def div(a, b): 
    return a//b 
print("""Select operation 
1.add 
2.sub 
3.mul 
4.div
""") 
choice = int(input("enter your choice")) 
a = int(input("enter number 1")) 
b = int(input("enter number 2")) 

if choice == 1: 
    print(add(a, b)) 
elif choice == 2: 
    print(sub(a, b)) 
elif choice == 3: 
    print(mul(a, b)) 
elif choice == 4: 
    print(div(a, b)) 
else: 
    print("enter correct choice") 

# final task answer print() 

print('Hi, I can code in Python!') 
print(''' 
My favourite animal is dog 
o-###-
    | |  # 
This is my home 
    _ | _ 
    |      | 
    |#    |____ 
    |      |        | 
    | #   | #     |
  _|___|_#__|_ 
Now Puzzle time 
''') 
born = input('What year were you born?') 
born = int(born) 
age = 2025 - born 
print('In the year 2025 you\'ll be', age, 'years old!') 


Spread the love