diff --git a/exercises/1901100251/1001S02E02_hello_python.py b/exercises/1901100251/1001S02E02_hello_python.py index 75d9766db..9c70d9b1e 100644 --- a/exercises/1901100251/1001S02E02_hello_python.py +++ b/exercises/1901100251/1001S02E02_hello_python.py @@ -1 +1 @@ -print('hello world') +print ("hello world!") \ No newline at end of file diff --git a/exercises/1901100251/1001S02E03_calculator.py b/exercises/1901100251/1001S02E03_calculator.py new file mode 100644 index 000000000..3fcca9b13 --- /dev/null +++ b/exercises/1901100251/1001S02E03_calculator.py @@ -0,0 +1,27 @@ +print('===================自制计算器====================') +a = float(input('请输入第一个数字:')) +b = input('请输入运算符(+,-,*,/):') +c = float(input('请输入第二个数字:')) +add = a + c +#减法 +sub = a - c +#乘法 +times = a * c +#除法 +division = a / c + +print('====================输出结果=====================') +if b == '+': + print('您输入的加法运算结果为: %f'%add) + +elif b == '-': + print('您输入的减法运算结果为: %f'%sub) + +elif b == '*': + print('您输入的乘法运算结果为: %f'%times) + +elif b == '/': + print('您输入的除法运算结果为: %f'%division) +else : + print('您输入的运算符有误!') +print('================================================') diff --git a/exercises/1901100251/1001S02E04_control_flow.py b/exercises/1901100251/1001S02E04_control_flow.py new file mode 100644 index 000000000..636ee11e1 --- /dev/null +++ b/exercises/1901100251/1001S02E04_control_flow.py @@ -0,0 +1,23 @@ +#使⽤for...in循环打印九九乘法表 +for a in range (1,10): + for b in range (1,10): + print (a,"x",b, "=",a*b,"\t", end= "") + if a == b: + print ("") + break + + + + + + +#使用while循环打印九九乘法表并⽤条件判断把偶数行去除掉 +for a in range (1,10): + for b in range (1,10): + while a % 2 == 0: + break + else: + print(a,"x",b,"=",a*b,"\t", end="") + if a == b: + print ("") + break \ No newline at end of file