Notas
Python
Conteúdo das notas (1)
Página 1
Lists
- The LIst is like an array but can contain many data types.
Creating Lists:
# Python program to demonstrate
# Creation of List
# Creating a List
List = []
print("Intial blank List: ")
print(List)
# Creating a List with
# the use of a String
List = ['GeeksForGeeks']
print("\nList with the use of String: ")
print(List)
# Creating a List with
# the use of multiple values
List = ["Geeks", "For", "Geeks"]
print("\nList containing multiple values: ")
print(List[0])
print(List[2])
# Creating a Multi-Dimensional List
# (By Nesting a list inside a List)
List = [['Geeks', 'For'] , ['Geeks']]
print("\nMulti-Dimensional List: ")
print(List)
# Creating a List with
# the use of Numbers
# (Having duplicate values)
List = [1, 2, 4, 4, 3, 3, 3, 6, 5]
print("\nList with the use of Numbers: ")
print(List)
# Creating a List with
# mixed type of values
# (Having numbers and strings)
List = [1, 2, 'Geeks', 4, 'For', 6, 'Geeks']
print("\nList with the use of Mixed Values: ")
print(List)
Slicing: List[:4]
LIst methods
List . append()
List. remove(item), List.pop(index)
Informações
- Descrição
- Notas sobre Python, criado por Sital Sitoula em 15-05-2019.
- Criado por
- Sital Sitoula
- Visualizações
- 0
- Avaliação