Do not worry about harming your computer, not understanding or any other worry you may have. Programming is a lot of fun and nothing on this blog will harm your computer.
The first statements we will be learning about are print statements. This is the way that you get the program to give you feedback on what you have done. The program can print out anything that you would like it to. Start off by typing out this simple program:
print("Hello World!")
print("This is a string")
print("This is another string")
print("I'm having fun!")
print(10)
print(1984)
print(10.0)
print("10")
print("2012: A Space Odyssey")
print("143.0")
print("Goodbye World!")
Save the file as tut1.py. Open up your consol. You can do this by searching for “cmd”, “consol” or “shell” in the start menu in the bottom left corner of the screen. In the place where it says “Type here to search”, type in one of the above commands without the quotes and open the consol.
Navigate to the directory where your file is saved by typing in cd (which stands for Change Directory), one space and then the directory location that you would like to move to. For instance I type in “cd C:\Users\UserName\desktop\python” (without the quotes) because my files are saved in a folder named python on my desktop.
Once you have navigated to the correct folder you are going to need to type in the word “python” (no quotes), one space and then the name of the file you are going to run. On some computers, it is “py” instead of “python”. So you are going to need to type in “python tut1.py” or “py tut1.py”.
The file will run and show the output. The output should be as follows:
Hello World!
This is a string
This is another string
I'm having fun!
10
1984
10.0
10
2012: A Space Odyssey
143.0
Goodbye World!
If you are getting errors, then look at my code again. If you are still having trouble trying reading through all of the code backwards line by line to ensure that they are exactly the same.
Here are some exercises for you:
- Print out your name, age, address, work address, etc.
- Print out some numbers
- Print out more lines of code until you are comfortable with print statements
- Notice that one of the 10s has quotes around it, one of the 10s has no quotes and one of the 10s is 10.0. What do you think the difference could be between these? Did they all print out the same?
I just applied for both an individual loan and an entitled Loan from Mr Pedro Jerome and his loan organization at the 3% rate I will be starting my loan repayment next month and it will really be helpful to anyone here looking for a loan to contact Mr Pedro Jerome on pedroloanss@gmail.com +1-863-231-0632 whatsapp text for individual or entitle loans with a simple loan repayment as mine.
ReplyDelete