Q.
4 Define a function which will find all such numbers which are divisible by 7 but are not a
multiple of 5,between 1000 and 3000 (both included)
def fun():
nl=[]
for x in range(1000, 3001):
if (x%7==0) and (x%5!=0):
nl.append(str(x))
print (','.join(nl))
fun()
Q.5 Define the same function of question no 4 where starting and ending number is passedas argument
def fun(start,end):
nl=[]
for x in range(start,end):
if (x%7==0) and (x%5!=0):
nl.append(str(x))
print (','.join(nl))
x=int(input("enter x value"))
y=int(input("enter y value"))
fun(x,y)
Q.6 Define a function that accepts a sentence and calculate the number of letters and digits
s = input("Input a string")
d=l=0
for c in s:
if c.isdigit():
d=d+1
elif c.isalpha():
l=l+1
else:
pass
print("Letters", l)
print("Digits", d)
Q.7 Define a function that accepts a sentence and calculate the number of upper case
letters and lower case letters
s = input("Input a string")
d=l=0
for c in s:
if c.isupper():
d=d+1
elif c.islower():
l=l+1
else:
pass
print("Upper case Letters", l)
print("Lower case letters", d)
Q.8 Define a function that can accept two strings as input and concatenate them and then print it in console.
def concatenet(str1,str2):
z=''
z=x+y
print(z)
x=input("enter string1")
y=input("enter string2")
concatenet(x,y)
Q.9 Define a function which can generate and print a list where the values are square of
numbers between 1 and 20 (both included).
def printValues():
l = list()
for i in range(1,21):
l.append(i**2)
print(l)
printValues()
Q.10 With a given tuple (1,2,3,4,5,6,7,8,9,10), define a function to print the first half values
in one line and the last half values in one line.
Def tup():
tp=(1,2,3,4,5,6,7,8,9,10)
tp1=tp[:5]
tp2=tp[5:]
print(tp1)
print(tp2)
tup()