In this Python 3.4 assignment, we want to do some preliminary data mining of the
ID: 663367 • Letter: I
Question
In this Python 3.4 assignment, we want to do some preliminary data mining of the prices of a variety of stocks, each is in a separate file. Your program will calculate the monthly average prices of the specified stock from the file (the file has one year of data). You will report facts about the monthly highs and lows for this data.
Specifications
1. A set of files of daily stock prices will be provided: Apple (APPL.txt), Google (GOOG.txt), Intel (INTC.txt), and Microsoft (MSFT.txt). You can examine these files by opening them in notepad, textedit or similar text editors. Data in each file is delimited by commas. (If you import a file into Excel, it will show you the data as a spreadsheet.) Note that each file has a header line describing the data in the file: values:Date,close,high,low,open,volume
2. You must implement the following functions:
a) get_input_descriptor()
In this function, you are required to repeatedly prompt for the name of an input file until the user enters a filename and the file is successfully opened for input. Return the file descriptor attached to the opened file. That is, if fp=open(
Explanation / Answer
# Python program to check if the input number is prime or not # take input from the user num = int(input("Enter a number: ")) # prime numbers are greater than 1 if num > 1: # check for factors for i in range(2,num): if (num % i) == 0: print(num,"is not a prime number") print(i,"times",num//i,"is",num) break else: print(num,"is a prime number") # if input number is less than # or equal to 1, it is not prime else: print(num,"is not a prime number")