Hello and Welcome to Coding for Beginners! This is an introduction to the very first thing that anybody learns when starting a new language, the Print statement.
The Print statement is perhaps the most simple code in the Python language. The syntax of the Print statement is also very easy to understand and use when you need it. However, it is always important what it is you are printing, because there are slight changes based on what you are printing.
Here is the base syntax for a Print statement in Python:
print(**whatever you want to print**)
All print statements begin with the word, 'print', with a parentheses after it. However, as with all languages, this syntax cannot be altered. 'print' must be all lowercase, and the parentheses that follow must be the curved parentheses, '().'
Now you will see the two basic things that can be printed, Integers, and Strings.
Integers:
Printing an integer is very simple, there are no extra tweaks to the print statement when print an integer.
To print an integer, all that is required is print(**the integer that you want to print**). For example:
Input:
print(5)
Output:
5
Strings:
Printing a string is fairly easy. Strings are always enclosed in double or single quotes.
To print a string, the only difference is that when you type what you want to print, you enclose that in double or single quotations, as such: print("Hello World").
Input:
print("Hello World!")
Output:
Hello World!
These are the basics of the Print Statement in Python. There are many other thing that can be printed as well, such as variable values, lists, arrays, and so on. These will be covered in a later post.
Thank you! Here are a few things you could try out yourself:
1. Try printing the number 10
2. Try to print, "Hello World!"
Please look out for other posts!
Very nice tutorial! I love 🐍 as long as it’s not the Anaconda type. But Anaconda is my favorite IDE
ReplyDeleteVery nice tutorial! I love 🐍 as long as it’s not the Anaconda type. But Anaconda is my favorite IDE
ReplyDelete