History, Scope, and Execution of Python Programming
Python is a script-based language executed directly by the Python interpreter. It is extremely easy to learn and lightweight compared to many other programming languages.
Python was originally created by Guido van Rossum to develop device driver-based applications. Today, Python has evolved into a complete ecosystem used for:
- System Software
- Application Software
- Data Science & Analytics
- Machine Learning & AI
- Interface Programming
- Game Development
- IoT & Arduino-based systems
- Automation & Testing
Python’s performance is exceptional compared to C, C++, Java, PHP, etc. It focuses on code simplicity rather than heavy structure.
🚀 How to Run Python Scripts
1️⃣ Online Mode
You can run Python without installing anything using online tools:
Example: Python Program for Addition
a = 10 b = 20 c = a + b print(c)
2️⃣ Offline Mode
Download Python from the official website:
- Download Python 3.x installer
- Run the installer (python-3.x.exe)
- After installation, Python provides default IDLE editor
🧠 Python Program Execution Flow
Python Source Code
↓ RUN
Python Interpreter Machine
↓
Machine Code
↓
Output
📘 Program: Calculate Simple Interest
p, r, t = 12000, 2.2, 3.5
si = (p * r * t) / 100
print("result is p={0} , r={1} , t={2} , si={3}".format(p, r, t, si))
# print("result is %.2f" % si)
📝 Input & Output Functions in Python
✔ Output Function: print()
print("hello") # single statement
print("hello", "world") # multiple statements
print("hello" + "world") # concatenation
print("%f" % 1.2345)
✔ Input Function: input()
var = input("message") # returns string
a = int(input("message"))
Example: Addition Program
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
c = a + b
print(c)
📚 ASSIGNMENTS
- WAP to calculate the Area of Triangle and Rectangle
- WAP to Reverse a Five-Digit Number
- WAP to Add Two Complex Numbers
✔ Solution: Reverse a Five-Digit Number
num = 78125
print("Actual number is", num)
a = num % 10
num = num // 10
b = num % 10
num = num // 10
c = num % 10
num = num // 10
d = num % 10
e = num // 10
num1 = a*10000 + b*1000 + c*100 + d*10 + e
print("Reverse of number is", num1)
✔ Addition of Complex Numbers (Without using complex())
r1 = 2
i1 = 3
r2 = 5
i2 = 7
r = r1 + r2
i = i1 + i2
print("{0}+{1}j".format(r1, i1))
print("{0}+{1}j".format(r2, i2))
print("{0}+{1}j".format(r, i))
✔ Addition Using Python Complex Numbers
num1 = 2 + 3j num2 = 4 + 5j num = num1 + num2 print(num1) print(num2) print(num)
57 Comments
area of traingle
ReplyDeleteb,h=10,20
Area=(b*h)//2
print(Area)
area of rectangle
ReplyDeletew,l=20,30
Area=(20*30)
print(Area)
adding complex number using complex number
ReplyDeleteA=2+3J
B=3+4J
C=A+B
print(A)
print(B)
print("addition of complex number",C)
ReplyDeleteprint("Knowing Base and Height")
h = int(input("Enter height of Triangle :\t"))
b = int(input("Enter length of the Base :\t"))
c = b*h/2
print("\n Area of a Triangle",c)
#Area of a Rectangle
ReplyDeleteprint(" If length and Width are given")
b = int(input("Enter Width of Rectangle :\t"))
l = int(input("Enter length of Rectangle :\t"))
c = l*b
print("\n Area of a Rectangle",c)
ReplyDelete#Code for Reversing Five Digit Number
f = str(input("Enter Five Digit No. :\t"))
l=f[::-1]
print("Answer :-",l)
Adarsh dixit
ReplyDeletei = int(input("enter a number :"))
rev = 0
while (i>0):
rev=(rev*10)+i%10
i=i//10
print("revers=",rev)
Adarsh dixit
ReplyDelete# Three sides of the triangle is a, b and c:
a = float(input('Enter first side: '))
b = float(input('Enter second side: '))
c = float(input('Enter third side: '))
# calculate the semi-perimeter
s = (a + b + c) / 2
# calculate the area
area = (s*(s-a)*(s-b)*(s-c)) ** 0.5
print('The area of the triangle is %0.2f' %area)
first = complex(input('enter first complex number: '))
ReplyDeletesecond = complex(input('enter second complex number: '))
addition = first + second
print('sum = ', addition)
Area of traingle
ReplyDeleteB=10
H=30
Area =(B*H) /2
Print ("Area")
Area of rectangle
ReplyDeleteW, L=20, 25
Area=(W*L)
Print("Area")
***Area of Triangle***
ReplyDeletebase=int(input("enter the base of traingle"))
height=int(input("enter the height of triangle"))
area=((base*height)*1/2)
print("area= %d"% area)
***Area of Rectangle***
ReplyDeletewidth=int(input("enter the width of ractangle = "))
height=int(input("enter the height of ractangle = "))
area=width*height
print("area= %d"% area)
***Addition of complex Number***
ReplyDeletea=2+3j
b=3+2j
c=a+b
print(c)
*** 5 digit reverse***
ReplyDeletea=int(input("enter the 5 digit no = "))
i=a%10
a=int(a/10)
j=a%10
a=int(a/10)
k=a%10
a=int(a/10)
l=a%10
a=int(a/10)
print(str(i)+str(j)+str(k)+str(l)+str(a))
#MOhit Chouhan
ReplyDeleteQuestion 1.
Area Of Triangle
B=4
H=5
area= (1/2*(B*H))
print("The Area of Triangle is " , area)
Area of rectangle
W=20
L=30
Area=(W*L)
print(Area)
Ques.2
a=12345
i=a%10
print(i) #5
a=int(a/10)
print(a) #1234
j=a%10
print(j)#4
a=int(a/10)
print(a) #123
k=a%10
print(k)#3
a=int(a/10)
print(a)#12
l=a%10
print(l)#2
a=int(a/10)
print(a) #1
print(str(i)+str(j)+str(k)+str(l)+str(a))
Ques.3 Addition of complex Number?
a=5+2j
b=2+5j
c=a+b
print(c)
#Mohit Singh Chouhan
ReplyDeletea= 12345
b=a%10 #5
v=a//10 #1234
c=v%10 #4
w=v//10 #123
d=w%10 #3
x=w//10 #12
e=x%10 #2
y=x//10 #1
print(str(b)+str(c)+str(d)+str(e)+str(y))
Area of Triangle
ReplyDeletej= 6
>>> k= 8
>>> area= (1/2*(j*k))
area of rectangle
l= 10
>>> b= 5.5
>>> a= l*b
>>> print(a)
>>> print(area)
reverse five digit of 12345
ReplyDeletea=12345
num=0
num=(a%10)*10
a=a//10
num=(num+(a%10))*10
a=a//10
num=(num+(a%10))*10
a=a//10
num=(num+(a%10))*10
a=a//10
num=(num+(a%10))
print(num)
addition of a complex no.
ReplyDelete>>> a= 4+5j
>>> b= 5+6j
>>> c= a+b
>>> print(c)
(9+11j)
#WAP to Reverse Five Digit Number?
ReplyDeletenum=10021
a=num%10 #1
num=num//10 #
b=num%10 #2
num=num//10 #
c=num%10 #0
num=num//10 #
d=num%10 #0
num=num//10 #
e=num%10 #1
num1=(a*10000+b*1000+c*100+d*10+e*1) # 10000 is place value
print(num1)
#1 wap to addition complex number
ReplyDeletecom=4+5j
com1=6+15j
com2=com+com1
print(com2)
# 2 wap to find the reminder
# %( reminder)
a=22
b= a%3
print(b)
#WAP to calculate the area of a triangle, circle, and rectangle ?
ReplyDeleteh=15
b=20
l=30
r=10
pi=3.14
p=int(input("press 1 for triangle and press 2 for circle and press 3 for rectangle :- "))
triangle=(h*b)/2
circle=pi*r*r
rectangle=l*b
if p==1:
print("Area of triangle ",triangle)
if p==2:
print("Area of circle ",circle)
if p==3:
print("Area of rectangle ",rectangle)
#SHREYA SINGH
ReplyDelete#WAP to Reverse Five Digit Number?
num=12345
print("Given Number is:",num)
a=num%10 #5
num=num//10 #1234
b=num%10 #4
num=num//10 #123
c=num%10 #3
num=num//10 #12
d=num%10 #2
e=num//10 #1
rev=a*10000+b*1000+c*100+d*10+e*1
print("Reverse of the Number is:",rev)
Addition of complex numbers without using complex()?
ReplyDeletea=int(input("enter real number:-"))
bj=int(input("enter imaginary number:-"))
c=int(input("enter real number:-"))
dj=int(input("enter imaginary number:-"))
r=a+c
r1=bj+dj
print("{0}+{1}j".format(a,bj))
print("{0}+{1}j".format(c,dj))
print("{0}+{1}j".format(r,r1))
h,b=int(input("enter heigth of triangle:-")),int(input("enter base of triangle:-"))
ReplyDeletearea=(h*b)/2
print("area of triangle is:-",area)
l,w=int(input("enter length of rectangle:-")),int(input("enter width of ractangle:-"))
area1=l*w
print("area of ractangle is:-",area1)
#reverse number using while loop
ReplyDeletenum=int(input("enter any number:="))
print("reverse num is:-")
while num>0:
print(num%10)
num=num//10
# reverse 5 digits number without while loop
ReplyDeletemun=int(input("enter any number:-"))
a=mun%10
mun=mun//10
b=mun%10
mun=mun//10
c=mun%10
mun=mun//10
d=mun%10
mun=mun//10
e=mun%10
mun=mun//10
print(a,b,c,d,e)
#Area of Tringle
ReplyDeleteb=10
h=20
Area=(b*h)/
/2
print(Area)
#Adding complex number using complex number
ReplyDeleteA=2+4J
B=4+5J
c=A+B
print(A)
print(B)
print("addition of complex number", c)
print(c)
sonam singh
ReplyDeletea=10
>>> b=20
>>> area=(a*b)//2
>>> print(area)
sonam singh
ReplyDeletea=10
>>> b=20
>>> area=(a*b)//2
>>> print(area)
SONAM SINGH
ReplyDelete>>> a=5
>>> print(a*a)
25
>>> print(a*a*a)
125
>>>
Area of Traingle
ReplyDeleteB=int (input("enter the first no ;"))
H=int (input("enter the second no ;"))
Area=(B*H)/2
print(Area)
SONAM SINGH
ReplyDeletea=145
>>> num1=a%10
>>> a=a//10
>>> num1=a%10
>>> format(num1)
'4'
>>> b=154
>>> num2=a%10
>>> b=b//10
>>> num2=b%10
>>> format(num2)
'5'
>>> c=451
>>> num3=c%10
>>> c=c//10
>>> num3=c%10
>>> format(num3)
'5'
>>>
SONAM SINGH
ReplyDeletebase=int(input("enter the base value"))
height=int(input("enter the height value"))
area=(base*height)//2
print(area)
Addition of complex number
ReplyDelete#Abhishek parihar
rn1=3
in1=4j
rn2=5
in2=6j
realnumber=(rn1+rn2)
imaginerynumber=(in1+in2)
print(realnumber+imaginerynumber)
#WAP to Calculate the Area of Triangle and Rectangle?
ReplyDelete#area of triangle = 1/2*b*h
#area of circle= 3.14*r**2
b=float(input("enter the base"))
h=float(input("enter the hight"))
r=float(input("enter tthe radius of circle"))
aot=(1/2)*b*h
aoc=3.14*r**2
print("the area of triangle and area of circle is", aot , aoc)
#WAP to Reverse Five Digit Number?
ReplyDeletenum=int(input("enter five digit no."))
a=num%10
num=num//10
b=num%10
num=num//10
c=num%10
num=num//10
d=num%10
e=num//10
rev=a*10000+b*1000+c*100+d*10+e*1
print("the reverse value is",rev)
#WAP to Calculate Addition of Complex Number?
ReplyDelete#6+9j,10+4j
A=6+9j
B=10+4j
C=A+B
print(A)
print(B)
print("the addition of complex no. is",C)
#WAP to Calculate Addition of Complex Number without adding complex ?
ReplyDeleter1=4
i1=3
r2=3
i2=5
r=r1+r2
i=i1+i2
print("{0}+(1)j".format(r1,i1))
print("{0}+{1}j".format(r2,i2))
print("{0}+{1}j".format(r,i))
#WAP to Calculate the Area of Triangle and Rectangle?
ReplyDelete#area of triangle = 1/2*b*h
#area of rectangle= wl
b=float(input("enter the base"))
h=float(input("enter the hight"))
width=float(input("enter the width "))
length=float(input("enter the length"))
aot=(1/2)*b*h
aor= width*length
print("the area of triangle and area of rectangle is", aot , aor)
Q1 WAP to Reverse Five Digit Number?
ReplyDeletenum=int(input("enter a five digit number"))
a=num%10
num=int(num/10)
b=num%10
num=int(num/10)
c=num%10
num=int(num/10)
d=num%10
num=int(num/10)
e=num%10
num1=a*10000+b*1000+c*100+d*10+e*1
print("reverse number is",num1)
Q2. WAP to Calculate Addition of Complex Number?
a=2+2j
b=2+2j
c=a+b
print(c)
Q3. WAP to Calculate the Area of Triangle and Rectangle and Circle?
b = int(input("enter base"))
h = int(input("enter height"))
area1 = (b*h)*2
print("area of triangle",area1)
w = int(input("enter width"))
h = int(input("enter height"))
area2 = w*h
print("area of ractangle",area2)
r = int(input("enter radious"))
area3 = 3.14*r*r
print("area of circle",area3)
#area of Rectangle
ReplyDeletel=int(input("enter the length"))
w=int(input("enter the width"))
area=w*l
print("the area is", area)
#addition of unknown complex number
ReplyDeletex=complex(input("enter first number"))
y=complex(input("enter second number"))
sum=x+y
print("the sum of complex number is", sum)
#reversing of known number
ReplyDeletex=12345
a=x%10
x=int(x/10)
b=x%10
x=int(x/10)
c=x%10
x=int(x/10)
d=x%10
x=int(x/10)
e=x%10
x=(a*10000+b*1000+c*100+d*10+e*1)
print("the reverse form is",x)
#reversing of unknown number
ReplyDeletex=int(input("enter five digit number to reverse"))
a=x%10
x=int(x/10)
b=x%10
x=int(x/10)
c=x%10
x=int(x/10)
d=x%10
x=int(x/10)
e=x%10
x=(a*10000+b*1000+c*100+d*10+e*1)
print("the reverse form is",x)
#swapping of two unknown numbers without third variable
ReplyDeletex=int(input("ente first number"))
y=int(input("enter second number"))
x=x+y
y=x-y
x=x-y
print(x,y)
#WAP to calculate simple interest.
ReplyDeletep=float(input("enter the princple amount:"))
r=float(input("enter the rate:"))
t=float(input("enter the time:"))
si=(p*r*t)%100
print("simple interest for princple amounr {0}={1}".format(p,si))
# Area of triangle
ReplyDeleteh= int(input("enter height of triangle"))
b=int (input("enter base of triangle"))
area=(h*b)//2
print(area)
#area of rectangle .
ReplyDeletew=int(input("enter width of rectangle"))
l=int(input("rnter length of rectancle"))
area=w*l
print(area)
#addition of complex number.
ReplyDeleter1=5
i1=2
r2=6
i2=4
r=r1+r2
i=i1+i2
print("{0}+{1}i".format (r,i))
l=input("Enter Length:")
ReplyDeleteb=input("Enter Breadth:")
h=input("Enter Height:")
At=(int(h)*int(b))/2
Ar=(int(l)*int(b))
print("Area of triange is:",At)
print("Area of rectangle is:",Ar)
num=int(input("Enter no.:")) #12345
ReplyDeletea=num%10
num=num//10
a1=num%10
num=num//10
a2=num%10
num=num//10
a3=num%10
num=num//10
RD=(a*10000+a1*1000+a2*100+a3*10+num)
print("Reverse Digit is:",RD)
a=2+3j
ReplyDeleteb=4+5j
Add=a+b
print("Addition of complex number is:",Add)
#Addition of a complex number with and without using complex number?
Deletenum1=5+4j
num2=3+7j
num=num1+num2
print(num)
#without
r1=5
i1=4
r2=3
i2=7
r=r1+r2
i=i1+i2
print("{0}+{1}i".format(r,i))
#wap to calculate the area of triangle and rectangle?
ReplyDeleteb=10
h=40
l=30
area=(b*h)//2
print("area of triangle",area)
area=l*b
print("area of rectangle",area)
POST Answer of Questions and ASK to Doubt