حالت آفلاین — محتوا از حافظهٔ کش نمایش داده می‌شود

محاسبه امتیاز تیم فوتبال

تمرین آسان 3189 visibility link download flag

جمع امتیازات یک تیم که در مسابقات لیگ برتر فوتبال کسب کرده در ورودی به شما داده می شود و شما جمع امتیازات تیم به همراه تعداد بردهای این تیم در این فصل را در خروجی چاپ می کنید.

این تیم، ۱۵ بازی انجام میدهد پس در ۱۵ خط امتیازات این تیم به شما داده می شود. به ازای هر بازی تیم یا صفر امتیاز کسب کرده یا یک و یا سه امتیاز. این تیم در صورت باخت صفر امتیاز، در صورت تساوی یک امتیاز و در صورت برد سه امتیاز کسب می کند.

ورودی نمونه:

3 3
3 3
3 0
0 0
0 0
1 1
1 1
1 3
3 3
3 3
0 0
0 0
0 1
1 1
1 1

reply 15

visibility
score = 0
number_of_game = 0
count_wins = 0
count_loss = 0
count_equal = 0

for x in range(1, 16):
    print ('-' * 11)
    number_of_game = number_of_game + 1

    my_team = int(input(f'''game {number_of_game} -> number of goal my team? '''))
    opponent_team = int(input('number of goal opponent team? '))

    if my_team > opponent_team:
        score = score + 3
        count_wins = count_wins + 1
    elif my_team < opponent_team:
        count_loss = count_loss + 1
    else:
        score = score + 1
        count_equal = count_equal + 1

print (f'''total points of my team -> {score}''')
print (f'''total wins my taem -> {count_wins}''')
print (f'''total loss of my team -> {count_loss}''')
print (f'''total equal of my team -> {count_equal}''')
print (f'''tatal all game of my team -> {(count_wins + count_loss + count_equal)}''')

score = input('Enter scores of team : ')
def calculate(score) :
    global sum_score
    sum_score = 0
    global win 
    win = 0
    res = False
    for i in score :
        try : 
            i = int(i)
            sum_score += i
            if i == 3 :
                win += 1
            res = True
        except:
            print('Please enter digit !')
            res = False
            break
    return res

if calculate(score):
    print(f'sum of score : {sum_score} and count wins : {win}')

points = []
for i in range(15):
    score = int(input("Enter the point(0,1,3):"))
    points.append(score)
total_points = sum(points)
wins = points.count(3)
print()
print("Total team points:", total_points)
print("The number of team wins:", wins)
from random import *
sum = 0
for i in range(1,16):
    golus = randint(0,3)
    golthey = randint(0,3)

    if golus == golthey:
        point = 1
        sum += point
    elif golus < golthey:
        point = 0
    else:
        point = 3
        sum += point

    print(golus,"_", golthey , "point=",point) \
print("sum points =",sum)

points = []
for _ in range(15):
    points.append(int(input().strip()))

total_points = sum(points)
wins = points.count(3)

print(total_points, wins)
پاسخ هوش مصنوعی Ai Python
team1=[3,3,3,0,0,1,1,1,3,3,0,0,0,1,1]
team2=[3,3,0,0,0,1,1,3,3,3,0,0,1,1,1]                    
victory_team1=0
victory_team2=0
def victory(a,b):
    global victory_team2,victory_team1
    for tem1,tem2 in zip(a,b):
        if tem1 == 3:
            victory_team1+=1
        if tem2 == 3:
            victory_team2+=1
victory(team1,team2)

print(f"team score1: {sum(team1)}")
print(f"team victories1: {victory_team1}")
print("----------------------")
print(f"team score2: {sum(team2)}")
print(f"team victories2: {victory_team2}")
team1 = [3,3,3,0,0,1,1,1,3,3,0,0,0,1,1]
team2 = [3,3,0,0,0,1,1,3,3,3,0,0,1,1,1]

def football(x):
    sum = 0
    count = 0

    for i in x:
        sum += i
        if i == 3:
            count += 1

    print("Total points = ",sum)
    print("Number of wins = ",count)

football(team1)
football(team2)
v,n,b=0,0,0
for i in range(15):
   x = int(input("enter :"))
   if(x==3)or(x==1)or(x==0):
     v = v + x
     if(x==3):
         b=b+1
   else:
       print("eruor")
       n=1
       break
if(n==0):
  print(b)
  print(v)
def calculate_team1_points():    
    sum = 0
    for i in range(15):
        team1_and_2 = input(f"Enter goals for game {i + 1} (format: team1 team2): ")
        team1_and_2 = team1_and_2.replace(" ","")
        team1 = team1_and_2[0]
        team2 = team1_and_2[1]
        if int(team1) > int(team2):
            sum += 3
        elif int(team1) == int(team2):
            sum += 1
        print(f"After game {i + 1}, total points for team1 : {sum}")
    return sum

total_points = calculate_team1_points()
print(f"Total points for team1 : {total_points}")
<< صفحه قبل 1 2 صفحه بعد >>

ارسال جواب

جوابت را با Markdown بنویس و ثبت کن

×
بستن