Practice1
中文版:练习 1
Review of variable and operator
-
create an variable, name is a, value is 10
-
create two variables, names are b and c, values are 9 and 11
-
save value 1 into a variable, print it
-
save “hello world”, (create a variable whose type is string)
-
print the result: Is a greater than b?
Try by yourself 1
-
save value 1 to 10
-
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)
-
create a empty list
-
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.
-
add a new value 1000 at the end of this list
-
print the 3rd value in the list
-
delete the 3rd value in the list, print the new list
-
print the result: is the 4th value smaller than the 1st value
Try by yourself 2
-
print 1,2,3…,10
-
print the variable a 10 times, print “hello world” 10 times
-
create an int variable n, calculate 1+2+3+…+n
using “Loop” to do the same line multiple times (refer to 07)
-
print 1,2,3,4,…,10 using “for” or “while”
-
print the variable a 10 times using “for”
-
print “hello world” 10 times using “while”
-
create an int variable n, calculate 1+2+3+…+n, using “for”
Try by youself 3
- create two variables A and B, compare A and B, print the greater value
using “if” to do the conditional structure
-
create two int variables A and B, compare A and B, print the name and value of the greater variable
-
consider the special condition: if A=B, print “A is equel to B” (using elif)
-
try A=10, B=20
-
try A=100, B=99.5
-
try A=12, B=12