Week 7_Assignment - Adi S.

docx

School

Indiana University, Bloomington *

*We aren’t endorsed by this school

Course

S364

Subject

Computer Science

Date

Feb 20, 2024

Type

docx

Pages

5

Uploaded by EarlNightingale4120

Report
Name(s): Please insert your name(s) here Assignment Week 7 (Total Points: 40) 1. Conceptual Questions (10 point): These questions pertain to key concepts covered during the class. This will include a series of multiple choice, fill in the blank, short answer, and matching questions. These questions are tightly linked to the learning objectives of that week. Questions are also likely candidates for exams. 2. Hands-on Exercises (15 point): These questions relate to the hands-on activity(ies). These activities are related to the content covered in the chapter and give students hands-on experience, which is highly sought after by employers for the exciting entry-level positions in the industry . 3. Custom Code Implementation (15 point): These questions allow students to create their own code to achieve a particular task of their choosing. The problem specification must be clear, code commented, and the code must also include concepts that were covered that week. These questions are intended to get students to think creatively about the concepts covered in class and build something of use or of interest to them. 4. Student Feedback (ungraded): These questions allow each student to offer feedback to the instructor of there were particular areas which were difficult or needed additional explanation. Students may form groups of up to two for assignments. You may also choose to work alone. However, the number of questions and the questions themselves will not change if you choose to work alone or with someone. If you choose to work with someone, only one of you is required to submit the assignment with BOTH of your names on it. Both of you will receive the same score for the assignment. You may choose to work individually for certain assignments, and in groups for others. However, you are responsible for making these decisions and resolving any potential conflicts (e.g., free-riding) – neither I nor the TAs will intervene. No late assignments will be accepted. In this course, turnitin.com will be utilized. Turnitin is an automated system which instructors may use to quickly and easily compare each student's assignment with billions of web sites, as well as an enormous database of student papers that grows with each submission. After the assignment is processed, as instructor I receive a report from turnitin.com that states if and how another author’s work was used in the assignment. For a more detailed look at this process visit http://www.turnitin.com. Suggestion The document is tightly styled. After every question, there is space to respond to the question. Questions use the “question” style and the blank space between questions uses the “answer” style. Students should just start typing into the space provided for the answers and their answers will be distinct from the questions to facilitate grading. 1
Name(s): Please insert your name(s) here Week 5: File input and output (I/O) Conceptual Questions (10 point) Underline the correct answer (possible answers in Bold) for the following ... 1. A special character(s) used in files and strings to indicate the end of a line. newline (\n) ; text file; slash (\); escape character; input 2. A sequence of characters stored in permanent storage like a hard drive. newline; slash (\); escape character; input; text file 3. The name we use when referring to the file being updated or created by our program random access file; output file ; input file; read file; 4. The type of file that we read and write to using our program that can also be understood/viewed by humans. binary file; random access file; machine file; text file ; sequential file 5. The function we use as a first step to access an input file or output file read; write; create; open ; close; 6. The letter code we use to tell python we want to retrieve data from a file using “w”, “r” , “o”,”a” Please refer to these links for additional resources about the questions: 1. Textbook: Ch 7 - http://do1.dr-chuck.com/pythonlearn/EN_us/pythonlearn.pdf 2. Reading Files - https://www.w3schools.com/python/python_file_open.asp 3. Writing/Creating File - https://www.w3schools.com/python/python_file_write.asp 4. Deleting Files - https://www.w3schools.com/python/python_file_remove.asp 1
Name(s): Please insert your name(s) here Hands-on Exercises (15 point) Hands on Exercise prompt Exercise 1: Write a program to read through a file and print the contents of the file (line by line) all in upper case. Only print lines that include an E-mail (hint: search for “@” symbol) Please include a screen shot of a portion of your OUTPUT along with your Python code. Below is an example of what the screen/output should look like where the yellow highlight depicts the user input and the rest is displayed or created by your program. python shout.py Enter a file name: mbox-short.txt FROM STEPHEN.MARQUARD@UCT.AC.ZA SAT JAN 5 09:14:16 2008 RETURN-PATH: <POSTMASTER@COLLAB.SAKAIPROJECT.ORG> MESSAGE-ID: <200801051412.M05ECIAH010327@NAKAMURA.UITS.IUPUI.EDU> FOR <SOURCE@COLLAB.SAKAIPROJECT.ORG>; FOR <SOURCE@COLLAB.SAKAIPROJECT.ORG>; SAT,5 JAN 2008 14:13:33 +0000 (GMT) Please refer to these links for additional resources about the questions: 1. Textbook: Ch 7 - http://do1.dr-chuck.com/pythonlearn/EN_us/pythonlearn.pdf 2. Reading Files - https://www.w3schools.com/python/python_file_open.asp 3. Writing/Creating File - https://www.w3schools.com/python/python_file_write.asp 4. Deleting Files - https://www.w3schools.com/python/python_file_remove.asp Custom Code Implementations (15 point) Please devise a custom script that includes the following functions or concepts: File input and output (I/O) . Please also answer the questions below concisely and precisely. What is the value or problem you are trying to solve? Open the text file: mbox-short.txt. Count the number of emails received in the file by referring to lines that only 2
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Name(s): Please insert your name(s) here What is the expected output of your program? A specific number of emails received in the mbox-short.txt file. What is the value of your program? The value of the program is to open and read through a file that then counts a specific number that is valuable to the company that is trying to get that information. Please paste a screenshot of sample outputs of your program below. Student Feedback (No Points; Ungraded) On a scale of 1 – 10 how difficult (1 being very easy and 10 being extremely difficult) was this assignment for you? 6 How long did this assignment take you to complete? 45 minutes Was there anything else I could have done to better help you complete this assignment? More clarification on the exercise portion. Please provide three short bullet points of what new items you learned from this assignment. - How to open and sift through a file using try and except - How to read through a file for a specific phrase - How to write to a new file by using open Please list any additional feedback you have about this assignment. 3
Name(s): Please insert your name(s) here I would like more clarification during the exercise portion on what to do if the user were to input an incorrect file name that is not found. 4