Professional Documents
Culture Documents
10
Q.1. Python maths built-in functions.
import math
num1=int(input("Enter number1:"))
num2=int(input("Enter number2:"))
Exercise Questions:-
Q.1. Write a Python function that accepts a string and calculate the number of upper case letters
and lowercase letters.
str="WelcomeToPythonProgramming"
lower=0
upper=0
for i in str:
if(i.islower()):
lower+=1
else:
upper+=1
print("Total uppercase letters:",upper)
print("Total lowercase letters:",lower)
O/P:-
Q.2. Write a Python program to generate a random float where the value is between 5 and 50
using Python math module.
import random
res=random.uniform(5,50)
print(res)
O/P:-
Practical No.11
Q.1. Write a Python function that takes a number as a parameter and check the number is
prime or not.
def primeNum(num):
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")
Q.3. Write a Python function that accepts a string and calculate the number of upper case
letters and lower case letters.
def calculateUpperLower(str):
lower = 0
upper = 0
for i in str:
if(i.islower()):
lower+=1
else:
upper+=1
print("Total uppercase letters:",upper)
print("Total lowercase letters:",lower)
str=input("Enter a string:")
calculateUpperLower(str)
O/P:-