Μπάμπης Μπουλής
Master of Science in Computer Engineering
Θέμα-Δ Απάντηση (25 μονάδες)
# – – – – – – ερώτημα Δ6 – – – – – – – – – – – – – – – – –
def taxinomisi(a,b):
—-n=len(b)
—-for i in range(1,n):
——–for j in range(n-1, i-1, -1):
—-——–if (b[j]>b[j-1]) or (b[j]==b[j-1] and a[j]<a[j-1]):
—-—-——–b[j],b[j-1]=b[j-1],b[j]
—-—-——–a[j],a[j-1]=a[j-1],a[j]
# – – – – – – ερώτημα Δ1 – – – – – – – – – – – – – – – – –
on=[]
vath=[]
n=50
f=open(“students.txt”,“r”)
for line in f:
—-on.append(line)
f.close()
# – – – – – – ερώτημα Δ2 – – – – – – – – – – – – – – – – –
for i in range(0,n):
—v=input(“Δώσε βαθμό 0-20: “)
—while v<0 or v>20:
——v=input(“Δώσε βαθμό 0-20: “)
—vath.append(v)
# – – – – – – ερώτημα Δ3 – – – – – – – – – – – – – – – – –
elax=vath[0]
for i in range(1,n):
—-if vath[i] < elax:
——–elax=vath[i]
for i in range(0,n):
—-if vath[i] == elax:
——–print on[i]
# – – – – – – ερώτημα Δ4 – – – – – – – – – – – – – – – – –
onoma=raw_input(“Δώσε όνομα: “)
found=False
for i in range(0,n,1):
—-if on[i] == onoma:
——–found=True
——–print vath[i]
if not found:
print “Το όνομα δεν βρέθηκε”
# – – – – – – – – – – ερώτημα Δ5 – – – – – – – – – – – – –
taxinomisi(on,vath)
for i in range(0,6,1):
—-print vath[i], on[i]