设为首页 收藏本站
查看: 336|回复: 0

[经验分享] Codecademy python

[复制链接]

尚未签到

发表于 2015-11-30 09:14:35 | 显示全部楼层 |阅读模式
  #1



print "Welcome to Python!"
  #2



my_variable = 10
  #3



# Set the variables to the values listed in the instructions!
my_int = 7
my_float = 1.23
my_bool = True
  #4



# my_int is set to 7 below. What do you think
# will happen if we reset it to 3 and print the result?
my_int = 7
# Change the value of my_int to 3 on line 8!
my_int = 3
# Here's some code that will print my_int to the console:
# The print keyword will be covered in detail soon!
print my_int
  #5



def spam():
eggs = 12
return eggs   
print spam()
  #6



def spam():
eggs = 12
return eggs     
print spam()
  #7



spam = True
eggs = False
  #8



#fuck you
mysterious_variable = 42
  #9



"""233
"""
  #10



# Set count_to equal to the sum of two big numbers
count_to = 100+1000

print count_to
  #11



#Set eggs equal to 100 using exponentiation on line 3!
eggs = 10**2
print eggs
  #12



#Set spam equal to 1 using modulo on line 3!
spam = 5 % 4
print spam
  #13



#fuck you
monty = True
python = 1.234
monty_python = python**2
  #14



# Assign the variable meal the value 44.50 on line 3!
meal = 44.50
  #15



meal = 44.50
tax = 6.75 / 100
  #16



# You're almost there! Assign the tip variable on line 5.

meal = 44.50
tax = 0.0675
tip = 15.0 /  100
  #17



# Reassign meal on line 7!
meal = 44.50
tax = 0.0675
tip = 0.15
meal = meal + meal*tax
  #18



# Assign the variable total on line 8!
meal = 44.50
tax = 0.0675
tip = 0.15
meal = meal + meal * tax
total = meal + meal * tip
print("%.2f" % total)
  #19



# Set the variable brian on line 3!
brian = "Hello life!"
  #20



# Assign your variables below, each on its own line!
caesar = "Graham"
praline = "John"
viking = "Teresa"

# Put your variables above this line
print caesar
print praline
print viking
  #21



# The string below is broken. Fix it using the escape backslash!
'This isn\'t flying, this is falling with style!'
  #22



"""
The string "PYTHON" has six characters,
numbered 0 to 5, as shown below:
+---+---+---+---+---+---+
| P | Y | T | H | O | N |
+---+---+---+---+---+---+
0   1   2   3   4   5
So if you wanted "Y", you could just type
"PYTHON"[1] (always start counting from 0!)
"""
fifth_letter = "MONTY"[4]
print fifth_letter
  #23



parrot = "Norwegian Blue"
print len(parrot)
  #24



parrot = "Norwegian Blue"
print  parrot.lower()
  #25



parrot = "norwegian blue"
print parrot.upper()
  #26



"""Declare and assign your variable on line 4,
then call your method on line 5!"""
pi=3.14
print str(pi)
  #27



ministry = "The Ministry of Silly Walks"
print len(ministry)
print ministry.upper()
  #28



"""Tell Python to print "Monty Python"
to the console on line 4!"""

print "Monty Python"
  #29



"""Assign the string "Ping!" to
the variable the_machine_goes on
line 5, then print it out on line 6!"""
the_machine_goes = "Ping!"
print the_machine_goes
  #30



# Print the concatenation of "Spam and eggs" on line 3!
print "Spam "+"and "+"eggs"
  #31



# Turn 3.14 into a string on line 3!
print "The value of pi is around " + str(3.14)
  #32



string_1 = "Camelot"
string_2 = "place"
print "Let's not go to %s. 'Tis a silly %s." % (string_1, string_2)
  #33



name = raw_input("What is your name?")
quest = raw_input("What is your quest?")
color = raw_input("What is your favorite color?")
print "Ah, so your name is %s, your quest is %s, " \
"and your favorite color is %s." % (name, quest, color)
  #34



# Write your code below, starting on line 3!
my_string ="haha"
print len(my_string)
print my_string.upper()
  #35
  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-145156-1-1.html 上篇帖子: python中string模块各属性以及函数的用法 下篇帖子: Python笔记(五)--Django中使用模板
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表