How to download Files from the Web with the requests Module

The requests module lets you easily download files from the Web without having to worry about complicated issues such as network errors, connection problems, and data compression. The requests module doesn’t come with Python, so you’ll have to install it first. From the command line, run pip3 install requests. Next, do a simple test to make sure the requests module…

Continue Reading →

Python Programming/Strings Tutorial

String There are three ways you can declare a string in Python: single quotes (‘), double quotes (“), and triple quotes (“””). You can use quotation marks within strings by placing a backslash directly before them, so that Python knows you want to include the quotation marks in the string, instead of ending the string there. Placing a backslash directly…

Continue Reading →

Working with files in Python

Files Note: Take care of Indentation in codes. While a program is running, its data is stored in random access memory (RAM). RAM is fast and inexpensive, but it is also volatile, which means that when the program ends, or the computer shuts down, data in RAM disappears. To make data available the next time the computer is turned on…

Continue Reading →

How to counts the number of decimal digits in a positive integer in Python

The following snippet counts the number of decimal digits in a positive integer: n = 40265 count = 0 while n != 0: count = count + 1 n = n // 10 print(count) This snippet demonstrates an important pattern of computation called a counter. The variable count is initialized to 0 and then incremented each time the loop body…

Continue Reading →