Back to Browse

#3 Python Playground: Strings | Computer Programming & Coding for Kids & Beginners

7.1K views
Oct 6, 2020
2:39

3. Python Programming for Kids and Beginners: Let's Display Strings on IDLE! Lesson 3 Liam Let's Display Strings on IDLE! Character data handled in a program is called a "string". Emma I'm not sure. Liam A string is a sequence of characters. Each character is simply a symbol. For example, “Emma” is a string, and “Emma” has 4 characters. Emma I see. Then, let's display Emma on IDLE! I write “print” and “Emma in parentheses” after prompt and press the Enter key. But I got some weird red letters. I didn't forget to write the parentheses properly. What's going on? Liam This is an indication of an error. IDLE says, "I can't understand that order." Emma Why does the error occur? I just wanted my name displayed. Liam In such a case, try adding double quotes before and after Emma. Emma I put double quotes before and after Emma and press the Enter key. Then, “Emma” is displayed properly! Liam In IDLE, a string must be written with single or double quotes on both sides. You can use either one, but use the same symbol on both sides. For example, if you want to display “Hello”, you can write it with single quotes like this. And when you press the Enter key, “Hello” is displayed. Similarly, when you write this with double quotes, “Hello” is displayed. Emma I understand how to display a string. What should I do when displaying a combination of string and number? Liam You can display multiple values in a row by separating the parentheses with commas. Let's write it like this. Don’t forget to put single or double quotes before and after the string part. Then you press the Enter key, "The answer is 30" is displayed. Emma Now I can display the string on the IDLE. Liam Well done.

Download

0 formats

No download links available.

#3 Python Playground: Strings | Computer Programming & Coding for Kids & Beginners | NatokHD