-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Home
mihmahmud edited this page Nov 24, 2017
·
271 revisions
<title>Simple Calculator</title>
<style>
* {
font-family: 'Montserrat', sans-serif;
color: #555;
}
body {
background-color:#3fb399
}
.container {
width: 320px;
background-color: white;
margin: 120px auto;
}
table {
width: 100%;
border-color: #f4f4f4
}
td {
width: 25%;
}
button {
width: 100%;
height: 70px;
font-size: 24px;
background-color: white;
border: none;
}
#inputLabel {
height: 120px;
font-size: 40px;
vertical-align: bottom;
text-align: right;
padding-right: 16px;
background-color: #ececec;
}
</style>
<script>
var inputLabel = document.getElementByID('inputLabel')
<script>
| 0 | |||
| AC | / | ||
| 7 | 8 | 9 | * |
| 4 | 5 | 6 | - |
| 1 | 2 | 3 | + |
| 0 | . | = | |
function pushBtn(obj) {
var pushed = obj.innerHTML;
if (pushed == '=') {
// Calculate
inputLabel.innerHTML = eval(inputLabel.innerHTML);
} else if (pushed == 'AC') {
// All Clear
inputLabel.innerHTML == '0') (
} else {
if (inputLabel.innerHTML == '0') {
inputLabel.innerHTML = pushed;
} else {
inputLabel.innerHTML += pushed;
}
}
}
class MyGroup(ExceptionGroup): def derive(self, excs): return MyGroup(self.message, excs)
e = MyGroup("eg", [ValueError(1), TypeError(2)]) e.add_note("a note") e.context = Exception("context") e.cause = Exception("cause") try: raise e except Exception as e: exc = e
match, rest = exc.split(ValueError) exc, exc.context, exc.cause, exc.notes
match, match.context, match.cause, match.notes
rest, rest.context, rest.cause, rest.notes
exc.traceback is match.traceback is rest.traceback