-



Download 9,79 Mb.
Pdf ko'rish
bet38/64
Sana16.01.2022
Hajmi9,79 Mb.
#372467
1   ...   34   35   36   37   38   39   40   41   ...   64
Bog'liq
[Nichola Lacey] Python by Example Learning to Pro(1)

from array import * 
This needs to be the first line of your program so that 
Python can use the array library. 
nums = array (‘i',[45,324,654,45,264]) 
print(nums) 
Creates an array called “nums”. It uses the integer data type and has five items in the 
array. It will display the following as the output:  
array('i', [45, 324, 654, 45, 264])
 
nums = sorted(nums) 
Sorts the array into 
ascending order. 
newValue = int(input(“Enter number: “)) 
nums.append(newValue) 
Asks the user to enter a new number which it will add to 
the end of the existing array. 
newArray = array(‘i’,[]) 
more = int(input(“How many items: ”)) 
for y in range(0,more): 
 newValue=int(input(“Enter num: ”)) 
 newArray.append(newValue) 
nums.extend(newArray) 
Creates a blank array called “newArray” which uses the 
integer data type. It asks the user how many items they 
want to add and then appends these new items to 
newArray. After all the items have been added it will join 
together the contents of newArray and the nums array. 

Download 9,79 Mb.

Do'stlaringiz bilan baham:
1   ...   34   35   36   37   38   39   40   41   ...   64




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

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish