5 月 132020
 

练习代码1及注释

# -*- coding: utf-8 -*-
print "Hello World!"
print "Hello Again"
print "I like typing this."
print "This is fun."
print 'Yay! Printing.'
print "I'd much rather you 'not'."
print 'I "said" do not touch this.'
# #号用来注释
# 使用Unicode UTF-8编码以避免乱码

练习代码2及注释

# -*- coding: utf-8 -*-
# A comment, this is so you can read your program later.
# Anything after the # is ignored by python.

print "I could have code like this." # and the comment after is ignored

# You can also use a commnet to "disable" or comment out a piece of code:
# print "This won't run."

print "This will run."
# 注释可以是对某行代码的自然语言描述也可以用作临时禁用该行代码
# 注释符的英文名称为octothorepe或者pound character
# 引号中的#号作为字符串中的一个普通字符

练习代码3及注释

# -*- coding: utf-8 -*-
print "I will now count my chickens:"

print "Hens", 25 + 30 / 6
print "Roosters", 100 - 25 * 3 % 4

print "Now I will count the eggs:"

print 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6

print "is it true that 3 + 2 < 5 - 7?"

print 3 + 2 < 5 - 7

print "What is 3 + 2?", 3 + 2
print "What is 5 - 7?", 5 - 7

print "Oh, that's why it's False."

print "How about some more."

print "Is it greater?", 5 > -2
print "Is it greater or equal?", 5 >= -2
print "is it less or equal?", 5 <= -2
# 百分号%表示求余数,75除4得18余3
# 运算优先级为括号,指数,乘,除,加,减
# 1/4运算结果舍去了小数部分

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据