Lecture 27. Lecture 27: Regular Expressions and Python Identifiers

Similar documents
Basic Syntax - First Program 1

ENGR 101 Engineering Design Workshop

CHAPTER 2: Introduction to Python COMPUTER PROGRAMMING SKILLS

Variable and Data Type I

Introduction to Problem Solving and Programming in Python.

Variable and Data Type I

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

PROGRAMMING FUNDAMENTALS

Chapter 3 : Informatics Practices. Class XI ( As per CBSE Board) Python Fundamentals. Visit : python.mykvs.in for regular updates

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

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

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

About Variables in Python F E B 1 1 T H

CMSC 201 Computer Science I for Majors

Chapter 2 Writing Simple Programs

Basic Concepts. Computer Science. Programming history Algorithms Pseudo code. Computer - Science Andrew Case 2

CSCE 110 Programming I Basics of Python: Variables, Expressions, Input/Output

D R S H YA M N C H AW D A

Basic Programming. Hans-Martin von Gaudecker

Programming with Python

Introduction to Python

Key Differences Between Python and Java

Getting Started. Office Hours. CSE 231, Rich Enbody. After class By appointment send an . Michigan State University CSE 231, Fall 2013

Coding Styles for Python

Table of Contents EVALUATION COPY

CSCE 110 Programming I

SI Networked Computing: Storage, Communication, and Processing, Winter 2009

The Three Rules. Program. What is a Computer Program? 5/30/2018. Interpreted. Your First Program QuickStart 1. Chapter 1

Identifiers and Variables

Getting Started with Python

The float type and more on variables FEB 6 TH 2012

Hello, World and Variables

Short, Unique and Mysterious

STEAM Clown & Productions Copyright 2017 STEAM Clown. Page 1

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

Fundamentals of Programming (Python) Getting Started with Programming

4. The is a diagram that graphically depicts the steps that take place in a program. a. Program b. Flowchart c. Algorithm d. Code e.

Introduction to Python! Lecture 2

Fall 2017 CISC124 9/16/2017

Babu Madhav Institute of Information Technology, UTU 2015

Some material adapted from Upenn cmpe391 slides and other sources

Introduction to Programming

class objects instances Fields Constructors Methods static

CSE 142/143 Unofficial Style Guide

Datatypes, Variables, and Operations

Extended Introduction to Computer Science CS1001.py Lecture 10, part A: Interim Summary; Testing; Coding Style

CS 152 Computer Programming Fundamentals Coding Standards

1. What type of error produces incorrect results but does not prevent the program from running? a. syntax b. logic c. grammatical d.

Topic 2: Making Decisions

Topic 2: Making Decisions

Jython. secondary. memory

CS 351 Design of Large Programs Coding Standards

CS 251 Intermediate Programming Coding Standards

SOFT 161. Class Meeting 1.6

Ruby: Introduction, Basics

PIC 16: Iterators and Generators


Variables, expressions and statements

Python Basics. 1 of 7 9/5/2018, 8:51 AM. txt1 = "ada lovelace, english mathematician and writer" print(txt1)

Scripting Languages. Python basics

PYTHON- AN INNOVATION

PRG PROGRAMMING ESSENTIALS. Lecture 2 Program flow, Conditionals, Loops

Getting started 7. Saving data 23

PYTHON MOCK TEST PYTHON MOCK TEST III

LINKED LISTS AND MIDTERM REVIEW

Iterators & Generators

Computer Components. Software{ User Programs. Operating System. Hardware

c. Typically results in an intractably large set of test cases even for small programs

CS 5142 Scripting Languages

COMP519 Web Programming Lecture 21: Python (Part 5) Handouts

ENGR 105: Introduction to Scientific Computing. Dr. Graham. E. Wabiszewski

Constants. Variables, Expressions, and Statements. Variables. x = 12.2 y = 14 x = 100. Chapter

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression

Data types Expressions Variables Assignment. COMP1400 Week 2

Loops and Conditionals. HORT Lecture 11 Instructor: Kranthi Varala

Reminders. Lecture Outline. Lecture Agenda. Namespaces II. Namespaces I. COMP10001 Foundations of Computing PEP8, Modules and Files

Ruby: Introduction, Basics

CSE 11 Style Guidelines

SNS COLLEGE OF ENGINEERING,

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

Python in 10 (50) minutes

Selection statements. CSE 1310 Introduction to Computers and Programming Alexandra Stefan University of Texas at Arlington

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

Flow Control: Branches and loops

Java Bytecode (binary file)

Lecture Writing Programs. Richard E Sarkis CSC 161: The Art of Programming

Pythonic Coding Style. C-START Python PD Workshop


Introduction to Computer Programming for Non-Majors

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

Variables, Expressions, and Statements

CIS192 Python Programming. Robert Rand. August 27, 2015

SCoLang - Language Reference Manual

CSC148 Recipe for Designing Classes

A Foolish Consistency is the Hobgoblin of Little Minds

Python for ArcGIS. Lab 1.

EECS 280 C++ Coding Standards

Beyond Blocks: Python Session #1

MRO Delay Line. Coding and Documentation Guidelines for Prototype Delay Line Software. John Young. rev June 2007

Execution order. main()

Transcription:

Lecture 27 Lecture 27: Regular Expressions and Python Identifiers

Python Syntax Python syntax makes very few restrictions on the ways that we can name our variables, functions, and classes. Variables names must start with a letter or an underscore Every character after the first (if any) must be a letter, underscore, or number Names cannot be a reserved Python keyword: False class finally is return None continue for lambda try True def from nonlocal while and del global not with as elif if or yield assert else import pass break except in raise

Python Syntax Python syntax makes very few restrictions on the ways that we can name our variables, functions, and classes. Variables names must start with a letter or an underscore Every character after the first (if any) must be a letter, underscore, or number Names cannot be a reserved Python keyword: False class finally is return None continue for lambda try True def from nonlocal while and del global not with as elif if or yield assert else import pass break except in raise But Python s PEP 8 (Python Enhancement Proposal 8) specifies, in detail, a list of naming conventions. These are not enforced by the language. They are enforced by us as programmers.

Naming Styles Other languages also have naming conventions. Popular styles include: b (single lowercase letter) B (single uppercase letter) lowercase lower case with underscores UPPERCASE UPPER CASE WITH UNDERSCORES CapitalizedWords (or CapWords, or CamelCase, or StudlyCaps). mixedcase (differs from CapitalizedWords by initial lowercase character!) Capitalized Words With Underscores We can define regular expressions for each.

Naming Styles Other languages also have naming conventions. Popular styles include: b (single lowercase letter) [a-z] B (single uppercase letter) lowercase lower case with underscores UPPERCASE UPPER CASE WITH UNDERSCORES CapitalizedWords (or CapWords, or CamelCase, or StudlyCaps). mixedcase (differs from CapitalizedWords by initial lowercase character!) Capitalized Words With Underscores We can define regular expressions for each.

Naming Styles Other languages also have naming conventions. Popular styles include: b (single lowercase letter) [a-z] B (single uppercase letter) [A-Z] lowercase lower case with underscores UPPERCASE UPPER CASE WITH UNDERSCORES CapitalizedWords (or CapWords, or CamelCase, or StudlyCaps). mixedcase (differs from CapitalizedWords by initial lowercase character!) Capitalized Words With Underscores We can define regular expressions for each.

Naming Styles Other languages also have naming conventions. Popular styles include: b (single lowercase letter) [a-z] B (single uppercase letter) [A-Z] lowercase [a-z]+ lower case with underscores UPPERCASE UPPER CASE WITH UNDERSCORES CapitalizedWords (or CapWords, or CamelCase, or StudlyCaps). mixedcase (differs from CapitalizedWords by initial lowercase character!) Capitalized Words With Underscores We can define regular expressions for each.

Naming Styles Other languages also have naming conventions. Popular styles include: b (single lowercase letter) [a-z] B (single uppercase letter) [A-Z] lowercase [a-z]+ lower case with underscores [a-z][a-z ]* UPPERCASE UPPER CASE WITH UNDERSCORES CapitalizedWords (or CapWords, or CamelCase, or StudlyCaps). mixedcase (differs from CapitalizedWords by initial lowercase character!) Capitalized Words With Underscores We can define regular expressions for each.

Naming Styles Other languages also have naming conventions. Popular styles include: b (single lowercase letter) [a-z] B (single uppercase letter) [A-Z] lowercase [a-z]+ lower case with underscores [a-z][a-z ]* UPPERCASE [A-Z]+ UPPER CASE WITH UNDERSCORES CapitalizedWords (or CapWords, or CamelCase, or StudlyCaps). mixedcase (differs from CapitalizedWords by initial lowercase character!) Capitalized Words With Underscores We can define regular expressions for each.

Naming Styles Other languages also have naming conventions. Popular styles include: b (single lowercase letter) [a-z] B (single uppercase letter) [A-Z] lowercase [a-z]+ lower case with underscores [a-z][a-z ]* UPPERCASE [A-Z]+ UPPER CASE WITH UNDERSCORES [A-Z][A-Z ]* CapitalizedWords (or CapWords, or CamelCase, or StudlyCaps). mixedcase (differs from CapitalizedWords by initial lowercase character!) Capitalized Words With Underscores We can define regular expressions for each.

Naming Styles Other languages also have naming conventions. Popular styles include: b (single lowercase letter) [a-z] B (single uppercase letter) [A-Z] lowercase [a-z]+ lower case with underscores [a-z][a-z ]* UPPERCASE [A-Z]+ UPPER CASE WITH UNDERSCORES [A-Z][A-Z ]* CapitalizedWords (or CapWords, or CamelCase, or StudlyCaps). [A-Z][a-zA-Z]* mixedcase (differs from CapitalizedWords by initial lowercase character!) Capitalized Words With Underscores We can define regular expressions for each.

Naming Styles Other languages also have naming conventions. Popular styles include: b (single lowercase letter) [a-z] B (single uppercase letter) [A-Z] lowercase [a-z]+ lower case with underscores [a-z][a-z ]* UPPERCASE [A-Z]+ UPPER CASE WITH UNDERSCORES [A-Z][A-Z ]* CapitalizedWords (or CapWords, or CamelCase, or StudlyCaps). [A-Z][a-zA-Z]* mixedcase (differs from CapitalizedWords by initial lowercase character!) [a-z][a-za-z]* Capitalized Words With Underscores We can define regular expressions for each.

Naming Styles Other languages also have naming conventions. Popular styles include: b (single lowercase letter) [a-z] B (single uppercase letter) [A-Z] lowercase [a-z]+ lower case with underscores [a-z][a-z ]* UPPERCASE [A-Z]+ UPPER CASE WITH UNDERSCORES [A-Z][A-Z ]* CapitalizedWords (or CapWords, or CamelCase, or StudlyCaps). [A-Z][a-zA-Z]* mixedcase (differs from CapitalizedWords by initial lowercase character!) [a-z][a-za-z]* Capitalized Words With Underscores [A-Z][a-zA-Z ]* We can define regular expressions for each.

Python Conventions Python specifies specific naming conventions depending on the usage: Class names : Exceptions : local variables : Function names : Instance variables (public) : Instance variables (private) : Constants : Modules : Magic object or attribute :

Python Conventions Python specifies specific naming conventions depending on the usage: Class names : [A-Z][0-9a-zA-Z ]* Exceptions : local variables : Function names : Instance variables (public) : Instance variables (private) : Constants : Modules : Magic object or attribute :

Python Conventions Python specifies specific naming conventions depending on the usage: Class names : [A-Z][0-9a-zA-Z ]* Exceptions : [A-Z][0-9a-zA-Z ]*Error local variables : Function names : Instance variables (public) : Instance variables (private) : Constants : Modules : Magic object or attribute :

Python Conventions Python specifies specific naming conventions depending on the usage: Class names : [A-Z][0-9a-zA-Z ]* Exceptions : [A-Z][0-9a-zA-Z ]*Error local variables : [a-z][0-9a-z ]* Function names : Instance variables (public) : Instance variables (private) : Constants : Modules : Magic object or attribute :

Python Conventions Python specifies specific naming conventions depending on the usage: Class names : [A-Z][0-9a-zA-Z ]* Exceptions : [A-Z][0-9a-zA-Z ]*Error local variables : [a-z][0-9a-z ]* Function names : [a-z][0-9a-z ]*\( Instance variables (public) : Instance variables (private) : Constants : Modules : Magic object or attribute :

Python Conventions Python specifies specific naming conventions depending on the usage: Class names : [A-Z][0-9a-zA-Z ]* Exceptions : [A-Z][0-9a-zA-Z ]*Error local variables : [a-z][0-9a-z ]* Function names : [a-z][0-9a-z ]*\( Instance variables (public) : self\.[a-z][a-z0-9 ]* Instance variables (private) : Constants : Modules : Magic object or attribute :

Python Conventions Python specifies specific naming conventions depending on the usage: Class names : [A-Z][0-9a-zA-Z ]* Exceptions : [A-Z][0-9a-zA-Z ]*Error local variables : [a-z][0-9a-z ]* Function names : [a-z][0-9a-z ]*\( Instance variables (public) : self\.[a-z][a-z0-9 ]* Instance variables (private) : self\. [a-z][a-z0-9 ]* Constants : Modules : Magic object or attribute :

Python Conventions Python specifies specific naming conventions depending on the usage: Class names : [A-Z][0-9a-zA-Z ]* Exceptions : [A-Z][0-9a-zA-Z ]*Error local variables : [a-z][0-9a-z ]* Function names : [a-z][0-9a-z ]*\( Instance variables (public) : self\.[a-z][a-z0-9 ]* Instance variables (private) : self\. [a-z][a-z0-9 ]* Constants : [A-Z][A-Z0-9 ]* Modules : Magic object or attribute :

Python Conventions Python specifies specific naming conventions depending on the usage: Class names : [A-Z][0-9a-zA-Z ]* Exceptions : [A-Z][0-9a-zA-Z ]*Error local variables : [a-z][0-9a-z ]* Function names : [a-z][0-9a-z ]*\( Instance variables (public) : self\.[a-z][a-z0-9 ]* Instance variables (private) : self\. [a-z][a-z0-9 ]* Constants : [A-Z][A-Z0-9 ]* Modules : [a-z][0-9a-z ]{0,15} Magic object or attribute :

Python Conventions Python specifies specific naming conventions depending on the usage: Class names : [A-Z][0-9a-zA-Z ]* Exceptions : [A-Z][0-9a-zA-Z ]*Error local variables : [a-z][0-9a-z ]* Function names : [a-z][0-9a-z ]*\( Instance variables (public) : self\.[a-z][a-z0-9 ]* Instance variables (private) : self\. [a-z][a-z0-9 ]* Constants : [A-Z][A-Z0-9 ]* Modules : [a-z][0-9a-z ]{0,15} Magic object or attribute : ( [a-z] ) ( [a-z][a-z0-9 ]*[a-z0-9] )