0% found this document useful (0 votes)
6 views2 pages

Python Functions for String Analysis

The document contains two practical Python programming tasks. The first task involves writing a function to count upper and lower case letters in a given string. The second task requires generating a random float between 5 and 50 and rounding it down using the math module.
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)
6 views2 pages

Python Functions for String Analysis

The document contains two practical Python programming tasks. The first task involves writing a function to count upper and lower case letters in a given string. The second task requires generating a random float between 5 and 50 and rounding it down using the math module.
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

PRACTICAL 10

1.1. Write a Python function that accepts a string and calculate the number of upper case
letters and lower case letters.

def check(str):
upper=0
lower=0
for i in str:
if [Link]():
upper+=1
elif [Link]():
lower+=1
else:
pass
print("Upper case=",upper)
print("Lower case=",lower)
str=input("Enter string to calculate upper and lower cases in string\n")
check(str)

2. Write a Python program to generate a random float where the value is between 5 and
50 using Python math module.

import random
import math
random_float = [Link](5, 50)
rounded_float = [Link](random_float)
print("Random float number between 5 and 50 =", random_float)
print("Rounded float number =", rounded_float)

You might also like