Python Programing Lab EXERCISE - 3(c)

Aim: 
            Write a program using a for loop that loops over a sequence. What is sequence?

Description: 


A Sequence is the generic form for an ordered set. There are several types of sequences in Python. The following 3 are most important.
Lists: There are the most versatile sequence type. The elements of a list can be any object and lists are mutable.

Tuples: These are like lists, But Tuples are immutable.

Strings: These are a special type of sequence that can store only characters and having special notations.

Algorithm:

Output: Elements of sequence(List). 

Step1: Start 
Step2: Initialize the days=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']
Step3: Repeat Step4 until the last element in the list is reached 
Step4: Print ith element 
Step5: Stop

Program:


days=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']
print("Days of the week:")
for day in days:
      print(day)

Output:

Days of the week:
Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday



No comments

Algorithms and Programs

  Algorithms and Programs Both the algorithms and programs are used to solve problems, but they are not the same things in terms of their fu...