Module 2 - Part 1 Variables, Assignment, and Data Types

Slides:



Advertisements
Similar presentations
Basic Syntax: Data & Expressions
Advertisements

Μαθαίνοντας Python [Κ4] ‘Guess the Number’
Introduction to Python
Chapter 2 Writing Simple Programs
Lab session 3 and 4 Topics to be covered Escape sequences Escape sequences Variables /identifiers Variables /identifiers Constants Constants assignment.
1 Character Strings and Variables Character Strings Variables, Initialization, and Assignment Reading for this class: L&L,
© 2004 Pearson Addison-Wesley. All rights reserved1-1 Intermediate Java Programming Lory Al Moakar.
Python Control of Flow.
INLS 560 – V ARIABLES, E XPRESSIONS, AND S TATEMENTS Instructor: Jason Carter.
1 Variables, Constants, and Data Types Primitive Data Types Variables, Initialization, and Assignment Constants Characters Strings Reading for this class:
Outline Character Strings Variables and Assignment Primitive Data Types Expressions Data Conversion Interactive Programs Graphics Applets Drawing Shapes.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
CPTR 124 Review for Test 1. Development Tools Editor Similar to a word processor Allows programmer to compose/save/edit source code Compiler/interpreter.
CSC 1051 – Algorithms and Data Structures I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
Program Statements Primitive Data Types and Strings.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-WesleyCopyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
CSC 1051 – Algorithms and Data Structures I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
CS346 Javascript -3 Module 3 JavaScript Variables.
Assignment An assignment statement changes the value of a variable The assignment operator is the = sign total = 55; Copyright © 2012 Pearson Education,
Chapter 2 Data and Expressions Part One. © 2004 Pearson Addison-Wesley. All rights reserved2-2/29 Data and Expressions Let's explore some other fundamental.
C++ Basics Tutorial 5 Constants. Topics Covered Literal Constants Defined Constants Declared Constants.
Chapter 2 topics Concept # on Java Subset Required for AP Exam print and println10. Testing of output is restricted to System.out.print and System.out.println.
Chapter 2 Data and Expressions Java Software Solutions Foundations of Program Design 1.
Chapter 2: Data and Expressions String and String Concatenation Escape Sequences Variables Primitive Date Types Expressions Interactive Programs.
By Austin Laudenslager AN INTRODUCTION TO PYTHON.
Python Let’s get started!.
Data and Expressions Let's explore some other fundamental programming concepts Chapter 2 focuses on: –character strings –primitive data –the declaration.
1 Data and Expressions Chapter 2 In PowerPoint, click on the speaker icon then the “play” button to hear audio narration.
I NTRODUCTION TO PYTHON - GETTING STARTED ( CONT )
3.1.3 Program Flow control Structured programming – SELECTION in greater detail.
Chapter 2 1.What is the difference between print / println 2.What are String Literals 3.What are the Escape Characters for backslash, double quotataions,
OCR Computing GCSE © Hodder Education 2013 Slide 1 OCR GCSE Computing Python programming 3: Built-in functions.
Today… Python Keywords. Iteration (or “Loops”!) Winter 2016CISC101 - Prof. McLeod1.
Next Week… Quiz 2 next week: –All Python –Up to this Friday’s lecture: Expressions Console I/O Conditionals while Loops Assignment 2 (due Feb. 12) topics:
CSc 127a/110, Autumn 2016 Lecture 1: Introduction; Basic Python Programs.
Chapter 2 Writing Simple Programs
Introduction to Python
Introduction to Java Programming
Lecture 1: Introduction; Basic Python Programs
Web Programming Chapter 1 : Introduction to Java Programming
Intermediate Java Programming
CS170 – Week 1 Lecture 3: Foundation Ismail abumuhfouz.
Python Let’s get started!.
Chapter 2 Data and Expressions
CSC 458– Predictive Analytics I, Fall 2017, Intro. To Python
CSC 1051 – Data Structures and Algorithms I
Scope, Objects, Strings, Numbers
Statement atoms The 'atomic' components of a statement are: delimiters (indents, semicolons, etc.); keywords (built into the language); identifiers (names.
Chapter 2 Data and Expressions
Escape Sequences What if we wanted to print the quote character?
Data and Expressions Part One
IDLE Hints To re-load a module after making changes:
CISC101 Reminders Quiz 1 grading underway Assn 1 due Today, 9pm.
An overview of Java, Data types and variables
CSC 458– Predictive Analytics I, Fall 2018, Intro. To Python
“If you can’t write it down in English, you can’t code it.”
Chapter 2 Create a Chapter 2 Workspace Create a Project called Notes
Escape sequences escape sequence: A special sequence of characters used to represent certain special characters in a string. \t Inserts a tab in the.
Module 2 - Part 1 Variables, Assignment, and Data Types
Module 2 Variables, Assignment, and Data Types
CISC101 Reminders All assignments are now posted.
More JavaScript B. Ramamurthy 5/7/2019.
CSC 1051 – Data Structures and Algorithms I
Module 2 - Part 1 Variables, Assignment, and Data Types
CSE 1321 Modules 1-5 Review Spring 2019
Java Programming Presented by Dr. K. SATISH KUMAR,
Python Reserved Words Poster
Module 2 - Part 1 Variables, Assignment, and Data Types
PYTHON - VARIABLES AND OPERATORS
Presentation transcript:

Module 2 - Part 1 Variables, Assignment, and Data Types 4/9/2019 CSE 1321 Module 2

Python Keywords False def if raise None del import return True elif in try and else is while as except lambda with assert finally nonlocal yield break for not class from or continue global pass 4/9/2019 CSE 1321 Module 2

Printing strings in Python (review) print (‘Whatever you are, be a good one.’) It’s just print! 4/9/2019 CSE 1321 Module 2 3

Pseudocode CLASS CountDown BEGIN METHOD Main() BEGIN s1 ← "Three... " s2 ← "Two... " s3 ← "One... " s4 ← "Zero... " PRINT(s1 + s2 + s3 + s4 + "Liftoff!") PRINTLINE() PRINT("Houston, we have a problem.") END Main END CountDown Output: Three... Two... One... Zero... Liftoff! Houston, we have a problem. Ps 4/9/2019 CSE 1321 Module 2 4

Python Output: def main(): s1 = 'Three... ' s2 = 'Two... ' s3 = 'One... ' s4 = 'Zero... ' print (s1 + s2 + s3 + s4 + 'Liftoff!') print () print ('Houston, we have a problem.') if __name__ == '__main__':   main() Output: Three... Two... One... Zero... Liftoff! Houston, we have a problem. 4/9/2019 CSE 1321 Module 2 5

Escape Sequences Printing and escape sequence prints a special character in an output string. Common escape sequences: \b backspace. (e.g “B\bsecz\bret” prints what?) \t tab \n newline \r carriage return \” double quote \’ single quote \\ backslash 4/9/2019 CSE 1321 Module 2 6

Python # Escape sequences def main(): print ('Roses are red,\n\tViolets are blue,\n' + 'Sugar is sweet,\n\tBut I have \'commitment issues\',\n\t' + 'So I\'d rather just be friends\n\t At this point in our ' + 'relationship.') if __name__ == '__main__':   main() 4/9/2019 CSE 1321 Module 2 7

Ps Pseudocode // Prints the number of keys on a piano. CLASS PianoKeys BEGIN METHOD Main() BEGIN keys ← 88 PRINT("A piano has " + keys + " keys.") END Main END PianoKeys Output: A piano has 88 keys. Ps 4/9/2019 CSE 1321 Module 2 8

Python #prints the number of keys on a piano. def main(): keys = 88 print("A piano has ", keys, " keys."); if __name__ == '__main__': main() Output: A piano has 88 keys. 4/9/2019 CSE 1321 Module 2 9

Pseudocode // Print the number of sides of several geometric shapes. CLASS Geometry BEGIN METHOD Main() sides ← 7 PRINT("A heptagon has " + sides + " sides.") sides ← 10 PRINT("A decagon has " + sides + " sides.") sides ← 12 PRINT("A dodecagon has " + sides + " sides.") END Main END Geometry Output: A heptagon has 7 sides. A decagon has 10 sides. A dodecagon has 12 sides. Ps 4/9/2019 CSE 1321 Module 2 10

Python def main(): sides = 7 # declare and initialize print("A heptagon has ", sides, " sides.") sides = 10 # assignment statement print("A decagon has ", sides, " sides.") sides = 12 # assignment statement print("A dodecagon has ", sides, " sides.") if __name__ == '__main__': main() 4/9/2019 CSE 1321 Module 2 11