IT 210 210
Minnesota State University, Mankato
Popular in Fundamentals of Programming
Popular in Information technology
This 2 page Class Notes was uploaded by Ahmed Notetaker on Thursday September 22, 2016. The Class Notes belongs to 210 at Minnesota State University - Mankato taught by Salivia, Guarionex in Fall 2016. Since its upload, it has received 6 views. For similar materials see Fundamentals of Programming in Information technology at Minnesota State University - Mankato.
Reviews for IT 210
Report this Material
What is Karma?
Karma is the currency of StudySoup.
You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!
Date Created: 09/22/16
WEEK 4 (MONDAY) IT 210 # Practice making functions #import math from math import * # imports everything from the module # without the need to call the module by name def circumference(radius:float): c = 2 * pi * radius return c def areaCircle(radius:float): a = pi * pow(radius, 2) # radius ** 2 return a # Archimedes approximation of Pi def archimedesPi(n:int): angle = radians(360 / (2*n)) pie = n * sin(angle) return pie #result = archimedesPi(100) #print(result) #HOW GOOD IS ACHIMEDES APPROXIMATION OF PI? # numOfSides = 10000000 # for i in range(3, numOfSides + 1): # sub = abs(archimedesPi(i) pi) # positive difference # print(sub) # Accumulators # Accumulates the the sum of numbers from 15 acc = 0 for x in range(1, 6): acc += x print(acc) # Sum of numbers between 0200 x = 0 for i in range(201): x += i print(x) # Sum of odd numbers between 1100 x = 0 for i in range(1, 101, 2): x += i print(x) # Sum of the first 100 evens x = 0 num = 201 for i in range(0, num, 2): x += i print(x) # Average of numbers from n to m def average(n, m): acc = 0 avg = 0 for i in range(n, m+1): acc += i if(n != m): avg = acc / abs(n m) return avg a = average(20, 20) print(a) # Factorial def factorial(n): acc = 1 for i in range(1, n+1): acc *= i return acc f = factorial(100) print(f)
Are you sure you want to buy this material for
You're already Subscribed!
Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'