PYTHON - VARIABLES AND OPERATORS

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Introduction to C Programming
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
 2002 Prentice Hall. All rights reserved. 1 Intro: Java/Python Differences JavaPython Compiled: javac MyClass.java java MyClass Interpreted: python MyProgram.py.
 2002 Prentice Hall. All rights reserved. 1 Chapter 2 – Introduction to Python Programming Outline 2.1 Introduction 2.2 First Program in Python: Printing.
JavaScript, Third Edition
Introduction to C Programming
A Variable is symbolic name that can be given different values. Variables are stored in particular places in the computer ‘s memory. When a variable is.
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 09/03/2010.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 2 Input,
Input, Output, and Processing
Computer Science 101 Introduction to Programming.
CPS120: Introduction to Computer Science
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
Chapter 2: Java Fundamentals
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Introducing Python CS 4320, SPRING Resources We will be following the Python tutorialPython tutorial These notes will cover the following sections.
Variables, Expressions and Statements
A Simple Java Program //This program prints Welcome to Java! public class Welcome { public static void main(String[] args) { public static void main(String[]
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
Python Let’s get started!.
2.1 The Part of a C++ Program. The Parts of a C++ Program // sample C++ program #include using namespace std; int main() { cout
Fundamentals of Programming I Overview of Programming
C++ First Steps.
Chapter 2 Variables.
Chapter Topics The Basics of a C++ Program Data Types
Topics Designing a Program Input, Processing, and Output
Chapter 6 JavaScript: Introduction to Scripting
Python: Experiencing IDLE, writing simple programs
What Actions Do We Have Part 1
Chapter 2 Introduction to C++ Programming
Input and Output Upsorn Praphamontripong CS 1110
Python Let’s get started!.
Introduction to Python
Chapter 2 - Introduction to C Programming
Introduction Python is an interpreted, object-oriented and high-level programming language, which is different from a compiled one like C/C++/Java. Its.
Computing Fundamentals
Basic Elements of C++.
Variables, Expressions, and IO
Introduction to Scripting
Basic operations in Matlab
Chapter 2 - Introduction to C Programming
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 2 Applications and Data.
Basic Elements of C++ Chapter 2.
Introduction to Python
Chapter 2 - Introduction to C Programming
2.1 Parts of a C++ Program.
Introduction to C++ Programming
WEB PROGRAMMING JavaScript.
Unit 1: Introduction Lesson 1: PArts of a java program
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Rocky K. C. Chang September 18, 2018 (Based on Zelle and Dierbach)
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
elementary programming
Chapter 2: Introduction to C++.
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
Chapter 2 - Introduction to C Programming
12th Computer Science – Unit 5
Chapter 1: Programming Basics, Python History and Program Components
Unit 3: Variables in Java
Chapter 2 Variables.
General Computer Science for Engineers CISC 106 Lecture 03
Introduction to C Programming
Presentation transcript:

PYTHON - VARIABLES AND OPERATORS 12th COMPUTER SCIENCE LESSON - 5 PYTHON - VARIABLES AND OPERATORS Padasalai.Net

Python is a general purpose programming language Introduction Python is a general purpose programming language It is created by Guido Van Rossum from CWI (Centrum Wiskunde & Informatica) which is a National Research Institute for Mathematics and Computer Science in Netherlands. The language was released in I991.

It is a platform independent programming language. Key features of Python It is a general purpose programming language which can be used for both scientific and non-scientific programming. It is a platform independent programming language. The programs written in Python are easily readable and understandable.

Programming in Python Interactive mode Script mode

Interactive mode Programming In interactive mode Python code can be directly typed and the interpreter displays the result(s) immediately. Script mode Programming A script is a text file containing the Python statements. Python Scripts are reusable code

Creating Scripts in Python FILE -> NEW CTRL + N Saving Python Script FILE -> SAVE CTRL + S   Executing Python Script RUN -> RUN MODULE F5 For all error free code, the output will appear in the IDLE window of Python

Input and Output Functions print()

Variable = input(“prompt string”) input() function Variable = input(“prompt string”) input( ) function is used to accept data as input at run time The input( ) takes whatever is typed from the keyboard and stores the entered data in the given variable. prompt string is used, it is displayed on the monitor; the user can provide expected data from the input device The input ( ) accepts all data as string or characters but not as numbers int( ) function is used to convert string data as integer data explicitly

Print() function print(“String”) print(variable) print(“String”,variable) print(variable ,“String”, variable ,“String”) The print() function is used to display result on the screen Comma ( , ) is used as a separator in print ( ) to print more than one item.

Comments in Python Indentation comments begin with hash symbol (#) Comments may be single line or no multi-lines. Indentation Python uses whitespace such as spaces and tabs to define program blocks All statements within the block must be indented with same amount spaces.

Tokens Identifiers Keywords Operators Delimiters Literals Python breaks each logical line into a sequence of elementary lexical components known as Tokens. Identifiers Keywords Operators Delimiters Literals

Identifiers An Identifier is a name used to identify a variable, function, class, module or object. An identifier must start with an alphabet (A..Z or a..z) or underscore ( _ ). Identifiers may contain digits (0 .. 9) Python identifiers are case sensitive i.e. uppercase and lowercase letters are distinct. Identifiers must not be a python keyword. Python does not allow punctuation character such as %,$, @ etc., within identifiers.

Keywords Keywords are special words used by Python interpreter to recognize the structure of program. Identifiers must not be a python keyword.

Operators In computer programming languages operators are special symbols which represent computations, conditional matching etc. The value of an operator used is called operands. Arithmetic operators Relational or Comparative operators Logical operators Assignment operators Conditional operator

Arithmetic operators An arithmetic operator is a mathematical operator that takes two operands and performs a calculation on them.

Relational or Comparative operators A Relational operator is also called as Comparative operator which checks the relationship between two operands.

Logical operators Logical operators are used to perform logical operations on the given relational expressions.

= is a simple assignment operator to assign values to variable. Assignment operators = is a simple assignment operator to assign values to variable.

Ternary operator Ternary operator is also known as conditional operator that evaluate something based on a condition being true or false. It simply allows testing a condition in a single line

Delimiters Python uses the symbols and symbol combinations as delimiters in expressions, lists, dictionaries and strings

Literals Literal is a raw data given in a variable or constant Numeric String Boolean Numeric Literals Numeric Literals consists of digits and are immutable String Literals In Python a string literal is a sequence of characters surrounded by quotes. Python supports single, double and triple quotes for a string. Boolean Literals A Boolean literal can have any of the two values: True or False.

Escape Sequences The backslash "\" is a special character, also called the "escape" character. It is used in representing certain whitespace characters

Python Data types Number String Boolean Tuples lists dictionaries

MAIL : mrajivgandhibcomca@gmail.com எந்த அளவு நீ உயர்ந்தவனாக வேண்டும் என்று நினைக்கிறாயோ அந்த அளவுக்கு கடுமையான சோதனைகளை நீ கடந்து செல்ல வேண்டும் CELL : 9524756933 MAIL : mrajivgandhibcomca@gmail.com