Question: in python 1. The following lines of code read numbers from the user and compute their average. Sort the lines into a working python script.

in python

1. The following lines of code read numbers from the user and compute their average. Sort the lines into a working python script. Ignore tabbing, only the order matters.

for i in range(0,5):

X=[]

print("Result is",sum(X)/len(X))

X.append(int(input("Enter Value: ")))

2.Fill in the blanks to complete the output of the below Python program.

def secret(n): p = 1 i = 0 while p <= n: print("p=",p) print("i=",i) p=p*2 i=i+1 r=i-1 print("r=",r) return r secret(10)

Complete the below output

Complete the below output

p= i= p= i= p= i= p= i= r=

3.What Data Type is returned by the input command?

String

Integer

Float

Audio File

4.

Match the loop with the description of what it computes.

x=0

for a in L:

x+=a

print("Answer:",x)

i=0

a=L[0]

while i < len(L):

if a <= L[i]:

a=L[i]

i+=1

print("Answer:",a)

q=L[0]

for m in L:

if m < q:

q=L[i]

print("Answer:",q)

i=0

q=0

while i < len(L):

q=q+L[i]/len(L)

i+=1

print("Answer:",q)

A.

The minimum element in the list L

B.

The sum of elements in the list L.

C.

The maximum of elements in the list L.

D.

The average of all element in the list L.

5.

The lines of code for the following function are out of order. Put the code in the correct order. Ignore tabbing.

The below comments explain how the function should work.

# This function computes the GCD. # The GCD(a,b) is the largest number # that divides both a and b evenly # Mathematically, it is defined below. # gcd(a,0)=a# gcd(a,b)=gcd(b,a%b) # for example gcd(30, 20) = 10 since 30/10=3 and 20/10=2

return a

b=y

a=b

def gcd(a,b):

while b > 0:

x = a // b

y = a-x*b

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!