Gen-AI Developer Classroom notes 27/Feb/2025

Sequence Data types in Python

  • str: This is sequence of character
  • list: this is sequence of objects which can be altered
  • tuple: this is sequence of objects which cannot be altered
  • range: this is generally a numerical sequence

indexing and slicing on sequences

  • Indexes in python
    Preview

  • Slicing in python: For all sequence types we can use slicing

[<start-index>:<stop-index>:<step>]
# default value
<start-index> = 0
<stop-index> = length -1
<step> = 1

Common sequence operations

Find out if the below are mutable or immutable

  • str
  • list: List is the only sequence type which is mutable
  • tuple
    Preview

Write a for loop to print each item of

  • str
  • list
  • tuple
  • range
for index = range(1,10,2):
    print(index)

Preview

list of all prime numbers from 10 to 1000

By continuous learner

enthusiastic technology learner

Leave a Reply

Discover more from Direct AI Powered By Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading