Andy Back-end Dev Engineer

Introduction_to_Computation-MIT6_0001F16_Lec2


这是MIT的第二节公开课,讲的都是基础的python语法知识,虽然这些语法都知道,但还是坚持把这节课听完,一可以锻炼听力也可以学点专业名次,二,这么简单的课程都不能坚持听完,更别说计划中都算法课了。

STRINGS

  • enclose in quotation marks or single quotes
  • concatenate strings
  • do some operations on a string as defined in Python docs

INPUT/OUTPUT: print input

print("my fav num is", x, ".", "x =", x)
print("my fav num is " + x_str + ". " + "x = " + x_str)

num = int(input("Type a number... "))
  print(5*num)

input gives you a string so must cast if working with numbers

COMPARISON OPERATORS ON int,float, string

LOGIC OPERATORS ON bools

not a True if a is False False if a is True a and b True if both are True a or b True if either or both are True

CONTROL FLOW - BRANCHING

if while for


Similar Posts

Comments