1. 程式人生 > >python基礎學習 day 1

python基礎學習 day 1

年齡 num break 2.7 歷程 it is log 學習 pre

  初學python,記錄下自己的歷程~

  了解了一下python的基本概念,現在使用的比較多的就是python2.7

  學習了if語句和兩個經典的循環語句

#關於if語句的應用
name = raw_input(input name)
age = input(input age)
#也可以用input
salary = raw_input(salary)

#使用if語句永遠只有一個結果,滿足條件即結束
if age > 60:
    msg = you are too old
elif age > 30:
    msg = you are not young
else: msg = you are still young print‘‘‘ information of %s: name:%s age:%d salary:%s ________________________ %s ‘‘‘ %(name, name, age ,salary, msg)#必須一一對應
#關於for循環(猜年齡)
real_age = 18

for i in range(10):
    age = input(age:)
    if age > real_age:
        print think smaller
elif age < real_age: print think bigger else: print you are right break print you still have %s shots % (9 - i)
#關於while循環(選定打印的數)
import sys
num = 0
count = 0

while count <=1000:
    if count == num:
        print there is the number, count
        
while num <= count: num = input(which number do you want? inuput 0 to exist) if num == 0: sys.exit() if num <= count: print it is over else: print loop:, count count += 1 else: print loop:, count

python基礎學習 day 1