python基本操作教程代碼學習

Published
2022-06-09
浏览次数 :  200

基本操作:先要安裝python, 安裝后之後輸入命令:python –version 查看版本

然後設置vscode , 安裝python 插件, 設置ctrl+shift+p設置python 解析為安裝的python版本

然後vscode打開python文件,在vscode終端裏可以運行文件,或者點擊文件右上角的播放按鈕,在終端運行文件:

python的注釋是 #

#this is python claimer
#print(5%2)
# first_name = 'Wayne'
# first_name = " Shen"
# print(first_name)

# input_val = input("what do you want to use")
# print(input_val)
# print (5!=3)
# from ast import If
# from xml.dom.minidom import TypeInfo

# age = 9
# chid_age = input("What is your child age")
# elementary_age = 8

# if int(chid_age) < elementary_age :
#     print("You child are too young for elementary")
# elif int(chid_age) == elementary_age : 
#     print("congrats you child are allowed to the school")
# else :
#     print('your child should be in another course')
    
# def print_name(text):
        
#         print(text)
#         print(text)
#         print(text)
# print_name('Your name is W')

# def school_age_require(age,name) : 
#     if age > 5 : 
#         print("Enjoy the time",name,"is only",age)
#     elif age == 5 :
#         print("Enjoy kindergarten",name)
#     else : 
#         print("thery grow up so fast")
        
# school_age_require(9,"Wayne")

# def add_ten_to_age(age) :
#     new_age = age + 10
#     return new_age

# how_old_i_will_be = add_ten_to_age(19)

# print(how_old_i_will_be)

# loop of while
x = 0
while (x<5) : 
    print(x)
    x = x+1
# for loop 類似 foreach loop
for x in range(5,9) : 
    print(x) 
    
days = ['mon','tues','weds','satur','friday','sunday']
for d in days : 
    if(d == 'satur') : break #如果d 等於 satur 就終止循環
    if(d == 'tues') : continue #如果d 等於 tues 就跳過 不循環這個值
    print(d)

import math #導入 庫的基本操作
print('pi is',math.pi)

Top