mardi 3 septembre 2019

Check if number is even or odd, add to var and print it / Python [on hold]

I am learning how to program and this is one of my tasks: I have 2 teams of players and I need to:

  1. Read integer that is number of teams
  2. weigh each player in the team
  3. compare total weight
  4. print out the values

I am guaranteed that teams will:

  1. Not have the same total weight

and:

I also know that first measured weight is going to be player from team 1, second measured weight will be player from team2, third measured weight is going to be again player from team 1 etc.

 #acquiring information
NbMembersTeam=int(input())
kilograms=int(input())

#initiating totals of kg's to 0
total1=0
total2=0

#checking if the player is team1 or team2 and adding values
for NbMembersTeam in range(NbMembersTeam):
  if (NbMembersTeam % 2) == 0:
    total2=kilograms
  else:
    total1=kilograms

if total1>total2:
  print("blblblba")
  print("total 1 : %d" (total1))
  print("total 2 : %d" (total2))

I am really on the basic here so for now we only started to use for loop in rage and if, else if..

Thank you

Aucun commentaire:

Enregistrer un commentaire