初识python代码
生活随笔
收集整理的這篇文章主要介紹了
初识python代码
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1、初識代碼
1 x = 3 2 y = 4 3 z = 3*4 4 5 print("x乘以y=", z) 6 7 print("z=", z)2、Hello,World!
1 C:\Users\Administrator\Desktop\python>python 2 Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD6 3 4)] on win32 4 Type "help", "copyright", "credits" or "license" for more information. 5 >>> print("Hello,World!") 6 Hello,World!3、Windows測試中文顯示(python2.x需要指定中文編碼:utf-8);python3.x編碼更新為Unicode,默認向下兼容所有編碼
1 #!-*- coding:utf-8 -*- 2 3 print ("我肚子餓了,想吃飯!")4、if.....else語句初識
(猜年齡)
1 age_of_princal = 45 2 guess_age = int(input(">>:")) 3 4 if guess_age == age_of_princal: 5 print("Yes,you got it..") 6 else: 7 print("No,it's wrong!")判定成績
1 score = int(input("score:")) 2 3 if score > 90: 4 print("A") 5 elif score >80: 6 print("B") 7 elif score >70: 8 print("C") 9 elif score > 50: 10 print("D") 11 else: 12 print("你掛科啦")?
轉載于:https://www.cnblogs.com/larryzhou/p/9260195.html
總結
以上是生活随笔為你收集整理的初识python代码的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 老式海尔空调怎么拆外盖
- 下一篇: 租房的应该怎么办居住证