高级编程技术第一周作业

1.python主页

        一上到python主页,首先映入我脑海的就是一系列python的代码,这些代码能很清晰的告诉初学者python的最大特点,那就是简洁,以往在c,c++需要几十行代码的文件,在python只需不到十行就能实现。继续往下浏览,可以找到python的历史版本,点开进去,发现有许多版,这给我一种印象就是python这种语言在高速发展中,与时俱进。在继续看有一些关于python成功故事,比如一家叫ILM的电影特效公司,尽管他们使用的计算机环境各有不同,他们都是用python来实现,python加大了他们的开发速度,因为python本身是一种极简洁的语言。

        在浏览了python主页之后,我深刻领会到了python的禅,这个禅包有许多东西,比如简洁,漂亮,可读性,化繁为简等等。这其中给我印象最深的就是简结,在我眼里其他的优点都是有简洁引申出来的。简洁能使一个程序变得更漂亮,更可读,我下定决心以后写的程序要重视简洁。

2.目标

        假如我成为了一个python高手,我觉得我最想写的就是一个游戏,一个随机性非常强的游戏。因为本人最喜欢的游戏是一种rougelike的游戏,我特别喜欢这种随机性。所以我的目标是写一个rougelike的游戏。

3.代码

2.1

message="hello world"

print(message)

2.2

message="hello world"

print(message)

message="import this"

print(message)

2.3

name="Leon"

print("Hello "+name+", would you like to learn some Python today?")

2.4

name="Leon"

print(name.lower())

print(name.upper())

print(name.title())

2.5

print('Socrates once said,"Other men live to eat, while I eat to live."')

2.6

famous_person="Socates"

message='"Other men live to eat, while I eat to live."'

print(famous_person+" once said,"+message)

2.7

person="\t\n Socates \t\n\t"

print(person)

print(person.lstrip())

print(person.rstrip())

print(person.strip())

2.8

print(1+7)

print(9-1)

print(2*4)

print(16/2)

2.9

num=5

message="My favorite number is "+str(num)

print(message)

2.10

#打印出四个用算术算出的8
print(1+7)

print(9-1)

print(2*4)

print(16/2)
#打印出名字小写大写和首字母大写
name="Leon"

print(name.lower())

print(name.upper())

print(name.title())

2.11

import this

猜你喜欢

转载自blog.csdn.net/liangjan/article/details/79516703
今日推荐