Getting started

Python Setup

Install python using the below link

Anaconda

present python version : 3.8.3

Python Environments

There are 3 main types of python Environments

  1. Text Editors
  2. Full IDEs
  3. Notebook Environments

Interactive mode - Interactive mode is a command line shell where user gets immediate result for the statements having the previous ran statements in active memory.

  • # for comments
  • """ """ for doc string - information about a function - for the purpose of documentation

Basic Data types

  • int
  • float
  • string

To know the type of variable

x = 'bhavya'
type(x)

+ Symbol

  • 2+3
  • 'Hello' + 'World'

Converting the data types

  • int()
  • float()
  • string()

Booleans

  • True
  • False
2 > 3

False

Numbers

2 + 3
2 - 3
2 * 3
2 ** 3
2 ** 0.5

round((0.1+0.2),1)
Order of precendence - PAMDES If there are operators with same precendence - calculate from left to right

String formatting

Formatting with .format() method

print('This is our new {}', format('string'))

print('These are the strings inline, {},{},{}', format('first', 'second', 'third'))

print('These are the strings inline, {0},{1},{2}', format('first', 'second', 'third'))

print('These are the strings inline, {f},{s},{t}', format(f ='first', s='second', t='third'))

Float formatting follows "{value:width.precision f}"

result = 100/777

print("The result was {r}".format(r=result))

print("The result was {r:1.3f}".format(r=result))

f-strings (formatted string literals) method

name = "Bhavya"
age = 28

print(f'{name} is {age} years old.')