Introduction to Python

Similar documents
Basic Syntax - First Program 1

S206E Lecture 19, 5/24/2016, Python an overview

Introduction to Python

Introduction to Bioinformatics

CSC Software I: Utilities and Internals. Programming in Python

Key Differences Between Python and Java

SOFT 161. Class Meeting 1.6

Lecture 27. Lecture 27: Regular Expressions and Python Identifiers

Variable and Data Type I

PYTHON- AN INNOVATION

CHAPTER 2: Introduction to Python COMPUTER PROGRAMMING SKILLS

Variable and Data Type I

CS 115 Lecture 8. Selection: the if statement. Neil Moore

Python at Glance. a really fast (but complete) ride into the Python hole. Paolo Bellagente - ES3 - DII - UniBS

Python The way of a program. Srinidhi H Asst Professor Dept of CSE, MSRIT

Working with JavaScript

BIT Java Programming. Sem 1 Session 2011/12. Chapter 2 JAVA. basic

CpSc 1111 Lab 4 Part a Flow Control, Branching, and Formatting

Datatypes, Variables, and Operations

Computational Expression

Python - Variable Types. John R. Woodward

Compound Data Types 1

Variables and Values

Chapter 2 Working with Data Types and Operators

ENGR 101 Engineering Design Workshop

The C++ Language. Arizona State University 1

Python I. Some material adapted from Upenn cmpe391 slides and other sources

Basic Data Types and Operators CS 8: Introduction to Computer Science, Winter 2019 Lecture #2

LECTURE 02 INTRODUCTION TO C++

Lecture 2 Tao Wang 1

COMP1730/COMP6730 Programming for Scientists. Data: Values, types and expressions.

Data types Expressions Variables Assignment. COMP1400 Week 2

The current topic: Python. Announcements. Python. Python

Review. Input, Processing and Output. Review. Review. Designing a Program. Typical Software Development cycle. Bonita Sharif

Variables. Store information needed by the program

Chapter 2: Functions and Control Structures

Software and Programming 1

CISC-124. Dog.java looks like this. I have added some explanatory comments in the code, and more explanation after the code listing.

Introduction to C++ General Rules, Conventions and Styles CS 16: Solving Problems with Computers I Lecture #2

Basic Scripting, Syntax, and Data Types in Python. Mteor 227 Fall 2017

CSE 142/143 Unofficial Style Guide

DaMPL. Language Reference Manual. Henrique Grando

4. If the following Java statements are executed, what will be displayed?

PYTHON. Varun Jain & Senior Software Engineer. Pratap, Mysore Narasimha Raju & TEST AUTOMATION ARCHITECT. CenturyLink Technologies India PVT LTD

Chapter 2: Introduction to C++

BEFORE CLASS. If you haven t already installed the Firebug extension for Firefox, download it now from

Gaddis: Starting Out with Java: From Control Structures through Objects, 6/e

Chapter 2: Special Characters. Parts of a C++ Program. Introduction to C++ Displays output on the computer screen

GE8151- PROBLEM SOLVING AND PYTHON PROGRAMMING Question Bank

All programs can be represented in terms of sequence, selection and iteration.

Java Fall 2018 Margaret Reid-Miller

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG

Data Types and Variables in C language

Final Exam CS 152, Computer Programming Fundamentals December 9, 2016

Interactive use. $ python. >>> print 'Hello, world!' Hello, world! >>> 3 $ Ctrl-D

Starting Out with Java: From Control Structures through Data Structures 3e (Gaddis and Muganda) Chapter 2 Java Fundamentals

CMSC 201 Computer Science I for Majors

Hello, World and Variables

Interactive use. $ python. >>> print 'Hello, world!' Hello, world! >>> 3 $ Ctrl-D

VARIABLES. 1. STRINGS Data with letters and/or characters 2. INTEGERS Numbers without decimals 3. FLOATING POINT NUMBERS Numbers with decimals

Quiz 1: Functions and Procedures

CSI33 Data Structures

Topic 2: Making Decisions

Introduction to Computer Programming CSCI-UA 2. Review Midterm Exam 1

Topic 2: Making Decisions

Fall 2017 CISC124 9/16/2017

Programming Language. Control Structures: Selection (switch) Eng. Anis Nazer First Semester

3 The Building Blocks: Data Types, Literals, and Variables

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I

Overview. - General Data Types - Categories of Words. - Define Before Use. - The Three S s. - End of Statement - My First Program

egrapher Language Reference Manual

Full file at

Programming Syntax and Style. David Greenstein Monta Vista High School

PYTHON MOCK TEST PYTHON MOCK TEST III

CS201- Introduction to Programming Current Quizzes

Armstrong State University Engineering Studies MATLAB Marina Switch-Case Statements Primer

Decisions. Arizona State University 1

! A literal represents a constant value used in a. ! Numbers: 0, 34, , -1.8e12, etc. ! Characters: 'A', 'z', '!', '5', etc.

Visualize ComplexCities

Software and Programming 1

Introduction to programming with Python

CGS 3066: Spring 2015 JavaScript Reference

COLLEGE OF ENGINEERING, NASHIK-4

CS1 Lecture 3 Jan. 18, 2019

Java Bytecode (binary file)

MICROPROCESSOR SYSTEMS INTRODUCTION TO PYTHON

Enumerated Types. CSE 114, Computer Science 1 Stony Brook University

2. C99 standard guarantees uniqueness of characters for internal names. A. 12 B. 26 C. 31 D. 48

Functions & Variables !

Chapter 3, Selection. Liang, Introduction to Programming with C++, Second Edition, (c) 2010 Pearson Education, Inc. All rights reserved.

The Big Python Guide

UNIVERSITÀ DI PADOVA. < 2014 March >

Strings in Python 1 Midterm#1 Exam Review CS 8: Introduction to Computer Science Lecture #6

CS 1803 Pair Homework 3 Calculator Pair Fun Due: Wednesday, September 15th, before 6 PM Out of 100 points

Python in 10 (50) minutes

WINTER. Web Development. Template. PHP Variables and Constants. Lecture

Student Number: Comments are not required except where indicated, although they may help us mark your answers.

Text Input and Conditionals

Introduction to Java & Fundamental Data Types

Transcription:

Introduction to Python

Why is Python? Object-oriented Free (open source) Portable Powerful Mixable Easy to use Easy to learn

Running Python Immediate mode Script mode Integrated Development Environment (IDE) >>> print( hello world ) hello world

Keywords Variable name X Function name X Case sensitive

Keywords(Contd.)

Identifiers Combination of Letters (lowercase or uppercase) Digits (o to 9) Underscore (_) Example : myclass, Var_1 etc. Cannot start with digit. Example : 1var (wrong), var1 (right) Any length Keywords cannot be used Cannot use special symbols like :, @, $, % etc.

Remember Case sensitive Example : var and Var are different. Appropriate naming Example : count = 10 instead of c = 10. Multiple words can be separated using underscore Example : This_is_a_long_variable Camel-case style Example : camelcaseexample

Lines and Indentation No braces to indicate blocks Indentation must be of same amount Example : if True : print ( True ) else : print ( False )

Line continuation character (\) Example : Total = 1 + 2 + 3 \ 4 + 5 + 6 Multi-Line Statements [], {}, () don t need (\) Example : days = [ Monday, Tuesday, Wednesday, Thursday, Friday ]

Quotation ( ), ( ), ( ) or ( ) can be used. Example 1 : word = word Example 2 : paragaph = This is a paragraph

Comments One line Example : # This is a comment print( First comment ) Multiple line Example : # This is a # multiple line comment print( Multiple line comment )

Declaring Variables Assigning value to a variable Example : name = python print (name) Changing value of a variable Example : x = 2 x = 3 print (x)

Declaring Variables (Contd.) Assigning multiple values to multiple variables Example 1 : a, b, c = 5, 3.2, hello print ( a=, a, b =, b, c =, c) Example 2 : x = y = z = 1 print( x =, x, y =, y, z =, z)

Rules and naming convension Create an appropriate name camelcase notation Never use special symbols!, @, #, $, % etc Don t start with digit Combination of letters or digits or underscore

Literals Numeric Literals String Literals Boolean Literals Special Literals Literal Collection

Literals (Contd.) Numeric Literals Example : integer1 = 10 float1 = 19.7 String Literals Example : string1 = We are learning python

Literals(Contd.) Boolean Literals Example : x = (1 == True) y = (1 == False) Special Literals Example : food = None Literal Collections Example : fruits = [ apple, orange, banana ] integer_list = [1, 2, 3] vowels = { a, e, i, o, u }

Data Types Numbers Strings List Tuple Set Dictionary

Data Types (Contd.) Numbers Example : var1 = 7 var2 = 6.8 Strings Example : str = hello world List Example : lst = [1, 6, 9, 3, 7] print(lst) print(lst[0:2])

Data Types (Contd.) Tuples Example : tupl = ( a, b, c, d, e ) print(tupl[1:4]) Set Example : a = {5, 9, 7, 2, 8}

Data Types (Contd.) Dictionary Example : tinydict = {1: Monday, 2: Tuesday, 3: Wednesday } print(tinydict.keys()) print(tinydict.values()) print(tinydict[1])

Question numbers = [3, 6, 9, 12, 15, 18]. What is the type of numbers? Tuple List Set Dictionary

Question numbers = [3, 6, 9, 12, 15, 18]. What is the type of the elements in numbers? String Integer Float

Question numbers = [3, 6, 9, 12, 15, 18]. What is the result for numbers[2:4]? [6, 9, 12] [9, 12] [9, 12, 15] [6, 9]

Question student_record = { name : john, id : 806, dept = statistics }. What is the type of student_record? List Dictionary Set

Question student_record = { name : john, id : 806, dept = statistics }. What is the result for student_record[ dept ]? john 806 statistics

Question Valid name for a variable - 4digits _digits digit_s digit$

color = red color = green color = blue What will be the result for print(color)? red green blue Question