Python Unit
|
|
- Silvia Tyler
- 6 years ago
- Views:
Transcription
1 Python Unit : OPERATORS, EXPRESSIONS, AND VARIABLES 1.2: STRINGS, FUNCTIONS, CASE SENSITIVITY, ETC. 1.3: OUR FIRST TEXT- BASED GAME Python Section 1
2 Text Book for Python Module Invent Your Own Computer Games With Python By Al Swiegert Easily found on the Internet:
3 Hint For Slides in This Class Code is typically in Courier New font. For Example: print( Hello Everybody ) This is a common font to represent computer code within textbooks. You can access the slides on the Intranet.
4 Python 1.1 OPERATORS, EXPRESSIONS, AND VARIABLES
5 Objectives By the end of this unit, you will be able to: Work in IDLE Define an Interpreter and describe its role Python Define Integers and Floating Point Numbers Work with Operators and Expressions Work with Values Store Values in Variables
6 Python Interpreter and IDLE Interpreter A program that processes each statement in a program. Three step process: 1. Evaluate (Does this statement look valid) 2. Translate (Convert from Python to machine code) 3. Execute (Make the machine perform this statement) IDLE Integrated Development Environment Text editor for writing and testing Python programs. Cross-platform (Unix, Linux and PC) Ships with all versions of Python
7 IDLE Development Environment IDLE helps you program in Python by: color-coding your program code debugging auto-indent The example above demonstrates the Python Shell. >>> Python Command Goes Here The Python Shell executes your command when you press enter.
8 Hello World In IDLE (Students Follow Along) >>> print('hello world') hello world >>> Enter your command to the right of the >>> symbols: >>> print('hello world') The Python Interpreter prints the result of the command on a line without the greater than signs: hello world
9 Operators and Expressions Operators and Operations Basic Operators: + - / * Expressions Calculations performed by combining values and operators.
10 Math in IDLE Practice doing mathematical expressions in IDLE Do some math (guided practice) Demonstrate a few basic math calculations <Alt><P> to bring up previous commands Students practice entering mathematical expressions in IDLE Addition Subtraction Division Multiplication Combinations of the above
11 Order of precedence Precedence - The order in which operations are computed Order of Precedence: 1. Items surrounded by parenthesis (5 / 4) 2. Exponentiation 5**4 3. Multiplication 5*4 4. Division 5/4 5. Addition Subtraction 5-4 There are significantly more rules of precedence
12 Language Syntax Syntax the structure of a program and the rules about that structure. The commands and the way they are formatted in a program. Other special characters like {} [] () ; \ Human readable Python Interpreter converts into machine code upon execution Syntax Error Python doesn t understand your command. Demonstrate a syntax error.
13 Variables Variable Temporary storage for a value. birthyear = 1964 Upon execution, the Python Interpreter creates the variable named birthyear and assigns it the value Variable values are set from right to left You can modify the value of birthyear by assigning a new value to it. birthyear = 1940 #Chuck Norris birth # year.
14 Variables in Other Languages In most other languages you must explicitly create the variable named birthyear. Java Example: int birthyear; birthyear = 1964; Data Type - The int identifies the type of data that may be placed into the birthyear variable. Python does this for you based upon the type of value assigned to the variable.
15 Data Types Data Type The way variables are stored and utilized within the computer. Types: Integer (Whole number) - myage = 47 Float (Decimal) - myweight = String - myname = Mr. Teacher Boolean - isteacher = True
16 Demonstration of variables (in IDLE) >>> age = 47 >>> Age Returns the value 47 >>> age + 5 Returns the value 52 >>> age = age + 10 >>> Age Returns: 57 >>> teachername = 'Mr. Sweigart' Creates a string variable named teachername and sets its value to: Mr. Sweigart >>> teachername Returns: 'Mr. Sweigart'
17 Variable Demo (Continued) >>> goodtextbook = True Creates a Boolean variable named goodtextbook and sets it to: True >>> weight = Creates a float (decimal) variable named weight and sets it to: >>> weight = Changes the value of weight to: (Returns: 167.5) >>> newweight = Weight + 22 Creates a variable named newweight and sets its value to >>> newweight + 22 >>> newweight Returns: 189.5
18 String (in IDLE) teachername = 'Mr. Sweigart teachername = 'Mr. Johnson teachername2 = 'Mr. Newbee teacher3 = teachername + teachername2 What is the value of teacher3?
19 Boolean (in IDLE) >>> goodtextbook = True Creates a Boolean variable named goodtextbook and sets it to: True >>> goodtextbook Returns: True
20 Float (in IDLE) weight = Creates a float (decimal) variable named weight and sets it to: weight = weight Returns: newweight = Weight + 22 newweight Returns: 189.5
21 Reading / Exercise(s) Read CH 2 (The Interactive Shell) in the Invent Your Own Games with Python book (PDF). Complete the Python exercises identified on planbook: Link goes here
22 Python 1.2 STRINGS, FUNCTIONS, AND CASE SENSITIVITY
23 Objectives By the end of this unit you will be able to: Work with data types (such as strings or integers) Use IDLE to write source code. Use the print() and input() functions. Create comments in your programs Demonstrate the importance Case-sensitivity in Python
24 Working with Strings (Text) classname = Video Game Programming o The single quotes (apostrophes) define this as a text string. Try it in IDLE String Concatenation classname = classname + - and Animation Demonstrate in IDLE and display result.
25 Hello World Create the hello_world.py program in IDLE o Hello World Program - Typically the first program written when learning a new language. o Execute and describe the program o Assist students in creating their own hello world program.
26 Hello World In Python: print( Hello World! ) In Java: public class HelloWorld{ public static void main (String[] args){ System.out.println("Hello, world!"); } }
27 Literals VS Variables Placing the literal 'Hello World' in myvariable myvariable = 'Hello World' Print using a literal string (has quotes) print('hello World') Print using the value within a variable (no quotes) print(myvariable) Strings inside variables are easily reused / manipulated.
28 Comments Only for programmers to read Used to describe what the code does (very useful for complex code) You will lose points on your program if you don t have comments o Your comments need to be unique to your program Single Line Comments (#) # Comments are not recognized by the interpreter. Multi-Line Comments (''') ''' Multiple lines of comments can go in the middle '''
29 Function Function A mini program that you can call to do something. Examples Include: print() Displays a message in the Interpreter. input() Allows a user to enter data. Both functions are used in the hello_world.py program. Calling a function and executing a function are synonymous.
30 The print() Function Displays a message to the user. print ('My name is Peter J. Newbee.') The following message is displayed My name is Peter J. Newbee.
31 The input() Function Most basic form of input() function: print ('Please enter your name') playername = input() print(playername) A more compact form of the input() function: playername = input('please enter your name') print(playername)
32 Advanced Hello World # This program says hello and asks for my name. print('hello world!') print('what is your name?') myname = input() print( Good to meet you, ' + myname) Question: Is myname a good name for this variable
33 Advanced Hello World print ( Hello World ) Displays Hello World on the screen when executed. print ( what is your name? ) Displays What is your name? when executed. myname = input () Places the user s response into a variable named myname. print( It is good to meet you, + myname) Displays It is good to meet you, and the name entered by the user.
34 Concatenation Concatenation merging two or more strings together. print( It is good to meet you, + myname) Displays It is good to meet you, xxx where xxx is the value entered when the user entered their name. The plus sign merges the string It is good to meet you, with the value of the myname variable.
35 Case-Sensitivity Case Capitalization or lack of capitalization of a letter. Case-Sensitive - Declaring different capitalizations of a name to mean different things. Python is a case-sensitive language score, Score, and SCORE are three different variables.
36 Case Sensitivity Variable names must be referenced in the exact case as when created For example: myname = Pete Cannot be referenced like this: print(myname) The N in myname must be capitalized.
37 Syntax Rules for Naming Variables Variable names in Python: o o Can contain letters, numbers, or underscores Must begin with a letter or underscore. Functions names follow the same rules. The next slide discusses classroom coding standards. o Differences between Syntax Rules and Coding Standards???
38 Standards for Variable Names Why are standards important? Our standards for naming variables: o Start with a lowercase letter o Capitalize every word after the first (Camel case). Example: userfirstname The F and N must be capitalized to meet our standards. o Must conform to the Python syntax rules See previous slide for syntax rules
39 Conventions for Working with Strings Use apostrophes (single quotes) for string values: Our Standard (single quotes) print( Hello World ) o Not our Standard (double quotes) print( Hello World )
40 1.2 Reading / Exercise See Intranet for reading and exercises. Exercises through 1-2-3
41 Python 1.3 OUR FIRST TEXT BASED GAME Python Unit 1
42 Objectives In this unit, we will discuss the following: o Modules and Import statements o Arguments o while statements o Blocks o Comparison Operators o Difference between = and == o if statements and conditions o The break keyword o The str() and int() functions o The random.randint() function
43 Modules and the Import Statement Module A Python program that contains useful functions. import statement Imports functions from another module so they can be used. import random Makes the functions in the random.py module available within our current module.
44 The randint() function import random randomnumber = random.randint(1, 100) The above statement generates a random number between 1 and 100 and places the number in the randomnumber variable. The randint function resides in the random module, which is copied in by the import statement.
45 Arguments and Functions Function arguments are passed inside the parenthesis of the function call: print( Hello World ) The argument is Hello World yourname = input( Please enter your name ) Asks the user to enter their name and places the result in the yourname variable. The argument is the text between the apostrophes.
46 Arguments and Functions Functions require that you enter the correct number of arguments: randomnumber = random.randint(1) o Generates a syntax error because the randint function requires two arguments.
47 Loops Loop Programming logic that is executed over and over again until a specific condition(s) is met. Two types of loops: while boolean_expression: Executes as long as the expression evaluates to True for Executes a set number of times Extremely useful Covered later in course
48 while Loop while boolean_expression (evaluates to true): # Perform block action # Perform block action while guessestaken < 6: # Ask the user to guess again # Accept user s guess # Evaluate the guess # Increment guessestaken variable by 1.
49 Blocks Block - one or more lines of code grouped together with the same minimum amount of indentation. while guessestaken < 6: Execute block o The colon after the 6 indicates that a block will follow. o Indented by four spaces (all lines of the block). o The block ends when return to previous indentation.
50 Block Example (while loop) while guessestaken < 6: ----print('take a guess.') ----guess = input() ----guess = int(guess) ----guessestaken = guessestaken if guess < number: print('your guess is too low.') ----if guess > number: print('your guess is too high.') if guess == number: ----guessestaken = str(guessestaken)
51 Conditions (Boolean Expressions) Conditions Expressions that evaluate to True or False (Boolean Expressions) myage = 50 if myage > 49: print ( You are old ) myage > 49 evaluates to True (the message prints) The following use Conditions: if statements while Loops for Loops
52 Comparison Operators (Conditions Continued) while guessestaken < 6: Execute block The < sign is the comparison operator When guessestaken becomes 6, the while loop ends and the block of code is no longer executed.
53 == Versus = (Conditions Continued) Use = to assign a value to a variable a = b Use == in a conditional (while, if, or for) if a == b: print ( a has the same value as b )
54 if Statements if guess < randomnumber: print('your guess is too low') If the user guessed a number less than randomnumber Your guess is too low is displayed.
55 The if Statement (Equals and Not) if name = = 'Pete Newbee': print('pete is the name') if name!= 'Chuck Norris': print('sorry, I am not your hero')
56 Compound Conditionals Using And if a < b and a < c: print ("a is less than b and c") Using Or if a < b or a < c: print ("a is less than either b or c") This will not work! if a < b or < c:
57 else and elif Decision logic where the variable x is an integer. if x <= 10: print('x is less than 11') elif x <= 20: print ('X is between 11 and 20') else: print('x is greater than 20') elif (like saying otherwise if ) else: (Default action if the if/elif conditions do not evaluate to True)
58 if Versus while If rupees < 50: If keyword condition (Boolean Expression) while rupees > 50: while keyword condition (Boolean Expression)
59 Booleans and Conditionals isinjured = True if isinjured: print( The dragon is injured ) Any non-zero value evaluates to True The following values evaluate to False: The number 0 (In a numeric data type) Empty strings (Example: mystring = '')
60 The int() Function guess = input( Take a guess ) guess = int(guess) Converts the text from guess into an integer value for evaluation purposes. Note: The getint() function of the game_dev module does the same as the two commands above.
61 Nested Functions The following code converts the string that is returned from the input function into an integer value. age = int(input( Enter your age? )) The input() function receives the age and passes it to the int() function which converts the value into an integer. What would happen if the user entered a non-integer value? Note: Same as game_dev.getint() function
62 Incrementing Variables Common to most languages: guessestaken = guessestaken + 1 Increments guessestaken by one. Python Shortcut: guessestaken += 1
63 The break Statement break a statement that tells the program to immediately jump out of the while-block to the first line after the end of the while-block. while True: # Code to generate number would go here. # Code to retrieve guess would go here. if guess == number: break Breaks out of the while loop if the values of the guess and number variables are equal.
64 Reading / Exercises See Intranet
65 Unit Exam You will be required to write sample code for the exam.
Python Games. Session 1 By Declan Fox
Python Games Session 1 By Declan Fox Rules General Information Wi-Fi Name: CoderDojo Password: coderdojowireless Website: http://cdathenry.wordpress.com/ Plans for this year Command line interface at first
More informationENGR 101 Engineering Design Workshop
ENGR 101 Engineering Design Workshop Lecture 2: Variables, Statements/Expressions, if-else Edgardo Molina City College of New York Literals, Variables, Data Types, Statements and Expressions Python as
More informationIntro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming
Intro to Programming Unit 7 Intro to Programming 1 What is Programming? 1. Programming Languages 2. Markup vs. Programming 1. Introduction 2. Print Statement 3. Strings 4. Types and Values 5. Math Externals
More informationPython Unit
Python Unit 2 2.1 2.3 2.1: Advanced print() and input() commands 2.2: Functions and Variable Scope 2.3: Flowcharting The Dragon Realm text-based game Python 2.1 Advanced print() and input() commands Objectives
More informationAlgorithms and Programming I. Lecture#12 Spring 2015
Algorithms and Programming I Lecture#12 Spring 2015 Think Python How to Think Like a Computer Scientist By :Allen Downey Installing Python Follow the instructions on installing Python and IDLE on your
More informationMobile Computing Professor Pushpendra Singh Indraprastha Institute of Information Technology Delhi Java Basics Lecture 02
Mobile Computing Professor Pushpendra Singh Indraprastha Institute of Information Technology Delhi Java Basics Lecture 02 Hello, in this lecture we will learn about some fundamentals concepts of java.
More informationObject-Oriented Programming
Object-Oriented Programming Java Syntax Program Structure Variables and basic data types. Industry standard naming conventions. Java syntax and coding conventions If Then Else Case statements Looping (for,
More informationIntroduction to: Computers & Programming: Review prior to 1 st Midterm
Introduction to: Computers & Programming: Review prior to 1 st Midterm Adam Meyers New York University Summary Some Procedural Matters Summary of what you need to Know For the Test and To Go Further in
More informationPRG PROGRAMMING ESSENTIALS. Lecture 2 Program flow, Conditionals, Loops
PRG PROGRAMMING ESSENTIALS 1 Lecture 2 Program flow, Conditionals, Loops https://cw.fel.cvut.cz/wiki/courses/be5b33prg/start Michal Reinštein Czech Technical University in Prague, Faculty of Electrical
More informationProgramming in Python 3
Programming in Python 3 Programming transforms your computer from a home appliance to a power tool Al Sweigart, The invent with Python Blog Programming Introduction Write programs that solve a problem
More informationText Input and Conditionals
Text Input and Conditionals Text Input Many programs allow the user to enter information, like a username and password. Python makes taking input from the user seamless with a single line of code: input()
More informationExpressions and Variables
Expressions and Variables Expressions print(expression) An expression is evaluated to give a value. For example: 2 + 9-6 Evaluates to: 5 Data Types Integers 1, 2, 3, 42, 100, -5 Floating points 2.5, 7.0,
More informationPython The way of a program. Srinidhi H Asst Professor Dept of CSE, MSRIT
Python The way of a program Srinidhi H Asst Professor Dept of CSE, MSRIT 1 Problem Solving Problem solving means the ability to formulate problems, think creatively about solutions, and express a solution
More informationCS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University
CS 112 Introduction to Computing II Wayne Snyder Department Boston University Today: Java basics: Compilation vs Interpretation Program structure Statements Values Variables Types Operators and Expressions
More informationIntroduction 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 informationSOFT 161. Class Meeting 1.6
University of Nebraska Lincoln Class Meeting 1.6 Slide 1/13 Overview of A general purpose programming language Created by Guido van Rossum Overarching design goal was orthogonality Automatic memory management
More informationDecisions, 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 informationFundamentals of Programming (Teacher Pack)
P a g e 1 P a g e 2 Fundamentals of Programming (Teacher Pack) Table of Contents Table of Contents ------------------------------------------------------------------------------------------------------------
More informationCMSC 201 Computer Science I for Majors
CMSC 201 Computer Science I for Majors Lecture 02 Intro to Python Syllabus Last Class We Covered Grading scheme Academic Integrity Policy (Collaboration Policy) Getting Help Office hours Programming Mindset
More informationCOMP-202: Foundations of Programming. Lecture 2: Variables, and Data Types Sandeep Manjanna, Summer 2015
COMP-202: Foundations of Programming Lecture 2: Variables, and Data Types Sandeep Manjanna, Summer 2015 Announcements Midterm Exams on 4 th of June (12:35 14:35) Room allocation will be announced soon
More informationBASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I
BASIC COMPUTATION x public static void main(string [] args) Fundamentals of Computer Science I Outline Using Eclipse Data Types Variables Primitive and Class Data Types Expressions Declaration Assignment
More informationThis summary is located here:
Copyright 2008, 2009 by Albert Sweigart "Invent Your Own Computer Games with Python" is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License. You are free:
More informationage = 23 age = age + 1 data types Integers Floating-point numbers Strings Booleans loosely typed age = In my 20s
Intro to Python Python Getting increasingly more common Designed to have intuitive and lightweight syntax In this class, we will be using Python 3.x Python 2.x is still very popular, and the differences
More informationProcedures, Parameters, Values and Variables. Steven R. Bagley
Procedures, Parameters, Values and Variables Steven R. Bagley Recap A Program is a sequence of statements (instructions) Statements executed one-by-one in order Unless it is changed by the programmer e.g.
More informationThere are two ways to use the python interpreter: interactive mode and script mode. (a) open a terminal shell (terminal emulator in Applications Menu)
I. INTERACTIVE MODE VERSUS SCRIPT MODE There are two ways to use the python interpreter: interactive mode and script mode. 1. Interactive Mode (a) open a terminal shell (terminal emulator in Applications
More informationWelcome to Python 3. Some history
Python 3 Welcome to Python 3 Some history Python was created in the late 1980s by Guido van Rossum In December 1989 is when it was implemented Python 3 was released in December of 2008 It is not backward
More informationLesson 3: Basic Programming Concepts
3 ICT Gaming Essentials Lesson 3: Basic Programming Concepts LESSON SKILLS After completing this lesson, you will be able to: Explain the types and uses of variables and operators in game programming.
More informationProfessor: Sana Odeh Lecture 3 Python 3.1 Variables, Primitive Data Types & arithmetic operators
1 Professor: Sana Odeh odeh@courant.nyu.edu Lecture 3 Python 3.1 Variables, Primitive Data Types & arithmetic operators Review What s wrong with this line of code? print( He said Hello ) What s wrong with
More informationData and Variables. Data Types Expressions. String Concatenation Variables Declaration Assignment Shorthand operators. Operators Precedence
Data and Variables Data Types Expressions Operators Precedence String Concatenation Variables Declaration Assignment Shorthand operators Review class All code in a java file is written in a class public
More informationReview. Input, Processing and Output. Review. Review. Designing a Program. Typical Software Development cycle. Bonita Sharif
Input, Processing and Output Bonita Sharif 1 Review A program is a set of instructions a computer follows to perform a task The CPU is responsible for running and executing programs A set of instructions
More informationCS2900 Introductory Programming with Python and C++ Kevin Squire LtCol Joel Young Fall 2007
CS2900 Introductory Programming with Python and C++ Kevin Squire LtCol Joel Young Fall 2007 Course Web Site http://www.nps.navy.mil/cs/facultypages/squire/cs2900 All course related materials will be posted
More informationThere are two ways to use the python interpreter: interactive mode and script mode. (a) open a terminal shell (terminal emulator in Applications Menu)
I. INTERACTIVE MODE VERSUS SCRIPT MODE There are two ways to use the python interpreter: interactive mode and script mode. 1. Interactive Mode (a) open a terminal shell (terminal emulator in Applications
More informationInvent Your Own Computer Games with Python 3 rd Edition
Invent Your Own Computer Games with Python 3 rd Edition By Al Sweigart ii http://inventwithpython.com Copyright 2008-2015 by Albert Sweigart Some Rights Reserved. "Invent Your Own Computer Games with Python"
More informationNESTED IF STATEMENTS AND STRING/INTEGER CONVERSION
LESSON 15 NESTED IF STATEMENTS AND STRING/INTEGER CONVERSION OBJECTIVE Learn to work with multiple criteria if statements in decision making programs as well as how to specify strings versus integers in
More informationBasic Concepts. Computer Science. Programming history Algorithms Pseudo code. Computer - Science Andrew Case 2
Basic Concepts Computer Science Computer - Science - Programming history Algorithms Pseudo code 2013 Andrew Case 2 Basic Concepts Computer Science Computer a machine for performing calculations Science
More informationChapter 2 Working with Data Types and Operators
JavaScript, Fourth Edition 2-1 Chapter 2 Working with Data Types and Operators At a Glance Instructor s Manual Table of Contents Overview Objectives Teaching Tips Quick Quizzes Class Discussion Topics
More informationSoftware and Programming 1
Software and Programming 1 Lab 1: Introduction, HelloWorld Program and use of the Debugger 17 January 2019 SP1-Lab1-2018-19.pptx Tobi Brodie (tobi@dcs.bbk.ac.uk) 1 Module Information Lectures: Afternoon
More informationGetting Started. Office Hours. CSE 231, Rich Enbody. After class By appointment send an . Michigan State University CSE 231, Fall 2013
CSE 231, Rich Enbody Office Hours After class By appointment send an email 2 1 Project 1 Python arithmetic Do with pencil, paper and calculator first Idle Handin Help room 3 What is a Computer Program?
More information\n is used in a string to indicate the newline character. An expression produces data. The simplest expression
Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of
More informationComputer Components. Software{ User Programs. Operating System. Hardware
Computer Components Software{ User Programs Operating System Hardware What are Programs? Programs provide instructions for computers Similar to giving directions to a person who is trying to get from point
More informationKey Differences Between Python and Java
Python Python supports many (but not all) aspects of object-oriented programming; but it is possible to write a Python program without making any use of OO concepts. Python is designed to be used interpretively.
More informationInvent Your Own Computer Games with Python
Hello Wor ld! Invent Your Own Computer Games with Python Taesoo Kwon Heejin Park Hanyang University Introduction to Python Python Easier to learn than C. Serious programming language. Many expert programmers
More informationLecture 2. COMP1406/1006 (the Java course) Fall M. Jason Hinek Carleton University
Lecture 2 COMP1406/1006 (the Java course) Fall 2013 M. Jason Hinek Carleton University today s agenda a quick look back (last Thursday) assignment 0 is posted and is due this Friday at 2pm Java compiling
More informationSAMS Programming A/B. Lecture #1 Introductions July 3, Mark Stehlik
SAMS Programming A/B Lecture #1 Introductions July 3, 2017 Mark Stehlik Outline for Today Overview of Course A Python intro to be continued in lab on Wednesday (group A) and Thursday (group B) 7/3/2017
More informationIntroduction 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 informationHello, World! An Easy Intro to Python & Programming. Jack Rosenthal
An Easy Intro to Python & Programming Don t just buy a new video game, make one. Don t just download the latest app, help design it. Don t just play on your phone, program it. No one is born a computer
More informationPython Programming Exercises 1
Python Programming Exercises 1 Notes: throughout these exercises >>> preceeds code that should be typed directly into the Python interpreter. To get the most out of these exercises, don t just follow them
More informationFull file at
Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class
More informationVARIABLES. Aim Understanding how computer programs store values, and how they are accessed and used in computer programs.
Lesson 2 VARIABLES Aim Understanding how computer programs store values, and how they are accessed and used in computer programs. WHAT ARE VARIABLES? When you input data (i.e. information) into a computer
More informationProgramming with Python
Programming with Python Dr Ben Dudson Department of Physics, University of York 21st January 2011 http://www-users.york.ac.uk/ bd512/teaching.shtml Dr Ben Dudson Introduction to Programming - Lecture 2
More informationcis20.1 design and implementation of software applications I fall 2007 lecture # I.2 topics: introduction to java, part 1
topics: introduction to java, part 1 cis20.1 design and implementation of software applications I fall 2007 lecture # I.2 cis20.1-fall2007-sklar-leci.2 1 Java. Java is an object-oriented language: it is
More informationChapter 2 Getting Started with Python
Chapter 2 Getting Started with Python Introduction Python Programming language was developed by Guido Van Rossum in February 1991. It is based on or influenced with two programming languages: 1. ABC language,
More information3. Java - Language Constructs I
Educational Objectives 3. Java - Language Constructs I Names and Identifiers, Variables, Assignments, Constants, Datatypes, Operations, Evaluation of Expressions, Type Conversions You know the basic blocks
More informationValues and Variables 1 / 30
Values and Variables 1 / 30 Values 2 / 30 Computing Computing is any purposeful activity that marries the representation of some dynamic domain with the representation of some dynamic machine that provides
More information4 Programming Fundamentals. Introduction to Programming 1 1
4 Programming Fundamentals Introduction to Programming 1 1 Objectives At the end of the lesson, the student should be able to: Identify the basic parts of a Java program Differentiate among Java literals,
More informationProgramming with Java
Programming with Java Variables and Output Statement Lecture 03 First stage Software Engineering Dep. Saman M. Omer 2017-2018 Objectives ü Declare and assign values to variable ü How to use eclipse ü What
More informationProgramming. We will be introducing various new elements of Python and using them to solve increasingly interesting and complex problems.
Plan for the rest of the semester: Programming We will be introducing various new elements of Python and using them to solve increasingly interesting and complex problems. We saw earlier that computers
More informationLanguage Basics. /* The NUMBER GAME - User tries to guess a number between 1 and 10 */ /* Generate a random number between 1 and 10 */
Overview Language Basics This chapter describes the basic elements of Rexx. It discusses the simple components that make up the language. These include script structure, elements of the language, operators,
More information6.096 Introduction to C++ January (IAP) 2009
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. Welcome to 6.096 Lecture
More informationBIT Java Programming. Sem 1 Session 2011/12. Chapter 2 JAVA. basic
BIT 3383 Java Programming Sem 1 Session 2011/12 Chapter 2 JAVA basic Objective: After this lesson, you should be able to: declare, initialize and use variables according to Java programming language guidelines
More informationThe current topic: Python. Announcements. Python. Python
The current topic: Python Announcements! Introduction! reasons for studying languages! language classifications! simple syntax specification Object-oriented programming: Python Types and values Syntax
More informationBasics of Java Programming
Basics of Java Programming Lecture 2 COP 3252 Summer 2017 May 16, 2017 Components of a Java Program statements - A statement is some action or sequence of actions, given as a command in code. A statement
More informationEntry Point of Execution: the main Method. Elementary Programming. Learning Outcomes. Development Process
Entry Point of Execution: the main Method Elementary Programming EECS1021: Object Oriented Programming: from Sensors to Actuators Winter 2019 CHEN-WEI WANG For now, all your programming exercises will
More informationCOMS 469: Interactive Media II
COMS 469: Interactive Media II Agenda Review Data Types & Variables Decisions, Loops, and Functions Review gunkelweb.com/coms469 Review Basic Terminology Computer Languages Interpreted vs. Compiled Client
More information6.S189 Homework 1. What to turn in. Exercise 1.1 Installing Python. Exercise 1.2 Hello, world!
6.S189 Homework 1 http://web.mit.edu/6.189/www/materials.html What to turn in Do the warm-up problems for Days 1 & 2 on the online tutor. Complete the problems below on your computer and get a checkoff
More informationRTL Reference 1. JVM. 2. Lexical Conventions
RTL Reference 1. JVM Record Transformation Language (RTL) runs on the JVM. Runtime support for operations on data types are all implemented in Java. This constrains the data types to be compatible to Java's
More informationScripting Languages. Python basics
Scripting Languages Python basics Interpreter Session: python Direct conversation with python (>>>) Python 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609] on linux Type "help", "copyright",
More informationCS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG
CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG 1 Notice Reading Assignment Chapter 1: Introduction to Java Programming Homework 1 It is due this coming Sunday
More informationIntroduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More informationCourse Outline. Introduction to java
Course Outline 1. Introduction to OO programming 2. Language Basics Syntax and Semantics 3. Algorithms, stepwise refinements. 4. Quiz/Assignment ( 5. Repetitions (for loops) 6. Writing simple classes 7.
More informationCSCE 110 Programming I Basics of Python: Variables, Expressions, Input/Output
CSCE 110 Programming I Basics of Python: Variables, Expressions, Input/Output Dr. Tiffani L. Williams Department of Computer Science and Engineering Texas A&M University Spring 2011 Python Python was developed
More informationObject oriented programming. Instructor: Masoud Asghari Web page: Ch: 3
Object oriented programming Instructor: Masoud Asghari Web page: http://www.masses.ir/lectures/oops2017sut Ch: 3 1 In this slide We follow: https://docs.oracle.com/javase/tutorial/index.html Trail: Learning
More informationUnit 6 - Software Design and Development LESSON 3 KEY FEATURES
Unit 6 - Software Design and Development LESSON 3 KEY FEATURES Last session 1. Language generations. 2. Reasons why languages are used by organisations. 1. Proprietary or open source. 2. Features and tools.
More informationChapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines.
Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of
More informationPython Input, output and variables
Today s lecture Python Input, output and variables Lecture 22 COMPSCI111/111G SS 2016! What is Python?! Displaying text on screen using print()! Variables! Numbers and basic arithmetic! Getting input from
More informationHonors Computer Science Python Mr. Clausen Programs 4A, 4B, 4C, 4D, 4E, 4F
PROGRAM 4A Full Names (25 points) Honors Computer Science Python Mr. Clausen Programs 4A, 4B, 4C, 4D, 4E, 4F This program should ask the user for their full name: first name, a space, middle name, a space,
More informationIntroduction to Java. Java Programs Classes, Methods, and Statements Comments Strings Escape Sequences Identifiers Keywords
Introduction to Java Java Programs Classes, Methods, and Statements Comments Strings Escape Sequences Identifiers Keywords Program Errors Syntax Runtime Logic Procedural Decomposition Methods Flow of Control
More informationProgram Fundamentals
Program Fundamentals /* HelloWorld.java * The classic Hello, world! program */ class HelloWorld { public static void main (String[ ] args) { System.out.println( Hello, world! ); } } /* HelloWorld.java
More informationIntroduction to Java Applications
2 Introduction to Java Applications OBJECTIVES In this chapter you will learn: To write simple Java applications. To use input and output statements. Java s primitive types. Basic memory concepts. To use
More informationJava Foundations: Introduction to Program Design & Data Structures, 4e John Lewis, Peter DePasquale, Joseph Chase Test Bank: Chapter 2
Java Foundations Introduction to Program Design and Data Structures 4th Edition Lewis TEST BANK Full download at : https://testbankreal.com/download/java-foundations-introduction-toprogram-design-and-data-structures-4th-edition-lewis-test-bank/
More informationCOMP-202 Unit 2: Java Basics. CONTENTS: Using Expressions and Variables Types Strings Methods
COMP-202 Unit 2: Java Basics CONTENTS: Using Expressions and Variables Types Strings Methods Assignment 1 Assignment 1 posted on WebCt and course website. It is due May 18th st at 23:30 Worth 6% Part programming,
More informationChapter 3. More Flow of Control. Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley
Chapter 3 More Flow of Control Overview 3.1 Using Boolean Expressions 3.2 Multiway Branches 3.3 More about C++ Loop Statements 3.4 Designing Loops Slide 3-3 Flow Of Control Flow of control refers to the
More informationPython Input, output and variables. Lecture 22 COMPSCI111/111G SS 2016
Python Input, output and variables Lecture 22 COMPSCI111/111G SS 2016 Today s lecture u What is Python? u Displaying text on screen using print() u Variables u Numbers and basic arithmetic u Getting input
More informationIntroduction to programming with Python
Introduction to programming with Python Ing. Lelio Campanile 1/61 Main Goal - Introduce you to programming - introduce you to the most essential feature of python programming 2/61 Before to start The name
More informationCHAPTER 2: Introduction to Python COMPUTER PROGRAMMING SKILLS
CHAPTER 2: Introduction to Python COMPUTER PROGRAMMING SKILLS 1439-1440 1 Outline 1. Introduction 2. Why Python? 3. Compiler and Interpreter 4. The first program 5. Comments and Docstrings 6. Python Indentations
More informationCS11 Java. Fall Lecture 1
CS11 Java Fall 2006-2007 Lecture 1 Welcome! 8 Lectures Slides posted on CS11 website http://www.cs.caltech.edu/courses/cs11 7-8 Lab Assignments Made available on Mondays Due one week later Monday, 12 noon
More informationComputer and Programming: Lab 1
01204111 Computer and Programming: Lab 1 Name ID Section Goals To get familiar with Wing IDE and learn common mistakes with programming in Python To practice using Python interactively through Python Shell
More informationIntroduction to Computer Programming CSCI-UA 2. Review Midterm Exam 1
Review Midterm Exam 1 Review Midterm Exam 1 Exam on Monday, October 7 Data Types and Variables = Data Types and Variables Basic Data Types Integers Floating Point Numbers Strings Data Types and Variables
More informationMICROPROCESSOR SYSTEMS INTRODUCTION TO PYTHON
MICROPROCESSOR SYSTEMS INTRODUCTION TO PYTHON Table of contents 2 1. Learning Outcomes 2. Introduction 3. The first program: hello world! 4. The second program: hello (your name)! 5. More data types 6.
More informationThe Big Python Guide
The Big Python Guide Big Python Guide - Page 1 Contents Input, Output and Variables........ 3 Selection (if...then)......... 4 Iteration (for loops)......... 5 Iteration (while loops)........ 6 String
More informationCS1 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 informationConstants. Variables, Expressions, and Statements. Variables. x = 12.2 y = 14 x = 100. Chapter
Variables, Expressions, and Statements Chapter 2 Unless otherwise noted, the content of this course material is licensed under a Creative Commons Attribution 3.0 License. http://creativecommons.org/licenses/by/3.0/.
More informationc) Comments do not cause any machine language object code to be generated. d) Lengthy comments can cause poor execution-time performance.
2.1 Introduction (No questions.) 2.2 A Simple Program: Printing a Line of Text 2.1 Which of the following must every C program have? (a) main (b) #include (c) /* (d) 2.2 Every statement in C
More informationFull file at C How to Program, 6/e Multiple Choice Test Bank
2.1 Introduction 2.2 A Simple Program: Printing a Line of Text 2.1 Lines beginning with let the computer know that the rest of the line is a comment. (a) /* (b) ** (c) REM (d)
More informationVLC : Language Reference Manual
VLC : Language Reference Manual Table Of Contents 1. Introduction 2. Types and Declarations 2a. Primitives 2b. Non-primitives - Strings - Arrays 3. Lexical conventions 3a. Whitespace 3b. Comments 3c. Identifiers
More informationSoftware and Programming 1
Software and Programming 1 Lab 1: Introduction, HelloWorld Program and use of the Debugger 11 January 2018 SP1-Lab1-2017-18.pptx Tobi Brodie (tobi@dcs.bbk.ac.uk) 1 Module Information Lectures: Afternoon
More informationegrapher Language Reference Manual
egrapher Language Reference Manual Long Long: ll3078@columbia.edu Xinli Jia: xj2191@columbia.edu Jiefu Ying: jy2799@columbia.edu Linnan Wang: lw2645@columbia.edu Darren Chen: dsc2155@columbia.edu 1. Introduction
More informationWorking with JavaScript
Working with JavaScript Creating a Programmable Web Page for North Pole Novelties 1 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page 2 Objectives
More informationInterpreted vs Compiled. Java Compile. Classes, Objects, and Methods. Hello World 10/6/2016. Python Interpreted. Java Compiled
Interpreted vs Compiled Python 1 Java Interpreted Easy to run and test Quicker prototyping Program runs slower Compiled Execution time faster Virtual Machine compiled code portable Java Compile > javac
More informationHello, World and Variables
Hello, World and Variables Hello, World! The most basic program in any language (Python included) is often considered to be the Hello, world! statement. As it s name would suggest, the program simply returns
More information