here, we are implementing apython program for various list operations, following operations are being performed in the list,
在這裡,我們正在為各種列表操作實現python程式,正在列表中執行以下操作,
declaring an integer list
宣告乙個整數列表
printing the complete list
列印完整列表
printing the first element of the list
列印列表的第乙個元素
printing ith element of the list
列印列表的第i個元素
printing elements within the given indexes
在給定索引中列印元素
printing a specific element using negative indexing
使用負索引列印特定元素
將元素追加到列表
finding the index of a specific element in the list
在列表中查詢特定元素的索引
sorting the list elements
排序列表元素
popping an element from the list
從列表中彈出乙個元素
removing specified element from the list
從列表中刪除指定的元素
inserting an element at specified index
在指定索引處插入元素
extending the list i.e. insert set of element (list) in the list
擴充套件列表,即在列表中插入一組元素(列表)
reversing list elements
反轉列表元素
# python code for various list operation
# declaring a list of integers
ilist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
# list slicing operations
# printing the complete list
print('ilist: ',ilist)
# printing first element
print('first element: ',ilist[0])
# printing fourth element
print('fourth element: ',ilist[3])
# printing list elements from 0th index to 4th index
print('ilist elements from 0 to 4 index:',ilist[0: 5])
# printing list -7th or 3rd element from the list
print('3rd or -7th element:',ilist[-7])
# finding index of a specified element
print('index of \'80\': ',ilist.index(80))
# sorting the elements of ilist
ilist.sort()
print('after sorting: ', ilist);
# popping an element
print('popped elements is: ',ilist.pop())
print('after pop(): ', ilist);
# removing specified element
ilist.remove(80)
print('after removing \'80\': ',ilist)
# inserting an element at specified index
# inserting 100 at 2nd index
ilist.insert(2, 100)
print('after insert: ', ilist)
# counting occurances of a specified element
print('number of occurences of \'100\': ', ilist.count(100))
# extending elements i.e. inserting a list to the list
ilist.extend([11, 22, 33])
print('after extending:', ilist)
#reversing the list
ilist.reverse()
print('after reversing:', ilist)
output
輸出量
ilist: [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
first element: 10
fourth element: 40
ilist elements from 0 to 4 index: [10, 20, 30, 40, 50]
3rd or -7th element: 40
index of '80': 7
after sorting: [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 111]
popped elements is: 111
after pop(): [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
after removing '80': [10, 20, 30, 40, 50, 60, 70, 90, 100]
after insert: [10, 20, 100, 30, 40, 50, 60, 70, 90, 100]
number of occurences of '100': 2
after extending: [10, 20, 100, 30, 40, 50, 60, 70, 90, 100, 11, 22, 33]
after reversing: [33, 22, 11, 100, 90, 70, 60, 50, 40, 30, 100, 20, 10]
翻譯自:
帶有ECC的非同步SRAM儲存器適用於各種應用
賽普拉斯憑藉可服務於各種高可靠性工業,通訊,資料處理,醫療,消費和軍事應用的效能,快速sram器件可提供片上ecc。這些器件具有與老一代非同步sram相容的外形匹配功能。這使您無需投資pcb重新設計即可提高系統可靠性。帶有ecc的非同步sram適用於各種要求最高可靠性和效能標準的工業,醫療,商業,汽...
適用於python的 vimrc檔案
根據我的需求做了一些小的改動。file vimrc date 2009 09 22 author gashero note 配置乙份簡單的vim配置檔案 set nocompatible 非相容模式 syntax on 開啟語法高亮 set background dark 背景色 color des...
git 操作規範 (適用於公司團隊協作)
1 在公司的協作中git的操作都是很重要的,git 提交分為以下幾個步驟 首先建立向總專案提交需要建立自己的bug id號 git status檢視修改過操作過的檔案 git add 新增對應的檔案 在git status檢視新增本地倉庫是否成功 git stash 你想要切換分支但是你不想變更自己...