Introduction to programming with Python

Slides:



Advertisements
Similar presentations
Week 1 basic Python programs, defining functions Special thanks to Scott Shawcroft, Ryan Tucker, and Paul Beck for their work on these slides. Except where.
Advertisements

INTRODUCTION TO PYTHON PART 2 INPUT AND OUTPUT CSC482 Introduction to Text Analytics Thomas Tiahrt, MA, PhD.
INTRODUCTION TO PYTHON PART 1 CSC482 Introduction to Text Analytics Thomas Tiahrt, MA, PhD.
Python. What is Python? A programming language we can use to communicate with the computer and solve problems We give the computer instructions that it.
Python Introduction.
1 Introduction to Programming with Python. 2 Some influential ones: FORTRAN science / engineering COBOL business data LISP logic and AI BASIC a simple.
Fundamentals of Python: From First Programs Through Data Structures
Python quick start guide
 Computer Science 1MD3 Introduction to Programming Michael Liut Brandon Da Silva
Python Programming Fundamentals
Introduction to Python
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 09/03/2010.
Computer Science 111 Fundamentals of Programming I Overview of Programming.
Goals of Course Introduction to the programming language C Learn how to program Learn ‘good’ programming practices.
Introduction to Programming Peggy Batchelor.
PYTHON: PART 2 Catherine and Annie. VARIABLES  That last program was a little simple. You probably want something a little more challenging.  Let’s.
Computer Science 101 Introduction to Programming.
Guide to Programming with Python Chapter One Getting Started: The Game Over Program.
Intro to Python Adriane Huber Debbie Bartlett Python Lab #1Python Lab #1 1.
C463 / B551 Artificial Intelligence Dana Vrajitoru Python.
Week 1 basic Python programs, defining functions Special thanks to Scott Shawcroft, Ryan Tucker, and Paul Beck for their work on these slides. Except where.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
1 Introduction to Programming with Python: overview.
A Python Tour: Just a Brief Introduction "The only way to learn a new programming language is by writing programs in it." -- B. Kernighan and D. Ritchie.
1. COMPUTERS AND PROGRAMS Rocky K. C. Chang September 6, 2015 (Adapted from John Zelle’s slides)
PROGRAMMING USING PYTHON LANGUAGE ASSIGNMENT 1. INSTALLATION OF RASPBERRY NOOB First prepare the SD card provided in the kit by loading an Operating System.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Intro to Programming STARS College of Communication and Information Florida State University Written by: Hannah Brock Alissa Ovalle Nicolaus Lopez Martin.
5. Algorithm 1: Variables, Operators, Sequences 1.
PROBLEM SOLVING WARM-UP Fill in the spaces using any operation to solve the following (!, (), -/+,÷,×): = 6.
Fundamentals of Programming I Overview of Programming
Development Environment
Lecture 8: Return values and math
A Python Tour: Just a Brief Introduction
GCSE COMPUTER SCIENCE Practical Programming using Python
GCSE COMPUTER SCIENCE Practical Programming using Python
Topics Introduction Hardware and Software How Computers Store Data
Topics Introduction to Repetition Structures
Lesson 1 An Introduction
Design & Technology Grade 7 Python
Variables, Expressions, and IO
basic Python programs, defining functions
Python is a general-purpose interpreted, interactive, object-oriented, and high-level programming language. It was created by Guido van Rossum during.
Introduction to Programming
Topics Introduction to Repetition Structures
1 Python Lab #1 Intro to Python Adriane Huber Debbie Bartlett.
CS190/295 Programming in Python for Life Sciences: Lecture 1
What Is a Program? A program is like an algorithm, but describes a process that is ready or can be made ready to run on a real computer Retrieved from:
Introduction to Python
Lecture 7: Graphics, return values and math
basic Python programs, defining functions
Learning Outcomes –Lesson 4
Topics Introduction Hardware and Software How Computers Store Data
Let's Learn Python and Pygame
T. Jumana Abu Shmais – AOU - Riyadh
Compilers and Interpreters
Introduction to Programming with Python
CS 1111 Introduction to Programming Spring 2019
ICT Programming Lesson 1:
Welcome to AP Computer Science A!
Experiment No. (1) - an introduction to MATLAB
12th Computer Science – Unit 5
Chapter 1: Programming Basics, Python History and Program Components
Introduction to Python
Introduction to Programming with Python
Class code for pythonroom.com cchsp2cs
Introduction to Computer Science
Programming for Business Computing Introduction
PYTHON - VARIABLES AND OPERATORS
Presentation transcript:

Introduction to programming with Python Faiza Qadri Graduate Student,Department of Engineering,SSU Society of Women Engineering Session:01

Languages

Why is it important Python started as a scripting language for Linux like Perl but less cryptic. Now it is used for both web and desktop applications and is available on Windows too. According to IEEE Spectrum,its one of the top 5 software languages Must have skill for a Software Engineer! One of the official languages at Google NASA uses Python! (https://www.python.org/about/success/usa/) Courses it is useful in:Wireless Systems,Networking,Analog & Digital Systems

A little History Python programming language was created by Guido Van Rossum in 1991 at at the National Research Institute for Mathematics and Computer Science in the Netherlands. The inventor is a fan of "Monty Python's Flying Circus", a comedy series from the seventies. Python is derived from many other languages, including C, C++, SmallTalk, and Unix shell and other scripting languages. Its design philosophy emphasizes code readability

Key Features Python is a high-level,interpreted,interactive and object-oriented scripting language Python is Interpreted:Similar to PERL and PHP Many languages require you to compile (translate) your program into a form that the machine understands. Python is instead directly interpreted into machine instructions. compile execute output source code Hello.java byte code Hello.class interpret output source code Hello.py

Key Features Python is Interactive Python is Object-oriented Python is a Beginner's Language

Lets get started!! Python Official Website : http://www.python.org/

Program #1 (Input ,Print) Input: Reads a number from user input. You can assign (store) the result of input into a variable. Example: age = input("How old are you?”) n=eval(input(‘enter the input’)) print (“Your age is", age) print (“You have", 65 - age, "years until retirement”) print : Produces text output on the console. Syntax: print (“Message”) print (Expression) Program #1 Number Game:Program that takes any 2-digit number and outputs a 6-digit number,having the 2-digit repeated.For-example,24 becomes 242424.

Math commands Python has useful commands for performing calculations. To use many of these commands, you must write the following at top of your Python program: import math Command name Description abs(value) absolute value ceil(value) rounds up cos(value) cosine, in radians floor(value) rounds down log(value) logarithm, base e log10(value) logarithm, base 10 max(value1, value2) larger of two values min(value1, value2) smaller of two values round(value) nearest whole number sin(value) sine, in radians sqrt(value) square root Constant Description e 2.7182818... pi 3.1415926...

Program #2 Program #02 Saving Interest Program Concepts:String Formatting,Functions,Modules

Branching Branching A program should be able to execute different statements depending on calculations or users input. If-else if expression: statements else: Statements if expression is false Statements here execute after the if-else. Multiple if-else,Use elif i if condition: elif condition: Program #3 Tweet Decoder:Write a program that decodes a few common abbreviations (tweets) or email and provides the corresponding English Phrase.

Lists & Dicts A list is a container, which is an object that groups related objects together. A list is also a sequence; thus, the contained objects maintain a left-to-right positional ordering.For example list1 = ['physics', 'chemistry', 1997, 2000]; list 2=[1,2,3,4,5]; list3 = [“a”,“b”,“c”,“d”] List Methods:list.append(x) , list.insert(i,x) , list.remove(x), list.pop(0) A dictionary is another sort of type of container Dictionaries contain references to objects as key-value pairs – each key in the dictionary is associated with a value .For-example dict = {'Alice': '2341', 'Beth': '9102', 'Cecil': ‘3258'} dict1 = { 'abc': 456 }; dict2 = { 'abc': 123, 98.6: 37 };

Program Extract IP address program

Loops Programmer can use a loop that executes the same code over and over again as long as some condition is true. While Loop while expression: # Loop expression # Loop body: Sub-statements to execute... # if the loop expression evaluates to True... # Statements to execute after the expression evaluates to False

Loops For Loop Syntax for variable in container: # Loop body: Sub-statements to execute # for each item in the container # Statements to execute after the for loop is complete Example:Square of a Number: for x in range(1, 6): print (“squared is", x * x) Program #4 Write a program to find the Factorial of a number(Use While or For Loop)’ Notes:2 things about loops:No of times we want to run the loop,There has to be an exit condition

Nested Loops Loop inside a loop Program#05 Write a program that uses a nested for- loop to find the prime numbers from 2 to 100

Program #06 Phone Number Program Program allows the user to enter a phone number that includes letters, which appear on phone keypads along with numbers, as is commonly used by companies as a marketing tactic (e.g., 1-555- HOLIDAY). The program then outputs the phone number using numbers only.

Continued.. Session :02 OOP