AITC Wiki

Practice1

练习 1

Practice1

中文版:练习 1

Review of variable and operator

  1. create an variable, name is a, value is 10

  2. create two variables, names are b and c, values are 9 and 11

  3. save value 1 into a variable, print it

  4. save “hello world”, (create a variable whose type is string)

  5. print the result: Is a greater than b?

Try by yourself 1

  1. save value 1 to 10

  2. save value 2,3,45,67,11,12,45,78,99 and print them all

using “List” to save and process a group of value (refer to 06)

  1. create a empty list

  2. save the group of value: 2,3,45,67,11,12.

print the length of the list.

print how many values save in the list.

  1. add a new value 1000 at the end of this list

  2. print the 3rd value in the list

  3. delete the 3rd value in the list, print the new list

  4. print the result: is the 4th value smaller than the 1st value

Try by yourself 2

  1. print 1,2,3…,10

  2. print the variable a 10 times, print “hello world” 10 times

  3. create an int variable n, calculate 1+2+3+…+n

using “Loop” to do the same line multiple times (refer to 07)

  1. print 1,2,3,4,…,10 using “for” or “while”

  2. print the variable a 10 times using “for”

  3. print “hello world” 10 times using “while”

  4. create an int variable n, calculate 1+2+3+…+n, using “for”

Try by youself 3

  1. create two variables A and B, compare A and B, print the greater value

using “if” to do the conditional structure

  1. create two int variables A and B, compare A and B, print the name and value of the greater variable

  2. consider the special condition: if A=B, print “A is equel to B” (using elif)

  3. try A=10, B=20

  4. try A=100, B=99.5

  5. try A=12, B=12