Skip to content

Commit 38271ef

Browse files
authored
Merge pull request #2 from simplearyan/add-content
added graded assignment for python course IITM
2 parents 8864090 + b76cfde commit 38271ef

5 files changed

Lines changed: 790 additions & 0 deletions

File tree

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
---
2+
title: GrPA 1 Numbers (Arithemetic)
3+
label: Graded
4+
weight: 1
5+
subject: programming
6+
subtitle: GrPA 1
7+
categories:
8+
- Python Graded Assignment
9+
---
10+
11+
---
12+
13+
## GrPA 1 Numbers (Arithemetic) Graded 👨‍💻
14+
15+
{{< border >}}
16+
17+
{{< tabs items="QUESTION,TEST CASES,SOLUTION" >}}
18+
19+
{{< tab >}}
20+
21+
Change in eligibility criteria to write oppe1 exam:
22+
A1>=40/100 AND A2>=40/100 AND A3>=40/100 AND A4>=40/100
23+
24+
Solve the below tasks related to Numbers.
25+
26+
Tasks 1 to 3 - building up Arithemetic expression
27+
Tasks 4 and 5 - floating point arithemetic
28+
Tasks 6 and 7 - modulo and floor division
29+
Problem Type: Input variable - Output Variable, Hidden suffix for evaluation
30+
31+
{{% details title="Instructions" closed="true" %}}
32+
33+
NOTE: In this type of questions you should not take input or print anything unless your are explicitly asked to. Assign the result of the required computation to the correct variable name as it will be evaluated for type and value by the evaluator.
34+
35+
The input variables will be assigned by the evaluator based on the test cases.
36+
37+
The grey part before the white part (if any) in the code is the prefix code. The grey part after the white part (if any) is the suffix code which are not editable. Usually they will be the part of code but in this type of questions it will be removed by the evaluator.
38+
39+
The Three dots (...) called as Ellipsis in python are like placeholders, replace them with your answer.
40+
41+
The inputs on the code blocks are just sample inputs they won't be evaluated in the actual testcases.
42+
43+
Each testcase will have its own set of testcases defined as variables. The check function in the testcases is in the hidden evaluation code that checks the value and type of the variable.
44+
45+
{{% /details %}}
46+
47+
{{% details title="Template Code" closed="true" %}}
48+
49+
```python
50+
output1 = ... # int: sum of a and b
51+
output2 = ... # int: twice the sum of a and b
52+
output3 = ... # int: absolute difference between a and b
53+
output4 = ... # int: absolute difference between sum and product of a and b
54+
55+
# Find discounted price given price and discount_percent
56+
# input variables : price: int, discount_percent: float
57+
discounted_price = ... # float
58+
59+
# Round the discounted_price
60+
rounded_discounted_price = ... # int
61+
62+
# Find hrs and mins given the total_mins
63+
# input variables : total_mins
64+
hrs = ... # int: hint: think about floor division operator
65+
mins = ... # int
66+
```
67+
68+
{{% /details %}}
69+
70+
Python Tutor
71+
72+
Starboard Notebook
73+
74+
Pyodide Terminal
75+
76+
{{< /tab >}}
77+
78+
{{< tab >}}
79+
80+
{{< tabs items="CASE 1,CASE 2,CASE 3,CASE 4,CASE 5,CASE 6,CASE 7" >}}
81+
82+
{{< tab >}}
83+
84+
###### Input
85+
86+
a=5
87+
b=7
88+
check('output1',12)
89+
{{< /tab >}}
90+
91+
{{< tab >}}
92+
a,b = 2,-5
93+
check("output2", -6)
94+
95+
{{< /tab >}}
96+
97+
{{< tab >}}
98+
a,b = 6,4
99+
check('output3', 2)
100+
a,b = 4,7
101+
check('output3', 3)
102+
103+
{{< /tab >}}
104+
105+
{{< tab >}}
106+
a,b = 4,7
107+
check('output4',17)
108+
109+
{{< /tab >}}
110+
111+
{{< tab >}}
112+
a=5
113+
b=7
114+
check('output1',12)
115+
{{< /tab >}}
116+
117+
{{< tab >}}
118+
a=5
119+
b=7
120+
check('output1',12)
121+
{{< /tab >}}
122+
123+
{{< tab >}}
124+
a=5
125+
b=7
126+
check('output1',12)
127+
{{< /tab >}}
128+
129+
{{< /tabs >}}
130+
131+
{{< /tab >}}
132+
133+
{{< tab >}}
134+
135+
```python {linenos=table,linenostart=1}
136+
# Sample inputs (# note: The values given in the prefix code(grey) will be changed by the autograder according to the testcase while running them.
137+
a = 5
138+
b = 6
139+
price, discount_percent = 80, 5.75
140+
total_mins = 470
141+
# <eoi>
142+
143+
output1 = a+b # int: sum of a and b
144+
output2 = 2*(a+b) # int: twice the sum of a and b
145+
output3 = abs(a-b) # int: absolute difference between a and b
146+
output4 = abs((a+b) - (a*b)) # int: absolute difference between sum and product of a and b
147+
148+
# Find discounted price given price and discount_percent
149+
# input variables : price: int, discount_percent: float
150+
discounted_price = (1-discount_percent/100)*price # float
151+
152+
# Round the discounted_price
153+
rounded_discounted_price = round(discounted_price) # int
154+
155+
# Find hrs and mins given the total_mins
156+
# input variables : total_mins
157+
hrs = total_mins//60 # int: hint: think about floor division operator
158+
mins = total_mins%60 # int
159+
160+
```
161+
162+
{{< /tab >}}
163+
164+
{{< /tabs >}}
165+
166+
{{</ border >}}
167+
168+
{{< border >}}
169+
170+
### Python Code 🧠
171+
172+
{{< tabs items="CODE" >}}
173+
174+
{{< tab >}}
175+
176+
```python {linenos=table,linenostart=1}
177+
# Sample inputs (# note: The values given in the prefix code(grey) will be changed by the autograder according to the testcase while running them.
178+
a = 5
179+
b = 6
180+
price, discount_percent = 80, 5.75
181+
total_mins = 470
182+
# <eoi>
183+
184+
output1 = a + b # int: sum of a and b
185+
output2 = 2 * (a + b) # int: twice the sum of a and b
186+
output3 = abs(a - b) # int: absolute difference between a and b
187+
output4 = abs((a + b) - (a * b)) # int: absolute difference between sum and product of a and b
188+
189+
# Find discounted price given price and discount_percent
190+
# input variables : price: int, discount_percent: float
191+
discounted_price = price * (1 - discount_percent / 100) # float
192+
193+
# Round the discounted_price
194+
rounded_discounted_price = round(discounted_price) # int
195+
196+
# Find hrs and mins given the total_mins
197+
# input variables : total_mins
198+
hrs = total_mins // 60 # int: hint: think about floor division operator
199+
mins = total_mins % 60 # int
200+
```
201+
202+
{{< /tab >}}
203+
204+
{{< /tabs >}}
205+
206+
{{</ border >}}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
draft: false
3+
description: Solution for IIT Madras Course Python Garaded Assignments
4+
cascade:
5+
title: Python
6+
subtitle: Graded Assignment
7+
label: Python
8+
subject: Python
9+
avatar: "/images/svg/python-svgrepo-com-2.svg"
10+
keywords: ["Python for Data Science 1", "Python", "Graded Assignment","IIT Madras"]
11+
---

0 commit comments

Comments
 (0)