History & scope of Python:-
Python is a script based language which will be executed by the Python interpreter itself.
The python script is easy to learn and a light-weight script as compare to other programming languages.
A python script was developed by GUIDO VAN ROSSUM to create a device driver-based application initially.
but now Python is complete technology which is used to develop System Software, Application Software, Data Science, Machine Learning, Interface Programming, Game Development,
Electronic Software Implementation with IoT and Aurdino, Automation Programming for Software Testing.
Python Script performance is best as compare to other languages means its performance is much better as compared to C, CPP, Java, PHP, and Another Programming language.
Python script only focuses on a set of code .it not use code pattern and code structure.
.....................................................................................................................................................
How to run the Python Script:-
1 Online Mode:-
We can run a python script without using any software because Python Software tools are online available.
www.jupyter.org/try
Python Program for Addition
Offline Mode:-
python.org download python software
python 3.9.exe file will be downloaded from here
double click and execute them.
After Successfully installation Python Provide Default IDLE Tools
...............................................................................................................................................................
Python Program Execution:-
1 Python Source Code ------> Run -----> PYTHON INTERPRETER MACHINE ----> Machine Code----> Output
.....................................................................................................................................
Program to calculate simple interest?
python.org download python software
python 3.9.exe file will be downloaded from here
double click and execute them.
After Successfully installation Python Provide Default IDLE Tools
...............................................................................................................................................................
Python Program Execution:-
1 Python Source Code ------> Run -----> PYTHON INTERPRETER MACHINE ----> Machine Code----> Output
.....................................................................................................................................
Program to 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 function for Python Console Application:-
Output Function
print():- it is used to print a single line statement and multiple line statements both.
print("hello") #single statement
print("hello","world") #Multiple Statement
print("hello" + "world") #Conacatenation
print(" %f " % 1.2345)
input():- it is used to take input from the user's.
var=input("message")
input return data in String format
a= int(input("message"))
#program for addition
a=int(input("enter first number"))
b=int(input("enter second number"))
c=a+b
print(c)
#ASSIGNMENT:-
WAP to Calculate the Area of Triangle and Rectangle?
WAP to Reverse Five Digit Number?
WAP to Calculate Addition of Complex Number?
Solution:-
Reverse Program Answer?
num=78125
print("Actual 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
num1= a*10000+b*1000+c*100+d*10+e*1
print("Reverse of number is",num1)
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 of a complex number with a complex number:-
num1 = 2+3j
num2 = 4+5j
num = num1+num2
print(num1)
print(num2)
print(num)
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)
Post a Comment
If you have any doubt in programming or join online classes then you can contact us by comment .