Ex 2

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

CSE304 – PYTHON PROGRAMMING WITH WEB FRAMEWORKS

EX NO.2 - Programs using looping and conditional constructs

1. Compute the time required to double an initial investment amount with a specified
rate of interest.

2. Use for loop construct for the following: accept ‘n’ strings as input. Do the following
in each string.
a) reverse the case of each character
b) remove the vowels and print the new string
c) remove the duplicate characters in each string and print the new string
d) compare the current string with the previous string; if they match, print
‘Duplicate value’

3. Compute the compound interest on an initial investment, for a defined number of


years and a fixed rate of interest. Print all of the values at the end of each year in the
form a table.

4. Define the following conditions for validating a string as a valid password. The
string should have a minimum of 8 characters and maximum 20 characters. It can
contain alphabets(upper and lower case), digits(0 to 9) and the following special
characters only (*, $, #). The password should contain a minimum of one uppercase
letter, one lowercase letter, two digits and only one of the special characters. The
two digits should not be in successive positions. Accept strings as input and print if
they are valid passwords or not.

5. Write a python code for the following scenario:


A student will not be allowed to sit in exam if his/her attendance is less than
75%.Take the following input from user:- Number of classes held, Number of
classes attended. Compute and print the percentage of class attended and also print
if the student is allowed to sit in exam or not.

You might also like