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

Python Programs for class 8 SET 4

The document contains a series of Python programs that perform various tasks such as calculating the sum of a number range, printing a greeting message, counting characters in a string, displaying a calendar for a specific year, and manipulating strings (changing case, replacing substrings). Each program is presented with a brief description and includes user input for interaction. The programs cover basic programming concepts and operations in Python.
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)
4 views

Python Programs for class 8 SET 4

The document contains a series of Python programs that perform various tasks such as calculating the sum of a number range, printing a greeting message, counting characters in a string, displaying a calendar for a specific year, and manipulating strings (changing case, replacing substrings). Each program is presented with a brief description and includes user input for interaction. The programs cover basic programming concepts and operations in Python.
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

# 46 WAP display of sum of the given number range

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


sum=0
i=1
while i<=n:
sum=sum+i
i=i+1
print(sum)
# 47 WAP to subtraction of given number
i=100
while (i>0):
print(i)
i-=3

# 48 WAP to print greeting message


name=input("Enter the name :")
print("Greetings!!!")
print("Hello",name)
print("How do you do ?")

# 49 WAP find number of character from string


count=0
name=input("Enter string :")
ch=input("Enter a letter :")
for i in name:
if i==ch:
count=count+1
print(count)
# 50 WAP to print calender of particular year

import calendar
year=int(input("Enter the year :"))
month=int(input("Enter the month :"))
calendar=calendar.month(year,month)
print(calendar)
# 51 WAP to find string
name=input("enter the string :")
L=len(name)
for i in range(L):
print(name[i])

# 52 WAP to string length


name=input("enter the string :")
L=len(name)
for i in range(L):
print(name[i],"-",i)

# 53 WAP to print multiplication table of given number

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


for i in range(1,11):
print(n,'*',i,'=',n*i)
print("Well done!!!")

#54 WAP to print range of numbers

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


for i in range(1,n,2):
print(i)

#55 WAP to find total vowels in the string

name=input("Enter the string :")


count=0
for i in name:
if i in "aeiouAEIOU":
count=count+1
print(count)

# 56 WAP to replace a string given by user


string=input("Enter your string :")
a=input("Enter the string you want to replace :")
x=input("Enter the new string you want to replace with :")
s=string.replace(a,x)
print("New string is :",s)
print("Original string is :",string)

# 57 WAP to change upper case string given by user


string=input("Enter your string :")
s=string.upper()
print(s)

# 58 WAP to change lower case string given by user


string=input("Enter your string :")
s=string.lower()
print(s)

# 59 WAP to check string is upper case or not


string=input("Enter your string :")
s=string.isupper()
print(s)

# 60 WAP to check string is lower case or not


string=input("Enter your string :")
s=string.islower()
print(s)

You might also like