-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexercise1.py
168 lines (134 loc) · 3.88 KB
/
exercise1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
##A program that does##
#num1=int(input('Enter a number: '))
#num2=int(input('Enter another number: '))
#num3=int(input('Enter another number: '))
#answer=num1+num2+num3
#print('The sum of the three numbers you entered is: ',answer)
#name = input('Enter your name: ')
#age = 78
#address = input('Enter your address: ')
#print('Hello',name,age,address)
#print('i am here')
#temp=eval(input('Enther temperature in Celsius: '))
#print('In Fahrenheit, that is', 9/5*temp+32)
#A program to show the percentage of numbers 2,3,4,...12# when a dice is rolled twice
# from random import randint
# prob=[2,3,4,5,6,7,8,9,10,11,12]
# freq=[0]*11
# for k in range(10000):
# a=randint(1,6)+randint(1,6)
# freq[prob.index(a)]=freq[prob.index(a)]+1
# print(freq)
# for j in range(len(freq)):
# p=freq[j]/10000
# print(f'the percentage is {p}')
# from random import randint, sample
# lottary =[k for k in range(1,11)]
# users = [randint(1,10) for k in range(6)]
# print(f'users: {users}')
# correct=False
# countCorrect=0
# for k in range(1000):
# drawings=sample(lottary,6)
# print(f'drawings: {drawings}')
# for m in range(len(drawings)):
# if drawings.count(drawings[m])==users.count(drawings[m]):
# correct=True
# else:
# correct=False
# break
# if correct ==True:
# countCorrect=k
# break
# print(f'average: {countCorrect}')
#Physics'
# print(list(range(3)))
# print(list('physics'))
# print(list(str(124)))
#enters months and displays days
# month = int(input('Enter a month: '))
# days =[31,28,31,30,31,30,31,31,30,31,30,31]
# print(days[month-1])
#using a dictionary
# month = int(input('Enter a month: '))
# days ={'January':31,'February':28,'March':31,'April'30,'May':31,'June':30,'July':31,'August':31,'September':30,'October':31,'November':30,'Decemebr':31}
# print(days[month-1])
#Creating a dictionary for a bunch of words in a sentence and display the largest
# s= 'I am a great man of the great father in this world'
# words =s.split( )
# frequency= { }
# for w in words:
# if w in frequency:
# frequency[w] = frequency[w]+1
# else:
# frequency[w] =1
# print(frequency)
# value = list(frequency.values())
# maxValue = max(value)
# for key in frequency:
# if frequency[key]==maxValue:
# print(key)
# from random import shuffle
# word =['Letter', 'amen', 'zero','physics']
# shuffle(word)
# for w in word:
# word = set(w)
# if len(w) != len(word):
# pass
# else:
# print(w)
# break
# from random import shuffle
# word =['Letter', 'amen', 'zero','physics']
# shuffle(word)
# for w in word:
# word = set(w)
# if len(w) == len(word):
# print(w)
# break
# from random import shuffle, sample
# word=['letter', 'amen', 'zero', 'physics', 'bring','question', 'high']
# shuffle(word)
# for each word
# count the letters
# if a letter -count >1
# the word has a repeated character
# else:
# the word has a unique character
# return word
# end
# for w in word:
# for c in w:
# if w.count(c) > 1:
# break
# else:
# print(w)
# break
# data =[[0]*5 for i in range (5)]
# from random import sample, shuffle
# # data2[0]=20
# i =0
# while i < 2:
# for j in range (len(data[i])):
# data[i][j] = 1
# i+= 1
# shuffle(data)
# print(data)
# def fullName(firstName, lastName):
# name=f'{firstName} {lastName}'
# return name
# firstName= input('Enter your first name ')
# lastName= input('Enter your last name ')
# personName =fullName(firstName, lastName)
# print(personName)
# def printItems(data):
# for items in data:
# print(items)
# words =['word', 'road', 'man', 'woman', 'boy', 'girl']
# printItems(words)
def average(*args):
value =sum(args)/len(args)
return value
if __name__=='__main__':
menNumber = average(1,2,4,5,7,9,11,23,24)
print(menNumber)