Telegram Group & Telegram Channel
Python dasturlash maktabi
⭕️ 3-bo'lim "Nazorat tarkibi" ————————————— Ⓜ️ "if" va "elif" operatorlari Biror shart bajarish uchun if operatorlaridan foydalanishingiz mumkin va shart operatori deyarli barcha dasturlarda ishtirok etadi. Shart operatori 3 qismdan iborat (if, elif, else).…
Ⓜ️ Roʼyxat

Ro'yxat - ma'lumotlar to'plamini saqlash uchun ishlatiladigan ma'lumot turi.

To'rtburchakli qavs ichida ro'yxat yaratilganda uning barcha elementlari vergul bilan ajratilib yoziladi. ['olma', 'anor', 'gilos']

Ro'yxat massivga o'xshaydi va farqi shundaki massiv o'zida butun va haqiqiy sonlarni saqlaydi, ro'yxat esa boshqa turdagi ma'lumotlarni ham o'zida saqlashi mumkkin.

list() funksiyasi, literallar yoki ro'yxat gneratorlari yordamida ro'yxatlarni tuzish mumkin.

list_funksiyasi = list('pythonuz')
print(list_funksiyasi)
['p', 'y', 't', 'h', 'o', 'n', 'u', 'z']

literal = ['p', 'y', 't', 'h', 'o', 'n']
print(literal)
['p', 'y', 't', 'h', 'o', 'n']

royxat_gneratori = [ord(i) for i in 'pythonuz']
print(royxat_gneratori)
[112, 121, 116, 104, 111, 110, 117, 122]

none = list()
print(none)
[] # boʻsh roʻyxat

Ro'yxat bo'laklari

Ro'yxat bo'laklari ro'yxatdan qiymatlarni olishning yanada rivojlangan usulini taqdim etadi. Ro'yxatni qismlarga ajratish ikki nuqta bilan ajratilgan butun sonlar bilan indekslanadi.

# indeks 0, 1, 2, 3, 4, 5, 6, 7
squares = [4, 9, 16, 25, 36, 49, 64, 81]

2-elelmentdan 6-elementgacha bo'lgan elementlarni chop qiladi.
print(squares[2:6])
[16, 25, 36, 49]

3-elelmentdan 8-elementgacha bo'lgan elementlarni chop qiladi.
print(squares[3:8])
[25, 36, 49, 64, 81]

0-elelmentdan 1-elementgacha bo'lgan elementlarni chop qiladi.
print(squares[0:1])
[4]

4-elementgacha bo'lgan elementlarni chop qiladi.
print(squares[:4])
[4, 9, 16, 25]

4-elelmentdan oxirgi elementgacha bo'lgan elementlarni chop qiladi.
print(squares[4:])
[36, 49, 64, 81]

2 qadam bilan ro'yxatni chop qiladi.Ro'yxatadgi har 2-elementni chop qiladi.
print(squares[::2])
[4, 16, 36, 64]

4-elelmentdan 6-elementgacha bo'lgan har 3-elementlarni chop qiladi.
print(squares[2:6:3])
[16, 49]

Manfiy indeks ro'yxatning oxiridan boshlab hisoblash uchun xizmat qiladi.
1-elelmentdan 7-elementgacha bo'lgan elementlarni chop qiladi.
print(squares[1:-1])
[9, 16, 25, 36, 49, 64]

1-elelmentdan 5-elementgacha bo'lgan elementlarni chop qiladi.
print(squares[1:-3])
[9, 16, 25, 36]

Ro'yxat o'zgarmaydi.Ro'yxatni teskari tartibda chop qiladi.
print(squares[::-1])
[81, 64, 49, 36, 25, 16, 9, 4]

Ro'yxat o'zgaradi.Ro'yxatni teskari tartibda chop qiladi.
squares.reverse()
print(squares)
[81, 64, 49, 36, 25, 16, 9, 4]

@pythonuz



tg-me.com/pythonuz/367
Create:
Last Update:

Ⓜ️ Roʼyxat

Ro'yxat - ma'lumotlar to'plamini saqlash uchun ishlatiladigan ma'lumot turi.

To'rtburchakli qavs ichida ro'yxat yaratilganda uning barcha elementlari vergul bilan ajratilib yoziladi. ['olma', 'anor', 'gilos']

Ro'yxat massivga o'xshaydi va farqi shundaki massiv o'zida butun va haqiqiy sonlarni saqlaydi, ro'yxat esa boshqa turdagi ma'lumotlarni ham o'zida saqlashi mumkkin.

list() funksiyasi, literallar yoki ro'yxat gneratorlari yordamida ro'yxatlarni tuzish mumkin.

list_funksiyasi = list('pythonuz')
print(list_funksiyasi)
['p', 'y', 't', 'h', 'o', 'n', 'u', 'z']

literal = ['p', 'y', 't', 'h', 'o', 'n']
print(literal)
['p', 'y', 't', 'h', 'o', 'n']

royxat_gneratori = [ord(i) for i in 'pythonuz']
print(royxat_gneratori)
[112, 121, 116, 104, 111, 110, 117, 122]

none = list()
print(none)
[] # boʻsh roʻyxat

Ro'yxat bo'laklari

Ro'yxat bo'laklari ro'yxatdan qiymatlarni olishning yanada rivojlangan usulini taqdim etadi. Ro'yxatni qismlarga ajratish ikki nuqta bilan ajratilgan butun sonlar bilan indekslanadi.

# indeks 0, 1, 2, 3, 4, 5, 6, 7

squares = [4, 9, 16, 25, 36, 49, 64, 81]

2-elelmentdan 6-elementgacha bo'lgan elementlarni chop qiladi.
print(squares[2:6])
[16, 25, 36, 49]

3-elelmentdan 8-elementgacha bo'lgan elementlarni chop qiladi.
print(squares[3:8])
[25, 36, 49, 64, 81]

0-elelmentdan 1-elementgacha bo'lgan elementlarni chop qiladi.
print(squares[0:1])
[4]

4-elementgacha bo'lgan elementlarni chop qiladi.
print(squares[:4])
[4, 9, 16, 25]

4-elelmentdan oxirgi elementgacha bo'lgan elementlarni chop qiladi.
print(squares[4:])
[36, 49, 64, 81]

2 qadam bilan ro'yxatni chop qiladi.Ro'yxatadgi har 2-elementni chop qiladi.
print(squares[::2])
[4, 16, 36, 64]

4-elelmentdan 6-elementgacha bo'lgan har 3-elementlarni chop qiladi.
print(squares[2:6:3])
[16, 49]

Manfiy indeks ro'yxatning oxiridan boshlab hisoblash uchun xizmat qiladi.
1-elelmentdan 7-elementgacha bo'lgan elementlarni chop qiladi.
print(squares[1:-1])
[9, 16, 25, 36, 49, 64]

1-elelmentdan 5-elementgacha bo'lgan elementlarni chop qiladi.
print(squares[1:-3])
[9, 16, 25, 36]

Ro'yxat o'zgarmaydi.Ro'yxatni teskari tartibda chop qiladi.
print(squares[::-1])
[81, 64, 49, 36, 25, 16, 9, 4]

Ro'yxat o'zgaradi.Ro'yxatni teskari tartibda chop qiladi.
squares.reverse()
print(squares)
[81, 64, 49, 36, 25, 16, 9, 4]

@pythonuz

BY Python dasturlash maktabi


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/pythonuz/367

View MORE
Open in Telegram


Python dasturlash maktabi Telegram | DID YOU KNOW?

Date: |

Pinterest (PINS) Stock Sinks As Market Gains

Pinterest (PINS) closed at $71.75 in the latest trading session, marking a -0.18% move from the prior day. This change lagged the S&P 500's daily gain of 0.1%. Meanwhile, the Dow gained 0.9%, and the Nasdaq, a tech-heavy index, lost 0.59%. Heading into today, shares of the digital pinboard and shopping tool company had lost 17.41% over the past month, lagging the Computer and Technology sector's loss of 5.38% and the S&P 500's gain of 0.71% in that time. Investors will be hoping for strength from PINS as it approaches its next earnings release. The company is expected to report EPS of $0.07, up 170% from the prior-year quarter. Our most recent consensus estimate is calling for quarterly revenue of $467.87 million, up 72.05% from the year-ago period.

Telegram auto-delete message, expiring invites, and more

elegram is updating its messaging app with options for auto-deleting messages, expiring invite links, and new unlimited groups, the company shared in a blog post. Much like Signal, Telegram received a burst of new users in the confusion over WhatsApp’s privacy policy and now the company is adopting features that were already part of its competitors’ apps, features which offer more security and privacy. Auto-deleting messages were already possible in Telegram’s encrypted Secret Chats, but this new update for iOS and Android adds the option to make messages disappear in any kind of chat. Auto-delete can be enabled inside of chats, and set to delete either 24 hours or seven days after messages are sent. Auto-delete won’t remove every message though; if a message was sent before the feature was turned on, it’ll stick around. Telegram’s competitors have had similar features: WhatsApp introduced a feature in 2020 and Signal has had disappearing messages since at least 2016.

Python dasturlash maktabi from sg


Telegram Python dasturlash maktabi
FROM USA