Variables are a way of ____ pieces of data in your program. When you create a ____, an area of the computer’s ____ is ____ for you and the ____ is stored in it. This area of memory is now ____ by you: you can ____ data from it, ____ the data, or get rid of it all together. To create a ____ in Python you give it a ____ and make it ____ to a value. This is known as ____. For example my_variable = "some useful data" Next you will ____ your program to store your name in a ____ and then display it. Add the following ____ to the bottom of your ____ to create a new variable called ____ to hold your name. my_name = "Martin" You should put your name (or any other name you like!) in ____ the ____ marks: "Martin". When your computer ____ this ____, a variable called my_name will be ____ and the text of your name will be ____. Once a variable has been ____, it can then be used in your program. Use print to ____ your name to the screen by adding this code to the bottom of your program. print(my_name) Notice how when using print you put the name of the ____ between the () instead of ____. The print instruction will ____ the value from the my_name variable and ____ it. ____ your program to see your name ____ under the first 2 print statements. Tip: a common problem is to put the variable name inside ____ ____, e.g. print("my_name"). (What will this do? If you are not sure, ____ it!) You can improve the message by putting the text “My name is “ in ____ of your name.____ the ____ to add the text "My name is " before the ____ ____: print("My ____ is " + my_name) Note the use of the ____ sign to add the ____ piece of text to the text in the variable. ____ pieces of text ____ like this is known as ____. ____ your program. Reflect: ____ line of code would you change if you wanted the ____ printed line to say “My name is ____ instead? (There may be ____ than one answer!)
0%
Program two variables
แชร์
แชร์
แชร์
โดย
Robert272
แก้ไขเนื้อหา
สั่งพิมพ์
ฝัง
เพิ่มเติม
กำหนด
ลีดเดอร์บอร์ด
แสดงเพิ่มขึ้น
แสดงน้อยลง
ลีดเดอร์บอร์ดนี้ตอนนี้เป็นส่วนตัว คลิก
แชร์
เพื่อทำให้เป็นสาธารณะ
ลีดเดอร์บอร์ดนี้ถูกปิดใช้งานโดยเจ้าของทรัพยากร
ลีดเดอร์บอร์ดนี้ถูกปิดใช้งานเนื่องจากตัวเลือกของคุณแตกต่างสำหรับเจ้าของทรัพยากร
แปลงกลับตัวเลือก
เติมประโยคให้สมบูรณ์
เป็นแม่แบบแบบเปิดที่ไม่ได้สร้างคะแนนสำหรับลีดเดอร์บอร์ด
ต้องลงชื่อเข้าใช้
สไตล์ภาพ
แบบ อักษร
ต้องสมัครสมาชิก
ตัวเลือก
สลับแม่แบบ
แสดงทั้งหมด
รูปแบบเพิ่มเติมจะปรากฏเมื่อคุณเล่นกิจกรรม
เปิดผลลัพธ์
คัดลอกลิงค์
คิวอาร์โค้ด
ลบ
คืนค่าการบันทึกอัตโนมัติ:
ใช่ไหม