Any time
Open links in new tab
- ✕This summary was generated using AI based on multiple online sources. To view the original source information, use the "Learn more" links.
Here are some basic Python codes to get you started with common tasks.
Print "Hello, World!"
This is the most basic program that prints "Hello, World!" to the console.
print("Hello, World!")Copied!✕CopyAdd Two Numbers
This program adds two numbers provided by the user.
# Input from the usernum1 = float(input("Enter first number: "))num2 = float(input("Enter second number: "))# Adding two numberssum = num1 + num2# Display the sumprint("The sum is:", sum)Copied!✕CopyFind the Factorial of a Number
This program calculates the factorial of a given number using recursion.
def factorial(n):if n == 1:return nelse:return n * factorial(n-1)num = int(input("Enter a number: "))print("The factorial of", num, "is", factorial(num))Copied!✕CopyCheck if a Number is Prime
This program checks if a given number is prime.
Python Basics
- Fundamentals. Syntax – introduce you to the basic Python programming syntax. Variables – …
- Operators. Comparison operators – introduce you to the comparison operators and how to use …
- Control flow. if…else statement – learn how to execute a code block based on a condition. Ternary …
- Functions. Python functions – introduce you to functions in Python, and how to define functions, …
- Lists. List – introduce you to the list type and how to manipulate list elements effectively. Tuple – …
Learn Python Basics - GeeksforGeeks
Feb 7, 2026 · Python is a high-level programming language with a simple and readable syntax. It is commonly used for web development, data analysis, …
Microsoft Python - Learn Python Programming
Sponsored Prepare for a new career by building in-demand Python skills with Microsoft training. Design, develop, deploy. Earn the Microsoft Python Development Professional Certificate.40% off Coursera Plus · Valid Mar 24 - Apr 27"Great Website, very useful content." - from consumer review
Get Started for Free | Learn Python in 15 Hours
Sponsored Learn Python by doing interactive coding exercises. Start now. Start learning Python - the world's most in demand programming languageIntroduction To Python | Learn For Free With Codecademy
Sponsored Learn in-demand coding skills for free with Codecademy. Start your coding journey for free with Codecademy.