Eben
Eben
Basics of Python
Theory Question:
Features:
1)Easy to Read and Write: Python has a simple and clean syntax, making it easy to
learn and use
2) Object-Oriented: Python supports object-oriented programming, which promotes code
reuse and modularity.
3)Robust Frameworks and Libraries: Python offers powerful frameworks and libraries
for web development , data science , machine learning and more.
4)Cross-Platform Compatibility: Python runs on various operating systems (Windows,
macOS, Linux) without requiring significant changes to the code.
5)Dynamically Typed: Variables in Python do not require explicit declaration, allowing
for flexible and rapid development.
10. Write a print statement to display the output Hello ”World” Everyone.
A)
Experiment -1A
Program:
i=7 c=24+8j
f=70.1
s=”HELLO” b=
True
print("the value of c is:",i,'\nits type is:',type(i))
print("the value of c is:",f,'\nits type is:',type(f)) print("the
value of c is:",c,'\nits type is:',type(c)) print("the value of
c is:",s,'\nits type is:',type(s)) print("the value of c
is:",b,'\nits type is:',type(b)) Output:
Experiment 1B
Program:
a=10; b=3
print("Addition of a:",a,"&b:",b,"is:",a+b)
print("Subtraction of a:",a,"&b:",b,"is:",a-b)
print("Multiplication of a:",a,"&b:",b,"is:",a*b)
print("Floor Division of a:",a,"&b:",b,"is:",a/b)
print("Int division of a:",a,"&b:",b,"is:",a//b)
print("Modulus of a:",a,"&b:",b,"is:",a%b)
print("exponent of a:",a,"&b:",b,"is:",a**b)
Output:
Experiment 1C
Aim:Write a program that takes an amount in euro as input. You need to find its
equivalent in Indian rupee and display it. Assume 1 euro= Rs. 78.85
Program :
x=eval(input("Enter the value of Euro")) Rs=x*78.85
print("Amount of", x ,"Euro is",Rs,"Rupee" )
Output :
Enter the value of Euro1
Amount of 1 Euro is 78.85 Rupee
Enter the value of Euro 10
Amount of 100 Euro is 788.4999999999999 Rupee
Output:
Experiment 1D
Aim:Write a python program to swap two numbers and check if the first number is positive
or negative or zero.
Program:
print("Program for Swapping two numbers")
a=int(input("Enter first no:"))
b=float(input("Enter second no:"))
print("Before swapping a=",a," b=",b) a,b=b,a
print("After swapping a=",a," b=",b)
print("b is positive")
# print("{0} is Positive".format(a))
elif
b<0:
"b is negative"
print()
else:
"b is 0" print()
/*if a>0:
print("a is positive") elif
a<0:
"a is negative"
print() else:
"a is 0" print()
*/
Output:
Experiment 1E
Aim : Write a python program to convert temperature to and from Celsius to fahrenheit
Program:
while(1):
print("1.CELSIUS TO FAHRENHEIT\n2.FAHRENHEIT TO CELSIUS\n3.EXIT\n")
choice=input("ENTER YOUR CHOICE:")
ch=int(choice) if(ch==1):
c=int(input("ENTER TEMPERATURE IN CELSIUS:")) f=((9*c)/5)+32
print("converted temperature is:",f)
elif(ch==2):
f=int(input("ENTER TEMPERATURE IN FAHRENHEIT:")) c=((f-32)/9)*5
print("converted temperature is:",c)
elif(ch==3): exit()
else:
print("wrong choice")
Output:
Exercise
1. Write a Python program to display your name using Interactive Mode
2.Write a Python program to display “PCE” using Script Mode
3.Write a program to calculate area and perimeter of the square.Accept side from user.
4.Write a program to find out absolute value of an input number
5.Write a Python program to calculate factorial of a number(While,For)
Conclusion: