In this course, you will learn a lot of built in functionalities for you to become a better Python developer. You will also learn how to implement best practices and some unit testing
File size: 1.07 GB
Skillshare – Advanced Python Skills Become a Better Python Developer
Project Description
The class project is going to be a series of exercises where you will need to use what you learn in this course. Avoid the use of for loops.
Write a function that sums two numbers like in school. This means, that you should sum digits from right to left and carry 1 if the sum of two digits is greater than or equal to 10. HINT: you should use the zip_longest function and the modulo operator (%).
In school, you may have done this without knowing that this algorithm also works for numbers in any base. Refactor this function in order to sum two numbers in any given base. HINT: your function should now receive the base as an argument. Your function should sum like in the first point if you pass 10 as the number base. If you pass 2, then you will be able to sum binary numbers!
Remember that we said that in TDD, we should first write a failing test and then start writing code. We are going to break this rule for a moment. Implement some tests with pytest in order to show that your function works perfectly. Make sure to write tests for differente number bases.
The second exercise is related to generators! In this course you learned how to build them. Now let’s implement two generators that are interesting.
Implement a generator that yields the Fibonnaci numbers. Take advantage of the fact that local state is rememberd on subsequent calls to the generator. Remember the definition of Fibonacci numbers in this Wikipedia article: Fibonacci Numbers
Make a generator that yields prime numbers. Remember the definition of prime numbers in this article: Prime numbers
Now instead of returning the number, return also the time it took to yield the next prime number. Store the numbers and times in such a way that you can make a simple scatter plot where you will put the prime numbers in the x-axis and the time in the y-axis. You can see an example of how to do this with Matplotlib and Numpy in this article: Scatterplots
Read more here!
Get Skillshare – Advanced Python Skills Become a Better Python Developer download immediately on AMZLibrary.com!