Skip to main content

Featured

Python using requests module to download the image

The requests module is a popular Python library used for making HTTP requests. It simplifies the process of sending and receiving data over the web, making it a great tool for downloading images and other files. Before we dive into how to download an image with requests module we need to install request module. To install requests module: pip install requests   How to Download an Image with requests To download an image, you can use the requests.get() method, which sends a GET request to the image's URL. You then save the content of the response to a file. Here's a basic breakdown of the steps: Send the request : Use requests.get(url) to retrieve the image data. Check the status code : Always check the response's status code to ensure the request was successful. A 200 status code indicates that the request was successful. Save the content : The image data is available in the response.content attribute. You should write this content to a file in binary mode ( ...

Python program to calculate simple interest

Program to calculate Simple Interest


print("Program to calculate simple interest\n\n")
try:
    P = int(input("Enter principal: "))
    T = int(input("Enter time in year: "))
    R = int(input("Enter rate of interest: "))

    SI = (P*T*R)/100
    print(f"\n\nSimple Interest is {SI}")

except Exception as e:
    print(e)

Comments

Popular Posts