Python Loops Tutorial | Python For Loop | While Loop Python | Python Training | Edureka

  Рет қаралды 326,261

edureka!

edureka!

Күн бұрын

🔥 Python Certification Training (Use Code "𝐘𝐎𝐔𝐓𝐔𝐁𝐄𝟐𝟎"): www.edureka.co/data-science-p...
This Edureka "Python Loops" tutorial (Python Tutorial Blog: goo.gl/wd28Zr) will help you in understanding different types of loops used in Python. You will be learning how to implement all the loops in python practically. Check out our playlist for more videos: goo.gl/Na1p9G
Below are the topics covered in this tutorial:
1) Why to use loops?
2) What are loops
3) Types of loops in Python: While, For, Nested
4) Demo on each Python loop
Subscribe to our channel to get video updates. Hit the subscribe button above.
#Python #Pythontutorial #Pythononlinetraining #Pythonforbeginners #Pythonloops
-------------------------------------------------------------------------------------------
How it Works?
1. This is a 5 Week Instructor led Online Course,40 hours of assignment and 20 hours of project work
2. We have a 24x7 One-on-One LIVE Technical Support to help you with any problems you might face or any clarifications you may require during the course.
3. At the end of the training you will be working on a real time project for which we will provide you a Grade and a Verifiable Certificate!
- - - - - - - - - - - - - - - - -
About the Course
Edureka's Python Online Certification Training will make you an expert in Python programming. It will also help you learn Python the Big data way with integration of Machine learning, Pig, Hive and Web Scraping through beautiful soup. During our Python Certification training, our instructors will help you:
1. Master the Basic and Advanced Concepts of Python
2. Understand Python Scripts on UNIX/Windows, Python Editors and IDEs
3. Master the Concepts of Sequences and File operations
4. Learn how to use and create functions, sorting different elements, Lambda function, error handling techniques and Regular expressions ans using modules in Python
5. Gain expertise in machine learning using Python and build a Real Life Machine Learning application
6. Understand the supervised and unsupervised learning and concepts of Scikit-Learn
7. Master the concepts of MapReduce in Hadoop
8. Learn to write Complex MapReduce programs
9. Understand what is PIG and HIVE, Streaming feature in Hadoop, MapReduce job running with Python
10. Implementing a PIG UDF in Python, Writing a HIVE UDF in Python, Pydoop and/Or MRjob Basics
11. Master the concepts of Web scraping in Python
12. Work on a Real Life Project on Big Data Analytics using Python and gain Hands on Project Experience
- - - - - - - - - - - - - - - - - - -
Why learn Python?
Programmers love Python because of how fast and easy it is to use. Python cuts development time in half with its simple to read syntax and easy compilation feature. Debugging your programs is a breeze in Python with its built in debugger. Using Python makes Programmers more productive and their programs ultimately better. Python continues to be a favorite option for data scientists who use it for building and using Machine learning applications and other scientific computations.
Python runs on Windows, Linux/Unix, Mac OS and has been ported to Java and .NET virtual machines. Python is free to use, even for the commercial products, because of its OSI-approved open source license.
Python has evolved as the most preferred Language for Data Analytics and the increasing search trends on python also indicates that Python is the next "Big Thing" and a must for Professionals in the Data Analytics domain.
Customer Review
Sairaam Varadarajan, Data Evangelist at Medtronic, Tempe, Arizona: "I took Big Data and Hadoop / Python course and I am planning to take Apache Mahout thus becoming the "customer of Edureka!". Instructors are knowledge... able and interactive in teaching. The sessions are well structured with a proper content in helping us to dive into Big Data / Python. Most of the online courses are free, edureka charges a minimal amount. Its acceptable for their hard-work in tailoring - All new advanced courses and its specific usage in industry. I am confident that, no other website which have tailored the courses like Edureka. It will help for an immediate take-off in Data Science and Hadoop working."
For more information, Please write back to us at sales@edureka.co or call us at IND: 9606058406 / US: 18338555775 (toll free).
Instagram: / edureka_learning
Facebook: / edurekain
Twitter: / edurekain
LinkedIn: / edureka

Пікірлер: 151
@edurekaIN
@edurekaIN 5 жыл бұрын
Got a question on the topic? Please share it in the comment section below and our experts will answer it for you. For Edureka Python Course curriculum, Visit our Website: bit.ly/2OpzQWw
@ganeshprem3043
@ganeshprem3043 3 жыл бұрын
I loved your lecture. Your presentation is straightforward and efficient. No wasted words. Your students are lucky.
@shreyawafgaonkar5275
@shreyawafgaonkar5275 3 жыл бұрын
Hey, I am studying in 7th grade and I am learning python. This video really helped me a lot to understand loops. Thanks :)
@edurekaIN
@edurekaIN 3 жыл бұрын
Hi Shreya, thank you :)
@matthewmckeen2302
@matthewmckeen2302 2 жыл бұрын
I've watched Dozens of Python tutorials and this in depth look at loops is the ONLY one that has made me really understand how to use loops! THANK YOU!!!!
@edurekaIN
@edurekaIN 2 жыл бұрын
Hey:) Thank you so much for your sweet words :) Really means a lot ! Glad to know that our content/courses is making you learn better :) Our team is striving hard to give the best content. Keep learning with us -Team Edureka :) Don't forget to like the video and share it with maximum people:) Do subscribe the channel:)
@muhammadaftabzafar6089
@muhammadaftabzafar6089 3 жыл бұрын
Your method of teaching is outstanding. i have become a fan of your teaching skills. This lecture was really helpful. Thanks a lot.
@muskanjacob8563
@muskanjacob8563 3 жыл бұрын
really helpful! thanks for this knowledge.♥️
@paidimarryprithvirakshaksh8153
@paidimarryprithvirakshaksh8153 4 жыл бұрын
the most useful and completely beginner-friendly video on loops ever. thank you so much
@zenentertaintment
@zenentertaintment 5 жыл бұрын
Thanks for the explanation.its very clear for me now.
@edurekaIN
@edurekaIN 5 жыл бұрын
Hey, thanks for watching the video. Do subscribe to our channel and stay connected with us. Cheers!
@anusmitasamanta2608
@anusmitasamanta2608 4 жыл бұрын
sir u r extremely good!!! thank you so much for clearing all my doubts! much appreciation :)
@karanmpallan4551
@karanmpallan4551 3 жыл бұрын
Best explanation for loops and bEST EXPLAINATION FOR ATM MACHINE!!!!
@kavyathakore2823
@kavyathakore2823 3 жыл бұрын
It's really helpful....thank you so much..The explanation was very clear that I was able to understand complex programs easily.
@suryabh2307
@suryabh2307 2 жыл бұрын
You rocked it man! Finally I'm with a clear explanation
@edurekaIN
@edurekaIN 2 жыл бұрын
Hi : ) We really are glad to hear this ! Truly feels good that our team is delivering and making your learning easier :) Keep learning with us .Stay connected with our channel and team :) . Do subscribe the channel for more updates : ) Hit the bell icon to never miss an update from our channel : )
@hayatop2124
@hayatop2124 6 жыл бұрын
wow its osm channel to lern python... thank you
@edurekaIN
@edurekaIN 6 жыл бұрын
Thank you for watching our video. Do subscribe, like and share to stay connected with us. Cheers :)
@munivenkatesh4530
@munivenkatesh4530 6 жыл бұрын
ThankQ for giving this video its really good for us
@edurekaIN
@edurekaIN 6 жыл бұрын
Hey Venkatesh, thank you for watching our video. We are glad to know that you liked our tutorial. Do subscribe and stay connected with us. Cheers :)
@NewfieNL
@NewfieNL 4 жыл бұрын
you are a great teacher
@akaez2807
@akaez2807 2 жыл бұрын
excellent work good job👏
@mlittleprogramming780
@mlittleprogramming780 4 жыл бұрын
Great video 👌🏻
@manojsah007007
@manojsah007007 6 жыл бұрын
Amazing Loop concept provided.
@deepakmakhija5047
@deepakmakhija5047 5 жыл бұрын
Sir thanks a lot for such a fantastic explanation.
@edurekaIN
@edurekaIN 5 жыл бұрын
Hey Deepak, we are glad you loved the video. Do subscribe to the channel and hit the bell icon to never miss an update from us in the future. Cheers!
@primeplug6189
@primeplug6189 Жыл бұрын
I have a question please.The logic to generate the random number (n * random.random()) + 1, is this a python code or you created this by yourself. And can someone explain this code to me and how it will generate a random number. I am new and fresh to python. Thanks
@tonygaurav
@tonygaurav 7 жыл бұрын
Thanks Sourav.... Really helped a lot....
@vasundharakushte3620
@vasundharakushte3620 2 жыл бұрын
Hi this is viraj Ur videos cleared my doubt in while loop and for thank u sir. I just cleared 12th and python is very easy language and with it videos it becomes very fluent. Again thank you sir
@edurekaIN
@edurekaIN 2 жыл бұрын
Hi : ) We really are glad to hear this ! Truly feels good that our team is delivering and making your learning easier :) Keep learning with us .Stay connected with our channel and team :) . Do subscribe the channel for more updates : ) Hit the bell icon to never miss an update from our channel : )
@yogendrasingh-wn5pn
@yogendrasingh-wn5pn 4 жыл бұрын
Really helpful for me... Corresponds to currently class 11 course
@edurekaIN
@edurekaIN 4 жыл бұрын
Thanks Yogendra! We are glad that our video was of great help to you. :)
@abdoulayebalde2139
@abdoulayebalde2139 5 жыл бұрын
great video with good explaination
@edurekaIN
@edurekaIN 5 жыл бұрын
Hey Abdoulaye, thank you for watching our video. We are glad that you liked our content. Do subscribe and stay connected with us. Cheers :)
@MohamedRaffiM
@MohamedRaffiM 3 жыл бұрын
Thank You sir I definitely say edureka is a best learning platform compare to all , once again thank you management and thank you sir .
@edurekaIN
@edurekaIN 3 жыл бұрын
Thanks for watching! Glad you liked it ! We are glad to have learners like you . Do subscribe our channel and hit that bell icon to never miss an video from our channel .
@srikarrar261
@srikarrar261 5 жыл бұрын
in the program about bank in nested loop, i had a doubt in 'restart' option i.e. why it is used and why it has given 'not in' in while loop
@edurekaIN
@edurekaIN 4 жыл бұрын
If restart is not in (a membership operator), the loop will break.
@manishapriya2703
@manishapriya2703 3 жыл бұрын
Great teacher
@JyotiPathak2019jcc
@JyotiPathak2019jcc 3 жыл бұрын
Great Sir🙏🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻
@qaeedrawal9803
@qaeedrawal9803 2 жыл бұрын
Thanks Edureka for the explanation of python Language it was very useful
@edurekaIN
@edurekaIN 2 жыл бұрын
We are super happy that Edureka is helping you learn better. Your support means a lot to us and it motivated us to create even better learning content and courses experience for you . Do subscribe the channel for more updates : ) Hit the bell icon to never miss an update from our channel : )
@dheerendrasingh6623
@dheerendrasingh6623 6 жыл бұрын
thanks saurav sir for my help regarding the prob of python
@k.g.goletar6881
@k.g.goletar6881 Жыл бұрын
I was really confused about the loops before seeing the video now I completely understood it
@edurekaIN
@edurekaIN Жыл бұрын
Hi : ) We really are glad to hear this ! Truly feels good that our team is delivering and making your learning easier :) Keep learning with us .Stay connected with our channel and team :) . Do subscribe the channel for more updates : ) Hit the bell icon to never miss an update from our channel : )
@tarekererajeeva3917
@tarekererajeeva3917 3 жыл бұрын
Very interesting sir. Well explained. Sir can you explain how to update the database in a loop for the nested calculations
@edurekaIN
@edurekaIN 3 жыл бұрын
Thanks for watching! Glad you liked it ! Definitely ! We are glad to have learners like you .Drop your mail id in the comment section for us to share the data sheets or source codes :) Do subscribe our channel and hit that bell icon to never miss an video from our channel .
@bhumikabansal3651
@bhumikabansal3651 2 жыл бұрын
In the nested for loop code : for a in the range (a ,n+1) and for b in the range (a ,n) why is it ('n+1' for a) and (only 'n' for b )?
@sourabhhole4061
@sourabhhole4061 2 жыл бұрын
Thank you
@RanbirSingh-ch4lr
@RanbirSingh-ch4lr 6 жыл бұрын
Going through your videos and that's a great stuff you provided. But I want to ask that what is the purpose of factorial variable and what if I enter its value other than 1??
@dfolks7781
@dfolks7781 3 жыл бұрын
iam studying in grade 11 but new for python,actually it is a good video with good lecture all were explained well in short and sweet
@manuk4771
@manuk4771 Жыл бұрын
Very helping video
@edurekaIN
@edurekaIN Жыл бұрын
Thank you 😊 Glad it helped !! and Keep learning with us
@tahermahmud3053
@tahermahmud3053 Жыл бұрын
Bossssssssssss , thank uuuu
@mangeshraj8913
@mangeshraj8913 Жыл бұрын
loved this video
@edurekaIN
@edurekaIN Жыл бұрын
Thank you 😊 Glad it was helpful!!
@nitinchaudhary7686
@nitinchaudhary7686 5 жыл бұрын
i didn't understand , n*random.random ( how this works ,and why we use it ?) what if, we use only n*random ?
@edurekaIN
@edurekaIN 4 жыл бұрын
In the example, the import statement does not have an alias, so in order to access the random function we are doing random.random(). For example: if we wrote it as import random as r, we could have written it as r.random().
@renujain5966
@renujain5966 4 жыл бұрын
Nice
@subernaguhan3332
@subernaguhan3332 5 жыл бұрын
Hello Sir, Great lecture! The examples really helped me understand the concept in depth. Just a quick Q: In the Nested while loop - bank ATM example,(26:14) in the elif option = 2 block, there's an option2='Y' statement. I don't understand why it is written & also seems like the video was cut short while you were explaining that particular block. Can you please re-upload the full video of this tutorial or explain why we use that piece of code? Thank you very much!
@edurekaIN
@edurekaIN 4 жыл бұрын
As, we move forward into the program, it basically shows the other options if were chosen at all, the execution will move in that block. If the option is 2, and option2 = 'Y', the execution will move to this block.
@anishafernando65
@anishafernando65 2 жыл бұрын
ThankYou
@samyakjain4178
@samyakjain4178 6 жыл бұрын
sir what is the use of abstract classes in python
@technostrike9804
@technostrike9804 5 жыл бұрын
To provide a baseline to build other classes It has at least 1 pure virtual function.
@vaishnaviventrapragada6536
@vaishnaviventrapragada6536 5 жыл бұрын
I didn't understand , how it took the correct answer
@ankitkotnala
@ankitkotnala 4 жыл бұрын
At 17:57 after print("current fruit:",fruit) Here after comma it should be fruits i think????? Because above you stated fruits as variable.
@edurekaIN
@edurekaIN 4 жыл бұрын
"Fruit" is used because we are using the 'for loop' to extract one item at a time from the list.
@Wow-oz4ym
@Wow-oz4ym 3 жыл бұрын
It's interesting, but the black background put there for the subtitle is oftentimes blocking the output.... That I think is not helping matters. Beside, ur spoken English is clear for 99% of audience to understand. Kip it up👍🏾
@onyebuchichukwu7462
@onyebuchichukwu7462 2 жыл бұрын
You're an excellent teacher, but you're a bit fast can you reduce your speed please. I really like your teaching.
@edurekaIN
@edurekaIN 2 жыл бұрын
Thank you for your review : ) We are glad that you found our videos /contents useful . We are also trying our best to further fulfill your requirements and enhance your expirence :)We are sorry for the inconvenience you had to bear.We'll surely take your suggestion in our future videos and updates :) Do subscribe the channel for more updates : ) Hit the bell icon to never miss an update from our channel : )
@thilaks5809
@thilaks5809 6 жыл бұрын
in your factorial program enter the number -1 it says "must be positive" and also shows 1 on the output screen.. same way if you enter 1 the output is factorial=1 and again types 1....the extra 1 shouldn't be displaying right ?this worked fine for me. please suggestn=int(input("enter a number")) fact=1 if n
@edurekaIN
@edurekaIN 5 жыл бұрын
Hey Thilak, sorry for the delay. Yes, your approach is good. In the video what happens is if a number is not positive it just gives an output as a negative number. Hope this helps!
@maruthjain5875
@maruthjain5875 5 жыл бұрын
In while loop part why (n*random.random()) Doesnt it give any number not just a number less then equals to 20? And if its only upto 20 then is this code functioning?
@edurekaIN
@edurekaIN 4 жыл бұрын
It works like a game, where you guess a number. So random fits the function perfectly.
@5_alenrenny567
@5_alenrenny567 Жыл бұрын
It help me and i won first place in programming compitition
@edurekaIN
@edurekaIN Жыл бұрын
Good To know our videos are helping you learn better :) Stay connected with us and keep learning ! Do subscribe the channel for more updates : )
@thilaks5809
@thilaks5809 6 жыл бұрын
this code works the same right import random n=10 correct=int(n*random.random()) while 1: g=int(input("guess your number")) if g>correct: print("you entered greater number") elif g
@edurekaIN
@edurekaIN 6 жыл бұрын
Hey Tilak, yeah pretty much, but it won't terminate (exit the game) once you provide a negative value. Hope this helps :)
@demonslayer7669
@demonslayer7669 2 жыл бұрын
why you define withdrawl == 1: because it is the amount i.e. 10 20 30 etc. how it works @ time 27:06
@mawjal-jadirjy1336
@mawjal-jadirjy1336 Жыл бұрын
Thanx for this great knowledge and presentation. Can I have this data sheet plz??
@edurekaIN
@edurekaIN Жыл бұрын
Good to know your learning with Edureka :) please share your mail id to share the data sheet! We'll Update you soon ! Do subscribe our channel for more such videos :)
@sambatuti1054
@sambatuti1054 2 жыл бұрын
plz explain step by step of every program include example program too plzzz, tq
@edurekaIN
@edurekaIN 2 жыл бұрын
Thanks for showing interest in edureka kindly visit the channel for more videos our content creators are eagerly waiting for your suggestion to make new videos on your interest :) DO subscribe for the video update
@mastiedits3183
@mastiedits3183 Жыл бұрын
Write a program to take a number (n) as input. Take n names as input and for every name entered, print "Hello" + name. What a code of thise question in while loop
@divyanshsachdeva2295
@divyanshsachdeva2295 Жыл бұрын
good video
@edurekaIN
@edurekaIN Жыл бұрын
Glad you enjoyed
@mdraja1836
@mdraja1836 5 жыл бұрын
Sir how to reverse an integer using for loop??please tell
@edurekaIN
@edurekaIN 5 жыл бұрын
Hey Raja, "# Python Program to Reverse a Number using While loop Number = int(input(""Please Enter any Number: "")) Reverse = 0 while(Number > 0): Reminder = Number %10 Reverse = (Reverse *10) + Reminder Number = Number //10 print("" Reverse of entered number is = %d"" %Reverse)" Hope this helps!
@cookingwithdono7109
@cookingwithdono7109 4 жыл бұрын
but why in 13:10 we need to type if guess >1 ? if the user inputs -1 then it means that the user is giving up ? Thanks!
@edurekaIN
@edurekaIN 4 жыл бұрын
It is just a demonstration to show how the control flow works in case a statement turns out to be false.
@denniskamonde6836
@denniskamonde6836 7 жыл бұрын
great video
@edurekaIN
@edurekaIN 7 жыл бұрын
Hey Dennis, thanks for checking out our tutorial! We're glad you found it useful. Here's another video that we thought you might like: kzfaq.info/get/bejne/b56JmLSh0rfJeGw.html. Do subscribe to our channel to stay posted on upcoming tutorials. Cheers!
@mahalaxmihiremath1423
@mahalaxmihiremath1423 5 жыл бұрын
In the nested loop 1st example what will happen if i use for loop instead while loop
@edurekaIN
@edurekaIN 5 жыл бұрын
Hey Mahalaxmi, "A for loop runs for a pre-determined number of times. So, it can iterate through an array from start to finish, say, but it will only ever loop for that specific number. A while loop will carry on until a pre-determined scenario takes place. That may happen immediately, or it may require a hundred iterations. So, the number of loops is governed by an outcome, not a number." Hope this helps!
@ganeshveer3989
@ganeshveer3989 6 жыл бұрын
I want for loop program on histogram
@edurekaIN
@edurekaIN 4 жыл бұрын
Here is a matplotlib tutorial to learn about plotting graphs such as scatter plots, histogram, etc. - kzfaq.info/get/bejne/r8CEdbB-ybazp6s.html
@nirajanwagle1132
@nirajanwagle1132 Жыл бұрын
lifesaver
@pradeepkumar-or7go
@pradeepkumar-or7go 5 жыл бұрын
what if we press n in the code..in nested loops examples ... and why are we using " " in the code...can you please explain
@edurekaIN
@edurekaIN 5 жыл бұрын
Hey Pradeep, You use for a new-line. This is called an escape character. Simply typing n wont help. Hope this helps!
@rajeevdarla1806
@rajeevdarla1806 7 жыл бұрын
In the For loop factorial example: you didn't increment the 'i' value, is it automatically incremented by 1? Don't we need to write like: for i in range(1, num + 1, 1) ? Please explain. Great videos by the way, very clear voice.
@edurekaIN
@edurekaIN 7 жыл бұрын
Hey Rajeev, thanks for checking out our tutorial! We're glad you liked it. With regard to your query, by default, the increment value is 1 in for loop. Hope this helps. Cheers!
@narayanareddy3543
@narayanareddy3543 6 жыл бұрын
if u write range(1,num) suppose num=5 range (1,5) is 1,2,3,4 it wiil end by 4 so range (1,num+1) 1,2,3,4,5=5!
@suneetachauhan1984
@suneetachauhan1984 4 жыл бұрын
## Why the below command does not move the cursor to the end of the statement? print('welcome to the bank') count = 3 while count >= 0: pin = int(input('enter the pin :')) if pin == 1234: print('the correct pin',end=' ') break elif pin!= ('1234'): print('incorrect pin') count -= 1 if count == 0: print(' please collect your card') break
@edurekaIN
@edurekaIN 4 жыл бұрын
Looking at the code, the execution will go on until the count is 0, that means you will be able to give the pin 3 times. In the incorrect pin statement there is no break statement. so the loop continues to execute the next statements.
@vyshnavipolepalle5562
@vyshnavipolepalle5562 5 жыл бұрын
what is random?.....is that any module, built in function?...could tell more about it and u called random() function too...what does random.random() means and how these two random's are different?
@edurekaIN
@edurekaIN 4 жыл бұрын
Yes, there is a module called as random which is used to generate random numbers. But to use them, we would need to call the random file. That is the reason we import random. Once the random file/module is imported, we need to call the random function, that's the reason we have random.random() where the first random is the built-in file and the second random() is the function to generate the random number.
@darshitagrawal2486
@darshitagrawal2486 5 жыл бұрын
In guessing game in 3rd line of code why we are adding 1
@edurekaIN
@edurekaIN 5 жыл бұрын
Hi Darshit, thanks for watching our video. The reason for adding 1 is to make sure that the random number generated is equal to or greater than 1. Here is our complete playlist on Python: kzfaq.info/sun/PL9ooVrP1hQOHY-BeYrKHDrHKphsJOyRyu. You can also check out our complete Python course here: www.edureka.co/python. Do subscribe to our channel to stay posted on upcoming tutorials. Hope this helps. Cheers!
@darshitagrawal2486
@darshitagrawal2486 5 жыл бұрын
Ok sir thanks for uploading such a nice video
@dakshbhardwaj7189
@dakshbhardwaj7189 5 жыл бұрын
Have a Doubt.. sir...
@edurekaIN
@edurekaIN 5 жыл бұрын
Hey Vidushi, please feel free to ask your doubts over here.
@rajatji
@rajatji 4 жыл бұрын
to_be_guessed=int(n*random.random())+1 what does this line mean? 14:23
@edurekaIN
@edurekaIN 4 жыл бұрын
random(): Generates a random float number between 0.0 to 1.0
@atitchauhan6563
@atitchauhan6563 5 жыл бұрын
Python
@arihantsaxena4757
@arihantsaxena4757 5 жыл бұрын
Why have we used count=count+1 in while loop?
@edurekaIN
@edurekaIN 5 жыл бұрын
Hey Saxena! Its there to increase the counter variable by 1. So, in the while loop, since we want a set of actions to be executed till the condition is satisfied. we use this counter variable to iterate to each and every step. Hope this helps!
@veerraghavareddy735
@veerraghavareddy735 6 жыл бұрын
num=int(input("enter any number")) for s in range(num): if(s/2==0) print(s) The output of this program is showing none .please explain why output us showing none
@edurekaIN
@edurekaIN 4 жыл бұрын
Let's suppose you enter the num as 6, then s will be (0,1,2,3,4,5). And the statement will be true for 2. and it will print 2.
@nitinchaudhary7686
@nitinchaudhary7686 5 жыл бұрын
why do we use , +1 ( count = count +1 ) ?
@edurekaIN
@edurekaIN 4 жыл бұрын
count += 1, it means the same as writing count = count + 1
@SaimDiscoveries
@SaimDiscoveries 6 жыл бұрын
I do not understand that what is the purpose of this line "to_be_guessed =int(n*random.random())+1"
@edurekaIN
@edurekaIN 5 жыл бұрын
Hey, sorry for the delay. """to_be_guessed =int(n*random.random())+1"" is used to keep the range of the number between 1 and 20. random.random() gives you a random number less than zero in floating point Ex: print (random.random()) will give 0.95795482028667 as output, which is less than zero and not suitable for our code. n*random.random() is done so that when another number is multiplied with the random number generated, the value becomes more than zero. But suppose n=1, then n*random.random() will give the same number that is less than 1. To avoid this, we add 1 to n*random.random(). Finally, (n*random.random())+1 will result in a number greater than 0 and less than or equal to 20. And then this number is converted to int type from float. Hence, we use the line ""to_be_guessed =int(n*random.random())+1""" Hope this helps!
@soniasardana8965
@soniasardana8965 3 жыл бұрын
Sir i have doubt in nested for loops
@soniasardana8965
@soniasardana8965 3 жыл бұрын
How nested for loop works can ecplain
@edurekaIN
@edurekaIN 3 жыл бұрын
A nested loop is a loop within a loop, an inner loop within the body of an outer one. How this works is that the first pass of the outer loop triggers the inner loop, which executes to completion. Then the second pass of the outer loop triggers the inner loop again. This repeats until the outer loop finishes. Hope that solves your query.
@curiousbit9228
@curiousbit9228 6 жыл бұрын
@24:17 chances >= 0, doesn't it mean there are 4 chances in total and not 3. that is for each number 3,2,1,0 ??
@edurekaIN
@edurekaIN 4 жыл бұрын
There is a block that states, if chances == 0, it will print "no more tries".
@vickykumar5855
@vickykumar5855 4 жыл бұрын
I have doubt on the third line of code?
@edurekaIN
@edurekaIN 4 жыл бұрын
doing int('123') returns an instance of an int object. However, (in standard Python aka CPython) for small integers (in the range -5 to 256, inclusive) the int constructor doesn't actually build a new integer object.
@curiousbit9228
@curiousbit9228 6 жыл бұрын
@34:00 how can one be sure that c is less than n??
@edurekaIN
@edurekaIN 4 жыл бұрын
C is basically square root of sum of two numbers a and b. Hence it will be greater.
@cookingwithdono7109
@cookingwithdono7109 4 жыл бұрын
is it mean that we cannot name our file to 'random' ?
@edurekaIN
@edurekaIN 4 жыл бұрын
You can follow the python filename naming conventions here in the official documentation- www.python.org/dev/peps/pep-0008/
@vickykumar5855
@vickykumar5855 4 жыл бұрын
The third line of code why u use convert in int? that's already int ??????
@edurekaIN
@edurekaIN 4 жыл бұрын
doing int('123') returns an instance of an int object. However, (in standard Python aka CPython) for small integers (in the range -5 to 256, inclusive) the int constructor doesn't actually build a new integer object.
@fathoorchisty9519
@fathoorchisty9519 7 жыл бұрын
i got into a problem in atm programme .........when it asked me would you like to go back? if i say yes it breaks the loop........ if i say no then it comes back to entering pin then i give the pin and it came back for enter pin and i gave the pin and it happens always so what should i do??
@edurekaIN
@edurekaIN 4 жыл бұрын
You can change the logic in the block so that when you enter no, so that it would take the execution to the desired block .
@annamdurgashivaprasad9593
@annamdurgashivaprasad9593 5 жыл бұрын
Sir, plz help me In game guessing program I didn't see 13, where it is defined but when we run &give new number 13 it shows congratulations. How?
@edurekaIN
@edurekaIN 5 жыл бұрын
Hey Annam, sorry for the delay. Check for proper the indentation. Python using indents to create blocks so if your code is not properly indented under the right condition/loop, you might not get the expected result. Please share your code to this email id: social.media@edureka.co so that we can help you better. Thanks!
@anitakumawat8103
@anitakumawat8103 6 жыл бұрын
but sir you don't create any fruit type variable and then how you put fruit keyword on variable place?
@edurekaIN
@edurekaIN 4 жыл бұрын
It is like writing for i in range(10): print(i). So i here is basically all the elements in the range function from 0-9.
@preetirai255
@preetirai255 4 жыл бұрын
@@edurekaIN good
@saranyathiyagarajan439
@saranyathiyagarajan439 7 жыл бұрын
why post loops not present in python
@edurekaIN
@edurekaIN 4 жыл бұрын
We can emulate a do-while like a loop in python as well. Here is small example - i = 1 while True: print(i) i = i + 1 if(i > 3): break
@nitesh732477
@nitesh732477 6 жыл бұрын
my pycharm is not showing math why?
@edurekaIN
@edurekaIN 4 жыл бұрын
Try to install math using pip or add it from the project interpreter.
@Siri-qh6vl
@Siri-qh6vl Жыл бұрын
Ok
@vedantmaurya7497
@vedantmaurya7497 4 жыл бұрын
Sir, can we use Import math instead of using import random
@edurekaIN
@edurekaIN 4 жыл бұрын
We can use the math module too, but in that case the random number to be guessed will no longer be a random number.
@anitakumawat8103
@anitakumawat8103 6 жыл бұрын
sir how the random function work?
@edurekaIN
@edurekaIN 4 жыл бұрын
random.random(): Generates a random float number between 0.0 to 1.0. The function doesn't need any arguments.
Как быстро замутить ЭлектроСамокат
00:59
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 12 МЛН
КАРМАНЧИК 2 СЕЗОН 6 СЕРИЯ
21:57
Inter Production
Рет қаралды 505 М.
#20 Python Tutorial for Beginners | While Loop in Python
12:43
Telusko
Рет қаралды 1,5 МЛН
While loops in Python are easy ♾️
6:58
Bro Code
Рет қаралды 306 М.
Swift Programming Tutorial for Beginners (Full Tutorial)
3:22:45
CodeWithChris
Рет қаралды 7 МЛН
Object Oriented Programming with Python - Full Course for Beginners
2:12:35
freeCodeCamp.org
Рет қаралды 1,7 МЛН
Python for Beginners - Learn Python in 1 Hour
1:00:06
Programming with Mosh
Рет қаралды 17 МЛН