pyhton
pyhton
” program:
print("Hello, World!")
1. Binary to decimal
2. 11011 to 26
3. Eliminate vowels and consonants in a string
print(i)
python code for displaying all even in a set of even numbers list
n = int(input("Enter the limit: ")) # take user input for the limit of
the list
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n-1)
Python code for comparing two numbers using the else-if statement and
output smaller and larger numbers:
if a > b:
print(a, "is greater than", b)
elif a < b:
print(a, "is less than", b)
else:
print(a, "is equal to", b)
else:
def fibonacci(n):
if n <= 1:
return n
else:
for i in range(n):
print(fibonacci(i))
if n == n[::-1]:
else:
if i % j == 0:
break
else:
print(i)
Python code for printing the pyramid of stars using nested for loops:
for i in range(n):
for j in range(n-i-1):
for j in range(i*2+1):
print("*", end="")
print()
for j in range(n-i):
for j in range(i*2-1):
print("*", end="")
print()