AITC Wiki

print

打印输出复习

print

中文版:打印输出复习

some examples for using function “print()“

#print the string or the calculation result
print("hello world")
print("1+3")
print(1+3)
print("1+3=",1+3)# don't forget the comma
#print the value of variable or print the string
a=10
 
print(a)
print("a")
#print 2 variables
a=9
b="hi"
print(a,b)
#print with/without enter
 
print(1,2,3,4)
 
print(1)
print(2)
print(3)
print(4)
 
print(1,end="")
print(2,end="")
print(3,end="")
print(4,end="")

practice

  1. print your name

  2. print the result of 3+46

  3. print the expression 3+46=49

  4. print the name of 2 variables a=4 and b=“we”

  5. print the value of 2 variables a=4 and b=“we”

  6. print the value of a=4, and then print the value of b=5 without line break

fix the errors:

print 2
a=b=3
print a+b
a=b=3
 print(a+b)
print(a"hi")
print(ab)
print(a,"end=""")