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

In python: 1. Goal: write an algorithm that calculates the average of a sequence

ID: 3664099 • Letter: I

Question

In python:

1. Goal: write an algorithm that calculates the average of a sequence of numbers.

Inputs: Assume that you start with a variable called "list_of_numbers" that contains all numbers in a sequence to be averaged.

Output: A floating point number representing the average of list_of_numbers.

2.

Goal: write an algorithm that determines whether or not the supplied number is either an integer (whole number) or a floating point number (decimal number).   
Input: Assume that you start with a variable called "user_input" that contains the input to be verified.
Output: Whether user_input is an integer or floating point number

Explanation / Answer

Answer for Question 1 :

This below Python algorthim will calculate the Avarege of List of Numbers from the keyboard and dispaly the result..

count = 0
list_of_numbers = 0
ask = raw_input("Do you want to enter a number? (Y/N)")
try:
while ask == "Y":
numbers = float(raw_input("Enter number"))
count = count + 1
list_of_numbers = list_of_numbers + numbers
con_ask = raw_input("Do you want to continue entering a number? (Y/N)")
if con_ask == "Y":
continue
elif con_ask == "N":
print "The average of", count, "numbers is", list_of_numbers / count
break
except:
print "Zero Division Occured. Average cannot be calculated"
  
  
Answer for Question 2 :

this below Python algorthim will determine the entered number is float or int See the below python code

inNumber = raw_input("Enter Number ")
inNumberint = int(inNumber)
if inNumber == inNumberint:
print "this number is an int"
else:
print "this number is a float"
  
  

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote