01 - Introduction
Example 1:
# Check the python version, some operating system use python3
python --version
python3 --version
Example 2:
# Check the pip version, pip is python package manage
pip --version
pip3 --version
Example 3:
# Check the python version from python console
import sysprint(sys.version)
print(sys.version.index)
Example 4:
# Print Hello Friends
print("Hello Friends")02 - Modules, Comments, & Pip
Modules:1. Built in modules - Pre installed
2. External modules - Need to install using pip
Comments:
1. Single line comments
2. Multi line comments
Pip:
Pip is a package manager in python
Example 1:
# Built in modules
import os
os.system("ls")
Example 2:
# Built in modules
import sys
print(sys.version)
print(sys.version)
Example 3:
# External modules, that you need to install from internet
# Below command gives you the error, you need to install flash
import flash
Example 4:
# Single line comments
# my first comment
Example 5:
# Multi line comments
'''First line
Second line
Third line'''
Example 6:
# Get the installed and pre installed module details
pip list
pip3 list
03 - Variables & Datatypes
Datatype
Numbers (
String
List
Tuple
Dictionary
# Variables
a="Ravin"
b=123
c=12.34
# Check the type of variables
print(type(a))
print(type(b))
print(type(c))
# Operators in Python
Arithmetic (+, -, *, /)
Assignment (=, +=, -=)
Comparison (==, >, >=, <, !=)
Logical (and, or, not)
# Typecast
a="1234"
a=int(a)
print(type(a))
print(a+5)
# Input String
a=input("Enter your name: ")
print(a)
# Input Integer
a=input("Enter number: ")
a=int(a)
print(a)
04 - Strings
# Single quoted strings
a='Ravin'
print(a)
b='Ravin"s'
print(b)
# Double quoted strings
a="Ravin"
print(a)
b="Ravin's"
print(b)
# Triple quoted strings
a='''Ravin'''
print(a)
b='''Ravin's'''
print(b)
c='''Ravin"s'''
print(c)