0% found this document useful (0 votes)
12 views4 pages

Python Practical 24 - 09 - 24

practical file

Uploaded by

Khushboo Garg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views4 pages

Python Practical 24 - 09 - 24

practical file

Uploaded by

Khushboo Garg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Ques1: Write a program to enter two integers, two floating number

and then perform all arithmetic on them.


Input:
num1 = int(input("Enter first number ")) num2 = int(input("Enter
second number ")) num3 = float(input("Enter the first floating
number ")) num4 = float(input("Enter the second floating number "))
print("integer number are : ", num1) print("integer number are : ",
num2) print("floating number are : ", num3) print("floating number
are : ", num4) print("Enter your choice for the following: \n1.
addition \n2. substraction
\n3. multiplication \n4. division \n5. modulous
\n6.Exponential") choice = int(input("Enter your choice :
")) if choice == 1:
result1 = num1 + num2
result2 = num3 + num4
print(result1, "\n",
result2) elif choice == 2:
result1 = num1 - num2
result2 = num3 - num4
print(result1,"\n",
result2) elif choice ==
3:
result1 = num1 * num2
result2 = num3 * num4
print(result1,"\n",
result2) elif choice ==
4:
result1 = num1 / num2
result2 = num3 / num4
print(result1,"\n",
result2) elif choice ==
5:
result1 = num1 % num2
result2 = num3 % num4
print(result1,"\n",
result2) elif choice ==
6:
result1 = num1 ** num2
result2 = num3 ** num4
print(result1,"\n",
result2)

pg1
output:

pg2
Ques2: Write a program to check whether a number is an
Armstrong number or not.
Input:
num = int(input("Enter the number
: ")) sum = 0 temp = num while
temp > 0:
digit = temp %
10 sum += digit
** 3 temp //=
10 if num == sum:
print(num, " is a armstrong
number") else:
print(num, " is not a armstrong number")

output:
Ques3: Write a program to swap two string.

Input:
str1 = "hello" str2 = "world" print("Before swapping the
strings : " + str1 + " " + str2) str1 = str1+str2 str2 =
str1[0:(len(str1)len(str2))] str1 = str1[len(str2):]
print("After swapping the strings : " + str1 + " " + str2)

Output:

You might also like