Hello i am writing a python program and i need some help. i need to get the even
ID: 3661819 • Letter: H
Question
Hello i am writing a python program and i need some help.
i need to get the even number from the list of 10 randomly generated number add them together then print the results i also need to do the same with the odd.
This is what i have thus far.
This is the output i am getting
Here are the integers in nums:
19 19 74 66 77 38 72 29 59 41
ODD 19 ODD 19 EVEN 74 EVEN 66 ODD 77 EVEN 38 EVEN 72 ODD 29 ODD 59 ODD 41
Process finished with exit code 0
i need to also format them this is what it is supposed to look like.
SAMPLE OUTPUT
Here are the integers in nums:
23 85 31 55 42 85 72 33 39 20
Even integers total to 134
Odd integers total to 351
List of integers was written to file.
End of program.
I also need help with this portion as well
This program should consider that the integers in angles.txt represent angles measured in degrees. The program should read angles.txt and generate a table showing the trigonometric ratios sine, cosine, and tangent of the angles. The ratios should be displayed in formatted columns accurate to 5 decimal places as shown in the sample output below. See the math module functions on page 219. See also the format function on pages 68-71.
SAMPLE OUTPUT
Angle Sine Cosine Tangent
20 0.34202 0.93969 0.36397
23 0.39073 0.92050 0.42447
31 0.51504 0.85717 0.60086
33 0.54464 0.83867 0.64941
39 0.62932 0.77715 0.80978
42 0.66913 0.74314 0.90040
55 0.81915 0.57358 1.42815
72 0.95106 0.30902 3.07768
85 0.99619 0.08716 11.43005
85 0.99619 0.08716 11.43005
End of program.
Explanation / Answer
For Even / Odd Sum
print "Enter your numbers"
arr = []
elem = int(raw_input("How many elements do you want to add?"))
for i in range(0, elem):
arr.append(int(raw_input("Enter next no :")))
print arr
even = []
odd = []
for i in range(len(arr)):
if (arr[i]%2==0):
even.append(arr[i])
else:
odd.append(arr[i])
print "This is your even List"
print even
print "This is your odd List"
print odd
evenSum=0
for i in range(len(even)):
evenSum=evenSum+even[i]
oddSum=0
for i in range(len(odd)):
oddSum=oddSum+odd[i]
print "Sum of Even values"
print evenSum
print "Sum of Odd values"
print oddSum
For the Trignometric Function mentioned, the pages specified are missing. Please update the pages here.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.