0% found this document useful (0 votes)
14 views7 pages

Struktury Danych

The document contains examples of using lists and other collection types in Python. It demonstrates creating, accessing, modifying, sorting and iterating over lists using various techniques like for loops, range, append and more.

Uploaded by

ktak7302
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views7 pages

Struktury Danych

The document contains examples of using lists and other collection types in Python. It demonstrates creating, accessing, modifying, sorting and iterating over lists using various techniques like for loops, range, append and more.

Uploaded by

ktak7302
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

list = [input[0], input[1], input[2]]

print(list)

list = ['dog', "cat", "hamster"]

print(list)

listA = [1, 2, 3]
listB = [4, 5, 6]
listC = [7, 8, 9]

print(listA)
print(listB)
print(listC)

list = [input[0], input[1], input[2], input[3], input[4]]

print(list)

list = []

list.append(input[0])
list.append(input[1])
list.append(input[2])

print(list)
list = []

for i in input:
list.append(i)

print(list)

list = []

for i in input:
if(i % 2 == a):
list.append(i)

print(list)

list = []

for i in input:
for j in i.split():
list.append(int(j))

print(list)

list = range(1, 51)

print(list)

for i in input:
list = range(int(i.split()[0]), int(i.split()[1]) + 1)
print(list)
for i in input:
list = range(int(i.split()[0]), int(i.split()[2]) + 1, int(i.split()[1]) - int(i.split()[0]))
print(list)

start = 0
list = []

for i in range(0, len(input)):


if len(input[i].split()) == 2:
start = i
break
else:
list.append(input[i])

for i in range(start, len(input)):


list.insert(int(input[i].split()[1]), input[i].split()[0])

print(list)

minIndex, maxIndex = 0, 0

for i in range(0, len(input)):


if len(input[i]) <= len(input[minIndex]):
minIndex = i
elif len(input[i]) >= len(input[maxIndex]):
maxIndex = i

if minIndex < maxIndex:


del(input[minIndex:maxIndex + 1])
else:
del(input[maxIndex:maxIndex + 1])

for i in input:
print(i)
list = []

for i in input:
list.append(i)

print(list)

min, max = list[0], list[0]

for i in range(0, len(list)):


if list[i] < min:
min = list[i]
elif list[i] > max:
max = list[i]

list.remove(min)
list.remove(max)

print(list)

list = []

for i in input:
list.extend(i.split())

print(list)

list = []

for i in input:
start, end = int(i.split()[0]), int(i.split()[1]) + 1
list.extend(range(start, end))

print(list)
list = []

for i in input:
list.append(int(i))

list.sort(reverse = True)

for i in list:
print(i)

list = []

for i in input:
list.append(i)

list.sort()

for i in list:
print(i)

for i in range(0, len(input)):


print(str(input[i]) + '\t' + str(sorted(input, reverse = True)[i]))

for i in reversed(input):
print(i)

tuple = (1, "one", 1.0)

print(tuple)
for i in input:
list = []

for j in i.split():
list.append(int(j))

tuple_ = tuple(list)
print(tuple_)

to poniżej to 23 (nie działa) może lepiej nie przepisywać


for i in input:
list = i.split()
left, right = [], []

for i in list:
if i |= "|":
left.append(int(i))
else:
break

for i in reversed(list):
if i |= "|":
right.append(int(i))
else:
break
right.reverse()

if left > right:


print("Left")
elif right > left:
print("Right")
else:
print("Same")

print(list(enumerate(input)))
print(list(enumerate(sorted(input))))

26 też nie działa


words = ["rabbit", "hamster", "frog"]

for index, word in enumerate(words):


print(str(index) + " - " + word)

for i, number in enumerate(input):


if i % 2:
print(number)

for i, product in enumerate(sorted(input)):


print(str(i + 1) +") " + product)

You might also like