Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PYTHON PROGRAMMING HELP!! ASSIGNMENT AND MY CODE IS POSTED PLEASE HELP ME CORREC

ID: 3808769 • Letter: P

Question

PYTHON PROGRAMMING HELP!! ASSIGNMENT AND MY CODE IS POSTED PLEASE HELP ME CORRECT CODE SO IT RUNS! THANKS

Write a program in Python with loops that computes: a) The sum of all even numbers between 0 and 10 (inclusive) b) All powers of 2 from 20 up to 2 c) The factorial of all numbers between 1 and 10 (inclusive) Show the results on the screen For the coding, use: camel or Hungarian notation in-program comments logic accuracy efficiency Remark: you can't use any Math built-in function. (3 points). (3 points) (3 points).

Explanation / Answer

I have written my code:

def SumOfEvenNumbers():
sum = 0
i = 0
for i in range(0,11):
if i % 2 == 0:
sum = sum + i
print "sum of even numbers is = ",sum

def TwoPowers():
i = 0
value = 1
for i in range(0,17):
value = value * 2
if value == 0:
value = 1
print "2^0 = ",value
print "2^",i," = ",value
  
def Factorial():
i = 0
fact = 1
k = 1
for i in range(1,11):
if i == 1:
print i, "! = " , k
else:
n = 1
while n <= i:
fact = fact * n
n = n + 1
print i, "! = " , fact
fact = 1
  
SumOfEvenNumbers()
TwoPowers()
Factorial()

output:

sum of even numbers is = 30
2^ 0 = 2
2^ 1 = 4
2^ 2 = 8
2^ 3 = 16
2^ 4 = 32
2^ 5 = 64
2^ 6 = 128
2^ 7 = 256
2^ 8 = 512
2^ 9 = 1024
2^ 10 = 2048
2^ 11 = 4096
2^ 12 = 8192
2^ 13 = 16384
2^ 14 = 32768
2^ 15 = 65536
2^ 16 = 131072
1 ! = 1
2 ! = 2
3 ! = 6
4 ! = 24
5 ! = 120
6 ! = 720
7 ! = 5040
8 ! = 40320
9 ! = 362880
10 ! = 3628800
>>>