iT邦幫忙

第 12 屆 iThome 鐵人賽

0
自我挑戰組

笨方法學python 大家來一起開心學python XD系列 第 2

Day2:How to use comments,octothorpe and variable in Python

  • 分享至 

  • xImage
  •  

Comment is a very important part in programing

Comments can tell you something does,and they also are used to disable parts of your program if you need remove them temporarily.

if you want comments in python,use'#'

     # In python,anything ignored after use '#'
     
     print "I want write this thing" #comment is ignored
     
     # print "這串不會執行"
     
     print "這會執行"
                    

Names and Variables

Variables is a thing to represent 'Something" in your code. Programmers use varibles to make code read more like English or other language.

     cake=50
     people=20
     tottal_cake_and_people = cake+people
     
     
     
     print "There have",cake,"cake to eat."
     print "We have",people," want to eat cake today."
     print "If everybody want to eat cake we need at least",tottal_cake_and_people,"cake"

上一篇
Day1:Hello World!
下一篇
Day3:String Formatting 字串格式化
系列文
笨方法學python 大家來一起開心學python XD12
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言