intro-to-programming | Instructional materials for a one day intro | Learning library
kandi X-RAY | intro-to-programming Summary
kandi X-RAY | intro-to-programming Summary
Instructional materials for a one day intro to programming class taught using Python
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Returns the most common item from the input list
- Check if two strings are similar
- Check if a string is a palindrome
- Return the number of functions
- Find the number of two functions
- Returns the intersection of two lists
- Returns True if item contains item
- Return a list of duplicates in the input_list
- Print the number of loops in loops
- Add two parameters
- Compute two numbers
intro-to-programming Key Features
intro-to-programming Examples and Code Snippets
Community Discussions
Trending Discussions on intro-to-programming
QUESTION
Following is the problem set from MIT opencourseware
Part C: Finding the right amount to save away
- Your semiannual raise is .07 (7%)
- Your investments have an annual return of 0.04 (4%)
- The down payment is 0.25 (25%) of the cost of the house
- The cost of the house that you are saving for is $1M.
I am now going to try to find the best rate of savings to achieve a down payment on a $1M house in 36 months. And I want your savings to be within $100 of the required down payment.I am stuck with the bisection search and 'It is not possible to pay the down payment in three years.' this output. I am new to programmers and English.Any help is appreciated.
And here is my code:
...ANSWER
Answered 2018-Nov-19 at 13:33I've already addressed most of my points in the comments, but I will recap: You are trying to solve a problem using a method called recursive solving, in this case using the bisection method.
The steps are as follows:
- start with an initial
guess
you chose0.5
- Perform your calculations in a loop and iterate the initial guess, in this case you must account for the following:
- Maximum number of steps before failure, remember we can always add 2 values and divide by 2, your result will tend to 0.999999.. otherwise
- A certain tolerance, if your step size is not small enough 25% of 1 M is 250 000 and you might never hit that number exactly, that' why you make a tolerance interval, for example: anything between 250 000 and 251 000 --> break loop, show result.
- Your if statements for changing
low
andhigh
to adjust guess are correct, but you forget to re-initialize savings to 0 which means savings was going to infinity.
Now that's all said, here's a working version of your code:
QUESTION
My objective is to scrape as many profile links as possible on Khan Academy. And then scrape some specific data on each of these profiles to write them into a CSV file.
My problem is simple: the script is way to slow.
Here is the script:
...ANSWER
Answered 2019-Mar-31 at 03:01One reason this script takes much time is because of the high number of requests it sends, One way for it to consume less time is to limit the number of requests. This could be achieved by using their internal API to get the profile data. For example: sending a get request to this link https://www.khanacademy.org/api/internal/user/discussion/summary?username=user_name&lang=en (and changing user_name to the actual username) will return the profile data you require (and more) as JSON instead of having to scrape many sources. You can then extract the data from the JSON output, and convert them to CSV. You will need to use selenium to only get the discussion data and find the list of usernames. This would cut script running time greatly.
Side note: even the modules links could be extracted using the JS variable that is parsed when scraping the main URL. The variable contains JSON that stores course data including links.
Here's the code that does that:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install intro-to-programming
You can use intro-to-programming like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page