Skip to content

Commit 71c9344

Browse files
committed
add uooc
1 parent 8be4ade commit 71c9344

File tree

7 files changed

+118
-0
lines changed

7 files changed

+118
-0
lines changed

uooc/examinations/week1/1.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Hello World的条件输出
2+
# 描述
3+
# 获得用户输入的一个整数,参考该整数值,打印输出"Hello World",要求:‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‮‬
4+
# 如果输入值是0,直接输出"Hello World"‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‮‬
5+
# 如果输入值大于0,以两个字符一行方式输出"Hello World"(空格也是字符)‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‮‬
6+
# 如果输入值小于0,以垂直方式输出"Hello World"
7+
8+
s = int(input())
9+
str = "Hello World"
10+
if s == 0:
11+
print(str)
12+
elif s<0:
13+
for i in str:
14+
print(i)
15+
else:
16+
print("He\nll\no \nWo\nrl\nd")

uooc/examinations/week1/2.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
'''
2+
数值运算
3+
描述
4+
获得用户输入的一个字符串,格式如下:‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‮‬
5+
M OP N‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‮‬
6+
其中,M和N是任何数字,OP代表一种操作,表示为如下四种:+, -, *, /(加减乘除)‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‮‬
7+
根据OP,输出M OP N的运算结果,统一保存小数点后2位。‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‮‬
8+
注意:M和OP、OP和N之间可以存在多个空格,不考虑输入错误情况。
9+
'''
10+
11+
''' 我的答案
12+
s = input()
13+
if "+" in s:
14+
temp = s.split("+")
15+
# first number
16+
fn = float(eval(temp[0].strip()))
17+
# second number
18+
ln = float(eval(temp[1].strip()))
19+
result = fn+ln
20+
elif "*" in s:
21+
temp = s.split("*")
22+
fn = float(eval(temp[0].strip()))
23+
ln = float(eval(temp[1].strip()))
24+
result = fn*ln
25+
elif "/" in s:
26+
temp = s.split("/")
27+
fn = float(eval(temp[0].strip()))
28+
ln = float(eval(temp[1].strip()))
29+
result = fn/ln
30+
elif "-" in s:
31+
temp = s.split("-")
32+
if s[0] != "-":
33+
fn = float(eval(temp[0].strip()))
34+
ln = float(eval(temp[1].strip()))
35+
result = fn-ln
36+
else:
37+
result = -fn-ln
38+
print("{:.2f}".format(result))
39+
'''
40+
41+
#参考答案
42+
s = input()
43+
print("{:.2f}".format(eval(s)))
44+

uooc/exercises/week1/1.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
s = input()
2+
temp = float(s[:-1])
3+
if s[-1].upper() == "C":
4+
result = temp*1.8+32
5+
# print(str(round(result,2))+"F")
6+
print("%.2fF"%float(round(result,2)))
7+
elif s[-1].upper() == "F":
8+
result = (temp-32)/1.8
9+
# print(str(round(result,2))+"C")
10+
print("%.2fC"%float(round(result,2)))
11+
else:
12+
print("输入格式错误")

uooc/exercises/week1/2.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
s = input()
2+
str = "零一二三四五六七八九"
3+
for temp in range(len(s)):
4+
print(str[int(s[temp])],end="")

uooc/exercises/week1/3.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
s = input()
2+
temp = float(s[1:])
3+
if s[0].upper() == "C":
4+
result = temp*1.8+32
5+
# print(str(round(result,2))+"F")
6+
print("F%.2f"%float(round(result,2)))
7+
elif s[0].upper() == "F":
8+
result = (temp-32)/1.8
9+
# print(str(round(result,2))+"C")
10+
print("C%.2f"%float(round(result,2)))

uooc/exercises/week1/4.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# 货币转换 I
2+
# 描述
3+
# 人民币和美元是世界上通用的两种货币之一,写一个程序进行货币间币值转换,其中:‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‮‬
4+
# 人民币和美元间汇率固定为:1美元 = 6.78人民币。‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‮‬
5+
# 程序可以接受人民币或美元输入,转换为美元或人民币输出。人民币采用RMB表示,美元USD表示,符号和数值之间没有空格。‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‮‬
6+
# 注意:‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‮‬
7+
# (1) 这是一个OJ题目,获得输入请使用input() ;‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‮‬
8+
# (2) 不提示输出格式错误,结果小数点后保留两位。
9+
10+
s = input()
11+
money = float(s[3:])
12+
money_type = s[:3]
13+
if money_type == "RMB":
14+
result = money/6.78
15+
print("USD",end="")
16+
elif money_type == "USD":
17+
result = money*6.78
18+
print("RMB",end="")
19+
else:
20+
pass
21+
print("{:.2f}".format(result))

uooc/readme.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Python语言程序设计 (第11期)
2+
>国家精品在线开放课"Python语言程序设计"(中国大学MOOC平台)对应的实践课程,第11次开课。
3+
4+
课程链接:[中国大学MOOC](https://www.icourse163.org/course/BIT-268001) [Python123](https://python123.io/student/courses/1521/intro)
5+
6+
记录平常课后习题和测验的代码:
7+
8+
- `examinations` 目录下为测验题代码
9+
10+
- `exercises` 目录下为练习题代码
11+

0 commit comments

Comments
 (0)