BeyondPapers

BeyondPapers RC - 9424055

We are a group of people dedicated to dynamically bridging the gaps the African education system creates between theory and practice.

🔑 PYTHON CHALLENGE  #10 (File Downloader)Using the requests module for instance, you can send a GET request to a web ser...
16/05/2022

🔑 PYTHON CHALLENGE #10 (File Downloader)

Using the requests module for instance, you can send a GET request to a web server to provide a web content or resource. Besides requesting for .html web pages, it can request for .jpg images, .mp4 videos, .exe executables, .js scripts or any other file type available out there! Provided you have the URL to that file.

Create a program that is able to get and save (download) any online resource from the Internet, using the URL provided by a user.

Such URL should point directly to a file on the web server, or your program would need to allow redirects to the destination file. Most of such URLs are gotten either by viewing the source code of the containing web page, or at the point of download on a web browser, and end with the filename (with extension). Use the URL below, if you cannot easily get one.

https://www.pngitem.com/pimgs/b/16-163788_watercolor-bouquet-png.png

(This is the URL to a PNG image of flowers hosted at pngitem.com's server. This URL should display the image when opened in a browser.)

Of course, your program should be able to save the file with either the filename of the online media (if available via the 'Content-Disposition' header) or the filename as suggested by the URL provided. The file should also be saved with the right file extension, such that your device would open it as expected. If for example, an MP4 video file is downloaded, it should be saved with a .mp4 file format, and play perfectly in a video player.

Additionally, your program should be sensitive to the 'Content-Type' header and/or the Status Code of the server response, to be sure the server has not responded with a web page (error page) instead, while a different file is intended to be downloaded. When, for instance, a wrong or inaccessible URL is entered, or an error occurs, the server may respond with an HTML error page instead. 404 Not Found error, may be.

HINT:
Remember, while certain files may come in plain texts, most files come as binary files.

Upon verifying that all files downloaded via your program behave as expected, push your code to Github, and post the repository link here.

Property of BeyondPapers Technologies by Akinpelumi Michael.

© 2022 Michael Akinpelumi, BeyondPapers
License: http://creativecommons.org/licenses/by/4.0/

🔑 PYTHON CHALLENGE  #9 (My Palindromic Odometer)"I was driving on the highway the other day and I happened to notice my ...
15/05/2022

🔑 PYTHON CHALLENGE #9 (My Palindromic Odometer)

"I was driving on the highway the other day and I happened to notice my odometer. Like most odometers, it shows six digits, in whole miles only. So, if my car had 300,000
miles, for example, I'd see 3-0-0-0-0-0.

"Now, what I saw that day was very interesting. I noticed that the last 4 digits were
palindromic; that is, they read the same forward as backward. For example, 5-4-4-5 is a
palindrome, so my odometer could have read 3-1-5-4-4-5.

"One mile later, the last 5 numbers were palindromic. For example, it could have read
3-6-5-4-5-6, One mile after that, the middle 4 out of 6 numbers were palindromic. And
you're ready for this? One mile later, all 6 were palindromic!

"The question is, what was on the odometer when I first looked?"

Write a Python program that tests all the six-digit numbers and prints any numbers that
satisfy these requirements.

Adapted from Think Python, 2nd Edition
by Allen Downey.
Copyright 2015 Allen Downey
License: http://creativecommons.org/licenses/by/4.0/

Upon getting a satisfactory result, push your code to Github, and post the repository link here.

Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.

🔑 PYTHON CHALLENGE  #8 (Spreadsheets)CSV files are spreadsheets containing Comma Separated Values, that are saved with t...
15/05/2022

🔑 PYTHON CHALLENGE #8 (Spreadsheets)

CSV files are spreadsheets containing Comma Separated Values, that are saved with the .csv file extension.

In a CSV file, neighbouring cells (columns) are basically separated by a delimiting comma (,), while rows are separated by line breaks.

For example, a file prepared in Notepad or Visual Studio Code with the following content:

Member,Surname,Age,Height,Weight
Ali,Abubakar,36 years,171 cm,62 kg
Zira,Ashley,41 years,161 cm,70 kg
Franklin,Olumide,32 years,180 cm,59 kg
Danladi,Muhammed,33 years,168 cm,63 kg
Doris,Chukwuma,36 years,170 cm,71 kg

will display as shown in the image, if saved with the .csv file extension and opened in Microsoft Excel. Wow! Wonderful, huh?

With Python, we can read this file as a plain text, and access its values.

The above (comma separated) list is the record of some 5 members of a team. Create a .csv file with the above content, and write a Python program to access the cells of the spreadsheet for the details of each member.

The program operates by accepting interactive inputs from its user, and processing the input.

If for example, the user enters "Age of Ali", the program prints "36 years". When "Surname of Doris" is entered, the output will be "Chukwuma".

Furthermore, when the input is "Members", the Output is: "Ali, Zira, Franklin, Danladi, Doris", but when "Member 1" is entered, the result is "Ali".

Your program should not process the title row (first row), since it does not hold the record of any person.

What's more? Your program should be flexible enough to accommodate changes, such as new members, changed names etc on the spreadsheet.

Remember to handle exceptions!

Upon testing and debugging your program, push your code and file to Github, and post the repository link here.

Property of BeyondPapers Technologies by Akinpelumi Michael.

© 2020 Michael Akinpelumi, BeyondPapers
License: http://creativecommons.org/licenses/by/4.0/

🔑 PYTHON CHALLENGE  #7 (Calculus)Differentiating 3x^2 gives 6x, while Integrating the result gives back 3x^2 (+ c).The P...
15/05/2022

🔑 PYTHON CHALLENGE #7 (Calculus)

Differentiating 3x^2 gives 6x, while Integrating the result gives back 3x^2 (+ c).

The Power Rule:
Generally, differentiating a.x^n gives n.a.x^(n-1)

On the other hand, when a.x^n is integrated, the result will be (a/[n+1]).x^[n+1] + c

Where,
x is a mathematical variable
a is the coefficient of x
n is the power of x
c is an arbitrary constant

(A picture from BeyondPapers Workshop 1.0 (2020) has been attached to help you understand the concept better.)

Write a Python program that can differentiate or integrate any given (single variable) mathematical term, such as 3x^2, using the Power Rule. The term must contain only one variable, say x, but not necessarily x. Your program should be able to accept any letter.

It does this by receiving an input (that contains the type of calculus operation and the term) from the user, and gives the following results:

If the input is: "D 3x2"
The output is: "f'(3x^2) = 6x"

(That was Differentiation: Input starts with a "D ")

If the input is: "S 8x3"
The output is: "S (8x3) dx = 2x^4 + c"

(That was Integration: Input starts with an "S ")

Remember certain terms may come with 1 or 0 power of x. Your code should be able to handle this. It should for example, be able to understand an input of '6x' as '6x1' [6x^1] and '12' as '12x0' [12x^0].

Remember to handle exceptions!

Upon completing an extensive test on your new program, push your code to Github, and post the repository link here.

Property of BeyondPapers Technologies by Akinpelumi Michael.

© 2020 Michael Akinpelumi, BeyondPapers
License: http://creativecommons.org/licenses/by/4.0/

15/05/2022

🔑 PYTHON CHALLENGE #6 (Write In Words)

Create a figure-to-word program, that receives a positive integer as an input, and prints the integer in words.

The program for example takes 90678008 and prints "Ninety million, six hundred and seventy-eight thousand and eight" as result.

Upon doing this, the program asks if the user wants to convert another number. If yes, the program starts all over.

Remember to handle all possible exceptions at the point of receiving user's inputs.

For a pretty output, you are required to first do a study on how figures are really written out in English language, taking note of punctuations etc.

Upon completing an extensive test on your new program, push your code to Github, and post the repository link here.

15/05/2022

🔑 PYTHON CHALLENGE #5 (Prime Numbers)

Create a program that receives inputs (as figures with commas and spaces) from a user, and supplies a list of all the prime numbers between 1 and that number.

The program receives, for example, the number, "1, 234, 567" from a user, removes all unneeded characters, and produces a list such as [2,3,5,7,11,13...]. 😱

Remember: A Prime Number is a number that has only two factors: 1 and itself.

Upon testing and debugging your code, push your code to Github, and post the repository link here.

15/05/2022

🔑 PYTHON CHALLENGE #4 (Binary Numbers)

Create a program that converts X, an integer (in base 10) to a binary number (in base n), where X and n are integers entered by the user.

The program then displays the solution in the form:

âž–âž–âž–âž–âž–âž–âž–âž–âž–âž–âž–
3 | 7
| 2 r 1
| 0 r 2

:. 7 base 10 = 21 base 3
âž–âž–âž–âž–âž–âž–âž–âž–âž–âž–âž–

Upon testing and debugging your code, push your code to Github, and post the repository link here.

15/05/2022

🔑 PYTHON CHALLENGE #3 (Factors)

The factors of a number are those lesser (and equal) positive integers that can easily divide a number without giving remainders.

For example, the factors of 6 are 1, 2, 3 and 6.

The factors of 15 are 1, 3, 5 and 15.

Write a program that finds all the factors of a particular given number, N.

The program first takes an input from the user, and raises an exception, if the input is not a positive integer. If the exception is passed, it prints the factors of N.

If for instance, N is given as -8.2, the program raises an exception saying "Wrong input!"

If N is 36, it prints:

âž–âž–âž–âž–âž–âž–âž–âž–âž–âž–âž–
The factors of 36 are 1, 2, 3, 4, 6, 9, 12, 18 and 36.
âž–âž–âž–âž–âž–âž–âž–âž–âž–âž–âž–

Include comments in your code.

Upon testing and debugging your code, push your code to Github, and post the repository link here.

15/05/2022

🔑 PYTHON CHALLENGE #2

We have the profiles (first name, middle name, last name) of all registered users on a website written to a variable 'users' as:

users = """Olalade John Adewole
Alimat Faizah Suleman
Ekene James Benson"""

(Notice that the profiles are separated by the line break \n character)

We need to extract only parts of these names for any specified user. (Users are specified by indices 1 - 3).

Write a class named 'profile' that gives the first name, middle name, last name, initials or full name of any of the users.

After creating the class, append your code with the following lines of code:

âž–âž–âž–âž–âž–âž–âž–âž–âž–âž–âž–
user1 = profile(1)
user2 = profile(2)
user3 = profile(3)

print(user1.user)
print(user2.first)
print(user3.initials)
âž–âž–âž–âž–âž–âž–âž–âž–âž–âž–âž–

Your output should be:
âž–âž–âž–âž–âž–âž–âž–âž–âž–âž–âž–
Olalade John Adewole
Alimat
EJB
>>>
âž–âž–âž–âž–âž–âž–âž–âž–âž–âž–âž–

Upon getting the above output from your code, push your code to Github, and post the repository link here.

Property of BeyondPapers Technologies by Akinpelumi Michael.

© 2020 Michael Akinpelumi, BeyondPapers
License: http://creativecommons.org/licenses/by/4.0/

15/05/2022

🔑 PYTHON CHALLENGE #1

We have a .txt file that contains a list of users who responded to our questionnaire. Our questionnaire could be answered multiple times, so we ended up having duplicated names in our text file, as shown below:

Anderson
Olakunle
Ifeoma
Lee
Margaret
Olakunle
Musa
Musa
Lee
Anderson
Yvonne
Albert
Ofori
Ofori
Rofiyat
Rofiyat
Dele
Muhammed
Rofiyat
Ofori
Lee
Ifeoma

Create a file named 'users.txt' that contains the above list of names as is in a directory. (You should be able to select a text or long-press it to copy it from here.)

Now, write a program that removes the excess/duplicate names, and now saves them in a new file named 'new.txt', such that the new file now contains:

Anderson
Olakunle
Ifeoma
Lee
Margaret
Musa
Yvonne
Albert
Ofori
Rofiyat
Dele
Muhammed

Upon verifying that your new file 'new.txt' now contains the specified list above, push your code and files to Github, and post the repository link here.

Property of BeyondPapers Technologies by Akinpelumi Michael.

© 2020 Michael Akinpelumi, BeyondPapers
License: http://creativecommons.org/licenses/by/4.0/

Address

Akure

Alerts

Be the first to know and let us send you an email when BeyondPapers posts news and promotions. Your email address will not be used for any other purpose, and you can unsubscribe at any time.

Contact The Business

Send a message to BeyondPapers:

Share