Mirzo ulug‘bek nomidagi


Python 3 # Creating a List with


Download 148.56 Kb.
bet3/13
Sana30.04.2023
Hajmi148.56 Kb.
#1406197
1   2   3   4   5   6   7   8   9   ...   13
Bog'liq
Dasturiy injenering

Python 3

# 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)

Chiqish
Raqamlardan foydalangan holda ro'yxat:
[1, 2, 4, 4, 3, 3, 3, 6, 5]


Aralash qiymatlardan foydalangan holda ro'yxat:
[1, 2, “Geeks”, 4, “For”, 6, “Geeks”]
Roʻyxatdagi elementlarga kirish
Ro'yxat elementlariga kirish uchun indeks raqamiga murojaat qiling. Roʻyxatdagi elementga kirish uchun indeks operatoridan [ ] foydalaning. Indeks butun son bo'lishi kerak. Ichki ro'yxatlarga kirish ichki indekslash yordamida amalga oshiriladi. 
1-misol: Ro'yxatdagi elementlarga kirish
Python 3

# Python program to demonstrate
# accessing of element from list

# Creating a List with
# the use of multiple values
List = ["Geeks", "For", "Geeks"]

# accessing a element from the
# list using index number

Download 148.56 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7   8   9   ...   13




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling