An Introduction to Computer Science with Java, Python and C++ Community College of Philadelphia Edition
Total Page:16
File Type:pdf, Size:1020Kb
An Introduction to Computer Science with Java, Python and C++ Community College of Philadelphia edition Copyright 2017 by C.W. Herbert, all rights reserved. Last edited August 28, 2017 by C. W. Herbert This document is a draft of a chapter from An Introduction to Computer Science with Java, Python and C++, written by Charles Herbert. It is available free of charge for students in Computer Science courses at Community College of Philadelphia during the Fall 2017 semester. It may not be reproduced or distributed for any other purposes without proper prior permission. Please report any typos, other errors, or suggestions for improving the text to [email protected] 01010000 01111001 01110100 01101000 01101111 01101110 01001010 01100001 01110110 01100001 01000011 00101011 00101011 Chapter 1 – Introduction Contents About the Course .......................................................................................................................................... 2 Course Materials and Instructors.................................................................................................................. 3 Chapter 1 – Introduction ............................................................................................................................... 5 Learning Outcomes ....................................................................................................................................... 5 Computing and Computer Science ................................................................................... 6 The Computer Science Accreditation Board ........................................................................................... 10 Computer Science Specializations .......................................................................................................... 11 Algorithms and Objects ................................................................................................... 12 Programming Languages ................................................................................................. 14 The Python Programming Language ............................................................................... 37 Lab 1 – Getting Started with Python ....................................................................................................... 41 Key Terms in Chapter 1 ........................................................................................................................... 47 Chapter 1 - Questions ............................................................................................................................. 48 Chapter 1 - Exercises ............................................................................................................................... 49 Intro to CSCI with Java, Python, and C++ Chapter 1 page 2 About the Course Welcome to Computer Science 111. This course, along with Computer Science 112, provides students with a solid foundation in computer programming and algorithm development, as well as associated topics from Computer Science. This course is a first course in programming for Computer Science majors and students in related majors, such as Computer Information Systems, Mathematics, Science, or Engineering. Computer Science 111 and 112 use three of the most popular computer programming languages available today: Python, Java and C++. However, many of the topics covered in this course are language independent -- such as Boolean logic, or algorithmic efficiency. Students who successfully complete the two courses should be proficient in the use of all three languages and should have sufficient experience and knowledge of programming topics and techniques to succeed independently in learning to use other programming languages. The key to success in this course is to keep up with the course material each week and to spend an appropriate amount of time each week working on course material. This is especially true for online students, who must have the discipline to allocate enough time to complete all of the coursework. Courses at Community College of Philadelphia are based on a standard 15-week semester – with 14 weeks of instruction and a week for final exams. Computer Science 111 is a 4-3-2 course, which means it is a four-credit course with each week of the course in a standard semester requiring three hours of instruction and an additional two hours to work on programming or research exercises – as well as time to complete out-of-class (homework) assignments. During shorter semesters, more time needs to be spent each week to cover the course material. For example, in a 7-week Summer semester, twice as much time must be spent each week to cover the same material as in a traditional semester’s 14 weeks of instruction. The course is primarily intended for students who wish to transfer to baccalaureate programs in Computer Science, Software Engineering, or related disciplines. The course is also a practical one, in which students will develop a set of marketable skills. The course material is relatively well-defined. It is based on the content described by the Pennsylvania Statewide Program-to-Program (P2P) Articulation Agreement in Computer Science1. These requirements are, in turn, based on requirements of the Computer Science Accreditation Board2, the professional agency responsible for accrediting baccalaureate programs in Computer Science. The content of this course is in line with state, national, and international guidelines for what should be taught in Computer Science courses and programs. 1 The agreement is available online at: http://patrac.org/Portals/6/PAFiles/PATRAC_P2P_COMPUTER_SCIENCE_Apr11_2012_rev.pdf 2 On the Web at: http://www.csab.org Intro to CSCI with Java, Python, and C++ Chapter 1 page 3 Course Materials and Instructors The course material is composed of a series of chapters with reading material, sample software, programming exercises, programing assignments, research assignments, and class discussions as appropriate for each topic. Your instructor will decode which chapters to include in the course and which exercises need to be completed for each chapter. Core lessons in programming build upon one another, so they should be completed in order. Associated topics – such as the history of programming – can be included as your instructor deems appropriate. All course material is available free of charge for students enrolled in the course at Community College of Philadelphia. It includes a combination of instructor-generated material, freely available online learning material, and freely available programming tools – including language compilers and interpreters and IDEs – Integrated Development Environments used for software development. All course material, including instructor-generated materials, are of a professional quality. The principal author, C.W. Herbert, has written text books and teaching materials for Course Technology, Cengage, Prentice Hall, Pearson, and others. He has degrees in Education, Mathematics, and Computer Science and has been teaching Computer Science and working as a consultant and professional software developer for more than 35 years. Each instructor for Computer Science 111 is a professional educator, with significant teaching experience and a degree in Computer Science, or in a closely related field with significant coursework in Computer Science. The IDEs chosen for use in CSCI 111,112 and 211 are among the most widely used by professional software developers. They include Python 3 and IDLE from the Python Software Foundation, the NetBeans IDE and Java compiler from the Oracle Corporation, and the CODE::Blocks IDE with GCC C++ from The Code::Blocks Team and the GNU Project. Please remember: We are here to begin to learn to become professional software developers who can contribute to large-scale software development projects and computer science research. We are not here to learn to build simple software, nor to learn to use quick and easy software development tools. Course materials were created with this in mind. The software languages and development tools chosen for the course were developed with this in mind. The use of formal software development techniques may seem like overkill for small projects, but we trying to develop professional habits. Course materials were written, and software development tools were chosen for the course, with cross- platform computing in mind. The software development tools chosen for the course can be used with Windows, macOS3, or Linux systems. As much as possible, all coursework can be completed using Windows, macOS, or Linux systems, and software developed for the course can be run on Windows, macOS, or Linux systems. 3 macOS is the new name for Apple’s operating system previously known as OS X. Intro to CSCI with Java, Python, and C++ Chapter 1 page 4 There are two aspects of Computer Science – things that don’t change and things that change all the time. Technology changes. The latest, greatest way to do something today will someday be old fashioned – maybe as soon as tomorrow. The fundamental math and logic underlying technology does not change. It is constant. The goal of Computer Science educators is to give students a firm foundation in those aspects of computing that are constant, and to enable them to deal with the aspects of computing that constantly change. As you study Computer Science, it helps to keep this in mind and to see how each thing you learn fits into these two realms of understanding. It also helps