# Write a python program using while loop to reverse a number and print the reversed number - Python

Categories:
Viewed: 7 - Published at: a few seconds ago

### Write a python program using while loop to reverse a number and print the reversed number

``````Number = int(input("Please Enter any Number: "))
Reverse = 0
while(Number > 0):
Reminder = Number %10
Reverse = (Reverse *10) + Reminder
Number = Number //10

print("\n Reverse of entered number is = %d" %Reverse)
``````

### Write a python program to take year as input and check if it is a leap year or not

``````year = int(input("Enter a year: "))
if (year % 4) == 0:
if (year % 100) == 0:
if (year % 400) == 0:
print(f"{year} is a leap year")
else:
print(f"{year} is not a leap year")
else:
print(f"{year} is a leap year")
else:
print(f"{year} is not a leap year")
``````

### Write a python program to input a number to test and print if it is a prime number

``````num = int(input("Enter number :"))
lim = int(num/2) + 1
for i in range(2,lim):
rem = num % i
if rem == 0 :
print(num,"is not a prime number")
break
else:
print(num,"is a prime number")
``````

### Write a python program to input a string from user and convert input string into all upper case and print the result

``````string = input("Please Enter your Own String : ")

string1 = string.upper()

print("\nOriginal String in Lowercase  =  ", string)
print("The Given String in Uppercase =  ", string1)
``````

### Write a python program to input a string from user and count vowels in a string and print the output

``````str1 = input("Please Enter Your Own String : ")
vowels = 0

for i in str1:
if(i == 'a' or i == 'e' or i == 'i' or i == 'o' or i == 'u' or i == 'A'
or i == 'E' or i == 'I' or i == 'O' or i == 'U'):
vowels = vowels + 1

print("Total Number of Vowels in this String = ", vowels)
``````

### Write a python program to input a Number N from user and print Odd Numbers from 1 to N

``````maximum = int(input(" Please Enter any Maximum Value : "))

for number in range(1, maximum + 1):
if(number % 2 != 0):
print("{0}".format(number))
``````

### Write a python program to input a Number N from user and print Even Numbers from 1 to N

``````maximum = int(input(" Please Enter the Maximum Value : "))

for number in range(1, maximum+1):
if(number % 2 == 0):
print("{0}".format(number))
``````

### Write a python program to input two numbers from user and add two Numbers and print the result

``````number1 = input(" Please Enter the First Number: ")
number2 = input(" Please Enter the second number: ")

sum = float(number1) + float(number2)
print('The sum of {0} and {1} is {2}'.format(number1, number2, sum))
``````

### Write a python program that takes two integers as input and check if the first number is divisible by other

``````num1 = int(input("Enter first number :"))
num2 = int(input("Enter second number :"))
remainder  = num1 % num2
if remainder == 0:
print(num1 ," is divisible by ",num2)
else :
print(num1 ," is not divisible by ",num2)
``````

### Write a python program to print the table of input integer

``````num = int(input("Please enter a number "))
for a in range(1,11):
print(num , 'x' , a , '=' ,num*a)
``````

### Write a python program to print the factorial of number

``````num = int(input("Please enter a number "))
fact = 1
a = 1
while a <= num :
fact *= a
a += 1
print("The factorial of ",num, " is ",fact)
``````

### Write a python program which takes 3 numbers as input and to print largest of three numbers using elif statement

``````a = float(input("Please Enter the First value: "))
b = float(input("Please Enter the First value: "))
c = float(input("Please Enter the First value: "))

if (a > b and a > c):
print("{0} is Greater Than both {1} and {2}". format(a, b, c))
elif (b > a and b > c):
print("{0} is Greater Than both {1} and {2}". format(b, a, c))
elif (c > a and c > b):
print("{0} is Greater Than both {1} and {2}". format(c, a, b))
else:
print("Either any two values or all the three values are equal")
``````

### Write a python program which takes input a number N and print first N elements of fibonacci series

``````N = int(input("Please enter a number "))
first = 0
second = 1
print(first)
print(second)
for a in range(1,N-1):
third = first + second
print(third)
first,second = second , third
``````
{"ft_lang_label":"__label__en","ft_lang_prob":0.720865,"math_prob":0.99900645,"size":3904,"snap":"2023-14-2023-23","text_gpt3_token_len":1094,"char_repetition_ratio":0.17794871,"word_repetition_ratio":0.17671233,"special_character_ratio":0.3319672,"punctuation_ratio":0.10012674,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9991647,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-03-22T00:18:12Z\",\"WARC-Record-ID\":\"<urn:uuid:d7460d6d-c9af-486b-a82a-37cd201c586e>\",\"Content-Length\":\"37224\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:fb5563a7-7ab2-4ff3-a930-a42a986eabee>\",\"WARC-Concurrent-To\":\"<urn:uuid:41deec98-43a0-48e5-b670-858546865617>\",\"WARC-IP-Address\":\"45.63.49.36\",\"WARC-Target-URI\":\"https://www.codevelop.art/write-a-python-program-using-while-loop-to-reverse-a-number-and-print-the-reversed-number.html\",\"WARC-Payload-Digest\":\"sha1:WPTEWU3OEXSVBK5AU74CDX5ZUZBJQFBB\",\"WARC-Block-Digest\":\"sha1:AHSAVJQR5IL7OER6CEUKF7RKV2VQOAR2\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-14/CC-MAIN-2023-14_segments_1679296943747.51_warc_CC-MAIN-20230321225117-20230322015117-00390.warc.gz\"}"}