Skip to content

Commit a6462cc

Browse files
authored
Merge pull request selfteaching#1905 from yangbisheng/master
19100401dsay4
2 parents bf9dd8e + 2ba3fda commit a6462cc

File tree

2 files changed

+30
-15
lines changed

2 files changed

+30
-15
lines changed

19100401/yangbisheng/d3_exercise_calculator.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,3 @@
55
66
@author: yangbisheng
77
"""
8-
def cal():
9-
numA = float(raw_input('Please enter a number: '))
10-
op = raw_input('Please enter a operator: ')
11-
numB = float(raw_input('Please enter another number: '))
12-
if op == '+':
13-
print "result: ",numA+numB
14-
elif op == '-':
15-
print "result: ",numA-numB
16-
elif op == '*':
17-
print "result: ",numA*numB
18-
elif op == '/':
19-
print "result: ",numA/numB
20-
else:
21-
print "Unknown operator ",op
22-
cal()
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
Spyder Editor
4+
5+
This is a temporary script file.
6+
"""
7+
8+
for i in range (1,10):
9+
for j in range(1,10):
10+
print(i,"*",j,"=",i*j,"\t",end="")
11+
if i==j:
12+
print("")
13+
break
14+
15+
i=0
16+
j=0
17+
while i<9:
18+
i+=1
19+
if i%2==0:#i等于偶数不执行后续代码
20+
continue
21+
while j<9:
22+
j+=1
23+
print(i,"*",j,"=",i*j,"\t",end="")
24+
if i==j:
25+
j=0
26+
print("")
27+
break
28+
29+
30+

0 commit comments

Comments
 (0)