Programs, Scripts, and print()

A program is a collection of program statements that performs a specific task when a computer runs it. A program is often called software. A program can…

Programs and scripts
A program is a collection of program statements that performs a specific task when a computer runs it. A program is often called software.
A program can be written in many programming languages. We will use Python. By convention Python code is stored in a file called a script, which ends in .py, and you write scripts in an IDE (Integrated Development Environment).
Your first program
The print() function displays a message on the console. Characters enclosed in quotes, single or double, form a literal string. The quotes mark where the text starts and ends, so they are not part of what gets printed.
Every print() ends the line
By default print() ends its output with a newline character, a special control character that marks the end of a line. Calling print() with nothing inside prints an empty line. Inside a string literal you can also write a newline yourself as a backslash followed by n.
CodePrints
print("hi")hi
print()an empty line
print("a\nb")a, then b on the next line
print() is not only for text
print() evaluates a math expression before printing the result. Numbers print without quotes, because they were never text to begin with.
CodePrints
print(4)4
print(3.14)3.14
print(3 + 4)7
Several values at once
print() accepts any number of positional arguments separated by commas: zero, one, or many. It joins everything you pass it and inserts exactly ONE space between each pair. This is how you mix text with numbers and math expressions in a single line of output.