Programs Of Python Fundamentals (2)
Programs Of Python Fundamentals (2)
SOLVED QUESTIONS :-
2. Code to add two numbers in python by taking numbers from the user.
x = int(input("Enter First Number:\n"))
y = int(input("Enter Second Number:\n"))
Sum = x+y
print("Sum of", x, "and", y, "is", Sum)
Output:
Enter First Number: 12
Enter Second Number: 32
Sum of 12 and 32 is 44
Output:
Enter number 1: 7
Enter number 2: 3
Enter number 3: 13
Three numbers are: 7 3 13
Sum is : 23
5. Program to obtain length and breadth of a rectangle and calculate its area.
# to calculate area
length = float(input("Enter length of the rectangle :"))
breadth = float(input("Enter breadth of the rectangle :"))
area = length * breadth
print ("Length = ", length)
print ("breadth = ", breadth)
print ("Area = ", area)
Output:
Enter length of the rectangle : 8.75
Enter breadth of the rectangle: 35.0
Length = 8.75
Breadth = 35.0
Area = 306.25
Output:
Enter temp in Celsius : 15
Temperature in Celsius is : 15
Temperature in Fahrenheit is : 59
Output:
The value of x after swapping : 10
The value of y after swapping : 5
[Without Using Temporary Variable]
x = 5
y = 10
x, y = y, x # multiple assignment property
print("x =", x)
print("y =", y)
Output:
x = 10
y=5
OR
x = 5
y = 10
x = x + y
y = x - y
x = x - y
print("x =", x)
print("y =", y)
Output:
x = 10
y=5
ASSIGNMENT:-
1. Write a program with a maximum of three lines of code and assign the first 5
multiples of a number to 5 variables and then print them.
2. Write a Python program that accepts the radius of a circle and prints its area.
3. Write a program to read a number n and print n², n³, n⁴.
4. Write a program to find the area of a triangle.
5. Predict the output of the following code:-
a) a, b, c = 2, 3, 4
a, b, c = a*a, a*b, a*c
print(a, b, c)
b) first = 2
second = 3
third = first + second
print(first, second, third)
first = first + second + third
third = second * first
print(first, second, third)
c) X = 10
X = X + 10
X = X - 5
print(X)
X, Y = X-2, 22
print(X, Y)
a) a = 3
print(a)
b = 4
print(b)
s = a + b
print(s)
b) name = "Prajith"
age = 26
print("Your name & age are ", name + age)
c) a = 3
s = a + 10
a = "New"
q = a / 10
print(q)
hello madam mai na 3 hfto se wait kr rha thaki ab baat krog ab krogi! lekin tumne nhi tumne school me baat krne se mana mai kisi ke samne tmse
baat tk nhi krta aur akele tum rheti nhi ho school mai koi na koi tumhare sath ota tumse eyecontact krne ki koshish tum waha se hatt jati rajat se kuch
khane ke bejta tha tum wo bhi mana kr deti thi ......class me tum sbse baat krti ho sirf mujhe chod kr baar baar tumhe durr se koshish krta kabhi
ground se toh kabhi commerce ki window se pr koi na koi aa jata hai.devsena dekho tm baar kahe ki tum mujhse baat nhi chahti mai sach mai tumhe
disturb nhi pr please baat ko tlna nhi .mai na 5 dino tumhri coaching aata hu phir ghr ke aas pass gumta hu kaogi toh proof ke liye maine video bana
rakhi hai mai bej dunga agr tum kaogi toh! tum bs ek baar kahe do ki tumhe chidd hoti dekh tumhe disturb hota hai mai sach me aj ke baad kayi pr
bhi tummhe pareshan nhi krunga. kasam se bs ek baar likh class me bhi sochta rhetaki ab koi kaam bologi mujhse pr rajat tanish keshav aatrey inhi
ka naam leti kl bhi . areh tumse kuch mt krawao tum mujse agr pani ki bootle br do tum bag utha lau toh mai ye bhi khusi khusi kr dunga .. pr agr
baat krni hai toh kro wrna plss mana kr do jaise 1.5 saal bina baat kiye rha waise abhi bhi rhe lunga