Write A Python Program To Check Whether The Given Number Is Positive or Negative
Write A Python Program To Check Whether The Given Number Is Positive or Negative
Write A Python Program To Check Whether The Given Number Is Positive or Negative
Output:-
Output:-
n1, n2 = 0, 1
count = 0
if nterms <= 0:
print("Please enter a positive integer")
elif nterms == 1:
print("Fibonacci sequence upto",nterms,":")
print(n1)
else:
print("Fibonacci sequence:")
while count < nterms:
print(n1)
nth = n1 + n2
n1 = n2
n2 = nth
count += 1
Output:-
Output:-
6. Write a Python Find Prime numbers in a given range
lower = int(input("Enter lower range: "))
upper = int(input("Enter upper range: "))
Output:-
if num == sum:
print(num,"is an Armstrong number")
else:
print(num,"is not an Armstrong number")
Output
8. Write a Python Program to check if given number is palindrome or not
num = int(input("enter a number: "))
temp = num
rev = 0
while temp != 0:
rev = (rev * 10) + (temp % 10)
temp = temp // 10
if num == rev:
print("number is palindrome")
else:
print("number is not palindrome")
Output:-
Output
10. Write a Python Program to find out the ASCII value of a character
ch = input("Enter any character: ")
Output
11. Write a Python Program to find the size of int, float, double and char
Output
Output
if num <= 0:
print("Enter a whole positive number!")
else:
while num > 0:
sum = sum + num
num = num - 1
print("Sum of first", hold, "natural numbers is: ", sum)
Output
16. Program to to take a input as string and check the string is on the
upper case or in lower case if upper case then display is in exact case and
then convert string from upper case to lower case and vice versa.
str1=input("Enter the string:");
newStr = "";
else:
newStr += str1[i];
print("String after case conversion : " + newStr);
Output