Python : Variables, Data Types, Boolean & Operators

varible

Basic Foundation Concepts - Project 3

In this program the basic python such as comments , varibles, Data Types, Booleans and operations are explained with examples. 

The int() function converts the specified value into an integer number. 

      int(value, base) -syntex

Creating Variables : Variables are containers for storing data values.Unlike other programming languages, Python has no command for declaring a variable.A variable is created the moment you first assign a value to it. 

String Literals

String literals in python are surrounded by either single quotation marks, or double quotation marks.

‘hello’ is the same as “hello”.

You can display a string literal with the print() function:

example :

print(‘in 2020, you will be’, 2020 -int3)
counter = 100
miles = 1000.0
name = “john”

Built-in Data Types In programming, data type is an important concept.Variables can store data of different types, and different types can do different things.Python has the following data types built-in by default, in these categories:

Text Type:

str

Numeric Types:

int, float, complex

Sequence Types:

list, tuple, range

Mapping Type:

dict

Set Types:

set, frozenset

Boolean Type:

bool

Binary Types:

bytes, bytearray, memoryview

Python Arithmetic Operators:

 

Operator

Name

Example

+

Addition

x + y

Subtraction

x – y

*

Multiplication

x * y

/

Division

x / y

%

Modulus

x % y

**

Exponentiation

x ** y

//

Floor division

x // y

 

Share on facebook
Facebook
Share on twitter
Twitter
Share on linkedin
LinkedIn
Share on pinterest
Pinterest
Categories

Leave a Reply

Your email address will not be published. Required fields are marked *