DataType Variable Expression

DataType Variable Expression

Introduction

Basic Data Types Numeric
Integer
Floating
point
Boolean
String
• Composite Data Types
List
Tuple
Dictionary
Set

NUMBERS
•Use numbers directly in your source code
Do not use quotation marks as they are for strings.
Note: * Pick variable name that represent data that variable will hold

BOOLEAN
A Boolean variable can reference one of two values: True or False.Boolean variables are commonly used as flags, which indicate whetherspecific conditions exist.

VARIABLES AND STRING
StringsRepresent text
Surrounded by quotes

Note: * Strings are start with ‘ or “ and end with ’or ”
Using Quotes within Strings
VARIABLES AND STRING
sentence = 'She said, "That is a great tasting apple!" '
sentence = " That's a great tasting apple! "

Using Quotes within Strings
double = "She said, \"That 's a great tasting apple! \" " single = 'She said, "That\'s a great tasting apple! " '

PYTHON OPERATORS
What are operators in python?
Operators are special symbols in Python that carry outarithmetic or logical computation. The value that the operator operates on is called the operand.

ARITHMETIC OPERATORS

COMPARISON OPERATORS

LOGICAL OPERATORS

BITWISE OPERATORS

ASSIGNMENT OPERATORS

IDENTITY OPERATORS
is and is not are the identity operators in Python. They are used to check if two values (or variables) are located on the same part of the memory. Two variables that are equal does not imply that they are identical.

MEMBERSHIP OPERATORS
in and not in are the membership operators in Python. They are used to testwhether a value or variable is found in a sequence (string, list, tuple, set and dictionary).In a dictionary we can only test for presence of key, not the value.

INPUT
Programs commonly need to read input typed by the user on thekeyboard. We will use the Python functions to do this. Python's built-in input function to read input from the keyboard. The input function reads a piece of data that has been entered at the keyboard and returns that data, as a string, back to the program. You normally use the input function in an assignment statement that follows this general format

INPUT NUMBERS
The input function always returns the users input as a string, even if the user enters numeric data. For example, suppose you call the input function, type the number 87, and press the Enter key. The value that is returned from the input function is the string '87'. This can be a problem if you want to use the value in a math operation. Math operations can be performed only on numeric values, not strings.

COMMENTS
Comments are notes of explanation that document lines or sections of a program. Comments are part of the program, but the Python interpreter ignores them. They are intended for people who may be reading the source code.