Professional Documents
Culture Documents
Ankit Vashisth Python
Ankit Vashisth Python
WORKSHEET 1.1
1. Aim: Write a program that takes string as input from user and prints out number
of vowels, consonants, digits and symbols and characters in that string. Use
datatypes, control statements and func<on to implement this.
2. Source Code:
def count(s):
vowels = 0
consonants = 0
digits = 0
symbols = 0
for ch in s:
if ch.islower() and ch in 'aeiou':
vowels += 1
elif ch.isalpha():
consonants += 1
elif ch.isdigit():
digits += 1
COMPUTER SCIENCE & ENGINEERING
else:
symbols += 1
3. Screenshot of Outputs:
4. Learning Outcomes:
• Dictionary Handling
• List Manipulation
• Iteration and Looping
• User Input Handling
• Functions