• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
PythonForBeginners.com

PythonForBeginners.com

Learn By Example

  • Home
  • Learn Python
    • Python Tutorial
  • Categories
    • Basics
    • Lists
    • Dictionary
    • Code Snippets
    • Comments
    • Modules
    • API
    • Beautiful Soup
    • Cheatsheet
    • Games
    • Loops
  • Python Courses
    • Python 3 For Beginners

Code Snippets

Review our python code snippet articles below. We have covered so many examples it may take you awhile to browse them all. Feel free to use our search for a specific python coding example.

Get the Geo Location of an IP Address

Author: PFB Staff Writer
Last Updated: August 28, 2020

Time for a script again, this one will geolocate an IP address based on input from the user. For this script, we will be using a bunch of Python … [Read more...] about Get the Geo Location of an IP Address

Filed Under: Beautiful Soup, Code Snippets, Scripts Author: PFB Staff Writer

Reversing lists and strings

Author: PFB Staff Writer
Last Updated: June 12, 2020

This short post will show how to do a reverse loops in Python. The first example will show how to do that in a list a and the other example how to … [Read more...] about Reversing lists and strings

Filed Under: Code Snippets Author: PFB Staff Writer

Script : Get the username from a prompt…

Author: PFB Staff Writer
Last Updated: August 28, 2020

This script will ask the user for its username, by using the raw_input function. Then a list of allowed users is created named user1 and user2. The … [Read more...] about Script : Get the username from a prompt…

Filed Under: Code Snippets, Scripts Author: PFB Staff Writer

Parse JSON objects in Python

Author: PFB Staff Writer
Last Updated: August 27, 2020

Overview In this post we will explain how you can parse JSON objects in Python. Knowing how to parse JSON objects is useful when you want to access … [Read more...] about Parse JSON objects in Python

Filed Under: Code Snippets, Json, Python On The Web Author: PFB Staff Writer

Python : OS.listdir and endswith( )

Author: PFB Staff Writer
Last Updated: August 27, 2020

This short script uses the os.listdir function (that belongs to the OS module) to search through a given path (".") for all files that endswith … [Read more...] about Python : OS.listdir and endswith( )

Filed Under: Code Snippets, OS, Scripts Author: PFB Staff Writer

Socket examples in Python

Author: PFB Staff Writer
Last Updated: May 22, 2020

The socket module in Python provides access to the BSD socket interface. This post will show examples on how to use the socket functions. For more … [Read more...] about Socket examples in Python

Filed Under: Code Snippets Author: PFB Staff Writer

Using the web browser in Python

Author: PFB Staff Writer
Last Updated: August 28, 2020

The webbrowser module in Python provides an interface to display Web-based documents. Webbrowser Under most circumstances, simply calling the open() … [Read more...] about Using the web browser in Python

Filed Under: Code Snippets, Scripts Author: PFB Staff Writer

OS.walk in Python

Author: PFB Staff Writer
Last Updated: August 27, 2020

Python has a cool built-in function in the OS module that is called os.walk() . OS.Walk() OS.walk() generate the file names in a directory tree by … [Read more...] about OS.walk in Python

Filed Under: Code Snippets, Scripts Author: PFB Staff Writer

Python Game : Rolling The Dice

Author: PFB Staff Writer
Last Updated: June 11, 2023

Dice games are one of the easiest yet most entertaining games. In this article, we will implement the rolling dice game in Python using two … [Read more...] about Python Game : Rolling The Dice

Filed Under: Code Snippets, Games Author: PFB Staff Writer

Monitor Apache / Nginx Log File

Author: PFB Staff Writer
Last Updated: August 27, 2020

Count the number of hits in a Apache/Nginx This small script will count the number of hits in a Apache/Nginx log file. How it works This script … [Read more...] about Monitor Apache / Nginx Log File

Filed Under: Code Snippets, Scripts Author: PFB Staff Writer

  • « Go to Previous Page
  • Go to page 1
  • Go to page 2
  • Go to page 3
  • Go to page 4
  • Go to page 5
  • Go to Next Page »

Primary Sidebar

Menu

  • Basics
  • Cheatsheet
  • Code Snippets
  • Development
  • Dictionary
  • Error Handling
  • Lists
  • Loops
  • Modules
  • Scripts
  • Strings
  • System & OS
  • Web

Get Our Free Guide To Learning Python

Most Popular Content

  • Reading and Writing Files in Python
  • Python Dictionary – How To Create Dictionaries In Python
  • How to use Split in Python
  • Python String Concatenation and Formatting
  • List Comprehension in Python
  • How to Use sys.argv in Python?
  • How to use comments in Python
  • Try and Except in Python

Recent Posts

  • Count Rows With Null Values in PySpark
  • PySpark OrderBy One or Multiple Columns
  • Select Rows with Null values in PySpark
  • PySpark Count Distinct Values in One or Multiple Columns
  • PySpark Filter Rows in a DataFrame by Condition

Copyright © 2012–2025 · PythonForBeginners.com

  • Home
  • Contact Us
  • Privacy Policy
  • Write For Us