I have been working as a software developer since 2019. I have started coding since 2014. I have watched a lot of tutorials and read many books. But today I understood "Generator" properly. Thank you sir, you are really great. ❤❤
51:00 So, basically what I've understood, "yield" is kind of like the "static" keyword which is used in c/c++. when we say, "static int a = 5;" inside of a function & we call that function multiple times or call that function using a loop, that static variable "a" saves it's previous state in memory & performs the next tasks with it's previous state every single time function is called. not saying they are the same. But yeah, i found it familiar.
19:45 Precision can be achieved using round() function as given below: def circle_stats(radius): area=math.pi*radius**2 circumference=2*math.pi*radius return *round(area,2),round(circumference,2)* print(circle_stats(5)) (78.54, 31.42) *Further, can we round off multiple values at once instead of doing separately for each one?*
Thanks for such a simplistic, professional and in-depth content for question 6(26:06), I used this: cube = lambda user_in: user_in ** 3 user_in = float(input('Input a number for cube')) print(cube(user_in))
20:12 1) first method Below formatted variable will be displayed with 5 decimal values formatted = "{:.5f}".format(9.999875698989) print(formatted) # output : 9.99988 And suppose we write like this formatted = "{:.3f}".format(9.999875698989) print(formatted) # output : 10 Then it will return 10 as output. 2) using round() In this function we will pass two parameters, first is our value or variable and second is how many decimal values we want. Example_1: Number = 5.375829473 print(round(Number,2) # output : 5.36 Example_2 : print(round(5.53627894,2)) # output : 5.53
Learning Python day 10 - present sir 00:03 Introduction to functions in Python 02:16 Learning functions in Python with confidence 06:06 Variables and function parameters in Python 08:07 Using the return keyword to output a result from a function in Python 12:05 Polymorphism in Python functions 14:17 Creating functions to return multiple values in Python 18:22 Returning multiple values from a function in Python 20:22 Creating and handling functions in Python. 24:13 Creating a function to compute the cube of a number 25:53 Understanding function definitions in Python 29:25 Using Python's special parameters to handle input values efficiently. 31:21 Printing and investigating errors in Python functions 34:53 Functions in Python and their usage with keyword arguments 36:52 Understanding function definitions and arguments in Python 40:42 Using formatting strings to print values in Python functions 42:33 Creating a function to generate even numbers with a limit in Python. 46:37 Understanding function implementation in Python 48:38 Functions in Python use yield to produce a sequence of values 52:16 Creating a function to calculate factorial and understanding recursion 54:18 Recursive approach to calculate factorial in Python 57:56 Learned the key concepts of functions in Python
51:07 I have worked on some personal projects in deep learning and one use case of yield is handling huge amount of datasets where we need to fetch a batch of numbers from the datasets to perform calculation of gradients during backpropogation which is a way to optimized neural networks loss calculations
my mind is just tuned with all your words, they just directly print into my mind i just simply run those without any errors , i think you have hacked my mind....grate full to u sir
20:11 import math def circlestat(radius): area = math.pi * radius **2 circumference = 2* math.pi *radius return area ,circumference a,b = circlestat(6) a= round(a,3) b=round(b,3) print("area: ",a , "circumference",b) round() is used to take those values upto 2 or 3 decimal places only
To avoid those recurring decimal in solution_04, we can use round() method to avoid those recurring decimals and can convert it to 1 , 2 or any decimal place you like. Source Code: import math def circle_stats(radius): area = round(math.pi * radius ** 2,2) circumference = round(2 * math.pi * radius,2) return area, circumference a , c = circle_stats(3) print("Area: ", a, "Circumference: ", c)
import math def circle(radius): area = round(math.pi*(radius**2),2) circumference = round((2 * math.pi * radius) ,2); return area , circumference; r = int(input("Enter Radius: ")) a , c = circle(r) print("The Area is: ",a) print("The Circumference is: ",c)
def area_circumference(a): area = (3.14)*(a)*(a) circumference =2*3.14*(a) print("area=",area) print("circumference=",circumference) a = float(input("enter the radius:")) (area_circumference(a))
Now I'm feeling that I'm diving into the internal working of python. The way he explains every topics that is phenomenal. I'm regularly waiting for his python series videos. Thanks sir for making this wonderful series.
We can use the f-strings functionality. For example, if we want precision up-to 2 digits, then we can type: - print(f"Area : {a:.2f} Circumference: {c:.2f}")
import math def circle(r): area = math.pi * r * r circumference = 2 * math.pi * r return(f'%.2f'%area,f'%.2f'%circumference) # to get output in 2 decimal r = int(input("Enter the radius:-")) print(circle(r))
import math def circle_stats(radius): area = round(math.pi *radius**2,2) circum = round(2*math.pi*radius,2) return (" area is" ,area, "circumference is ",circum) print(circle_stats(5))
sir aapko killvish ko bhi add karna chahiye tha main villan ki tor pe wese is tarike se python ke function ko sikh kar ke maza hi aa gaya love from mumbai sir ji ❤❤
Thanks sir for the Class . My Code of Todays Class import math def square(num): return (num ** 2) def add(numOne,numTwo): return numOne+numTwo def multiply(p1,p2): return p1*p2 def Circle(r): Area= math.pi*r**2 circumference=2*math.pi*r return Area,circumference a,b=Circle(4); ''' Lamba Function''' cube = lambda x:x**3 ''' Function with *args , * means it takes all the val , if only args then only 1 value''' def sum_all(*args): return sum(args) def print_kwargs(**kwargs): for key,value in kwargs.items(): print(f"{key} : {value}") """ Yeilds!""" def even_generator(limit):
for i in range(2,limit+1,2): yield i
def factorial(n): if(n==0): return 1 else: return n *factorial(n-1) print("Sqaure",square(4)) print("Addition",add(5,5)) print("multiplication",multiply(7,4)) print("Area of cirlce " ,math.floor(a)) print("circumference of circle",math.floor(b)) print("Lamba Function",cube(3)) print("function with *args",sum_all(3)) print("function with *args",sum_all(3,4,5)) print("function with *args",sum_all(3,7,8,8,9)) print_kwargs(name="faraz",power="infinity", enemy="DSA") for num in even_generator(10): print(num) print("factorial ",factorial(5))
#assignment import math def circle(radius): area = round(math.pi*(radius**2),2) circumference = round((2 * math.pi * radius) ,2); return area , circumference; r = int(input("Enter Radius: ")) a , c = circle(r) print("The Area is: ",a) print("The Circumference is: ",c)
Sir,For the question no.3 When two inputs are taken from the user like one is int and other is string types without direct passing as an argument then what will be happend ??
I know some basics of python but whenever I watch your videos , I consistently gain new insights and knowledge.
But your code shows errors lol
19:52
import math
def circle_stats(radius):
area = math.pi* 2 * radius**2
circumference = 2 * math.pi * radius
return area, circumference
a, c = circle_stats(3)
print(f"Area = {round(a,2)}
Circumference = {round(c,2)}")
I have been working as a software developer since 2019. I have started coding since 2014. I have watched a lot of tutorials and read many books. But today I understood "Generator" properly. Thank you sir, you are really great. ❤❤
amazing video :)
TimeStamp:-
20:24
Precision upto x decimal places can be achieved by using
round(variable_name,x)
51:00
So, basically what I've understood,
"yield" is kind of like the "static" keyword which is used in c/c++.
when we say, "static int a = 5;" inside of a function & we call that function multiple times or call that function using a loop, that static variable "a" saves it's previous state in memory & performs the next tasks with it's previous state every single time function is called.
not saying they are the same. But yeah, i found it familiar.
19:45
Precision can be achieved using round() function as given below:
def circle_stats(radius):
area=math.pi*radius**2
circumference=2*math.pi*radius
return *round(area,2),round(circumference,2)*
print(circle_stats(5))
(78.54, 31.42)
*Further, can we round off multiple values at once instead of doing separately for each one?*
Solution of 20:26 :
print(“area:”,round(a,2),”circumference”,round(b,2))
Thanks buddy..........
Sir, apke help se hum sab to hopeful hain... Thanks Alot!
Thanks for such a simplistic, professional and in-depth content
for question 6(26:06), I used this:
cube = lambda user_in: user_in ** 3
user_in = float(input('Input a number for cube'))
print(cube(user_in))
20:12
1) first method
Below formatted variable will be displayed with 5 decimal values
formatted = "{:.5f}".format(9.999875698989)
print(formatted) # output : 9.99988
And suppose we write like this
formatted = "{:.3f}".format(9.999875698989)
print(formatted) # output : 10
Then it will return 10 as output.
2) using round()
In this function we will pass two parameters, first is our value or variable and second is how many decimal values we want.
Example_1:
Number = 5.375829473
print(round(Number,2) # output : 5.36
Example_2 :
print(round(5.53627894,2)) # output : 5.53
Great! The format method was new to me.
Learning Python day 10 - present sir
00:03 Introduction to functions in Python
02:16 Learning functions in Python with confidence
06:06 Variables and function parameters in Python
08:07 Using the return keyword to output a result from a function in Python
12:05 Polymorphism in Python functions
14:17 Creating functions to return multiple values in Python
18:22 Returning multiple values from a function in Python
20:22 Creating and handling functions in Python.
24:13 Creating a function to compute the cube of a number
25:53 Understanding function definitions in Python
29:25 Using Python's special parameters to handle input values efficiently.
31:21 Printing and investigating errors in Python functions
34:53 Functions in Python and their usage with keyword arguments
36:52 Understanding function definitions and arguments in Python
40:42 Using formatting strings to print values in Python functions
42:33 Creating a function to generate even numbers with a limit in Python.
46:37 Understanding function implementation in Python
48:38 Functions in Python use yield to produce a sequence of values
52:16 Creating a function to calculate factorial and understanding recursion
54:18 Recursive approach to calculate factorial in Python
57:56 Learned the key concepts of functions in Python
You are the best teacher,❤ in this platform,,
Kudos to you, sir, for explaining yield in such a simplified manner, as if you were explaining it to a 5-years-old.
thank you sir. I came to know about yeild for the first time. One application of args is in shoping cart.
51:07 I have worked on some personal projects in deep learning and one use case of yield is handling huge amount of datasets where we need to fetch a batch of numbers from the datasets to perform calculation of gradients during backpropogation which is a way to optimized neural networks loss calculations
Great video, yr 2 din se kuch smj nhi aa rha tha ise dekh k maza aa gya
my mind is just tuned with all your words, they just directly print into my mind i just simply run those without any errors , i think you have hacked my mind....grate full to u sir
20:11 import math
def circlestat(radius):
area = math.pi * radius **2
circumference = 2* math.pi *radius
return area ,circumference
a,b = circlestat(6)
a= round(a,3)
b=round(b,3)
print("area: ",a , "circumference",b)
round() is used to take those values upto 2 or 3 decimal places only
20:10
import math
def circle_stats(radius):
area = math.pi * radius * radius
circumference = 2 * math.pi * radius
return area, circumference
a, c = circle_stats(3)
print(f"Area: {a:.3f}, Circumference: {c:.3f}")
Super Guru ji.....Very insightful.....You are a great teacher Hitesh sir ji....keep up the great work......Respect from Bangalore...
To avoid those recurring decimal in solution_04, we can use round() method to avoid those recurring decimals and can convert it to 1 , 2 or any decimal place you like.
Source Code:
import math
def circle_stats(radius):
area = round(math.pi * radius ** 2,2)
circumference = round(2 * math.pi * radius,2)
return area, circumference
a , c = circle_stats(3)
print("Area: ", a, "Circumference: ", c)
import math
def circle(radius):
area = round(math.pi*(radius**2),2)
circumference = round((2 * math.pi * radius) ,2);
return area , circumference;
r = int(input("Enter Radius: "))
a , c = circle(r)
print("The Area is: ",a)
print("The Circumference is: ",c)
in your code you are not defined how many precision after point like 2,3or 4
Yr 900 views h fir bhi 400 comment kyu nhi hai😢 support kro yr sab chai aur code ko
this is my favorite youtube channel , nice teaching sir ji
The way he explained Yield keyword is beautiful !! LoveFromINDORE
def square(a):
print(a*a)
a =int(input("enter the number:"))
square(a)
We do use round method for getting precise values. e.g., round(number, 2) for getting precision upto 2 digits.
Thank you for this video, never learned in this simplified way
def sums(*arg):
total =0
for i in arg:
total+=i
print(total)
sums(1200.50,
340.75,
560.00,
980.25,
2150.00)
I have never ever seen this kind of teaching 🙏,Thank you sir for you your efforts for us.
thank you so much for teaching us in depth, lots of love from Jharkhand
y =lambda x:x**3
x = float(input("enter the number:"))
print(y(x))
def radius(r):
area = 3.14* r*r
circumference = 2*3.14*r
return area, circumference
area, circumference = radius(5)
formatted = "{:.3f}".format(area)
formatted = "{:.3f}".format(circumference)
print(formatted)
# print(radius(5))
really a good teaching technique sir
def area_circumference(a):
area = (3.14)*(a)*(a)
circumference =2*3.14*(a)
print("area=",area)
print("circumference=",circumference)
a = float(input("enter the radius:"))
(area_circumference(a))
import math
def circle_calculate(radius):
area = math.pi *radius**2
circumference = 2 * math.pi * radius
return area, circumference
a,c = circle_calculate(3)
print("Area:",round(a,2), "Circumference:",round(c,2))
Now I'm feeling that I'm diving into the internal working of python. The way he explains every topics that is phenomenal. I'm regularly waiting for his python series videos. Thanks sir for making this wonderful series.
51:00 amazing explanation sir👏
We can use the f-strings functionality. For example, if we want precision up-to 2 digits, then we can type: -
print(f"Area : {a:.2f} Circumference: {c:.2f}")
import math
def circle_stats(radius):
circle = math.pi * radius ** 2
circumference = 2 * math.pi * radius
return round(circle,2), round(circumference,2)
radius = int(input("Enter radius: "))
circle, circumference = circle_stats(radius)
print("Area: ",circle ,"&" , "Circumference: ",circumference)
reached functions!🥳 was left behind a few videos for a while, but covering it up!!!!🤧
❤ the way of teaching
Direct jump on hands on approach
05) USER INPUT
def greet(name="USER"):
return "HELLO ," + name + " !"
n1 = str(input("ENTER YOUR NAME : "))
if len(n1) >0:
print(greet(n1))
else:
print(greet())
Problem 4:
import math
def calc_circle(radius):
area = math.pi * radius ** 2
circumference = 2 * math.pi * radius
return area, circumference
a, c = calc_circle(3)
print("Area: ", round(a, 2), "Circumference: ", round(c, 2))
Sab mil kar appreciate kro yr sir ki dedication ko quality content ke liye..😊
Such in depth explanation is astonishing in free courses! 🙌
Thank you Sir, You really made thing so easy to understand.
Thank you so much sir for ❤ I love your way to teach and enjoying ever vedio of Chay and code .thank you❤
import math
def circle(r):
area = math.pi * r * r
circumference = 2 * math.pi * r
return(f'%.2f'%area,f'%.2f'%circumference) # to get output in 2 decimal
r = int(input("Enter the radius:-"))
print(circle(r))
19:51
print(f"Area: {a:.2f}
Circumference: {round(c,2)}")
import math
def circle_stats(radius):
area = round(math.pi *radius**2,2)
circum = round(2*math.pi*radius,2)
return (" area is" ,area, "circumference is ",circum)
print(circle_stats(5))
This series YIELDS in depth knowledge.😁😁
Every topic is explained very neatly and clearly.
I love your teaching hitesh sir !!! I connect with you in coding
sir aapko killvish ko bhi add karna chahiye tha main villan ki tor pe
wese is tarike se python ke function ko sikh kar ke maza hi aa gaya
love from mumbai sir ji ❤❤
you explained very well, thank you sir
Now "yield" is very clear to me ❤
the best channel to learn Python. need flask tutorial too Sir.
Best Video Ever on Functions
really loved this way of learning...
28:21
cube = lambda x : x**3
a = cube(4)
print(a)
print(cube(3))
it seems we can lambda like as def
Awsome Guru ji.......Pls make more videos on python DSA focused on Data Science and Machine Learning........Respect from Bangalore...
def greet(name):
if name == "":
print("hello world")
else:
print("hello",name)
name=input("enter the name:")
greet(name )
Easy Method
import math
def circle(radius):
area = round((math.pi * radius ** 2),2)
circumference = round((2 * math.pi * radius),2)
return area, circumference
print(circle(3))
Awesome lessons!!! Very well explained
Exited for the series that will based on python, Please start with Django if possible, It will be next level in your style and explanation in depth ♥
yup. django from his side will be amazing
Good way of teaching 👍
Amazing content sir..❤..if you plan to make another lecture, plz dive in little more in Recursion and Yield concept .
bahut achha lagta h sir ap se sikhane me
Thanks sir for the Class . My Code of Todays Class
import math
def square(num):
return (num ** 2)
def add(numOne,numTwo):
return numOne+numTwo
def multiply(p1,p2):
return p1*p2
def Circle(r):
Area= math.pi*r**2
circumference=2*math.pi*r
return Area,circumference
a,b=Circle(4);
''' Lamba Function'''
cube = lambda x:x**3
''' Function with *args , * means it takes all the val , if only args then only 1 value'''
def sum_all(*args):
return sum(args)
def print_kwargs(**kwargs):
for key,value in kwargs.items():
print(f"{key} : {value}")
""" Yeilds!"""
def even_generator(limit):
for i in range(2,limit+1,2):
yield i
def factorial(n):
if(n==0):
return 1
else:
return n *factorial(n-1)
print("Sqaure",square(4))
print("Addition",add(5,5))
print("multiplication",multiply(7,4))
print("Area of cirlce " ,math.floor(a))
print("circumference of circle",math.floor(b))
print("Lamba Function",cube(3))
print("function with *args",sum_all(3))
print("function with *args",sum_all(3,4,5))
print("function with *args",sum_all(3,7,8,8,9))
print_kwargs(name="faraz",power="infinity", enemy="DSA")
for num in even_generator(10):
print(num)
print("factorial ",factorial(5))
Thankyou so much sir for scenario teaching ❤
Perfect Teaching 👌
Best python tutorial ever
"This series is a hidden treasure for programmers."
round(number,2)
print("Area is : ",round(a,2) , "
Circumference is: ",round(c,2))
Very nice explanation of function concept
very nice recursive problem solving approch
# Lambda Function
# Problem: Create a lambda function to compute the cube of a number.
cube = lambda x : (x ** 3)
print(cube(2))
very helpful video for a new learner!
amazing way of teaching functions
yield and recursion are really interesting
Explanation of Recursive function with pen & diagram sir 😊
Loving These Pytho_Series❤
Nice sir your videos are very helpful love from Pakistan
solution:-
def radius(r1):
area=math.pi*r1**2
circumference=2*math.pi*r1
return area, circumference
a,c=radius(4)
print(f"area={round(a,2)}
circumference={round(c,2)}")
#assignment
import math
def circle(radius):
area = round(math.pi*(radius**2),2)
circumference = round((2 * math.pi * radius) ,2);
return area , circumference;
r = int(input("Enter Radius: "))
a , c = circle(r)
print("The Area is: ",a)
print("The Circumference is: ",c)
Thank you sir cover the function topics
20:20
Round method can be used to get result with n decimal places.
print "Area:", round(a,n), "Circumference:", round(c,n))
Sir whatever you will to teach I'll learn all of it
Love this way of solving problem learning ❤
Sir,For the question no.3
When two inputs are taken from the user like one is int and other is string types without direct passing as an argument then what will be happend ??
for Area and Circumference exercise, we can use Round of method to get result printed by 2 or 3 digits.
Very nicely explaining sir...
This is something you will never get for free. Best series for python !!
Better than a paid course 💯
Thank you sir for building this things easily
awesome really a good practice adapt to teach
Best Video for python
Thank you so much sir , we really love this series also. ❤❤
Thank you so much for deep explanation it is very helpful sir
print("Area :","%.2f"% a)
print("Circumference :","%.3f"% c)