0% found this document useful (0 votes)
2 views

Function Programs

The document contains several Python functions that perform different tasks: printing the Fibonacci series up to a given number, checking if a number is an Armstrong number, printing the multiplication table of a given number, and displaying specific series patterns. Additionally, it includes functions to count and display the total even and odd numbers from a list, as well as the total vowels and consonants from a string. Each function prompts the user for input and displays the results accordingly.

Uploaded by

Bhomesh Das
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Function Programs

The document contains several Python functions that perform different tasks: printing the Fibonacci series up to a given number, checking if a number is an Armstrong number, printing the multiplication table of a given number, and displaying specific series patterns. Additionally, it includes functions to count and display the total even and odd numbers from a list, as well as the total vowels and consonants from a string. Each function prompts the user for input and displays the results accordingly.

Uploaded by

Bhomesh Das
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

WAF to print the Fibonacci Series upto N

def fibonacci(n):

first=0

second=1

print("Fibonacci series:")

print(first,second,end=' ')

for i in range(2,n):

third=first+second

print(third,end=' ')

first=second

second=third

n=int(input("Enter the range:"))

fibonacci(n)

WAF to check the Armstrong number or not


def Armstrong(n):

num=n

sum=0

while n>0:

rem=n%10

sum=sum+rem**3

n=n//10

if num==sum:

print("Armstrong number")

else:

print("Not an Armstrong mumber")

n=int(input("Enter a number:"))

Armstrong(n)
WAF to print multiplication table of a given number

def Table(n):

for i in range(1,11):

print(n,'X', i,'=',n*i)

n=int(input("Enter a number:"))

Table(n)

WAF to print the series

111

22

def series():

for i in range(1,4):

for j in range(i,4):

print(i , end=' ')

print()

series()

WAF to print the series

AB

ABC

def series():

for i in range(65,68):

for j in range(65,i+1):

print(chr(j),end=' ')

print()

series()
#WAF to count and display the total even and odd numbers from a list
def Evenlist(L):

even=odd=0

for i in L:

if i%2==0:

even=even+1

else:

odd=odd+1

print("Totel even nos.=",even)

print("Totel odd nos.=",odd)

L=eval(input("Enter a list:"))

Evenlist(L)

#WAF to count and display the total vowels and consonants from a string

def Vowelcons(string):

vow=cons=0

for i in string:

if i.isalpha():

if i in 'AEIOUaeiou':

vow+=1

else:

cons+=1

print("No. of vowels=",vow)

print("No. of consonants=",cons)

string=input("Enter a string:")

Vowelcons(string)

You might also like