Solve 10 problems on functions in python

preview_player
Показать описание
Welcome to chai aur code, a coding/programming dedicated channel in Hindi language. Now you can learn best of programming concepts with industry standard practical guide in Hindi language.

All source code is available at my Github account:

Instagram pe yaha paaye jaate h:

Рекомендации по теме
Комментарии
Автор

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)}\nCircumference = {round(c, 2)}")

hellohere-puuj
Автор

I know some basics of python but whenever I watch your videos, I consistently gain new insights and knowledge.

justtt.prerna
Автор

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.

SadmanSakib
Автор

20:12
1) first method
Below formatted variable will be displayed with 5 decimal values
formatted =

print(formatted) # output : 9.99988

And suppose we write like this
formatted =

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

priya_chauhan
Автор

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}")

umairansari
Автор

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. ❤❤

zakirdev
Автор

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

dakshbhatnagar
Автор

Solution of 20:26 :
print(“area:”, round(a, 2), ”circumference”, round(b, 2))

softNandan
Автор

amazing video :)

TimeStamp:-
20:24
Precision upto x decimal places can be achieved by using
round(variable_name, x)

shikharpandya
Автор

20:20
Round method can be used to get result with n decimal places.

print "Area:", round(a, n), "Circumference:", round(c, n))

OMKARANAVKAR
Автор

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

swarnabhamajumder
Автор

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)

muhammadhilal
Автор

19:45
Precision can be achieved using round() function as given below:

def circle_stats(radius):
area=math.pi*radius**2

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?*

epslearns
Автор

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

odecgbu
Автор

Sir, apke help se hum sab to hopeful hain... Thanks Alot!

sheikhabdullah
Автор

Kudos to you, sir, for explaining yield in such a simplified manner, as if you were explaining it to a 5-years-old.

pranaypaul
Автор

thank you sir. I came to know about yeild for the first time. One application of args is in shoping cart.

atharvatirkhunde
Автор

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}")

viditvats
Автор

We do use round method for getting precise values. e.g., round(number, 2) for getting precision upto 2 digits.

ashishkumarbhagwani
Автор

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 ♥

zyhwyip