Lab 06
Lab 06
Lab #6
Dr Asad Mansoor Khan
LE Kashaf Raheem
QUIZ 4 (SYN-A)
EVEN SEAT ODD SEAT
Write a Python Write a Python
program that counts program that
the number of counts the number
vowels in a user of even digits in a
input string user input number.
Length is not fixed Length is not fixed
2
QUIZ 4 (SYN-B)
EVEN SEAT ODD SEAT
Write a Python Write a Python
program that counts program that
the number of removes all
consonants (words vowels from a
which are not vowel) user input
in a user input string string.
Length is not fixed Length is not fixed 3
Python Syntax
Lists
4
Python Basics: Lists, Tuples and
Dictionaries
• Built-in data structures in Python:
List
Tuple
Dictionary
• Lists are mutable – meaning that the value of any element (or sub-
element) can be changed at a later stage
my_list4[3]= [10,12]
my_list4 = [[1,2],[3,4],[5,6],[10,12]]
Python Basics: Lists (Cont’d)
• Other lists (sub-lists) can be an element of a list
my_list4 = [[1,2],[3,4],[5,6],[7,8]]
print(my_list4[0])
print(my_list4[3][0])
13
Tasks
Make sure to comment your code.
Use appropriate variable name
Know the location where file is being saved
Create different files for different tasks
15
Task 1:
Write a Python program that:
1. That takes numbers as input
from the user and adds them to a
list.
2. Squares the numbers in the list
and displays the result.
16
Task 2:
Design an Algorithm and write a
program in python that extracts all unique
characters entered in a sentence. E.g.,
User Enters:
Question for Lab 6
Output is:
There are 15 Unique Letters including:
Q, U, E, S, T, I, O, N, , F, R, L, A, B, 6,
17
Task 3:
Design an Algorithm and write a
program in python check if the user
entered word is in alphabetical order or
not.
If all the letters are not in alphabetical
order, then your program should
display till which letter they are in
alphabetical order.
Next week: MIPS and
Assembly!
Advice:
Download MARS simulator
26