-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem solving
More file actions
173 lines (121 loc) · 3.48 KB
/
Problem solving
File metadata and controls
173 lines (121 loc) · 3.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
---
Problem-solving:-A function type application development type question with multiple functions to implement.
---
---
title: a simple to-do list.
---
# Problem Statement
Implement the following functions:
1.add_task(tasks: dict, task: str): if not prsent already in the list Adds the task to the to-do list(dictionary) unticked(key value is "Not done") else informs "The task your trying to Add is Already present ".
2.remove_task(tasks:dict, task: str): if present in the list Removes a task from the to-do list or else informs "The task your trying Remove is Not present".
3.def tick_task(tasks:dict,task:str):Ticks the task(key value is "Done")
4.def untick_task(tasks:dict,task:str):Unticks the task(key value is "Not done")
5.view_tasks(tasks:dict): Displays all tasks in the to-do list, each on a new line.
**Example**
```
tasks={}
add_task(tasks, "Buy groceries")
add_task(tasks, "Read a book")
add_task(tasks, "Go for a walk")
view_tasks(tasks)
tick_task(tasks,"Buy groceries")
add_task(tasks, "Read a book")
view_tasks(tasks)
remove_task(tasks, "Go for a walk")
remove_task(tasks, "Go for a walk")
view_tasks(tasks)
```
Buy groceries:Not done
Read a book:Not done
Go for a walk:Not done
The task your trying to Add is Already present
Buy groceries:Done
Read a book:Not done
Go for a walk:Not done
The task your trying Remove is Not present
Buy groceries:Done
Read a book:Not done
# Solution
```py3 test.py -r 'python test.py'
<template>
def add_task(tasks:dict,task: str)->None:
if task not in tasks:
tasks[task]="Not done"
else: return "The task your trying to Add is Already present \n"
def remove_task(tasks:dict,task:str)->None:
if task in tasks:
tasks.pop(task)
else:return "The task your trying Remove is Not present \n"
def tick_task(tasks:dict,task:str)->None:
if task in tasks:
tasks.update({task:"Done"})
else:print("Task not present")
def untick_task(tasks:dict,task:str)->None:
if task in tasks:
tasks.update({task:"Not done"})
else:print("Task not present")
def view_tasks(tasks: dict) -> str:
s=""
for task in tasks:
s= s+f"{task}:{tasks[task]}"+"\n"
return s
</template>
<suffix_invisible>
{% include '../function_type_and_modify_check_suffix.py.jinja' %}
</suffix_invisible>
```
# Public Test Cases
## Input 1
```
tasks={}
add_task(tasks, "call 1534")
add_task(tasks, "message 8976")
add_task(tasks, "videocall 7864")
view_tasks(tasks)
tick_task(tasks, "call 1534")
add_task(tasks, "message 8976")
view_tasks(tasks)
remove_task(tasks, "videocall 7864")
remove_task(tasks, "videocall 7864")
view_tasks(tasks)
```
## Output 1
```
call 1534:Not done
message 8976:Not done
videocall 7864:Not done
The task your trying to Add is Already present
call 1534:Done
message 8976:Not done
videocall 7864:Not done
The task your trying Remove is Not present
call 1534:Done
```
# Private Test Cases
## Input 1
```
tasks={}
add_task(tasks, "Python lecture 7.1")
add_task(tasks, "GRPA week 5")
add_task(tasks, "Lve session")
view_tasks(tasks)
tick_task(tasks, "Python lecture 7.1")
add_task(tasks, "GRPA week 5")
view_tasks(tasks)
remove_task(tasks, "Lve session")
remove_task(tasks, "Lve session")
view_tasks(tasks)
```
## Output 1
```
Python lecture 7.1:Not done
GRPA week 5:Not done
Lve session:Not done
The task your trying to Add is Already present
Python lecture 7.1:Done
GRPA week 5:Not done
Lve session:Not done
The task your trying Remove is Not present
Python lecture 7.1:Done
GRPA week 5:Not done
```