CSCICMPE 4341 Topic Programming in Python Chapter 1

  • Slides: 25
Download presentation
CSCI/CMPE 4341 Topic: Programming in Python Chapter 1: Introduction to Python Xiang Lian The

CSCI/CMPE 4341 Topic: Programming in Python Chapter 1: Introduction to Python Xiang Lian The University of Texas – Pan American Edinburg, TX 78539 lianx@utpa. edu 1

Objectives • In this chapter, you will – Know requirements of this course –

Objectives • In this chapter, you will – Know requirements of this course – Recall basic components in a computer system – Learn the evolution of programming language – Refresh your memory about the structured programming vs. object-oriented programming – History of Python 2

Background Required • C++ Programming – If you made an A in 1370/1170 you

Background Required • C++ Programming – If you made an A in 1370/1170 you will do fine with some effort – If you have already taken 2380, you will find this course not very difficult • You need to be able to look up how to get things done (for example, look up syntax) 3

Programming, Programming • This class is unlike other courses in that you will spend

Programming, Programming • This class is unlike other courses in that you will spend a lot of time doing actual programming • You should never copy a program from someone else • Even if your program does not perform as good as someone else’s, you should submit what you have • You should not hesitate to ask questions in class 4

Assignments • Unless I announce it, programs are due in one week after assignment

Assignments • Unless I announce it, programs are due in one week after assignment is given in class, or posted • Occasionally, I will give two weeks for difficult programs • You should work on a program the same day it is assigned • That way you can ask questions during the following class period 5

Use of the Textbook • I will not be covering chapter by chapter •

Use of the Textbook • I will not be covering chapter by chapter • I will cover important points needed to complete the assignments • You need to search the index in the back to find the topic needed for each assignment • You can also obtain help from websites of online resources 6

Versions of Python • Python IDE software: – https: //www. python. org/downloads/ – Python

Versions of Python • Python IDE software: – https: //www. python. org/downloads/ – Python 2. 2. X – Python 3. 4. X • You will find differences for different versions Python – Thus, in your assignments, you need to specify which version (3. 4. 2 recommended) you are using 7

The Time for Class • I expect to hold the class for little over

The Time for Class • I expect to hold the class for little over an hour each time, with a 10 -minute break • For assignments, please do not exchange programs with each other, just ideas • For projects, you can discuss the project with your study group members 8

Study Group • Please form a team with 3 -4 team members • Each

Study Group • Please form a team with 3 -4 team members • Each team needs to finish one programming project, including: – A project report (e. g. , problem description, background, solution, implementation, experimental settings, empirical evaluation, and screen captures of graphical interface); – A statement of tasks for each team member; – Source code; – Demonstration (5 minutes); and – Presentation (10 -15 minutes). 9

Python 3. 4 Command Line Python 3. 4 GUI 10

Python 3. 4 Command Line Python 3. 4 GUI 10

CSCI 1380: Elements of a Computer System • Hardware – CPU – Main memory

CSCI 1380: Elements of a Computer System • Hardware – CPU – Main memory – Secondary storage – Input / Output devices • Software – System programs – Application programs (e. g. Python IDE) 11

Programming Languages • Machine language • Assembly language • High-level language – E. g.

Programming Languages • Machine language • Assembly language • High-level language – E. g. , Visual Basic, C, C++, Visual C#, Java, Python 12

Structured (Procedural) Programming Technology • Early Software Development – Complex and costly for businesses

Structured (Procedural) Programming Technology • Early Software Development – Complex and costly for businesses (1960 s) • Costs exceeded budgets • Final products unreliable – Research led to structured programming • Disciplined approach to programming – Programs clear and easy to modify • Several languages resulted from research – C, Pascal, Ada 13

Object-Oriented Programming Technology • We humans are very good in recognizing and working with

Object-Oriented Programming Technology • We humans are very good in recognizing and working with objects, such as a pen, a dog, or a human being • We learned to categorize them in such a way that make sense to us. – We may categorize them as animate object, inanimate objects, pets, friends, etc. 14

Object-Oriented Programming Technology(cont'd) • We some times classify objects based on their attributes, for

Object-Oriented Programming Technology(cont'd) • We some times classify objects based on their attributes, for example, green apples or red apples, fat or slim people, etc. • If you think about it each object has many attributes. – If I ask you list the attributes of an orange, you probably could list many things such as color, shape, weight, smell, etc. 15

Object-Oriented Programming Technology (cont'd) • In addition to attributes, all objects exhibit behaviors. •

Object-Oriented Programming Technology (cont'd) • In addition to attributes, all objects exhibit behaviors. • A dog eats, barks, wags its tail, plays, and begs. – A dog exhibits many more other behaviors than this short list. • Another thing we need to remember about objects is that objects interact between each other 16

History of Python • Created in 1989 by Guido van Rossum – Created as

History of Python • Created in 1989 by Guido van Rossum – Created as a scripting language for administrative tasks – Based on All Basic Code (ABC) and Modula-3 • Added extensibility – Named after comic troupe Monty Python • Released publicly in 1991 – Growing community of Python developers – Evolved into well-supported programming language 17

Python • Python is a scripting language – It is not compiled as an

Python • Python is a scripting language – It is not compiled as an executable file • Python – Structured programming • Like C – Object-oriented programming • Like C++ • Class and object 18

To Get Python Tutorial/Documentation • Visit: – Python How to Program, Deitel et al.

To Get Python Tutorial/Documentation • Visit: – Python How to Program, Deitel et al. – Learning to Program Using Python, Cody Jackson – Python Documentation 19

Hello Program # Fig. 2. 1: fig 02_01. py # Printing a line of

Hello Program # Fig. 2. 1: fig 02_01. py # Printing a line of text in Python. print ("Welcome to Python Programming Class!") Note: parentheses are needed for Python 3. 4. X, but not necessary for Python 2. 2. X (used in Textbook) # Results: # Welcome to Python Programming Class! 20

Hello Program (cont'd) • print ("Welcome to Python Programming Class!") • print ("-- Xiang!")

Hello Program (cont'd) • print ("Welcome to Python Programming Class!") • print ("-- Xiang!") ----------------------------- • print ("Welcome to Python Programming Class! n-- Xiang!") 21

Your First Assignment • Assignment #1 • The purpose of this assignment is to

Your First Assignment • Assignment #1 • The purpose of this assignment is to practice writing to shell and command-line window using Python 3. 4. It is a simple assignment. – Please submit Program listing and a screen capture of the program run. – Follow the textbook examples to add comments as documentation. 22

Assignment Submission • Make sure to include your name, assignment number, date due and

Assignment Submission • Make sure to include your name, assignment number, date due and date completed on each assignment you submit • Assignment should be submitted in a zip folder with your name and assignment number appearing on the tab • Submit your assignments to the Blackboard 23

Exercises • Install Python 3. 4 on your machine • Find a good Python

Exercises • Install Python 3. 4 on your machine • Find a good Python IDE (other than that on www. python. org) for programming graphical user interface (GUI) • How do you output the string “Total Square Feet: 1238” to the shell/command-line window. – Assume that 1238 in an integer stored in a variable called sq. Ft. • Describe 3 differences of Python from C++ 24

25

25