python基础学习

1、变量的定义

name="""print("hello word")
name="fengjinrong"
name2=name
print("my name is ",name,name2)
name="Paochege"
print(name,name2)
gf_of_oldboy = "fengjinrong"

print(gf_of_oldboy)
print(name)

2、交互

name=input("userName:")

age=int(input("age:"))

job=input("job:")

 

print(name,age)

print(type(age))

info='''

----------------info of %s---------------------

name:%s

age:%s

'''%(name,name,age)

print(info)

 

 

第二种方法:

info2='''

----------------info of {_name}---------------------

name:{_name}

age:{_age}

'''.format(_name=name,

_age=age,

)

第三种方法:

info3='''

----------------info of {0}---------------------

name:{0}

age:{1}

'''.format(name,name,age)

print(info3)

 

3、if语句:

age_of_oldboy = 56
guess_age = input("guess age:")
if(guess_age==age_of_oldboy):
    print("yes you got it.")
elif int(guess_age) > age_of_oldboy:
    print("think smaller...")
else:
    print("think bigger!")

 

4、for语句:

for i in range(0,10):
    if i< 5:
        print("loop ",i)
    else:
        print("hello ...",i)
        continue

你可能感兴趣的:(python)