Python - #1 - The Basics
1. Start with Commenting
Programmers write A LOT of code. They need to understand exactly what they have written, especially if they are working as part of a team or returning to code after working on other projects.
​
To help them understand what they have written, programmers use comments to annotate (explain) their code.
Task 1 - Create a new Python program and use # to write a comment that says your name and the date. Save the file as 1-Basics.py
![comment1.PNG](https://static.wixstatic.com/media/fb2250_e71e70cbc5384a8fa4849d5616cb7d38~mv2.png/v1/fill/w_439,h_168,al_c,q_85,usm_0.66_1.00_0.01,enc_avif,quality_auto/comment1_PNG.png)
In Python, type the # symbol then your message to write a comment.
​
Comments are not printed when you run a program!
​
It is a good idea to start every program with a comment, so you know what the program is about.
2. Printing to the Screen
The most basic and common command you will use in Python is print.
​
Inside the print brackets, you can write a message within speech marks.
​
Your print command should turn purple - don't use any capital letters in Python unless it is inside speech marks!
Task 2 - Write a nice message by using the print command, brackets and speech marks.
​
Press F5 to run your program.
![comment2.PNG](https://static.wixstatic.com/media/fb2250_cbfab0c1021944f58c139565da892121~mv2.png/v1/fill/w_450,h_154,al_c,q_85,usm_0.66_1.00_0.01,enc_avif,quality_auto/comment2_PNG.png)
![comment3.PNG](https://static.wixstatic.com/media/fb2250_d780865e841f46cb8eff6a28f8e60748~mv2.png/v1/crop/x_1,y_0,w_221,h_89/fill/w_221,h_89,al_c,q_85,enc_avif,quality_auto/comment3_PNG.png)
3. More Printing
You can write multiple print lines one after another to print on different lines.
![comment4.PNG](https://static.wixstatic.com/media/fb2250_a9739b3009ee4d13a61db5b4255c6993~mv2.png/v1/fill/w_441,h_158,al_c,q_85,usm_0.66_1.00_0.01,enc_avif,quality_auto/comment4_PNG.png)
Task 3 - Add two more print lines to your program. You can choose any message that you like.
![comment7.PNG](https://static.wixstatic.com/media/fb2250_c639947c488b4417a44ed8ca9e3ba5c1~mv2.png/v1/fill/w_230,h_104,al_c,q_85,usm_0.66_1.00_0.01,enc_avif,quality_auto/comment7_PNG.png)
4. New Lines
You can use the special command \n to start a new line. This allows you to write on multiple lines but only use one print line.
​
Use the backslash ( \ ) not the forward-slash ( / ).
![comment5.PNG](https://static.wixstatic.com/media/fb2250_ec847e43f29d46738f82f7db1087999e~mv2.png/v1/fill/w_432,h_186,al_c,q_85,usm_0.66_1.00_0.01,enc_avif,quality_auto/comment5_PNG.png)
Task 4 - Use \n to write a 3 sentence conversation in only one line of code.
![comment6.PNG](https://static.wixstatic.com/media/fb2250_23d9206da6294ff8bbe91f7d5c16b0f7~mv2.png/v1/fill/w_225,h_166,al_c,q_85,usm_0.66_1.00_0.01,enc_avif,quality_auto/comment6_PNG.png)
Challenge Programs
Use everything that you have learned on this page to help you create these programs...
​
Challenge Task 1 - Days of the Week
-
Create a new Python program. Save it as '1-Week.py'
-
Add a comment at the top with your name and the date.
-
Create a program that prints the days of the week, with each day on a new line.
​
-
BONUS: Try to use only one print line.
-
BONUS: Have no empty spaces at the start of each line.
​
When you run it, it should look like this:
![comment8.PNG](https://static.wixstatic.com/media/fb2250_5bd45ca5651a4b73be2d2ba87d45fb8a~mv2.png/v1/fill/w_138,h_241,al_c,q_85,enc_avif,quality_auto/comment8_PNG.png)
Challenge Task 2 - Conversation
-
Create a new Python program. Save it as '1-Conversation.py'
-
Add a comment at the top with your name and the date.
-
Create a program that prints a 6-line conversation between two people. It is up to you what these two people are talking about.
​
-
BONUS: Try to use only one print line.
-
BONUS: Have no empty spaces at the start of each line.
​
When you run it, it could look something like this:
![comment9.PNG](https://static.wixstatic.com/media/fb2250_36e9764c9a9e40099c9b11282a0fca1b~mv2.png/v1/fill/w_523,h_222,al_c,q_85,usm_0.66_1.00_0.01,enc_avif,quality_auto/comment9_PNG.png)