Programming With Python Practical 10

Question 1
Write a Python function that accepts a string and calculate the number of upper case letters and lower case letters.
count.py
Str=input("Enter a string: ")
count1=0
count2=0
for i in Str:
      if(i.islower()):
            count1+=1
      else:
            count2+=1
print("The number of lowercase letters is: ",count1)
print("The number of uppercase letters is: ",count2)
Output
Question 2
Write a Python program to generate a random float where the value is between 5 and 50 using Python math module.
randomfloat.py
import random

num=random.uniform(5, 50)
print("Random float number is: ",num)
Output

Leave a Comment

Your email address will not be published. Required fields are marked *