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

Python Prac

The document contains code to count vowels, consonants and spaces in a string. It also contains code to check if a number is prime or not.

Uploaded by

Shiwani Jha
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Python Prac

The document contains code to count vowels, consonants and spaces in a string. It also contains code to check if a number is prime or not.

Uploaded by

Shiwani Jha
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

3rd question korbo

a.

def vowel_count(str):

count = 0

count_space=0

count_consonent=0

vowel = set("aeiouAEIOU")

for alphabet in str:

if alphabet in vowel:

count = count + 1

elif alphabet in " ":

count_space=count_space + 1

else:

count_consonent=count_consonent + 1

print("No. of vowels :", count)

print("No. of space :", count_space)

print("No. of consonents :", count_consonent)

str = "Geeks for Geeks"

vowel_count(str)
b.

num = 11

if num > 1:

for i in range(2, int(num/2)+1):

if (num % i) == 0:

print(num, "is not a prime number")

break

else:

print(num, "is a prime number")

else:

print(num, "is not a prime number")

You might also like