Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Python OPERATORS, Data Types: LIST, SET, TUPLE, DICTIONARY

# Create a new Python file with the name 'lab8_YourName' and Save it.


# 1. Create a list, assign 5 different values and display it using the print command

sesame_street_characters = []
sesame_street_characters = ['Elmo', 'Big Bird', 'Oscar', 'Cookie Monster', 'Grover']
print('My Most favourite characters of sesame street', sesame_street_characters)

# 2. Add a new value to the end of the list and display it using the print command


sesame_street_characters = ['Elmo', 'Big Bird', 'Oscar', 'Cookie Monster', 'Grover', 'Kermit']
print(sesame_street_characters[5])

# 3. Remove the second value from the list and display it using the print command


sesame_street_characters = ['Elmo', 'Big Bird', 'Oscar', 'Cookie Monster', 'Grover', 'Kermit']
sesame_street_characters.pop(1)
print(sesame_street_characters)

# 4. Check the length of the list and display it using the print command

sesame_street_characters = ['Elmo', 'Big Bird', 'Oscar', 'Cookie Monster', 'Grover', 'Kermit']
print("Length of list of Sesame Street Characters is = ", len(sesame_street_characters))

# 5. Display the first item using the print command

sesame_street_characters = ['Elmo', 'Big Bird', 'Oscar', 'Cookie Monster','Grover', 'Kermit']
print (sesame_street_characters[0])


# 6. Display the last item using the print command

sesame_street_characters = ['Elmo', 'Big Bird', 'Oscar', 'Cookie Monster','Grover', 'Kermit']
print (sesame_street_characters[5])
Comment

PREVIOUS NEXT
Code Example
Python :: convert string input into a nested tuple in python 
Python :: Patch loop runner _run_once 
Python :: Python OrderedDict - LRU 
Python :: how to count the iteration a list python 
Python :: list generation for python 
Python :: django default template location 
Python :: python starting multiple processes in a loop 
Python :: how to hack instagram account using python 
Python :: printing a varible with a varible. python 
Python :: Multiple page UI within same window UI PyQt 
Python :: Python Program to Find sum Factorial of Number Using Recursion 
Python :: with suppress(exception) python 
Python :: pyqt5 tab order 
Python :: pandascheck if two columns match and populate new column 
Python :: showing typle results with for loop in py 
Python :: numpy array filter and count 
Python :: save csv with today date pandas 
Python :: whois eyedress 
Python :: how to print using .sh file from python 
Python :: hack twitter with python 
Python :: cython could not creat pyd file no such file or directory 
Python :: python data engineer interview questions 
Python :: parse tree tags 
Python :: dict to csv keys as rows and subkey as columns in python 
Python :: first hitting time python 
Python :: python matrix condensed to square 
Python :: pyqt create a qmenu on a button click 
Python :: how to add watermark in mp4 video using python 
Python :: fetch member by id discord.py 
Python :: pandas continues update csv with exception 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =