Advertisement
xavicano

Untitled

Aug 15th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. from random import randint
  2.  
  3. def count(target,scores):
  4.     counter = 0    # Initialise a variable for counting scores of ten
  5.  
  6.     for score in scores:
  7.       if score == target:
  8.           counter += 1
  9.      
  10.     #print("{0} learners got top marks".format(counter))
  11.     return counter
  12.  
  13. scores = []
  14. text="Hello mates how are you doing this agoust"
  15. itemlist=['FCB','MC','MU','TOT','ATM', 'FCB', 'MUN']
  16.  
  17. for x in range (0, 30):
  18.   scores.append(randint(0, 10))    # Generate a random number from 0 to 10 and append to scores
  19.  
  20. print(scores)
  21. print(" Num of 10",count(10,scores))
  22.  
  23. print (text)
  24. print(" Num of a",count('a',text))
  25.  
  26. print (itemlist)
  27. print(" Num of FCB",count('FCB',itemlist))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement