Professional Documents
Culture Documents
Output:
Enter Celcius: 48.9
Fahrenheit 120.02
Output:
Enter Fahrenheit: 87.6
Celsius 30.888888888888886
Output:
The value of a after swapping: 23
The value of b after swapping: 45
3. Write a Python Program to Convert Decimal to Binary, Octal and
Hexadecimal.
Code:
dec = int(input("enter integer"))
print("the decimal value of ",dec,"is:")
print(bin(dec),"in binary.")
print(oct(dec),"in octal.")
print(hex(dec),"in hexadecimal.")
Output:
enter integer : 45
the decimal value of 45 is:
binary: 0b101101
octal : 0o55
hexadecimal : 0x2d
print("Select operation.")
print("1.Add")
print("2.Subtract")
print("3.Multiply")
print("4.Divide")
while True:
if choice == '1':
print(num1, "+", num2, "=", add(num1, num2))
Output:
Enter First number : 45
Enter Second number : 56
Enter Third number : 34
The maximum of the 3 numbers is : 56
The miniumum of the 3 numbers is : 34
6. Write a program which will allow user to enter 10 numbers and display
largest odd number from them. It will display appropriate message in case
if no odd number is found.
Code:
class LargestOdd:
currO = -1
for num in list:
num = int(num)
if(num % 2 == 1 and num > currO):
currO = num
obj = LargestOdd()
obj.largestOdd(list_num)
Output:
Largest odd number is 65.
Output:
8. Write a Python program to check if the number provided by the user is a
palindrome or not.
Code:
Output: