Source Code
# programming
# programs
# python programming
# python
# interprator base language
# ------------------------------------
# print("a")
# print("string12")
# # 4 methods to display strings
# print("heelo,' world")
# print('hello" world')
# print('''
# hello"
# ,'a',"b"
# world''')
# print("""hello,'a',"b" world""")
# methods of displaying numbers and decimals
# print(12)
# print(12.12)
# variables
# _var=12
# _var1=12.12
# _var2="string1212"
# print(_var1,_var)
# print(_var2)
# ------------------------------------
#comment
'''
comments
'''
# ------------------------------------
# input
# input_stored_var=input("Enter the number:")
# print(input_stored_var)
# ------------------------------------
# type casting
# var=float(input("Enter the number must:"))
# print(var)
# ------------------------------------
# exercise programs
# num1=int(input("Enter the first number:"))
# num2=int(input("Enter the second number:"))
# result=num1+num2
# print(type(num1),type(num2))
# print(result)
# ------------------------------------
# Decision structures
# if ,if else, if elif else , nested if / if else
# print("""
# python
# c++
# c
# html
# css
# js""")
# name=input("Enter any one language name:")
# if name=="python":
# print("yes")
# elif name=="c++":
# print("yes")
# elif name=="c++":
# print("yes")
# elif name=="c":
# print("yes")
# elif name=="html":
# print("yes")
# elif name=="css":
# print("yes")
# elif name=="js":
# print("yes")
# else:
# print("No")
# logged in program exercise
# name=input("Enter name:")
# if name=="muhammad yasir hussain":
# pwd=input("Enter password:")
# if pwd=="mianwali_yasir_786":
# codevar=int(input("Enter secret code:"))
# if codevar=="786":
# print("you are logged in!")
# else:
# print("you enter the wrong name!")
# else:
# print("you enter the wrong password!")
# else:
# print("you enter the wrong name!")
# -----------------------------
# counter loop vs contional loop
# for loop is used when you know the iterations of instructions
# for loop is a counter loop
# for variable in range(start=0,end=end-1,stepped=1)
# for x in range(1,101,2):
# print(x,"pakistan and india")
# while loop is used when you don't iterations of instructions
# while loop is a contional control loop
# while contion:
# display massage
# var=input("continued?:")
# while var=="yes":
# print("you entered the program")
# print("it's done")
# var=input("contined?:")
# ---------------------------------
# functions contains set of instructions which will be needed in future
# def sum(num1,num2):
# addition=num1+num2
# print("sum of ",num1,"and",num2,"is",addition)
# def sub(num1,num2):
# subtruction=num1-num2
# print("subtruction of ",num1,"and",num2,"is",subtruction)
# sub(12,12)
# --------------------------------
# list, tuple , dictionary
# listvar=[12,"yasir",'c',12.23]
# print(type(listvar))
# print(listvar[0])
# tuplevar=(12,"yasir",'c',12.23)
# print(type(tuplevar))
# print(tuplevar[3])
# dictionary={"key1":1212,"key2":"nasir"}
# print(type(dictionary))
# print(dictionary["key1"])
# -------------------
# oop
# object and classes
# class Calculator:
# def __init__(self,v1,v2):
# self.var1=v1
# self.var2=v2
# def sum(self):
# self.result=self.var1+self.var2
# print("sum",self.result)
# def sub(self):
# result=self.var1-self.var2
# print("sub",result)
# def multi(self):
# result=self.var1*self.var2
# print("multi",result)
# def div(self):
# result=self.var1/self.var2
# print("div",result)
# v1=int(input("Enter the num1:"))
# v2=int(input("Enter the num2:"))
# obj=Calculator(v1,v2)
# obj.sum()
