Lecture 4. Introduction to Python! Lecture 4

Size: px
Start display at page:

Download "Lecture 4. Introduction to Python! Lecture 4"

Transcription

1 Lecture 4 Introduction to Python Lecture 4

2 Summary Modules (general things) Using modules Importing modules Standard Library modules Modules search path Import modules phases Packages Organizing Python applications

3 Modules Python modules Module File level program data Program and data packed together

4 Roles Code persistence Place to define names (attributes) Supports modular design architecture Code Reuse Module

5 Roles Code persistence Place to define names (attributes) Supports modular design architecture Code Reuse Module System namespace partitioning Avoids name clashing across the programs The names defined in modules are self-contained, they can be seen in other files only by using import

6 Roles Code persistence Place to define names (attributes) Supports modular design architecture Code Reuse Implementing shared services and data Module System namespace partitioning Helpful in implementing components shared across a program, requiring a single copy Avoids name clashing across the programs The names defined in modules are self-contained, they can be seen in other files only by using import

7 Python program structure module 2 Contains the main flow of the program This file runs when application launches module 1 Python top level file module 3 Modules usually are collections of functions and attributes module N One main top level file Zero or more additional files, named modules

8 Using modules Let s suppose we want to create a table header that looks like: id....name....title contains functions used to draw tables table.py main.py top level file strings.py contains functions used to decorate strings

9 Using modules def line(n): """ creates a dashed line of n dots """ return '-' * n table.py import table import strings print(table.line(30)) print(strings.dots('id') + ' ' + strings.dots('name') + ' ' + strings.dots('title')) print(table.line(30)) def dots(s): """ add dots in front and after a string sent as parameter """ return '..' + s + '..' strings.py main.py

10 Using modules Note that when importing table.py module, we are writing import table without using.py extension Importing table module gives access to the all the attributes defined at the top level of the table.py file. The modules import operation is performed at runtime. If the module defines objects, they are created at runtime, as the import executes. import table print(table.line(30)) Here, the method line(n) of the module table is used in the main.py file Python uses the object.attribute notation. This means Python fetches the attributes defined in different objects by the. operator.

11 Importing modules b.py a.py main.py If main.py depends on a.py and c.py, but a.py depends on b.py and copy depends on d.py, Pyhton will load all dependencies, no matter how deeper it should go through dependencies chain. c.py d.py If many files have a common dependency, that one will be loaded only once.

12 Standard Library Modules Standard Library Modules Collection of more than 200 modules, providing support for: object persistence operating system interfaces network scripting internet scripting GUI text pattern matching math many more These modules are not part of the core Python language, but they can be used by importing them. Also, coming in the Python distribution, you can be sure they work on most platforms Python runs.

13 Some modules from Python Standars Library Module Description datetime tempfile csv hashlib logging threading html os Performs calculation using date and time Functions for working with temporary files and directories CSV files processing Cryptographically secure hashes Write log messages and manages log files Supports multi-threading programming Collection of modules used to parse and generate HTML documents Supports calls to the OS specific commands

14 Examples of using standard library import calendar print(calendar.isleap(1900)) print(calendar.isleap(1993)) print(calendar.isleap(2000)) Output: False False True import random cars = ['Mercedes', 'Audi', 'BMW', 'Opel'] print(random.choice(cars)) Output: Opel import math print(math.radians(90)) print(math.sin(math.radians(90))) Output: import os print(os.getcwd()) Output: /PycharmProjects/uvt/lect-4

15 Backstage of the import operation example code here example.h #include example.h caller code here caller.cpp preprocessor a.py Find a.py Compile a.py Run a.py example code here caller code here C++ language main.py Python language

16 Modules search path In order to localise a module, Python looks for it on some predefined locations: 1. The home directory of the program 2. PYTHONPATH directory 3. Standard Library directories 4. The contant of any.pth file, if this is present 5. The site-packages home for third party extensions The result of concatenation of all these paths is a variable called sys.path (we ll talk about it later in this chapter)

17 Import phases Find modules Python does not require the path of the module in import Python does not require the extension of the file module in import (.py) It uses a module search path and known file types to locate the required modules Compile modules After the module was found, using the search method described above, it compiles in in byte code, if some conditions occur: Checks the timestamp of the Python source code (.py) and the timestamp of the compiled code (.pyc). If the source timestamp is newer than compiled timestamp, the code is compiled again. Python 3.2 or newer: the compiled files are aggregated under a pycache directory Suppose you have a file called base.py, Python creates a pycache subdirectory and inside there will be a file called base.cpython-25.pyc (if the current Python version is 3.5)

18 Import phases Compilation occurs only when the module is imported somewhere. Only the files that were imported have the.pyc correspondent. The top-level file also does not have a.pyc file, unless it was imported elsewhere. As a general rule, top-level files are designed to be executed directly and not imported. However, the top-level modules are also compiled but their byte code is discarded immediately after execution Run modules All the statements written in the file are executed from top to bottom and any assignment made to different names become attributes of the resulting module object. def fact(x): if x == 1: return 1 else: return x * fact(x -1) def runs at import time, creating the fact function, then it assigns an attribute with the same name in the module

19 Conclusions for modules import Some important conclusions related to modules import Importing a module is a complex process It requires finding it, compiling if necessary, then running it Due to its complexity, importing of a module is performed only once per process (by default) Any other attempt to import the same module after it was already imported will skip all the import phases and will use de module loaded in memory

20 Where Python looks for modules? In order to see where Python is looking for modules, run the following commands, from the interpreter (but they could be run from program too) >>> import sys >>> sys.path sys.path is a system variable A concrete example for which the output is: ['/Applications/PyCharm CE 2.app/Contents/helpers/pydev', '/Applications/ PyCharm CE 2.app/Contents/helpers/pydev', '/Projects/UVT/python_env/lib/ python35.zip', '/Projects/UVT/python_env/lib/python3.5', '/Projects/UVT/ python_env/lib/python3.5/plat-darwin', '/Projects/UVT/python_env/lib/ python3.5/lib-dynload', '/usr/local/cellar/python3/3.5.2/frameworks/ Python.framework/Versions/3.5/lib/python3.5', '/usr/local/cellar/ python3/3.5.2/frameworks/python.framework/versions/3.5/lib/python3.5/ plat-darwin', '/Projects/UVT/python_env/lib/python3.5/site-packages', '/ PycharmProjects/uvt/lab 4']

21 Extending sys.path If we need to extend the path in which Python searches for modules, we can append the new path to the sys.path variable. Suppose we want to add a new directory called ProgEnvExamples located in /Projects/UVT >>> sys.path.append('/projects/uvt/progenvexamples') >>> sys.path And now the output is: ['/Applications/PyCharm CE 2.app/Contents/helpers/pydev', '/Applications/ PyCharm CE 2.app/Contents/helpers/pydev', '/Projects/UVT/python_env/lib/ python35.zip', '/Projects/UVT/python_env/lib/python3.5', '/Projects/UVT/ python_env/lib/python3.5/plat-darwin', '/Projects/UVT/python_env/lib/ python3.5/lib-dynload', '/usr/local/cellar/python3/3.5.2/frameworks/ Python.framework/Versions/3.5/lib/python3.5', '/usr/local/cellar/ python3/3.5.2/frameworks/python.framework/versions/3.5/lib/python3.5/ plat-darwin', '/Projects/UVT/python_env/lib/python3.5/site-packages', '/ PycharmProjects/uvt/lab 4, '/Projects/UVT/ProgEnvExamples'] This is a temporary change. When exiting Python, the change will disappear

22 Importing names from a module Now, that we ve found how imports work, let s take a closer look on how we can avoid memory overloading with unnecessary imports. Suppose we need some functions from one or many big modules. Say that our module is called database which contains a lot of methods related to processing records from a database, but our program does need only a method that selects specific records, called select. We can access the select method in two ways: 1 import database database.select(args) In this case, Python loads the entire module, create the function objects in memory, prepares the module for being used by the caller If it is large, it will occupy memory for attributes that will never being used. 2 from database import select select(args) In this case, Python loads only the select method in memory and prepares the module for being used by the caller Only a small amount of memory will be used.

23 Running modules from the command line Python supports a similar functionality with other programming languages in what concerns the main() function, which executes when the application is launched. Usually, top-level files are designed with this feature in mind. def main(): print('hi from command line') if name == ' main ': main() global variable which is set by the Python interpreter to main when the user starts the program

24 Packages Python allows module to group classes and function together for a better organisation. One level up, it allows to group modules having common characteristics in something called a package. Considering we have an application processing geometrical shapes, we can have a file structure like: /shapes init.py square.py rectangle.py circle.py triangle.py polygon.py package name special file called package initialisation file import shapes.circle a = shapes.circle.area(radius) print(a) Note the. (dot) notation

25 Initialising a package When initialising a package, it is possible to write some code inside init.py file of the my_package package. def greetings(msg): print(msg) The greetings function will be available at the package level When called, the code looks like this: import my_package my_package.greetings( Hi, package ) Even it looks tempting to put some code there, it isn t always a good idea, from the organisation point of view. The code should be kept tied to the modules, to split the functionality and keep the consistence

26 Initialising a package If it is still the need for accessing a function at the package level, a better approach is to define a function at a module level, then import it in init.py file. In this way it will become available at the package level. my_module.py file: def greetings(msg): print(msg) init.py file: from my_package.my_module import greetings When called, the code looks like this: import my_package my_package.greetings( Hi, package )

27 Catalogue application User User interface Users Authentication Grades Viewer Grades Editor Reports Viewer API Backend Database Reports Generator Errors processor s processor

28 Organizing the application /user_interface init.py users_auth.py viewer.py editor.py reports.py api.py } packages /backend init.py database.py report_generator.py error_processor.py er.py } modules

29 Advantages of using modules Module 1 Module 2 New Module Main program Module 3 When a new functionality is needed, a new module can be added without interfering with the other modules. Module 1 Module 2 Change Module Module 3 When some changes are required inside a module, they are isolated, they don t affect the already existing modules Main program

30 Conclusions Modules and packages are a way to structure Python programs to support large applications The process through modules can be used in Python applications is called import The modules import has three phases: module finding, compiling (if necessary) and run

Modules and Packages. CS 339R (Python) Chapter 8

Modules and Packages. CS 339R (Python) Chapter 8 Modules and Packages CS 339R (Python) Chapter 8 Spring 2011 Loading a Module The import statement: Reads the source file Creates a module object in the current scope Executes all top-level statements You

More information

Import That! Import Basics. I have a small confession: I often think that I don t fully understand the Python

Import That! Import Basics. I have a small confession: I often think that I don t fully understand the Python Import That! DAVID BEAZLEY David Beazley is an open source developer and author of the Python Essential Reference (4th Edition, Addison-Wesley, 2009). He is also known as the creator of Swig (http://www.swig.org)

More information

Lessons on Python Modules and Packages

Lessons on Python Modules and Packages Lessons on Python Modules and Packages Walter Didimo [ 60 minutes ] Programs so far So far we have written and tested simple programs in one of the two following ways: using the Python interactive mode

More information

CS Programming Languages: Python

CS Programming Languages: Python CS 3101-1 - Programming Languages: Python Lecture 5: Exceptions / Daniel Bauer (bauer@cs.columbia.edu) October 08 2014 Daniel Bauer CS3101-1 Python - 05 - Exceptions / 1/35 Contents Exceptions Daniel Bauer

More information

Data type built into Python. Dictionaries are sometimes found in other languages as associative memories or associative arrays.

Data type built into Python. Dictionaries are sometimes found in other languages as associative memories or associative arrays. NETB 329 Lecture 4 Data Structures in Python Dictionaries Data type built into Python. Dictionaries are sometimes found in other languages as associative memories or associative arrays. 1 of 70 Unlike

More information

Webgurukul Programming Language Course

Webgurukul Programming Language Course Webgurukul Programming Language Course Take One step towards IT profession with us Python Syllabus Python Training Overview > What are the Python Course Pre-requisites > Objectives of the Course > Who

More information

Python Training. Complete Practical & Real-time Trainings. A Unit of SequelGate Innovative Technologies Pvt. Ltd.

Python Training. Complete Practical & Real-time Trainings. A Unit of SequelGate Innovative Technologies Pvt. Ltd. Python Training Complete Practical & Real-time Trainings A Unit of. ISO Certified Training Institute Microsoft Certified Partner Training Highlights : Complete Practical and Real-time Scenarios Session

More information

PTN-202: Advanced Python Programming Course Description. Course Outline

PTN-202: Advanced Python Programming Course Description. Course Outline PTN-202: Advanced Python Programming Course Description This 4-day course picks up where Python I leaves off, covering some topics in more detail, and adding many new ones, with a focus on enterprise development.

More information

Babes-Bolyai University

Babes-Bolyai University Babes-Bolyai University arthur@cs.ubbcluj.ro Overview 1 Modules programming - a software design technique that increases the extent to which software is composed of independent, interchangeable components

More information

Intermediate Python 3.x

Intermediate Python 3.x Intermediate Python 3.x This 4 day course picks up where Introduction to Python 3 leaves off, covering some topics in more detail, and adding many new ones, with a focus on enterprise development. This

More information

Alastair Burt Andreas Eisele Christian Federmann Torsten Marek Ulrich Schäfer. October 6th, Universität des Saarlandes. Introduction to Python

Alastair Burt Andreas Eisele Christian Federmann Torsten Marek Ulrich Schäfer. October 6th, Universität des Saarlandes. Introduction to Python Outline Alastair Burt Andreas Eisele Christian Federmann Torsten Marek Ulrich Schäfer Universität des Saarlandes October 6th, 2009 Outline Outline Today s Topics: 1 More Examples 2 Cool Stuff 3 Text Processing

More information

Modules and scoping rules

Modules and scoping rules C H A P T E R 1 1 Modules and scoping rules 11.1 What is a module? 106 11.2 A first module 107 11.3 The import statement 109 11.4 The module search path 110 11.5 Private names in modules 112 11.6 Library

More information

GIS 4653/5653: Spatial Programming and GIS. More Python: Statements, Types, Functions, Modules, Classes

GIS 4653/5653: Spatial Programming and GIS. More Python: Statements, Types, Functions, Modules, Classes GIS 4653/5653: Spatial Programming and GIS More Python: Statements, Types, Functions, Modules, Classes Statement Syntax The if-elif-else statement Indentation and and colons are important Parentheses and

More information

Computer Science 21b (Spring Term, 2015) Structure and Interpretation of Computer Programs. Lexical addressing

Computer Science 21b (Spring Term, 2015) Structure and Interpretation of Computer Programs. Lexical addressing Computer Science 21b (Spring Term, 2015) Structure and Interpretation of Computer Programs Lexical addressing The difference between a interpreter and a compiler is really two points on a spectrum of possible

More information

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

Chris Simpkins (Georgia Tech) CS 2316 Data Manipulation for Engineers Python Overview 1 / 9 http://xkcd.com/353/ Chris Simpkins (Georgia Tech) CS 2316 Data Manipulation for Engineers Python Overview 1 / 9 Python Python is a general-purpose programming language, meaning you can write any kind

More information

Table of Contents EVALUATION COPY

Table of Contents EVALUATION COPY Table of Contents Introduction... 1-2 A Brief History of Python... 1-3 Python Versions... 1-4 Installing Python... 1-5 Environment Variables... 1-6 Executing Python from the Command Line... 1-7 IDLE...

More information

assembler Machine Code Object Files linker Executable File

assembler Machine Code Object Files linker Executable File CSCE A211 Programming Intro What is a Programming Language Assemblers, Compilers, Interpreters A compiler translates programs in high level languages into machine language that can be executed by the computer.

More information

Problem 1 (a): List Operations

Problem 1 (a): List Operations Problem 1 (a): List Operations Task 1: Create a list, L1 = [1, 2, 3,.. N] Suppose we want the list to have the elements 1, 2, 10 range(n) creates the list from 0 to N-1 But we want the list to start from

More information

Code architecture and organisation

Code architecture and organisation RenderDoc Code architecture and organisation This document covers RenderDoc at a high level, giving you an idea of how the UI is separated from the rest of the code and generally how the capture & replay

More information

LECTURE 2. Python Basics

LECTURE 2. Python Basics LECTURE 2 Python Basics MODULES ''' Module fib.py ''' from future import print_function def even_fib(n): total = 0 f1, f2 = 1, 2 while f1 < n: if f1 % 2 == 0: total = total + f1 f1, f2 = f2, f1 + f2 return

More information

JavaScript Fundamentals_

JavaScript Fundamentals_ JavaScript Fundamentals_ HackerYou Course Syllabus CLASS 1 Intro to JavaScript Welcome to JavaScript Fundamentals! Today we ll go over what programming languages are, JavaScript syntax, variables, and

More information

Core Python is small by design

Core Python is small by design Core Python is small by design One of the key features of Python is that the actual core language is fairly small. This is an intentional design feature to maintain simplicity. Much of the powerful functionality

More information

Modules and Programs 1 / 14

Modules and Programs 1 / 14 Modules and Programs 1 / 14 Python Programs Python code organized in modules, packages, and scripts. We ve already used some modules, now we ll learn what they are, how they re orgainized in packages,

More information

PYTHON CONTENT NOTE: Almost every task is explained with an example

PYTHON CONTENT NOTE: Almost every task is explained with an example PYTHON CONTENT NOTE: Almost every task is explained with an example Introduction: 1. What is a script and program? 2. Difference between scripting and programming languages? 3. What is Python? 4. Characteristics

More information

Introduction to Python (All the Basic Stuff)

Introduction to Python (All the Basic Stuff) Introduction to Python (All the Basic Stuff) 1 Learning Objectives Python program development Command line, IDEs, file editing Language fundamentals Types & variables Expressions I/O Control flow Functions

More information

6 Git & Modularization

6 Git & Modularization 6 Git & Modularization Bálint Aradi Course: Scientific Programming / Wissenchaftliches Programmieren (Python) Prerequisites Additional programs needed: Spyder3, Pylint3 Git, Gitk KDiff3 (non-kde (qt-only)

More information

Flow Control: Branches and loops

Flow Control: Branches and loops Flow Control: Branches and loops In this context flow control refers to controlling the flow of the execution of your program that is, which instructions will get carried out and in what order. In the

More information

6.096 Introduction to C++

6.096 Introduction to C++ MIT OpenCourseWare http://ocw.mit.edu 6.096 Introduction to C++ January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. 6.096 Lecture 3 Notes

More information

TH IRD EDITION. Python Cookbook. David Beazley and Brian K. Jones. O'REILLY. Beijing Cambridge Farnham Köln Sebastopol Tokyo

TH IRD EDITION. Python Cookbook. David Beazley and Brian K. Jones. O'REILLY. Beijing Cambridge Farnham Köln Sebastopol Tokyo TH IRD EDITION Python Cookbook David Beazley and Brian K. Jones O'REILLY. Beijing Cambridge Farnham Köln Sebastopol Tokyo Table of Contents Preface xi 1. Data Structures and Algorithms 1 1.1. Unpacking

More information

Using Introspect ESP Python Modules in External Python Scripts

Using Introspect ESP Python Modules in External Python Scripts Using Introspect ESP Python Modules in External Python Scripts This document discusses the use of the Python modules that are supplied with Introspect IESP in external Python scripts that you write. The

More information

Decisions, Decisions. Testing, testing C H A P T E R 7

Decisions, Decisions. Testing, testing C H A P T E R 7 C H A P T E R 7 In the first few chapters, we saw some of the basic building blocks of a program. We can now make a program with input, processing, and output. We can even make our input and output a little

More information

CS1 Lecture 4 Jan. 24, 2018

CS1 Lecture 4 Jan. 24, 2018 CS1 Lecture 4 Jan. 24, 2018 First homework due Mon., 9:00am Meet specifications precisely. Functions only. Use a file editor! Don t type functions/long sections of code directly into Python interpreter.

More information

Intro. Scheme Basics. scm> 5 5. scm>

Intro. Scheme Basics. scm> 5 5. scm> Intro Let s take some time to talk about LISP. It stands for LISt Processing a way of coding using only lists! It sounds pretty radical, and it is. There are lots of cool things to know about LISP; if

More information

Java Bytecode (binary file)

Java Bytecode (binary file) Java is Compiled Unlike Python, which is an interpreted langauge, Java code is compiled. In Java, a compiler reads in a Java source file (the code that we write), and it translates that code into bytecode.

More information

NOTES ON RUNNING PYTHON CODE

NOTES ON RUNNING PYTHON CODE NOTES ON RUNNING PYTHON CODE ERIC MARTIN Part 1. Setting things up The School has python 3.2.3 installed. 1. Installing python if necessary On personal computers with no version of python 3 installed,

More information

BlenderPanda Documentation. Release 0.1.0

BlenderPanda Documentation. Release 0.1.0 BlenderPanda Documentation Release 0.1.0 May 01, 2018 Contents 1 Getting Started 3 1.1 Installing BlenderPanda......................................... 3 1.2 Viewport Preview............................................

More information

UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division. P. N. Hilfinger

UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division. P. N. Hilfinger UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division CS 164 Spring 2018 P. N. Hilfinger Project #2: Static Analyzer Due: Friday, 6 April 2018 The

More information

Scripting With Jython

Scripting With Jython Scripting With Jython In this chapter, we will look at scripting with Jython. For our purposes, we will define scripting as the writing of small programs to help out with daily tasks. These tasks are things

More information

Introduction to Python: Data types. HORT Lecture 8 Instructor: Kranthi Varala

Introduction to Python: Data types. HORT Lecture 8 Instructor: Kranthi Varala Introduction to Python: Data types HORT 59000 Lecture 8 Instructor: Kranthi Varala Why Python? Readability and ease-of-maintenance Python focuses on well-structured easy to read code Easier to understand

More information

The Dynamic Typing Interlude

The Dynamic Typing Interlude CHAPTER 6 The Dynamic Typing Interlude In the prior chapter, we began exploring Python s core object types in depth with a look at Python numbers. We ll resume our object type tour in the next chapter,

More information

CS1 Lecture 4 Jan. 23, 2019

CS1 Lecture 4 Jan. 23, 2019 CS1 Lecture 4 Jan. 23, 2019 First graded discussion sections this week yesterday/today 10 DS assignments worth 2 points each everyone gets one free 2-pointer. I.e. your lowest DS grade will be replaced

More information

Shell / Python Tutorial. CS279 Autumn 2017 Rishi Bedi

Shell / Python Tutorial. CS279 Autumn 2017 Rishi Bedi Shell / Python Tutorial CS279 Autumn 2017 Rishi Bedi Shell (== console, == terminal, == command prompt) You might also hear it called bash, which is the most widely used shell program macos Windows 10+

More information

Lecture #2: Programming Structures: Loops and Functions

Lecture #2: Programming Structures: Loops and Functions UC Berkeley EECS Adj. Ass. Prof. Dr. Gerald Friedland Computational Structures in Data Science Lecture #2: Programming Structures: Loops and Functions Administrivia If you are waitlisted: Please wait.

More information

CS1102: Macros and Recursion

CS1102: Macros and Recursion CS1102: Macros and Recursion Kathi Fisler, WPI October 5, 2009 This lecture looks at several more macro examples. It aims to show you when you can use recursion safely with macros and when you can t. 1

More information

STATS 507 Data Analysis in Python. Lecture 2: Functions, Conditionals, Recursion and Iteration

STATS 507 Data Analysis in Python. Lecture 2: Functions, Conditionals, Recursion and Iteration STATS 507 Data Analysis in Python Lecture 2: Functions, Conditionals, Recursion and Iteration Functions in Python We ve already seen examples of functions: e.g., type()and print() Function calls take the

More information

By default, it is assumed that we open a file to read data. So the above is equivalent to the following:

By default, it is assumed that we open a file to read data. So the above is equivalent to the following: LING115 Lecture Note Session #5: Files, Functions and Modules 1. Introduction A corpus comes packaged as a set of files. Obviously, we must know how to read data from a file into our program. At the same

More information

PYTHON TRAINING COURSE CONTENT

PYTHON TRAINING COURSE CONTENT SECTION 1: INTRODUCTION What s python? Why do people use python? Some quotable quotes A python history lesson Advocacy news What s python good for? What s python not good for? The compulsory features list

More information

CSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators)

CSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators) Name: Email address: Quiz Section: CSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators) Instructions: Read the directions for each question carefully before answering. We will

More information

CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch

CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch Purpose: We will take a look at programming this week using a language called Scratch. Scratch is a programming language that was developed

More information

GUI in C++ PV264 Advanced Programming in C++ Nikola Beneš Jan Mrázek Vladimír Štill. Faculty of Informatics, Masaryk University.

GUI in C++ PV264 Advanced Programming in C++ Nikola Beneš Jan Mrázek Vladimír Štill. Faculty of Informatics, Masaryk University. GUI in C++ PV264 Advanced Programming in C++ Nikola Beneš Jan Mrázek Vladimír Štill Faculty of Informatics, Masaryk University Spring 2017 PV264: GUI in C++ Spring 2017 1 / 23 Organisation Lectures this

More information

Linux desktop app guide Documentation. Thomas Kluyver & contributors

Linux desktop app guide Documentation. Thomas Kluyver & contributors Linux desktop app guide Documentation Thomas Kluyver & contributors Dec 13, 2018 Contents: 1 User Interface options 3 1.1 Desktop style: GTK or Qt........................................ 3 1.2 Web tech:

More information

Quick housekeeping Last Two Homeworks Extra Credit for demoing project prototypes Reminder about Project Deadlines/specifics Class on April 12th Resul

Quick housekeeping Last Two Homeworks Extra Credit for demoing project prototypes Reminder about Project Deadlines/specifics Class on April 12th Resul CIS192 Python Programming Web Frameworks and Web APIs Harry Smith University of Pennsylvania March 29, 2016 Harry Smith (University of Pennsylvania) CIS 192 March 29, 2016 1 / 25 Quick housekeeping Last

More information

CSE : Python Programming

CSE : Python Programming CSE 399-004: Python Programming Lecture 2: Data, Classes, and Modules January 22, 2007 http://www.seas.upenn.edu/~cse39904/ Administrative things Teaching assistant Brian Summa (bsumma @ seas.upenn.edu)

More information

Introduction to computers and Python. Matthieu Choplin

Introduction to computers and Python. Matthieu Choplin Introduction to computers and Python Matthieu Choplin matthieu.choplin@city.ac.uk http://moodle.city.ac.uk/ 1 Objectives To get a brief overview of what Python is To understand computer basics and programs

More information

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture 04 Programs with IO and Loop We will now discuss the module 2,

More information

Part IV. More on Python. Tobias Neckel: Scripting with Bash and Python Compact Max-Planck, February 16-26,

Part IV. More on Python. Tobias Neckel: Scripting with Bash and Python Compact Max-Planck, February 16-26, Part IV More on Python Compact Course @ Max-Planck, February 16-26, 2015 36 More on Strings Special string methods (excerpt) s = " Frodo and Sam and Bilbo " s. islower () s. isupper () s. startswith ("

More information

CMSC201 Computer Science I for Majors

CMSC201 Computer Science I for Majors CMSC201 Computer Science I for Majors Lecture 10 Functions Last Class We Covered The string data type Built-in functions Slicing and concatenation Escape sequences lower() and upper() strip() and whitespace

More information

CSC 015: FUNDAMENTALS OF COMPUTER SCIENCE I

CSC 015: FUNDAMENTALS OF COMPUTER SCIENCE I CSC 015: FUNDAMENTALS OF COMPUTER SCIENCE I Lecture 1: Class Introduction DR. BO TANG ASSISTANT PROFESSOR HOFSTRA UNIVERSITY 1 9/7/16 CSC15 - Python OUTLINE What is Computer Science? What is this Class

More information

Software api overview VERSION 3.1v3

Software api overview VERSION 3.1v3 Software api overview VERSION 3.1v3 Mari Software API Overview. Copyright 2016 The Foundry Visionmongers Ltd. All Rights Reserved. Use of this guide and the Mari software is subject to an End User License

More information

Report Commander 2 User Guide

Report Commander 2 User Guide Report Commander 2 User Guide Report Commander 2.5 Generated 6/26/2017 Copyright 2017 Arcana Development, LLC Note: This document is generated based on the online help. Some content may not display fully

More information

Python lab session 1

Python lab session 1 Python lab session 1 Dr Ben Dudson, Department of Physics, University of York 28th January 2011 Python labs Before we can start using Python, first make sure: ˆ You can log into a computer using your username

More information

Comp Sci 1570 Introduction to C++

Comp Sci 1570 Introduction to C++ guards Comp Sci 1570 Introduction to C++ Outline guards 1 2 guards 3 Outline guards 1 2 guards 3 Modular guards One file before system includes prototypes main driver function function definitions now

More information

Recall from Tuesday. Our solution to fragmentation is to split up a process s address space into smaller chunks. Physical Memory OS.

Recall from Tuesday. Our solution to fragmentation is to split up a process s address space into smaller chunks. Physical Memory OS. Paging 11/10/16 Recall from Tuesday Our solution to fragmentation is to split up a process s address space into smaller chunks. Physical Memory OS Process 3 Process 3 OS: Place Process 3 Process 1 Process

More information

Graphite and Grafana

Graphite and Grafana Introduction, page 1 Configure Grafana Users using CLI, page 3 Connect to Grafana, page 4 Grafana Administrative User, page 5 Configure Grafana for First Use, page 11 Manual Dashboard Configuration using

More information

TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA

TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA 1 TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and B. Ericson, and instructor materials prepared

More information

Lecture 10 Notes Linked Lists

Lecture 10 Notes Linked Lists Lecture 10 Notes Linked Lists 15-122: Principles of Imperative Computation (Summer 1 2015) Frank Pfenning, Rob Simmons, André Platzer 1 Introduction In this lecture we discuss the use of linked lists to

More information

OS Structure. Kevin Webb Swarthmore College January 25, Relevant xkcd:

OS Structure. Kevin Webb Swarthmore College January 25, Relevant xkcd: OS Structure Kevin Webb Swarthmore College January 25, 2018 Relevant xkcd: One of the survivors, poking around in the ruins with the point of a spear, uncovers a singed photo of Richard Stallman. They

More information

QUIZ. What are 3 differences between C and C++ const variables?

QUIZ. What are 3 differences between C and C++ const variables? QUIZ What are 3 differences between C and C++ const variables? Solution QUIZ Source: http://stackoverflow.com/questions/17349387/scope-of-macros-in-c Solution The C/C++ preprocessor substitutes mechanically,

More information

Introduction to Computer Programming in Python Dr. William C. Bulko. Data Types

Introduction to Computer Programming in Python Dr. William C. Bulko. Data Types Introduction to Computer Programming in Python Dr William C Bulko Data Types 2017 What is a data type? A data type is the kind of value represented by a constant or stored by a variable So far, you have

More information

Quick Installation Guide: TC-Python

Quick Installation Guide: TC-Python Quick Installation Guide: TC-Python Thermo-Calc Version 2018b Quick Installation Guide: TC-Python ǀ 1 of 7 TC-Python Quick Install Guide This quick guide helps you do a TC-Python API installation. There

More information

Lecture #16: Introduction to Runtime Organization. Last modified: Fri Mar 19 00:17: CS164: Lecture #16 1

Lecture #16: Introduction to Runtime Organization. Last modified: Fri Mar 19 00:17: CS164: Lecture #16 1 Lecture #16: Introduction to Runtime Organization Last modified: Fri Mar 19 00:17:19 2010 CS164: Lecture #16 1 Status Lexical analysis Produces tokens Detects & eliminates illegal tokens Parsing Produces

More information

Chat Channels Via Kafka (with Grading Notes)

Chat Channels Via Kafka (with Grading Notes) SE424: Distributed Systems Assignment 2 Semester 1 5778 Due: 10 Jan 2017 Chat Channels Via Kafka (with Grading Notes) In this assignment, we ll take the work from the previous assignment on channelized

More information

Spring 2017 CS 1110/1111 Exam 2

Spring 2017 CS 1110/1111 Exam 2 Spring 2017 CS 1110/1111 Exam 2 Bubble in your computing ID in the footer of this page. We use an optical scanner to read it, so fill in the bubbles darkly. If you have a shorter ID, leave some rows blank.

More information

Dynamic Cuda with F# HPC GPU & F# Meetup. March 19. San Jose, California

Dynamic Cuda with F# HPC GPU & F# Meetup. March 19. San Jose, California Dynamic Cuda with F# HPC GPU & F# Meetup March 19 San Jose, California Dr. Daniel Egloff daniel.egloff@quantalea.net +41 44 520 01 17 +41 79 430 03 61 About Us! Software development and consulting company!

More information

Arrays. myints = new int[15];

Arrays. myints = new int[15]; Arrays As you know from COMP 202 (or equivalent), an array is a data structure that holds a set of elements that are of the same type. Each element in the array can be accessed or indexed by a unique number

More information

Lecture 3: Functions & Modules (Sections ) CS 1110 Introduction to Computing Using Python

Lecture 3: Functions & Modules (Sections ) CS 1110 Introduction to Computing Using Python http://www.cs.cornell.edu/courses/cs1110/2019sp Lecture 3: Functions & Modules (Sections 3.1-3.3) CS 1110 Introduction to Computing Using Python [E. Andersen, A. Bracy, D. Gries, L. Lee, S. Marschner,

More information

CIS192 Python Programming

CIS192 Python Programming CIS192 Python Programming Graphical User Interfaces Robert Rand University of Pennsylvania December 03, 2015 Robert Rand (University of Pennsylvania) CIS 192 December 03, 2015 1 / 21 Outline 1 Performance

More information

Lecture 3. Functions & Modules

Lecture 3. Functions & Modules Lecture 3 Functions & Modules Labs this Week Lab 1 is due at the beginning of your lab If it is not yet by then, you cannot get credit Only exception is for students who added late (Those students should

More information

SCHEME 7. 1 Introduction. 2 Primitives COMPUTER SCIENCE 61A. October 29, 2015

SCHEME 7. 1 Introduction. 2 Primitives COMPUTER SCIENCE 61A. October 29, 2015 SCHEME 7 COMPUTER SCIENCE 61A October 29, 2015 1 Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme programs,

More information

CSC 360 Lab Assignment #6 Spring 2015 Due: March 13, 2015

CSC 360 Lab Assignment #6 Spring 2015 Due: March 13, 2015 CSC 360 Lab Assignment #6 Spring 2015 Due: March 13, 2015 The following are the end-of-chapter Labs from Chapter 7 through Chapter 12 of our textbook. Answer each question or describe the PowerShell command(s)

More information

Lecture 3: Functions & Modules

Lecture 3: Functions & Modules http://www.cs.cornell.edu/courses/cs1110/2018sp Lecture 3: Functions & Modules (Sections 3.1-3.3) CS 1110 Introduction to Computing Using Python [E. Andersen, A. Bracy, D. Gries, L. Lee, S. Marschner,

More information

Python: Getting Started. Ben

Python: Getting Started. Ben Python: Getting Started Ben Ramseth bramseth@esri.com @esrimapninja E M E R A L D S A P P H I R E T H A N K Y O U T O O UR SPONSORS Topics covered What s is python? Why use python? Basics of python ArcPy

More information

Lecture 10 Notes Linked Lists

Lecture 10 Notes Linked Lists Lecture 10 Notes Linked Lists 15-122: Principles of Imperative Computation (Spring 2016) Frank Pfenning, Rob Simmons, André Platzer 1 Introduction In this lecture we discuss the use of linked lists to

More information

YCL Session 4 Lesson Plan

YCL Session 4 Lesson Plan YCL Session 4 Lesson Plan Summary In this session, students will learn about functions, including the parts that make up a function, how to define and call a function, and how to use variables and expression

More information

12/7/09. How is a programming language processed? Picasso Design. Collaborating with Subversion Discussion of Preparation Analyses.

12/7/09. How is a programming language processed? Picasso Design. Collaborating with Subversion Discussion of Preparation Analyses. Picasso Design Finish parsing commands Collaborating with Subversion Discussion of Preparation Analyses How is a programming language processed? What are the different phases? Start up Eclipse User s Input

More information

Shorthand for values: variables

Shorthand for values: variables Chapter 2 Shorthand for values: variables 2.1 Defining a variable You ve typed a lot of expressions into the computer involving pictures, but every time you need a different picture, you ve needed to find

More information

PROGRAMMING FUNDAMENTALS

PROGRAMMING FUNDAMENTALS PROGRAMMING FUNDAMENTALS TESTING, MAIN, GLOBAL VARIABLES João Correia Lopes INESC TEC, FEUP 23 October 2018 FPRO/MIEIC/2018-19 23/10/2018 1 / 24 INTRODUCTION GOALS By the end of this class, the student

More information

Introduction to Programming Nanodegree Syllabus

Introduction to Programming Nanodegree Syllabus Introduction to Programming Nanodegree Syllabus Learn to Code Before You Start Prerequisites: In order to succeed, we recommend having experience using the web, being able to perform a search on Google,

More information

CMSC201 Computer Science I for Majors

CMSC201 Computer Science I for Majors CMSC201 Computer Science I for Majors Lecture 13 Functions Prof. Jeremy Dixon Based on concepts from: http://mcsp.wartburg.edu/zelle/python/ppics2/index.html Last Class We Covered Midterm exam Comments?

More information

App Engine MapReduce. Mike Aizatsky 11 May Hashtags: #io2011 #AppEngine Feedback:

App Engine MapReduce. Mike Aizatsky 11 May Hashtags: #io2011 #AppEngine Feedback: App Engine MapReduce Mike Aizatsky 11 May 2011 Hashtags: #io2011 #AppEngine Feedback: http://goo.gl/snv2i Agenda MapReduce Computational Model Mapper library Announcement Technical bits: Files API User-space

More information

Lecture 3. Functions & Modules

Lecture 3. Functions & Modules Lecture 3 Functions & Modules Labs this Week Lab 1 is due at the beginning of your lab If it is not yet by then, you cannot get credit Only exception is for students who added late (Those students should

More information

nostarch.com/pfk For bulk orders, please contact us at

nostarch.com/pfk For bulk orders, please contact us at nostarch.com/pfk For bulk orders, please contact us at sales@nostarch.com. Teacher: Date/Period: Subject: Python Programming Class: Topic: #1 - Getting Started Duration: Up to 50 min. Objectives: Install

More information

CIS192 Python Programming

CIS192 Python Programming CIS192 Python Programming Probability and Simulations (With Other Modules) Harry Smith University of Pennsylvania October 11, 2017 Harry Smith (University of Pennsylvania) CIS 192 Lecture 7 October 11,

More information

Reading and Writing Files on Your Computer

Reading and Writing Files on Your Computer Reading and Writing Files on Your Computer Code Snippets HW2-3, HW2-4 Function Recap #!/usr/bin/env python3 Though it s called sentence in main, in replace_hello() that value is called text def replace_hello(text):

More information

Functions. Rich Enbody. From Mathematics we know that functions perform some operation and return one value.

Functions. Rich Enbody. From Mathematics we know that functions perform some operation and return one value. Functions Rich Enbody From Mathematics we know that functions perform some operation and return one value. 2 1 Functions encapsulate the performance of some operation, so it can be used by others. (for

More information

Using Doxygen to Create Xcode Documentation Sets

Using Doxygen to Create Xcode Documentation Sets Using Doxygen to Create Xcode Documentation Sets Documentation sets (doc sets) provide a convenient way for an Xcode developer to search API and conceptual documentation (including guides, tutorials, TechNotes,

More information

TZWorks Portable Executable Scanner (pescan) Users Guide

TZWorks Portable Executable Scanner (pescan) Users Guide TZWorks Portable Executable Scanner (pescan) Users Guide Abstract pescan is a standalone, command-line tool that scans portable executable (PE) files and identifies how they were constructed and if they

More information

A computer program is a set of instructions that causes a computer to perform some kind of action. It isn t the physical parts of a computer like the

A computer program is a set of instructions that causes a computer to perform some kind of action. It isn t the physical parts of a computer like the 1 Not All Snakes Slither A computer program is a set of instructions that causes a computer to perform some kind of action. It isn t the physical parts of a computer like the wires, microchips, cards,

More information

Code Autocomplete Manual

Code Autocomplete Manual Code Autocomplete Manual Release 2.0.0 Jacques Lucke July 02, 2016 Contents 1 Setup 3 1.1 Installation................................................ 3 1.2 Check the Installation..........................................

More information

CS1 Lecture 3 Jan. 22, 2018

CS1 Lecture 3 Jan. 22, 2018 CS1 Lecture 3 Jan. 22, 2018 Office hours for me and for TAs have been posted, locations will change check class website regularly First homework available, due Mon., 9:00am. Discussion sections tomorrow

More information