Python is one of the most popular programming languages today due to its simplicity and versatility. It is widely used for web development, data analysis, artificial intelligence, and more.
Python is a high-level, interpreted language, meaning you don't need to worry about many of the complexities that other languages may require, such as memory management or complex syntax. It's designed to be easy to read and write, making it an ideal language for beginners.
print("Hello, World!")
The print()
function in Python outputs whatever is inside the parentheses to the console. In
this case, it prints the text "Hello, World!"
. Every Python program can be run by saving the
code in a file with a .py
extension and executing it in a Python environment.
name = input("Enter your name: ")
The input()
function allows users to provide input to the program. In this example, the program
prompts the user to enter their name, which is then stored in the variable name
. You can then
output this input back to the user using the print()
function:
print("Hello, " + name + "!")
Write a Python program that asks for your favorite hobby and prints a message including that hobby. This
will help you practice using both the input()
and print()
functions.
hobby = input("What is your favorite hobby? ")
print("My favorite hobby is " + hobby)