1PythonBasicPrograms
1PythonBasicPrograms
1. To display the message “My first program” and XI in separate lines on screen.
Output:
My First Program
XI
num1 = 1.5
#num1 is assigned the value 1.5
num2 = 6.3
print('The sum is ',num1+num2)
Output :
p=1000
r=5
t=2
si=(p*r*t)/100
print("Simple Interest is Rs ",si)
Output
Simple Interest is Rs 100
P4) Let the user Input values of Principle, rate, Time. Display Simple Interest
Output:
Enter the value for Principal : 100
Enter the value for rate : 2
Enter the value for Time : 3
Simple Interest is Rs 6
P5) Assign strings ‘hello’ and “world” to two string variables. Display their values.
a = 'hello'
# single and double quotes both can be used to #
enclose strings. a is
print(a)
b = "world"
print(b)
Output:
hello
world
Output:
Enter a character: A
The ASCII value of 'A' is 65
Enter a character: a
The ASCII value of 'a' is 97
P7: Let the user Input radius of a circle . Display its Area . (A= pi* r*r)
pi= 3.14
r = int(input(“Pl enter the Radius of circle”))
a= pi* r *r
print (“Area is”, a)
P
Output:
P8:
Input Temperature in Degrees Fahrenheit. Display in Celcius.
Output:
Enter Temperature in Fahrenheit 132
P9:
(Concatenation)
Let the user input his/her first name and Last name. Display Hello, lastname then First name.
Output
Input your First Name : Agamjot
Input your Last Name :Singh
Hello Singh Agamjot
P10:
Output:
Enter first number 23
Enter second number 45
P11:
To input 2 numbers and swap them WITHOUT using third variable
Output:
Enter first number 23
Enter second number 45
After swap:
Output
Enter Time in seconds 150000
Hrs 41.666666666666664 Minutes = 40.0 seconds = 0