• 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.

Python Code: Calculate the average score

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

Overview This script will calculate the average of three values. Make sure to put in "int" before the raw_input function, since we are using … [Read more...] about Python Code: Calculate the average score

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

Python Calendar : Show calendars

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

This script will ask for an input of a year. It will then take that input and return the calendar for that entire year. import calendar print "Show a … [Read more...] about Python Calendar : Show calendars

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

Urllib2 – User Agent

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

Overview This post will show how to add headers to a HTTP request. By default urllib2 identifies itself as Python-urllib/2.7 : GET / HTTP/1.1" … [Read more...] about Urllib2 – User Agent

Filed Under: Code Snippets, Network, urllib Author: PFB Staff Writer

Python Join Examples

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

Overview This post will show some examples of the Python join method. What is important to remember is that the character that joins the elements is … [Read more...] about Python Join Examples

Filed Under: Code Snippets, Data Types, Join Author: PFB Staff Writer

Check your external IP address

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

Overview This is a simple Python script to check which external IP address you have. First we are importing the urllib and re modules. Check your IP … [Read more...] about Check your external IP address

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

Python Hangman Game

Author: PFB Staff Writer
Last Updated: December 28, 2022

In Python, we can create simple games very quickly. In this article, we will discuss the implementation of the Python Hangman Game. Table of … [Read more...] about Python Hangman Game

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

Python Command Line IMDB Scraper

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

Overview This script will ask for a movie title and a year and then query IMDB for it. Command Line IMDB Scraper First step is to import the necessary … [Read more...] about Python Command Line IMDB Scraper

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

  • « Go to Previous Page
  • Go to page 1
  • Interim pages omitted …
  • Go to page 3
  • Go to page 4
  • Go to page 5

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