Keeping Records: The American Pastime
|
|
- Melanie Richards
- 5 years ago
- Views:
Transcription
1 Keeping Records: The American Pastime This exercise focuses on the modular design, implementation and testing of Python programs to process data files using lists and tuples. You and a partner will implement a Python program to manage information about baseball players. You will implement it in accordance with a modular design outlined in this exercise and in documentation in a starter program that we provide. Overview 1. The program will create and manipulate a dataset containing the following information for each player: player s name (string) team identifier (string) games played (integer) at bats (integer) runs scored (integer) hits (integer) home runs (integer) batting average (real) The first seven items will be read from a data file; the program will compute the last item using the following formula: batting average = (hits) / (at bats). A player with zero at bats is defined to have a batting average of zero. The program will represent the information for a player as a tuple, and the dataset as a list of tuples. 2. The program will recognize the following commands, where the first word in each is a keyword and the second word, if any, denotes information required to execute the command: QUIT HELP INPUT filename TEAM identifier HOMERS n The program will recognize commands entered with any mix of upper and lower case letters. The program will be operated interactively: it will repeatedly prompt the user for a command and then execute the command entered by the user from the keyboard. If the user enters an invalid command, the program will display an appropriate message and prompt the user to enter another command. 3. The QUIT command will halt execution.
2 4. The HELP command will display information to the user about the commands recognized by the program. 5. The INPUT command will contain a string indicating the name of an input file. The program will read the file to create a data set consisting of a list of tuples, where each tuple contains the information for one player. This will become the current dataset for future commands until the user indicates a new input file (by entering another INPUT command). An input file contains zero or more lines. A line that starts with a # is a comment line; your program will skip over comment lines. A correctly formatted non-comment line consists of the first seven items listed in 1 and separated by semicolons. For example: Cabrera, Miguel; DET; 148; 555; 103; 193; 44 If the user enters an invalid file name, the program will display an appropriate message and prompt the user to enter another command. If a non-comment line is improperly formatted, your program will display an informative error message, ignore the data in the line, and continue processing the rest of the file. 6. The TEAM command will contain a string representing a team identifier. The program will display all information about all players on that team, in alphabetical order. The player information will be displayed in tabular form. The fields will be identified using column headers and aligned beneath the headers. The program will print just the first 15 characters of any name longer than 15 characters. It will display real values with three digits of precision following the decimal point. (But save worrying about formatting for after you have finished implementing the program logic.) If the user enters an invalid team identifier, the program will display an appropriate message and prompt the user to enter another command; the program will not display an empty table. 7. The HOMERS command will be followed by a positive integer n. The program will report all information about the top n home-run hitters or, if n is larger than the number of players in the dataset, about all players. The report will be sorted in descending home-run order, starting with the player with the most home runs. Players with the same number of home runs will be displayed in alphabetical order. The information will be displayed in tabular form as in 6. If the user does not enter a positive integer for n, the program will display an error message and prompt the user to enter another command. If the player data set is empty, the program will display an error message and prompt the user to enter another command; it will not display an empty table. 8. If the user enters an invalid command, the program will display an appropriate message and prompt the user to enter another command; the program will not display an empty report.
3 9. You may not use any global variables in your program. All communication between the functions will be done using arguments, return values, and the constants defined at the beginning of the program. Get Ready: Download the following files into the same working directory: mlb.py a Python program containing some constant definitions and function stubs, which you will implement and use in your solution. mlb.2013.txt a sample input file containing information about players on the teams in Major League Baseball (MLB) in mlb.test.txt a smaller file containing information about some players and also containing some incorrectly formatted lines; this file will be useful for initial development and testing. The first 8 lines of that file are: # small data file to use in testing De Aza, Alejandro; CWS; 153; 607; 84; 160; 17 Hunter, Torii; DET; 144; 606; 90; 184; 17 Hamilton, Josh; LAA; 151; 576; 73; 144; 21 # the next line is missing the team ID Choo, Shin-Soo; 154; 569; 107; 162; 21 Upton, Justin; ATL; 149; 558; 94; 147; 27 Cabrera, Miguel; DET; 148; 555; 103; 193; 44 Before you do any coding, read the full documentation in mlb.py. Your program will implement the design described in the comments and docstrings. It will also use the symbolic constants defined at the start of the file in place of integer literals when indexing into playerinformation tuples. Implementation Strategy: We have started you out with a main code section that implements the QUIT and HELP commands. The starter program also recognizes an INPUT command, but just executes a print stub. Begin coding by deleting the last comment (# REPLACE) and extending the if-elif statement so that the program also recognizes if a TEAM command is entered, if a HOMERS command is entered, or if none of the five command keywords is entered. Use print stubs to print the command entered. Run the program and test that the logic to repeatedly prompt for commands is implemented correctly before proceeding further.
4 Next implement the read_file function. If the file cannot be opened for reading, the read_file function will return an empty list. 1 Otherwise, it will build the list of player information tuples to return as it processes each line of the file (in a for loop): Starting with an empty list (created before entering the for loop), in each iteration of the loop, it will calculate the tuple for a player from the information in the line and append the tuple to the list. To test the read_file function, run the program and enter quit. Then evaluate read_file( mlb.test.txt ) directly in the console. Check that it prints appropriate error messages for the two incorrectly formatted lines and that it returns a list containing a player information tuple for each correctly formatted line. Check several of the player information tuples the items should be of the specified types and in the same order as in the file. They should also contain a correct batting average (a float) as the final item. Also test calling read_file with a bad file name. It should print an error message and return an empty list. Next replace the print stub for the INPUT command with code implementing the command. This code will call read_file with the file name that the user entered in the command line. It will assign the return value to player_ds. To test your implementation of the INPUT command, run the program, enter INPUT mlb.test.txt at the first command prompt and enter quit at the second. Then evaluate player_ds in the console and check that it returns the expected list of player-information tuples. Run another test but with a bad file name this time. Continue in this fashion to implement the functions one-by-one and test them in the console. Then implement the commands that use the functions and test these commands. To simplify testing functions in the console, we recommend that you add an assignment after the while statement in the main code section such as ds = read_file( mlb.test.txt ) This will allow you to pass ds in for the roster parameter when you call a function in the console (e.g., to test get_team, you can evaluate get_team(ds, Det ) in the console). You will still need to quit the loop first. But it will save you having to retype the file name each time you want to test a function in the console. (When you are done testing your complete program, delete or comment out this assignment.) When you are satisfied that your code is correct, finally wrap the top-level code after all the function definitions in a main function definition and add a call to main at the end of your program. Test your program a final time. 1 Note that read_file does not repeatedly prompt for a file that it can open; instead, if the user enters a bad file name, it returns the empty list.
5 Suggestions for get_top_hitters: This is the most challenging function to implement because of the need to sort on two fields: the first (number of home runs) in descending order and the second (player names) in ascending order. Python provides both a sorted function and a sort method for lists. Both use lexicographic ordering when the items in a list are collections (e.g., tuples, lists, or strings). So if you were to sort the list passed in for roster, player information tuples would be sorted by player name, and then by team ID, and then by number of games played, etc. But you want to sort first by homeruns, not player names. One strategy for sorting the roster is outlined below. For concreteness, consider an example. Let s say the following list is passed in for roster. [('aname', 'cws', 153, 607, 84, 160, 17, ), ('fname', 'det', 144, 606, 90, 184, 17, ), ('bname', 'laa', 151, 576, 73, 144, 21, 0.25), ('ename', 'atl', 149, 558, 94, 147, 21, ), ('cname', 'det', 148, 555, 103, 193, 44, ), ('dname', 'col', 57, 165, 22, 40, 21, ), ('gname', 'cws', 1, 2, 0, 0, 0, 0.0)] From this list, you can create an intermediate list of two-tuples, where each tuple in the intermediate list contains the number of homeruns followed by the player information tuple: [(17, ('aname', 'cws', 153, 607, 84, 160, 17, )), (17, ('fname', 'det', 144, 606, 90, 184, 17, )), (21, ('bname', 'laa', 151, 576, 73, 144, 21, 0.25)), (21, ('ename', 'atl', 149, 558, 94, 147, 21, )), (44, ('cname', 'det', 148, 555, 103, 193, 44, )), (21, ('dname', 'col', 57, 165, 22, 40, 21, )), (0, ('gname', 'cws', 1, 2, 0, 0, 0, 0.0))] Calling the Python sorted function to sort this intermediate list produces: [(0, ('gname', 'cws', 1, 2, 0, 0, 0, 0.0)), (17, ('aname', 'cws', 153, 607, 84, 160, 17, )), (17, ('fname', 'det', 144, 606, 90, 184, 17, )), (21, ('bname', 'laa', 151, 576, 73, 144, 21, 0.25)), (21, ('dname', 'col', 57, 165, 22, 40, 21, )), (21, ('ename', 'atl', 149, 558, 94, 147, 21, )), (44, ('cname', 'det', 148, 555, 103, 193, 44, ))] But you want the home runs in descending order. So you can reverse this list to get another intermediate list: [(44, ('cname', 'det', 148, 555, 103, 193, 44, )), (21, ('ename', 'atl', 149, 558, 94, 147, 21, )), (21, ('dname', 'col', 57, 165, 22, 40, 21, )), (21, ('bname', 'laa', 151, 576, 73, 144, 21, 0.25)),
6 (17, ('fname', 'det', 144, 606, 90, 184, 17, )), (17, ('aname', 'cws', 153, 607, 84, 160, 17, )), (0, ('gname', 'cws', 1, 2, 0, 0, 0, 0.0))] You next want to collect the player information tuples from this intermediate list, but not exactly in the above order player information tuples with the same number of home runs need to be sorted in ascending order by the player name (they are currently in descending order). This can be done using nested while loops. Starting with an empty result list, each iteration of the outer loop can extend the result list with the list of properly sorted player information tuples for the next home run value. It can use a nested loop to build this latter list. Continuing with above example, the outer loop body will be executed four times. The first iteration will create a list of all player information tuples whose home run value is 44; it will then sort this list by player name, and extend the result list with the sorted list. The second iteration will create a list of all player information tuples whose home run value is 21, sort this list by player name, and extend the result list with the sorted list. And so on. Thus, after the first iteration of the outer loop, the result list will be: [('cname', 'det', 148, 555, 103, 193, 44, ))] After the second, it will be: [('cname', 'det', 148, 555, 103, 193, 44, )), ('bname', 'laa', 151, 576, 73, 144, 21, 0.25)), ('dname', 'col', 57, 165, 22, 40, 21, )), ('ename', 'atl', 149, 558, 94, 147, 21, ))] After the third, it will be: [('cname', 'det', 148, 555, 103, 193, 44, )), ('bname', 'laa', 151, 576, 73, 144, 21, 0.25)), ('dname', 'col', 57, 165, 22, 40, 21, )), ('ename', 'atl', 149, 558, 94, 147, 21, )), ('aname', 'cws', 153, 607, 84, 160, 17, )), ('fname', 'det', 144, 606, 90, 184, 17, ))] After the fourth, it will be: [('cname', 'det', 148, 555, 103, 193, 44, )), ('bname', 'laa', 151, 576, 73, 144, 21, 0.25)), ('dname', 'col', 57, 165, 22, 40, 21, )), ('ename', 'atl', 149, 558, 94, 147, 21, )), ('aname', 'cws', 153, 607, 84, 160, 17, )), ('fname', 'det', 144, 606, 90, 184, 17, )), ('gname', 'cws', 1, 2, 0, 0, 0, 0.0))] The function will then return this final result list.
CE151 ASSIGNMENT
Set by: Mike Sanderson Credit: 20% of total module mark Deadline: 11.59.59, Monday 8 December Submission of this assignment will be via the online submission system; your programs may be tested during
More information\n is used in a string to indicate the newline character. An expression produces data. The simplest expression
Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of
More informationTest #2 October 8, 2015
CPSC 1040 Name: Test #2 October 8, 2015 Closed notes, closed laptop, calculators OK. Please use a pencil. 100 points, 5 point bonus. Maximum score 105. Weight of each section in parentheses. If you need
More information(edit 3/7: fixed a typo in project specification 2-f) user_id that user enters should be in the range [0,n-1] (i.e., from 0 to n-1, inclusive))
CSE 231 Spring 2017 Programming Project 7 (edit 3/1: fixed a typo in num_in_common_between_lists(user1_friend_lst, user2_friend_lst as described in c) calc_similarity_scores(network)) (edit 3/7: fixed
More informationProgramming. We will be introducing various new elements of Python and using them to solve increasingly interesting and complex problems.
Plan for the rest of the semester: Programming We will be introducing various new elements of Python and using them to solve increasingly interesting and complex problems. We saw earlier that computers
More information[CHAPTER] 1 INTRODUCTION 1
FM_TOC C7817 47493 1/28/11 9:29 AM Page iii Table of Contents [CHAPTER] 1 INTRODUCTION 1 1.1 Two Fundamental Ideas of Computer Science: Algorithms and Information Processing...2 1.1.1 Algorithms...2 1.1.2
More informationCHAPTER 2: Introduction to Python COMPUTER PROGRAMMING SKILLS
CHAPTER 2: Introduction to Python COMPUTER PROGRAMMING SKILLS 1439-1440 1 Outline 1. Introduction 2. Why Python? 3. Compiler and Interpreter 4. The first program 5. Comments and Docstrings 6. Python Indentations
More informationegrapher Language Reference Manual
egrapher Language Reference Manual Long Long: ll3078@columbia.edu Xinli Jia: xj2191@columbia.edu Jiefu Ying: jy2799@columbia.edu Linnan Wang: lw2645@columbia.edu Darren Chen: dsc2155@columbia.edu 1. Introduction
More informationChapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines.
Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of
More informationTABLE OF CONTENTS 2 CHAPTER 1 3 CHAPTER 2 4 CHAPTER 3 5 CHAPTER 4. Algorithm Design & Problem Solving. Data Representation.
2 CHAPTER 1 Algorithm Design & Problem Solving 3 CHAPTER 2 Data Representation 4 CHAPTER 3 Programming 5 CHAPTER 4 Software Development TABLE OF CONTENTS 1. ALGORITHM DESIGN & PROBLEM-SOLVING Algorithm:
More informationCSI33 Data Structures
Outline Department of Mathematics and Computer Science Bronx Community College October 24, 2018 Outline Outline 1 Chapter 8: A C++ Introduction For Python Programmers Expressions and Operator Precedence
More informationBasic Python 3 Programming (Theory & Practical)
Basic Python 3 Programming (Theory & Practical) Length Delivery Method : 5 Days : Instructor-led (Classroom) Course Overview This Python 3 Programming training leads the student from the basics of writing
More informationMULTIPLE CHOICE. Chapter Seven
Chapter Seven MULTIPLE CHOICE 1. Which of these is associated with a specific file and provides a way for the program to work with that file? a. Filename b. Extension c. File object d. File variable 2.
More informationHonors Computer Science Python Mr. Clausen Programs 4A, 4B, 4C, 4D, 4E, 4F
PROGRAM 4A Full Names (25 points) Honors Computer Science Python Mr. Clausen Programs 4A, 4B, 4C, 4D, 4E, 4F This program should ask the user for their full name: first name, a space, middle name, a space,
More informationComputer Programming. Basic Control Flow - Loops. Adapted from C++ for Everyone and Big C++ by Cay Horstmann, John Wiley & Sons
Computer Programming Basic Control Flow - Loops Adapted from C++ for Everyone and Big C++ by Cay Horstmann, John Wiley & Sons Objectives To learn about the three types of loops: while for do To avoid infinite
More informationSorting Pearson Education, Inc. All rights reserved.
1 19 Sorting 2 19.1 Introduction (Cont.) Sorting data Place data in order Typically ascending or descending Based on one or more sort keys Algorithms Insertion sort Selection sort Merge sort More efficient,
More informationComputer Programming C++ (wg) CCOs
Computer Programming C++ (wg) CCOs I. The student will analyze the different systems, and languages of the computer. (SM 1.4, 3.1, 3.4, 3.6) II. The student will write, compile, link and run a simple C++
More informationIntroduction to Programming
Introduction to Programming Python Lab 9: Functions PythonLab9 lecture slides.ppt 27 November 2018 Ping Brennan (p.brennan@bbk.ac.uk) 1 Getting Started Create a new folder in your disk space with the name
More informationGIS 4653/5653: Spatial Programming and GIS. More Python: Statements, Types, Functions, Modules, Classes
GIS 4653/5653: Spatial Programming and GIS More Python: Statements, Types, Functions, Modules, Classes Statement Syntax The if-elif-else statement Indentation and and colons are important Parentheses and
More informationLecture 2 Tao Wang 1
Lecture 2 Tao Wang 1 Objectives In this chapter, you will learn about: Modular programs Programming style Data types Arithmetic operations Variables and declaration statements Common programming errors
More informationText Input and Conditionals
Text Input and Conditionals Text Input Many programs allow the user to enter information, like a username and password. Python makes taking input from the user seamless with a single line of code: input()
More informationLoop structures and booleans
Loop structures and booleans Michael Mandel Lecture 7 Methods in Computational Linguistics I The City University of New York, Graduate Center https://github.com/ling78100/lectureexamples/blob/master/lecture07final.ipynb
More informationXQ: An XML Query Language Language Reference Manual
XQ: An XML Query Language Language Reference Manual Kin Ng kn2006@columbia.edu 1. Introduction XQ is a query language for XML documents. This language enables programmers to express queries in a few simple
More informationPython The way of a program. Srinidhi H Asst Professor Dept of CSE, MSRIT
Python The way of a program Srinidhi H Asst Professor Dept of CSE, MSRIT 1 Problem Solving Problem solving means the ability to formulate problems, think creatively about solutions, and express a solution
More informationOther Loop Options EXAMPLE
C++ 14 By EXAMPLE Other Loop Options Now that you have mastered the looping constructs, you should learn some loop-related statements. This chapter teaches the concepts of timing loops, which enable you
More informationCSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York
CSc 10200! Introduction to Computing Lecture 2-3 Edgardo Molina Fall 2013 City College of New York 1 C++ for Engineers and Scientists Third Edition Chapter 2 Problem Solving Using C++ 2 Objectives In this
More information3. Except for strings, double quotes, identifiers, and keywords, C++ ignores all white space.
Chapter 2: Problem Solving Using C++ TRUE/FALSE 1. Modular programs are easier to develop, correct, and modify than programs constructed in some other manner. ANS: T PTS: 1 REF: 45 2. One important requirement
More informationCreating and Using an Excel Table
Creating and Using an Excel Table Overview of Excel 2007 tables In earlier Excel versions, the organization of data in tables was referred to as an Excel database or list. An Excel table is not to be confused
More informationName Section: M/W T/TH Number Definition Matching (8 Points)
Name Section: M/W T/TH Number Definition Matching (8 Points) 1. (8 pts) Match the words with their definitions. Choose the best definition for each word. Iteration Counter Event Counter Loop Abstract Step
More informationGridLang: Grid Based Game Development Language Language Reference Manual. Programming Language and Translators - Spring 2017 Prof.
GridLang: Grid Based Game Development Language Language Reference Manual Programming Language and Translators - Spring 2017 Prof. Stephen Edwards Akshay Nagpal Dhruv Shekhawat Parth Panchmatia Sagar Damani
More informationPYTHON. Values and Variables
December 13 2017 Naveen Sagayaselvaraj PYTHON Values and Variables Overview Integer Values Variables and Assignment Identifiers Floating-point Types User Input The eval Function Controlling the print Function
More informationCSC148 Fall 2017 Ramp Up Session Reference
Short Python function/method descriptions: builtins : input([prompt]) -> str Read a string from standard input. The trailing newline is stripped. The prompt string, if given, is printed without a trailing
More informationMATH 1MP3 Homework #4 Due: 11:59pm, Wednesday, March 6.
MATH 1MP3 Homework #4 Due: 11:59pm, Wednesday, March 6. Important notes: To start the assignment, download the Jupyter notebook file assignment 4 template.ipynb found here: https://ms.mcmaster.ca/~matt/1mp3/homework/assignment_4_template.
More informationIMPORTANT: Circle the last two letters of your class account:
Fall 2001 University of California, Berkeley College of Engineering Computer Science Division EECS Prof. Michael J. Franklin FINAL EXAM CS 186 Introduction to Database Systems NAME: STUDENT ID: IMPORTANT:
More informationLISTS WITH PYTHON. José M. Garrido Department of Computer Science. May College of Computing and Software Engineering Kennesaw State University
LISTS WITH PYTHON José M. Garrido Department of Computer Science May 2015 College of Computing and Software Engineering Kennesaw State University c 2015, J. M. Garrido Lists with Python 2 Lists with Python
More informationStudent Number: Comments are not required except where indicated, although they may help us mark your answers.
CSC 108H5 F 2018 Midterm Test Duration 90 minutes Aids allowed: none Student Number: utorid: Last Name: First Name: Do not turn this page until you have received the signal to start. (Please fill out the
More informationThe Big Python Guide
The Big Python Guide Big Python Guide - Page 1 Contents Input, Output and Variables........ 3 Selection (if...then)......... 4 Iteration (for loops)......... 5 Iteration (while loops)........ 6 String
More informationC++ Programming: From Problem Analysis to Program Design, Fourth Edition. Chapter 5: Control Structures II (Repetition)
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 5: Control Structures II (Repetition) Objectives In this chapter, you will: Learn about repetition (looping) control structures
More informationThe while Loop 4/6/16 4
Chapter 4: Loops Chapter Goals To implement while and for loops To hand-trace the execution of a program To become familiar with common loop algorithms To understand nested loops To implement programs
More informationKey Differences Between Python and Java
Python Python supports many (but not all) aspects of object-oriented programming; but it is possible to write a Python program without making any use of OO concepts. Python is designed to be used interpretively.
More informationWHAT IS A DATABASE? There are at least six commonly known database types: flat, hierarchical, network, relational, dimensional, and object.
1 WHAT IS A DATABASE? A database is any organized collection of data that fulfills some purpose. As weather researchers, you will often have to access and evaluate large amounts of weather data, and this
More informationFundamentals of Programming. Lecture 3: Introduction to C Programming
Fundamentals of Programming Lecture 3: Introduction to C Programming Instructor: Fatemeh Zamani f_zamani@ce.sharif.edu Sharif University of Technology Computer Engineering Department Outline A Simple C
More informationASML Language Reference Manual
ASML Language Reference Manual Tim Favorite (tuf1) & Frank Smith (fas2114) - Team SoundHammer Columbia University COMS W4115 - Programming Languages & Translators 1. Introduction The purpose of Atomic
More informationThere are two ways to use the python interpreter: interactive mode and script mode. (a) open a terminal shell (terminal emulator in Applications Menu)
I. INTERACTIVE MODE VERSUS SCRIPT MODE There are two ways to use the python interpreter: interactive mode and script mode. 1. Interactive Mode (a) open a terminal shell (terminal emulator in Applications
More informationLoops In Python. In this section of notes you will learn how to rerun parts of your program without having to duplicate the code.
Loops In Python In this section of notes you will learn how to rerun parts of your program without having to duplicate the code. The Need For Repetition (Loops) Writing out a simple counting program (1
More informationLevel 3 Computing Year 2 Lecturer: Phil Smith
Level 3 Computing Year 2 Lecturer: Phil Smith We looked at: Previously Reading and writing files. BTEC Level 3 Year 2 Unit 16 Procedural programming Now Now we will look at: Appending data to existing
More informationOverview. - General Data Types - Categories of Words. - Define Before Use. - The Three S s. - End of Statement - My First Program
Overview - General Data Types - Categories of Words - The Three S s - Define Before Use - End of Statement - My First Program a description of data, defining a set of valid values and operations List of
More informationThe SPL Programming Language Reference Manual
The SPL Programming Language Reference Manual Leonidas Fegaras University of Texas at Arlington Arlington, TX 76019 fegaras@cse.uta.edu February 27, 2018 1 Introduction The SPL language is a Small Programming
More informationINTERMEDIATE LEVEL PYTHON PROGRAMMING SELECTION AND CONDITIONALS V1.0
INTERMEDIATE LEVEL PYTHON PROGRAMMING SELECTION AND CONDITIONALS V1.0 OCTOBER 2014 Python Selection and Conditionals 1 SELECTION AND CONDITIONALS WHAT YOU MIGHT KNOW ALREADY You will probably be familiar
More informationFundamentals of Programming Session 4
Fundamentals of Programming Session 4 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Fall 2011 These slides are created using Deitel s slides, ( 1992-2010 by Pearson Education, Inc).
More informationWhat is an algorithm?
Reminders CS 142 Lecture 3 Analysis, ADTs & Objects Program 1 was assigned - Due on 1/27 by 11:55pm 2 Abstraction Measuring Algorithm Efficiency When you utilize the mylist.index(item) function you are
More informationChapter 5. Repetition. Contents. Introduction. Three Types of Program Control. Two Types of Repetition. Three Syntax Structures for Looping in C++
Repetition Contents 1 Repetition 1.1 Introduction 1.2 Three Types of Program Control Chapter 5 Introduction 1.3 Two Types of Repetition 1.4 Three Structures for Looping in C++ 1.5 The while Control Structure
More informationCSI33 Data Structures
Outline Department of Mathematics and Computer Science Bronx Community College September 6, 2017 Outline Outline 1 Chapter 2: Data Abstraction Outline Chapter 2: Data Abstraction 1 Chapter 2: Data Abstraction
More informationwww.thestudycampus.com Recursion Recursion is a process for solving problems by subdividing a larger problem into smaller cases of the problem itself and then solving the smaller, more trivial parts. Recursion
More informationChapter Five: Functions
Chapter Five: Functions Chapter Goals To be able to implement functions To become familiar with the concept of parameter passing To develop strategies for decomposing complex tasks into simpler ones To
More informationCROSSREF Manual. Tools and Utilities Library
Tools and Utilities Library CROSSREF Manual Abstract This manual describes the CROSSREF cross-referencing utility, including how to use it with C, COBOL 74, COBOL85, EXTENDED BASIC, FORTRAN, Pascal, SCREEN
More informationAPPENDIX E SOLUTION TO CHAPTER SELF-TEST CHAPTER 1 TRUE-FALSE FILL-IN-THE-BLANKS
APPENDIX E SOLUTION TO CHAPTER SELF-TEST CHAPTER 1 2. F The AS/400 family of computers, as with all IBM midrange and mainframe computers, uses the EBCDIC coding system. 3. F Arrival sequence files do not
More informationLesson 1: Creating and formatting an Answers analysis
Lesson 1: Creating and formatting an Answers analysis Answers is the ad-hoc query environment in the OBIEE suite. It is in Answers that you create and format analyses to help analyze business results.
More informationTopics. Introduction to Repetition Structures Often have to write code that performs the same task multiple times. Controlled Loop
Topics C H A P T E R 4 Repetition Structures Introduction to Repetition Structures The for Loop: a Count- Sentinels Nested Loops Introduction to Repetition Structures Often have to write code that performs
More informationLoops In Python. In this section of notes you will learn how to rerun parts of your program without having to duplicate the code.
Loops In Python In this section of notes you will learn how to rerun parts of your program without having to duplicate the code. Application Of Loops In Actual Software Play again? Re-running specific
More informationWorksheet 6: Basic Methods Methods The Format Method Formatting Floats Formatting Different Types Formatting Keywords
Worksheet 1: Introductory Exercises Turtle Programming Calculations The Print Function Comments Syntax Semantics Strings Concatenation Quotation Marks Types Variables Restrictions on Variable Names Long
More information2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program
Chapter 2: Introduction to C++ 2.1 Parts of a C++ Program Copyright 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Parts of a C++ Program Parts of a C++ Program // sample C++ program
More informationPython Basics. Lecture and Lab 5 Day Course. Python Basics
Python Basics Lecture and Lab 5 Day Course Course Overview Python, is an interpreted, object-oriented, high-level language that can get work done in a hurry. A tool that can improve all professionals ability
More informationLoops and Conditionals. HORT Lecture 11 Instructor: Kranthi Varala
Loops and Conditionals HORT 59000 Lecture 11 Instructor: Kranthi Varala Relational Operators These operators compare the value of two expressions and returns a Boolean value. Beware of comparing across
More informationC How to Program, 7/e by Pearson Education, Inc. All Rights Reserved.
C How to Program, 7/e This chapter serves as an introduction to data structures. Arrays are data structures consisting of related data items of the same type. In Chapter 10, we discuss C s notion of
More informationSTAT 7000: Experimental Statistics I
STAT 7000: Experimental Statistics I 2. A Short SAS Tutorial Peng Zeng Department of Mathematics and Statistics Auburn University Fall 2009 Peng Zeng (Auburn University) STAT 7000 Lecture Notes Fall 2009
More informationPart III Appendices 165
Part III Appendices 165 Appendix A Technical Instructions Learning Outcomes This material will help you learn how to use the software you need to do your work in this course. You won t be tested on it.
More informationFundamentals of Programming Session 8
Fundamentals of Programming Session 8 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Fall 2013 These slides have been created using Deitel s slides Sharif University of Technology Outlines
More informationB.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University
Unit 1 Programming Language and Overview of C 1. State whether the following statements are true or false. a. Every line in a C program should end with a semicolon. b. In C language lowercase letters are
More informationPython for Informatics
Python for Informatics Exploring Information Version 0.0.6 Charles Severance Chapter 3 Conditional execution 3.1 Boolean expressions A boolean expression is an expression that is either true or false.
More informationGnuCOBOL Quick Reference
GnuCOBOL Quick Reference For Version 2.2 Final [7Sept2017] Gary L. Cutler (cutlergl@gmail.com). For updates Vincent B. Coen (vbcoen@gmail.com). This manual documents GnuCOBOL 2.2 Final, 7Sept2017 build.
More information1 Truth. 2 Conditional Statements. Expressions That Can Evaluate to Boolean Values. Williams College Lecture 4 Brent Heeringa, Bill Jannen
1 Truth Last lecture we learned about the int, float, and string types. Another very important object type in Python is the boolean type. The two reserved keywords True and False are values with type boolean.
More informationCompare Data and Files
LOCATE OLD HISTORICAL SUBJECT DATABASE LABORATORY FILES. Lesson Data and Manuscript Documents File Groups for Models. Old data material is arranged by topic groups. Work with internet hypertext, or computer
More informationCommon File System Commands
Common File System Commands ls! List names of all files in current directory ls filenames! List only the named files ls -t! List in time order, most recent first ls -l! Long listing, more information.
More informationRETURN X return X Returning a value from within a function: computes the value of variable exits the function and returns the value of the variable
STUDENT TEACHER CLASS WORKING AT GRADE TERM TARGET YEAR TARGET Pseudocode Python Description BEGIN END Identifies the start of a program Identifies the end of a program READ X, Y, Z input() Identifies
More informationMicrosoft Word 2013 Working with tables
Microsoft Word 2013 Working with tables LIBRARY AND LEARNING SERVICES WORKING WITH TABLES www.eit.ac.nz/library/ls_computer_word2013_tables.html What is a table? A table is information arranged in horizontal
More informationC++ for Python Programmers
C++ for Python Programmers Adapted from a document by Rich Enbody & Bill Punch of Michigan State University Purpose of this document This document is a brief introduction to C++ for Python programmers
More informationIntroduction to Problem Solving and Programming in Python.
Introduction to Problem Solving and Programming in Python http://cis-linux1.temple.edu/~tuf80213/courses/temple/cis1051/ Overview Python sequences Lists, Tuples, and Ranges Built-in operations Slicing
More informationPython Working with files. May 4, 2017
Python Working with files May 4, 2017 So far, everything we have done in Python was using in-memory operations. After closing the Python interpreter or after the script was done, all our input and output
More informationUsing Microsoft Excel for Recording and Analyzing Data Noah Segall
Using Microsoft Excel for Recording and Analyzing Data Noah Segall The standard computer program used for record keeping of strength and conditioning is Microsoft s Excel. Its simple spreadsheets make
More informationDaMPL. Language Reference Manual. Henrique Grando
DaMPL Language Reference Manual Bernardo Abreu Felipe Rocha Henrique Grando Hugo Sousa bd2440 flt2107 hp2409 ha2398 Contents 1. Getting Started... 4 2. Syntax Notations... 4 3. Lexical Conventions... 4
More informationIntroduction to C# Applications
1 2 3 Introduction to C# Applications OBJECTIVES To write simple C# applications To write statements that input and output data to the screen. To declare and use data of various types. To write decision-making
More informationThe Practice of Computing Using PYTHON. Chapter 2. Control. Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley
The Practice of Computing Using PYTHON William Punch Richard Enbody Chapter 2 Control 1 Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Control: A Quick Overview 2 Selection
More informationVariable and Data Type I
Islamic University Of Gaza Faculty of Engineering Computer Engineering Department Lab 2 Variable and Data Type I Eng. Ibraheem Lubbad September 24, 2016 Variable is reserved a location in memory to store
More informationSQL STRUCTURED QUERY LANGUAGE
STRUCTURED QUERY LANGUAGE SQL Structured Query Language 4.1 Introduction Originally, SQL was called SEQUEL (for Structured English QUery Language) and implemented at IBM Research as the interface for an
More informationCHAPTER 5 1 RECORDS MANAGEMENT
Slide 1 Slide 2 Using Databases Databases are organized for rapid search and retrieval Databases have objects: Tables Forms Queries Reports Slide 3 Access Database Table Fields are arranged in columns
More informationLecture 3 Tao Wang 1
Lecture 3 Tao Wang 1 Objectives In this chapter, you will learn about: Arithmetic operations Variables and declaration statements Program input using the cin object Common programming errors C++ for Engineers
More informationGE PROBLEM SOVING AND PYTHON PROGRAMMING. Question Bank UNIT 1 - ALGORITHMIC PROBLEM SOLVING
GE8151 - PROBLEM SOVING AND PYTHON PROGRAMMING Question Bank UNIT 1 - ALGORITHMIC PROBLEM SOLVING 1) Define Computer 2) Define algorithm 3) What are the two phases in algorithmic problem solving? 4) Why
More informationCMSC 201 Spring 2016 Lab 08 Strings and File I/O
CMSC 201 Spring 2016 Lab 08 Strings and File I/O Assignment: Lab 08 Strings and File I/O Due Date: During discussion, April 4 th through April 7 th Value: 10 points Part 1: File Input Using files as input
More informationPython allows variables to hold string values, just like any other type (Boolean, int, float). So, the following assignment statements are valid:
1 STRINGS Objectives: How text data is internally represented as a string Accessing individual characters by a positive or negative index String slices Operations on strings: concatenation, comparison,
More informationPython Programming: An Introduction To Computer Science
Python Programming: An Introduction To Computer Science Chapter 8 Loop Structures and Booleans Python Programming, 3/e 1 Objectives To understand the concepts of definite and indefinite loops as they are
More informationCS201- Introduction to Programming Latest Solved Mcqs from Midterm Papers May 07,2011. MIDTERM EXAMINATION Spring 2010
CS201- Introduction to Programming Latest Solved Mcqs from Midterm Papers May 07,2011 Lectures 1-22 Moaaz Siddiq Asad Ali Latest Mcqs MIDTERM EXAMINATION Spring 2010 Question No: 1 ( Marks: 1 ) - Please
More informationChapter 3 : Informatics Practices. Class XI ( As per CBSE Board) Python Fundamentals. Visit : python.mykvs.in for regular updates
Chapter 3 : Informatics Practices Class XI ( As per CBSE Board) Python Fundamentals Introduction Python 3.0 was released in 2008. Although this version is supposed to be backward incompatibles, later on
More informationCONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17
List of Programs xxv List of Figures xxix List of Tables xxxiii Preface to second version xxxv PART 1 Structured Programming 1 1 Getting started 3 1.1 Programming 3 1.2 Editing source code 5 Source code
More informationThere are two ways to use the python interpreter: interactive mode and script mode. (a) open a terminal shell (terminal emulator in Applications Menu)
I. INTERACTIVE MODE VERSUS SCRIPT MODE There are two ways to use the python interpreter: interactive mode and script mode. 1. Interactive Mode (a) open a terminal shell (terminal emulator in Applications
More informationChapter 2: Introduction to C++
Chapter 2: Introduction to C++ Copyright 2010 Pearson Education, Inc. Copyright Publishing as 2010 Pearson Pearson Addison-Wesley Education, Inc. Publishing as Pearson Addison-Wesley 2.1 Parts of a C++
More informationPreviously. Iteration. Date and time structures. Modularisation.
2017 2018 Previously Iteration. Date and time structures. Modularisation. Today File handling. Reading and writing files. In order for a program to work with a file, the program must create a file object
More informationPython Input, output and variables. Lecture 23 COMPSCI111/111G SS 2018
Python Input, output and variables Lecture 23 COMPSCI111/111G SS 2018 1 Today s lecture What is Python? Displaying text on screen using print() Variables Numbers and basic arithmetic Getting input from
More informationINTRODUCTION... 1 UNDERSTANDING CELLS... 2 CELL CONTENT... 4
Introduction to Microsoft Excel 2016 INTRODUCTION... 1 The Excel 2016 Environment... 1 Worksheet Views... 2 UNDERSTANDING CELLS... 2 Select a Cell Range... 3 CELL CONTENT... 4 Enter and Edit Data... 4
More informationCopyright 2018 by KNIME Press
2 Copyright 2018 by KNIME Press All rights reserved. This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
More information