Question

Python correct this program to right format, so i can copy it thank you! #function to...

Python correct this program to right format, so i can copy it thank you!

#function to check alphabetical order

def isGreater(name1,name2):

length=0

if(len(name1)<len(name2)):

length=len(name1)

else:

length=len(name2)

for i in range(0,length):

if(ord(name1[i])>ord(name2[i])):

return True

elif (ord(name1[i])<ord(name2[i])):

return False

return False

def scoresData():

data=[]

while True:

player=input("Enter the Name and Score of a Player :: ")

if(player==''):

break

data.append(player.split());

print("----------------------------------")

print("\tEntered Order::\nPlayer Name \t Score")

print("----------------------------------")

for player in data:

print(player[0],"\t\t",player[1])

print()

for i in range(0,len(data)+1):

for j in range(0,len(data)-i-1):

if(isGreater(data[j][0],data[j+1][0])):

temp=data[j]

data[j]=data[j+1]

data[j+1]=temp

print("----------------------------------")

print("\tAplhabetical Order::\nPlayer Name \t Score")

print("----------------------------------")

for y in data:

print(y[0],"\t\t",y[1])

print()

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

for j in range(0,len(data)-1):

if(int(data[j][1])<int(data[j+1][1])):

temp=data[j]

data[j]=data[j+1]

data[j+1]=temp

print("----------------------------------")

print("\tScore Order::\nPlayer Name \t Score")

print("----------------------------------")

tot=0

for x in data:

print(x[0],"\t\t",x[1])

tot=tot+int(x[1])

print()

print("Congratulations! Mr/Ms."+data[0][0]," You scored highest of ",data[0][1],".")

print("Oh! Mr/Ms."+data[-1][0]," Sorry to say that scored minimum of ",data[-1][1],".")

print("Average of scores \t:: ",int(tot/len(data)))

scoresData()

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#function to check alphabetical order

def isGreater(name1,name2):
    length=0

    if(len(name1)<len(name2)):
        length=len(name1)
    else:
        length=len(name2)

    for i in range(0,length):
        if(ord(name1[i])>ord(name2[i])):
            return True

        elif (ord(name1[i])<ord(name2[i])):
            return False

    return False

def scoresData():
    data=[]
    while True:
        player=input("Enter the Name and Score of a Player :: ")
        if(player==''):
            break
        data.append(player.split());
    print("----------------------------------")
    print("\tEntered Order::\nPlayer Name \t Score")
    print("----------------------------------")

    for player in data:

        print(player[0],"\t\t",player[1])
        print()
    for i in range(0,len(data)+1):
        for j in range(0,len(data)-i-1):
            if(isGreater(data[j][0],data[j+1][0])):
                temp=data[j]
                data[j]=data[j+1]
                data[j+1]=temp
    print("----------------------------------")

    print("\tAplhabetical Order::\nPlayer Name \t Score")

    print("----------------------------------")

    for y in data:
        print(y[0],"\t\t",y[1])
        print()

    for i in range(0,len(data)+1):
        for j in range(0,len(data)-i-1):
            if(int(data[j][1])<int(data[j+1][1])):
                temp=data[j]
                data[j]=data[j+1]
                data[j+1]=temp

    print("----------------------------------")

    print("\tScore Order::\nPlayer Name \t Score")

    print("----------------------------------")

    tot=0

    for x in data:
        print(x[0],"\t\t",x[1])

    tot=tot+int(x[1])

    print()

    print("Congratulations! Mr/Ms."+data[0][0]," You scored highest of ",data[0][1],".")

    print("Oh! Mr/Ms."+data[-1][0]," Sorry to say that scored minimum of ",data[-1][1],".")

    print("Average of scores \t:: ",int(tot/len(data)))

scoresData()
Add a comment
Know the answer?
Add Answer to:
Python correct this program to right format, so i can copy it thank you! #function to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT