Python Practical 24 - 09 - 24
Python Practical 24 - 09 - 24
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: