0% found this document useful (0 votes)
7 views1 page

Coding Projects in Python (Dragged) 2

Uploaded by

Hayley Kelsey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views1 page

Coding Projects in Python (Dragged) 2

Uploaded by

Hayley Kelsey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

YO U R F I R S T P RO G R A M 23

4 Save the file


A pop-up box will appear. Type in a name for your
LINGO
program, such as “helloworld.py”, and click Save. .py files
Python programs usually have
Save As: helloworld.py
a name ending with “.py”,
Tags: which makes them easy to
Type the recognize. When you save a
Where: Documents name of program, Python automatically
your
program
adds “.py” at the end, so you
here. don’t need to type it in.
Cancel Save

5 Check it works
Now run the first line of the program
Python Shell >>>
to see if it works. Open the Run menu Check Module Hello, World!
and choose Run Module. You should
>>>
see the message “Hello, World!” in the Run Module
shell window.
The message will
appear in the shell.

6 Fix mistakes
If the code isn’t working, stay calm!
EXPERT TIPS
Every programmer makes mistakes, Keyboard shortcut
and finding these “bugs” is vital if you
want to become an expert at coding. A handy shortcut to run a program from
Go back and check your code for the editor window is simply to press F5 on
typing errors. Did you include the your keyboard. This is a lot quicker than
brackets? Did you spell the word selecting “Run” and then “Run Module”.
“print” correctly? Fix any mistakes,
then try running the code again.

7 Add more lines


Go back to the editor window and add two more lines to
print('Hello, World!')
your script. Now the middle line asks for your name and person = input('What’s your name?')
then stores it in a variable. The last line uses your name print('Hello,', person)
to print a new greeting. You can change it to a different
greeting if you prefer—as polite or as rude as you like!
This line asks for the user’s name and
stores it in a variable called “person”.

8 Final task
Run the code again to check it. When you type in your Hello, World!
User’s
name and hit the enter/return key, the shell should show What's your name?Josh name
a personalized message. Congratulations on completing
Hello, Josh
your first Python program! You’ve taken your first steps
towards becoming a powerful programmer.

You might also like