Python Training

Python

Trending Questions and Lessons

Follow 20,143 Followers

Feed

Ask a Question

All

Lessons

Discussion

Overview

Questions 810

Lessons 48

Total Shares  

Lesson Posted on 29 Mar IT Courses/Programming Languages/Python

Difference between Python 2.x and Python 3.x

Praveen Choudhary

I am an experienced and qualified trainer having more than 11 years of teaching computer science in...

Python 2.x and Python 3.x differs in following features: Division operator print function Unicode xrange Error Handling __future__ module
Comments
Dislike Bookmark Share

Lesson Posted on 25 Mar IT Courses/Programming Languages/Python

Python Demo

Madhu Nandha

8+ years of experience in coding, testing, developing, enhancing, and implementing applications. ->Selected...

https://www.youtube.com/watch?v=8AEhpZ4lbOI
Comments
Dislike Bookmark Share

Lesson Posted on 25 Mar IT Courses/Programming Languages/Python

Python Demo

Madhu Nandha

8+ years of experience in coding, testing, developing, enhancing, and implementing applications. ->Selected...

https://www.youtube.com/watch?v=8AEhpZ4lbOI
Comments
Dislike Bookmark Share

Top Contributors

Connect with Expert Tutors & Institutes for Python

Lesson Posted on 24 Feb IT Courses/Programming Languages/Python

OS Module

Praveen Choudhary

I am an experienced and qualified trainer having more than 11 years of teaching computer science in...

1. OS module interacts with your operating system. Use this to create folder, remove folder, move folder, change the working directory. Ex: import oscurDir=os.getcwd() #get current working directoryprint(curDir)os.mkdir('praveen') # make a new directoryos.rename('praveen','trainer')#change the name... read more

1. OS module interacts with your operating system.

Use this to create folder, remove folder, move folder, change the working directory.

Ex:

import os
curDir=os.getcwd() #get current working directory
print(curDir)
os.mkdir('praveen') # make a new directory
os.rename('praveen','trainer')#change the name of , or rename, a directory
os.rmdir('trainer') #remove a directory

 

2. OS Module interacts with your operating system for navigating directories.

Ex:

import os
#where are we?
#cwd=os.getcwd()
print("1:",os.getcwd())
#go down
os.chdir("Scripts")
print("2:",os.getcwd())

#go back up
os.chdir(os.pardir)
print("3:",os.getcwd())

os.chdir(os.pardir)
print("4:",os.getcwd())

read less
Comments
Dislike Bookmark Share

Lesson Posted on 19 Feb IT Courses/Programming Languages/Python

Decorator Introduction

Praveen Choudhary

I am an experienced and qualified trainer having more than 11 years of teaching computer science in...

A decorator takes in a function, adds some functionality and returns it. Functions can be passed as arguments to another function like map, filter and reduce Function that take other functions as arguments are called higher order functions. Ex:def inc(x): return x + 1 def dec(x): return x... read more

A decorator takes in a function, adds some functionality and returns it.

Functions can be passed as arguments to another function like map, filter and reduce

Function that take other functions as arguments are called higher order functions.

Ex:
def inc(x):
     return x + 1

def dec(x):
     return x - 1

def operate(func, x):
     result = func(x)
     return result

print(operate(inc,3)) #4
print( operate(dec,3)) #2

read less
Comments
Dislike Bookmark Share

Lesson Posted on 19 Feb IT Courses/Programming Languages/Python

Decorators In Python

Praveen Choudhary

I am an experienced and qualified trainer having more than 11 years of teaching computer science in...

A decorator takes in a function, adds some functionality and returns it. Functions and methods are called callable as they can be called. Any object which implements the special method __call__() is termed callable. A decorator is a callable that returns a callable. A decorator takes in a function,... read more

A decorator takes in a function, adds some functionality and returns it.

Functions and methods are called callable as they can be called.

Any object which implements the special method __call__() is termed callable.

A decorator is a callable that returns a callable.

A decorator takes in a function, adds some functionality and returns it.

def make_pretty(func):
           def inner():
                 print("I got decorated")
                 func()
           return inner

def ordinary():
           print("I am ordinary")

ordinary() #outputs "I am ordinary"
# let's decorate this ordinary function
pretty = make_pretty(ordinary)
pretty()

#outputs:
I got decorated
I am ordinary
#make_pretty() is a decorator.
#pretty = make_pretty(ordinary)
#The function ordinary() got decorated and the returned function was given the name pretty.

read less
Comments
Dislike Bookmark Share

Lesson Posted on 19 Feb IT Courses/Programming Languages/Python

Multiple Decorators

Praveen Choudhary

I am an experienced and qualified trainer having more than 11 years of teaching computer science in...

#Multiple decorators can be chained in Python.#A function can be decorated multiple times with different (or same) decorators.#We simply place the decorators above the desired function. def star(func): def inner(*args, **kwargs): print("*" * 30) func(*args,... read more

#Multiple decorators can be chained in Python.
#A function can be decorated multiple times with different (or same) decorators.
#We simply place the decorators above the desired function.

def star(func):
          def inner(*args, **kwargs):
                  print("*" * 30)
                  func(*args, **kwargs)
                  print("*" * 30)
          return inner

def percent(func):
        def inner(*args, **kwargs):
                 print("%" * 30)
                 func(*args, **kwargs)
                 print("%" * 30)
        return inner

@star
@percent
def printer(msg):
        print(msg)

printer("Hello")

#The order in which we chain decorators matter.Example below shows the difference.
@percent
@star
def printer(msg):
        print(msg)

printer("Hello")

read less
Comments
Dislike Bookmark Share

Lesson Posted on 19 Feb IT Courses/Programming Languages/Python

Shallow And Deep Copying

Praveen Choudhary

I am an experienced and qualified trainer having more than 11 years of teaching computer science in...

The difference between shallow and deep copying is only relevant for compound objects (objects that contain other objects, like lists or class instances): A shallow copy constructs a new compound object and then (to the extent possible) inserts references into it to the objects found in the original. A... read more

The difference between shallow and deep copying is only relevant for compound objects (objects that contain other objects, like lists or class instances):

A shallow copy constructs a new compound object and then (to the extent possible) inserts references into it to the objects found in the original.

A deep copy constructs a new compound object and then, recursively, inserts copies into it of the objects found in the original.

Here's a little demonstration:

import copy

a = [1, 2, 3]
b = [4, 5, 6]
c = [a, b]

Using normal assignment operatings to copy:

d = c

print id(c) == id(d) # True - d is the same object as c
print id(c[0]) == id(d[0]) # True - d[0] is the same object as c[0]
Using a shallow copy:

d = copy.copy(c)

print id(c) == id(d) # False - d is now a new object
print id(c[0]) == id(d[0]) # True - d[0] is the same object as c[0]
Using a deep copy:

d = copy.deepcopy(c)

print id(c) == id(d) # False - d is now a new object
print id(c[0]) == id(d[0]) # False - d[0] is now a new object.

read less
Comments
Dislike Bookmark Share

Lesson Posted on 19 Feb IT Courses/Programming Languages/Python

Datetime Module

Praveen Choudhary

I am an experienced and qualified trainer having more than 11 years of teaching computer science in...

#this examples demonstrate use of datetime module import datetimeob=datetime.datetime.now()print("-"*25)print(ob)print(ob.year)print(ob.month)print(ob.day)print(ob.hour)print(ob.minute)print(ob.second)str1=str(ob.hour)+':'+str(ob.minute)+':'+str(ob.second)print (str1)print("-"*25)print("1 week ago was... read more

#this examples demonstrate use of datetime module

import datetime
ob=datetime.datetime.now()
print("-"*25)
print(ob)
print(ob.year)
print(ob.month)
print(ob.day)
print(ob.hour)
print(ob.minute)
print(ob.second)
str1=str(ob.hour)+':'+str(ob.minute)+':'+str(ob.second)
print (str1)
print("-"*25)
print("1 week ago was it:",ob - datetime.timedelta(weeks=1))
print("100 days ago it was :",ob-datetime.timedelta(days=100))
print("1 week from now it will be:",ob + datetime.timedelta(weeks=1))
print("1000 days ago it will be :",ob + datetime.timedelta(days=100))
print("-"*25)
bday=datetime.datetime(1980,6,10)
print("Birthday in....",ob - bday)
print("-"*25)

 

read less
Comments
Dislike Bookmark Share

Answered on 21 Feb IT Courses/Programming Languages/Python

Kiran

Trainer

No problem learn Python 3.
Answers 5 Comments
Dislike Bookmark Share

About UrbanPro

UrbanPro.com helps you to connect with the best Python Training classes in India. Post Your Requirement today and get connected.

x

Ask a Question

Please enter your Question

Please select a Tag

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 25 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 6.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more