![]() The star * in the program above is a multiply sign. Python can also do calculations using text! What do you get if you multiply "hello" by 5? Let’s ask Python, by running this program: print ( "hello" * 5) You can create images of your hobbies, friends, family… anything you want! Here’s an example: screenshot Save Your Project Step 3: Calculating text Activity Checklist Write a Python program to tell others about yourself, by using text and ASCII art. Save Your Project Challenge: About yourself If you run this program, you’ll see it prints the same dog as before. If you prefer, you can use 3 single quotes ( ''') instead of speech marks, which allows you to print multiple lines of text with 1 print statement. To make this masterpiece, you can type the following into the IDLE editor and run the program: print ( "A picture of a dog.") print ( " 0_ ") print ( " |||| ") Here’s an example - it’s meant to be a dog! screenshot Let’s print something much more fun than text… ASCII art! ASCII art is creating pictures out of text. Save Your Project Challenge: What’s on your mind?Ĭhange the program above to print something more interesting to the screen! screenshot Save Your Project Step 2: About yourself Activity Checklist If you’ve made a mistake, for example missing out a speech mark ( "), then you’ll get an error message instead, telling you what went wrong! Try it! screenshotĬongratulations, you are now officially a Python programmer! Give yourself a pat on the back (or if you’re feeling lazy, get someone else to do it for you). ![]() If everything has worked properly, you should see your text printed to the screen. This is the place that your program will run. You should see another window appear, which is the Python shell. Run the file by clicking Run → Run Module. Without it, your program won’t be colour coded, which can be really helpful. py bit at the end, which tells the computer that it’s a Python file. Save the file, by clicking File → Save, and name the file hello.py or something similar. Here’s an image showing what you need to do: screenshot Notice that the text you want to print is surrounded by speech marks ( "). This program will print some text to the screen. On Linux, open up a Terminal, and type idle and press enter.Ĭlick File → New Window, and type the following into the window that appears: print ( "Hello, how are you?").On Mac, open up Terminal.app and type idle and press enter. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |