Your first Python program
Written by PIRATE KING
Let's write our first program, called Hello World!. It's a classic beginner's example used worldwide, including in my first computer science class at Carnegie Mellon University. I used Java back then. Instead, we'll print “Hello World!” using Python.
Python has many built-in functions, and one of them is called print. So, what does the print function do? It displays text on the screen. Let's try it out by printing Hello World! to the screen. When you use a function, we say you are "calling" it. Calling a function means running or executing it.
To call the print function, you need to follow some rules. You must put open ( and close ) parentheses after the function name. Also, if you want to use text, you must put it inside quotes. You can use double quotes " " or single quotes ' '. For this exercise, we'll use double quotes and write "Hello World!". To run the code, press the EXECUTE button below. Or, if you're on a Mac, press Cmd + Enter. On Windows, press Ctrl + Enter.
Congratulations! 🎉 You made your first program!
At the end of each section, you'll get a short quiz to review what we covered. Think about your answer, type it in the code editor, then EXECUTE it to check for errors. Here's the first quiz:
This is Python in the terminal.Expected output:
This is Python
When you're done, click the EXECUTE button in the editor to verify your answer. If your code outputs This is Python, you'll see a green Correct checkmark. However, if your code uses a lowercase 'p'—like This is python—it will be marked incorrect because Python is case-sensitive.
Please keep in mind that these quizzes only check if your final terminal output matches the solution exactly; they don't verify your actual code logic. For example, you could write your code using single quotes '' instead of double quotes (like this 'This is Python'), and you will still get the Correct checkmark as long as the text on the screen matches. In programming, there are often multiple ways to arrive at the same result. To verify that your code logic is sound, click the 'Check Answer ✔' button at the top of the editor to compare your code with my solution. Additionally, you can pass the quiz prompt and your code into an AI assistant to get feedback on your solution.
↺ to bring the code back to the initial version. You can also press the check button ✔ anytime to check your answer. Use these buttons to help you learn better and faster!