Loading lesson path
Python
Work with files, import code cleanly, and use Python’s built-in modules without guessing.
File handling is an important part of any web application. Python has several functions for creating, reading, updating, and deleting files. File Handling The key function for working with files in P…
This page lists the built-in modules that ship with the Python 3.13 Standard Library. These modules are available without extra installation (some are platform-dependent). A Module Description Introd…
How to Remove Duplicates From a Python List
Open a File on the Server Assume we have the following file, located in the same folder as Python: demofile.txt Hello! Welcome to demofile.txt This file is for testing purposes. Good Luck! To open th…
Python has a built-in module that you can use to make random numbers. The random module has a set of methods: Method Description seed() Initialize the random number generator getstate() Returns the c…
How to Reverse a String in Python
Write to an Existing File To write to an existing file, you must add a parameter to the open() function: "a" - Append - will append to the end of the file "w" - Write - will overwrite any existing co…
Example Make a request to a web page, and print the response text: import requests x = requests.get('https://w3schools.com/python/demopage.htm') print(x.text) Definition and Usage The requests module…
How to Add Two Numbers in Python
Delete a File To delete a file, you must import the OS module, and run its os.remove() function: Example Remove the file "demofile.txt": import os os.remove("demofile.txt") Check if File exist: To av…
Python statistics Module Python has a built-in module that you can use to calculate mathematical statistics of numeric data. The statistics module was new in Python 3.4. Statistics Methods Method Des…
Python math Module Python has a built-in module that you can use for mathematical tasks. The math module has a set of methods and constants. Math Methods Method Description math.acos() Returns the ar…
Python cmath Module Python has a built-in module that you can use for mathematical tasks for complex numbers. The methods in this module accepts int, float, and complex numbers. It even accepts Pytho…