I'm so lost, I don't even know where to start with ps2. I tried following the chickens/pigs/spiders problem he did, but it's slightly different. Can someone please help, nudge me in the right direction. Any help is greatly appreciated. Thanks
there is an equation just before problem one. using that equation you need to try out different combinations of a, b, and c to see if there are combinations where n = 50, 51, 52, 53, and 54 (problem 1). one common solution is to use loops - one each for a, b, and c. You should read the Python tutorial which should have been installed on your computer with the documentation. Here is a link to section 4 of the online Tutorial: http://docs.python.org/tutorial/controlflow.html#more-control-flow-tools
Sometimes it helps to work out the pseudo code first so you can get the logic of the problem clear before dealing with the syntax of python. example for # of chickens 0 through the #of total legs / 2[how many chickens have]: for # of cows 0 through the #of legs/ 4: for # of spiders 0 through #of legs/8: if chicken legs + cow legs + spider legs == legs: return the number of each animal in this combo Try to follow this through to get the logic of it. Once you get it down, I'm sure you can start to apply it to McNuggets too. Once you get it, another thing to think about is why the for loops are nested in that order and what would happen if the order of the animals was different (eg spiders/cows/chickens) Good luck, hope that helped!
hey thanks a lot, that really did help. I didn't get it yet, but I am on the right track. I'll update if I get it or not. Thanks again.
Awesome, I got it. Thanks so much for the help.
Glad to help!
Also, keep in mind that this course is operating in some version of Python 2, and not in Python 3. If you are running any version of Python 3 in your interpreter, then it will not read the syntax correctly. For example, Python 3 does not recognize raw_int, it only recognizes int. I was using Python 3 before I started this course, and I had to make some adjustments in order to accommodate the syntax of Python 2.
I am also using Idle...
Join our real-time social learning platform and learn together with your friends!