Introduction to Python

Similar documents
Lecture 1. basic Python programs, defining functions

Selection Statement ( if )

Python Input, output and variables. Lecture 23 COMPSCI111/111G SS 2018

The current topic: Python. Announcements. Python. Python

Chris Simpkins (Georgia Tech) CS 2316 Data Manipulation for Engineers Python Overview 1 / 9

What you get When you install Python for your computer, you get a number of features:

Get It Interpreter Scripts Arrays. Basic Python. K. Cooper 1. 1 Department of Mathematics. Washington State University. Basics

Introduction to Python. Didzis Gosko

CHAPTER 2: Introduction to Python COMPUTER PROGRAMMING SKILLS

Variable and Data Type I

Welcome to Python! Ilhoe Jung. Graphics & Media Lab

There are two ways to use the python interpreter: interactive mode and script mode. (a) open a terminal shell (terminal emulator in Applications Menu)

Table of Contents EVALUATION COPY

Python Input, output and variables

Python Input, output and variables. Lecture 22 COMPSCI111/111G SS 2016

Assembly Language Lab # 11 Kyboard input with int 16 & Macros

Short, Unique and Mysterious

Writing and Running Programs

CS 190C: Introduction to Computational Thinking

Computer Programming: C++

Variable and Data Type I

Programming Environments

Arrays. Eng. Mohammed Abdualal

Level 3 Computing Year 2 Lecturer: Phil Smith

Senthil Kumaran S

Introduction to computers and Python. Matthieu Choplin

Lab # 2. Sequential Statements

Variable and Data Type 2

CSE 101 Introduction to Computers Development / Tutorial / Lab Environment Setup

Python for Analytics. Python Fundamentals RSI Chapters 1 and 2

Flow Control: Branches and loops

Lab1. Introduction to Python. Lab 4: Selection Statement. Eng. Mai Z. Alyazji

SQL Retrieving Data from Multiple Tables

Python is available at: Why Python is awesome:

Lab # 6. Using Subqueries and Set Operators. Eng. Alaa O Shama

There are two ways to use the python interpreter: interactive mode and script mode. (a) open a terminal shell (terminal emulator in Applications Menu)

Introduction to Python

Eclipse. JVM, main method and using Eclipse. Dr. Siobhán Drohan. Produced by: Department of Computing and Mathematics

Notepad++ The COMPSCI 101 Text Editor for Windows. What is a text editor? Install Python 3. Installing Notepad++

Programming for AmI MOTIVATIONS AND GOALS

JatinSir - Mastering Python

Eng. Mohammed Alokshiya

Week - 01 Lecture - 04 Downloading and installing Python

Chapter 2 Getting Started with Python

Computer Programming: C++

Faculty of Engineering Computer Engineering Department Islamic University of Gaza C++ Programming Language Lab # 6 Functions

You Need an Interpreter! Comp Spring /28/08 L10 - An Interpreter

Semester 2, 2018: Lab 1

Eng. Mohammed S. Abdualal

STEAM Clown & Productions Copyright 2017 STEAM Clown. Page 1

ERTH3021 Exploration and Mining Geophysics

BCH339N Systems Biology/Bioinformatics Spring 2018 Marcotte A Python programming primer

Eng. Mohammed S. Abdualal

Introduction to Python, Cplex and Gurobi

Introduction to Programming

Hacettepe University Computer Engineering Department. Programming in. BBM103 Introduction to Programming Lab 1 Week 4. Fall 2018

Winter 2019 CISC101 1/17/2019

AP Computer Science A Summer Assignment

LAB 1: FAMILIARITY WITH NETBEANS IDE ENVIRONMENT

CS2900 Introductory Programming with Python and C++ Kevin Squire LtCol Joel Young Fall 2007

Welcome to Python! If you re the type of person who wants to know

Introduction to Programming

Level 3 Computing Year 2 Lecturer: Phil Smith

Welcome to the Bash Workshop!

Tcl/Tk for XSPECT a Michael Flynn

Introduction to Python

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming

Computer Science AP 2017 Summer Assignment Mrs. McFarland

DSC 201: Data Analysis & Visualization

Computer and Programming: Lab 1

Reading Input from Text File

CS Introduction to Computational and Data Science. Instructor: Renzhi Cao Computer Science Department Pacific Lutheran University Spring 2017

Introduction to Python. Prof. Steven Ludtke

Welcome to Python 3. Some history

Introduction to Python - Part I CNV Lab

Some material adapted from Upenn cmpe391 slides and other sources

Rapid Application Development with

Professor Hugh C. Lauer CS-1004 Introduction to Programming for Non-Majors

OOP and Scripting in Python

Eclipse Environment Setup

Introduction to Programming with Python. By: Victoria Kahian and Kyla Boswell

CS 1110 SPRING 2016: GETTING STARTED (Jan 27-28) First Name: Last Name: NetID:

Welcome to the Bash Workshop!

The >>> is a Python prompt indicating that Python is ready for us to give it a command. These commands are called statements.

Disk Operating System

Computer Science Seminar. Whats the next big thing? Ruby? Python? Neither?

History Installing & Running Python Names & Assignment Sequences types: Lists, Tuples, and Strings Mutability

Python Development with PyDev and Eclipse -

Adding Existing Source Code in NetBeans CS288, Autumn 2005 Lab 002

Component V Supporting Materials / Learn More Interesting Facts. Interesting Facts

age = 23 age = age + 1 data types Integers Floating-point numbers Strings Booleans loosely typed age = In my 20s

Week One: Introduction A SHORT INTRODUCTION TO HARDWARE, SOFTWARE, AND ALGORITHM DEVELOPMENT

Vortex OpenSplice. Python DDS Binding

Python Workshop. January 18, Chaitanya Talnikar. Saket Choudhary

Introduction to programming with Python

Episode 1 Using the Interpreter

Downloaded from Chapter 2. Functions

Introduction to Python for Scientific Computing

Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 4111: Digital Systems Design Lab. Lab # 5. Concurrent Statements

Accelerating Information Technology Innovation

Transcription:

Islamic University Of Gaza Faculty of Engineering Computer Engineering Department Lab 1 Introduction to Python Eng. Ibraheem Lubbad September 17, 2016

Introduction: Python is a high-level, object-oriented programming language created by Guido van Rossum. Python is used for software development at companies and organizations such as Google, Yahoo, and NASA, it is designed to be highly readable. It has a very easy-to-use and simple syntax, making it the perfect language for someone trying to learn computer programming for the first time. It s is an interpreted language. Interpreter is a program that converts the high-level program we write into low-level program that the computer understands. There are two major Python versions, Python 2 and Python 3. Python 2 and 3 are quite different. For our lab, we will use Python 2 Programs written in Python are typically much shorter than equivalent C, C++, or Java programs, for several reasons: The high-level data types allow you to express complex operations in a single statement. Java Python Statement grouping is done by indentation instead of beginning and ending brackets {}. Java Python No variable or argument declarations are necessary. as first example

Writing a Python Program: Python programs must be written with a particular structure. The syntax must be correct, or the interpreter will generate error messages and not execute the program. Listing 1.1 (hello.py) is one of the simplest Python programs that does something: Example 1: hello.py print( "This is a simple Python program" ) Installing Python: Installing Python is an easy task, after download file, we simply double-click this icon to open the Python.

Then follow steps to setup Python:

The following icon appears after type search window from now on we simply doubleclick this icon to open the Python IDE, it is a simple IDE.

The command window, shell, appears: There two different modes of programming: 1. Interactive Mode Programming: Invoking the interpreter without passing a script file as a parameter. We can see the prompt >>>, where we can write and execute Python code in interactive mode. At the prompt, enter your first command. Output 2. Script Mode Programming (batch mode): Invoking the interpreter with a script parameter begins process of writing and executing the lines of Python code one by one until the script is finished. When the script is finished, the interpreter is no longer active. This becomes impractical for larger programs, so an alternative exists. In batch mode, we first write all the lines in a separate file, and then run them all at once.

Let us write a simple Python program in a script. Python files have extension.py type the following source code in a hello.py file. In the shell window, click File New File A new window appears, without the Python prompt >>> Where we can enter one or more Python commands before executing them all at once. When you re ready, click Run Run Module (or just press the function key F5). IDLE will first ask you to save the file, then it will execute it, with the results shown back in the shell window.

In our lab we will use another IDE (Integrated development environment) called PyCharm Community Edition: Firstly sure Python interpreter is downloaded and installed on your computer (that we did it) Then make double-click this icon to open the PyCharm then click Next >

Click on Create New Project: Select location project and its name, and sure you select correct Python interpret Then click on Create. Select Python interpret

Right Click on the Project File in our example (FirstProject) Then click New Python File Insert a new File Name And Kind of file in our case (Python)

PyCharm WorkSpace: After when you are write script code click Run Run script file (or press the function key shift +F10). Script Window Project Files Output Window Alos you can run Python shell through Pycharm by click Tools Python Console Test Python Console:

Work Lab: Example 2: arrow.py print(" * ") print(" *** ") print(" ***** ") print(" * ") print(" * ") print(" * ") print(" * ") Output of Example 2 (arrow.py):

Exercises: 1) What is an interpreter? 2) What is necessary to execute a Python program? 3) Write a program that displays Welcome to Engineering, Welcome to Python, and Programming is fun (Display three messages). 4) Write a program that displays the following pattern? (Display a pattern). END