PYTHON BASICS

PRINTING:

To print output in console print() statement is used.

  • To print sequence, the text is enclosed in single or double quotes
  • To print numeric, the numbers are need not to be placed in quotation marks

Syntax: print(" ")

print(10)
print("hello")

VARIABLE:

A variable is character or name given to store any values.

  • To assign variable to a sequence, a variable is declared followed by "=" sign and then the text is enclosed in single or double quotes
  • To assign variable to a numeric, a variable is declared followed by "=" sign and then the value 

a=3
b="hello"
print(a,b)

EXPRESSIONS:

An expression is a basic mathematical calculation.
a=3
b=3
c=a+b
print(c)

CONDITIONS:
a=3
b=3
if a==b:
    print("True")
elif a==6:
    print("a is 6")
else:
    print("False")

FUNCTIONS:
def addition(a,b)
    return a+b
addition(3,2)

def addition(a,b)
    print(a+b)
addition(3,2)

DATA TYPES:
Numeric:
  -> Integer
    a = 5
    print("Type of a: ", type(a))
  -> Float
    b = 5.0
    print("Type of b: ", type(b))
  -> Complex Numbers
    c = 2 + 4j
    print("Type of c: ", type(c))
Sequence:
  -> Strings
    String1 = "CodeCraft"
    print(String1) 
  -> List
    List1=[]
    List2 = ['Code','Craft'] 
    print(List1, List2) 
  -> Tuple
    Tuple1=()
    Tuple2= ('Code','Craft') 
    print (Tuple1, Tuple2) 
Boolean
    print(type(True))
    print(type(False))
    print(type(true))
Set
    set1 = set() 
    print(set1)
Dictionary
    Dict1 = {} 
    Dict2 = {1: 'Geeks', 2: 'For', 3: 'Geeks'} 
    print(Dict1, Dict2)