fpythons 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. fpythons/__init__.py +12 -0
  2. fpythons/__main__.py +4 -0
  3. fpythons/data/00_START_HERE.md +144 -0
  4. fpythons/data/ALL_SLIPS_CODE.txt +1854 -0
  5. fpythons/data/README.md +35 -0
  6. fpythons/data/Slip_01.md +160 -0
  7. fpythons/data/Slip_02.md +104 -0
  8. fpythons/data/Slip_03.md +95 -0
  9. fpythons/data/Slip_04.md +131 -0
  10. fpythons/data/Slip_05.md +120 -0
  11. fpythons/data/Slip_06.md +161 -0
  12. fpythons/data/Slip_07.md +121 -0
  13. fpythons/data/Slip_08.md +95 -0
  14. fpythons/data/Slip_09.md +92 -0
  15. fpythons/data/Slip_10.md +113 -0
  16. fpythons/data/Slip_11.md +109 -0
  17. fpythons/data/Slip_12.md +181 -0
  18. fpythons/data/Slip_13.md +163 -0
  19. fpythons/data/Slip_14.md +141 -0
  20. fpythons/data/Slip_15.md +100 -0
  21. fpythons/data/Slip_16.md +127 -0
  22. fpythons/data/Slip_17.md +93 -0
  23. fpythons/data/Slip_18.md +96 -0
  24. fpythons/data/Slip_19.md +94 -0
  25. fpythons/data/Slip_20.md +165 -0
  26. fpythons/data/Slip_21.md +122 -0
  27. fpythons/data/VIVA.md +195 -0
  28. fpythons/data/code/slip1/.gitignore +2 -0
  29. fpythons/data/code/slip1/package.json +31 -0
  30. fpythons/data/code/slip1/public/index.html +12 -0
  31. fpythons/data/code/slip1/src/App.js +7 -0
  32. fpythons/data/code/slip1/src/index.js +10 -0
  33. fpythons/data/code/slip1/src/slip1/loginForm.js +26 -0
  34. fpythons/data/code/slip1/src/slip1/style.css +46 -0
  35. fpythons/data/code/slip10/.gitignore +2 -0
  36. fpythons/data/code/slip10/package.json +31 -0
  37. fpythons/data/code/slip10/public/index.html +12 -0
  38. fpythons/data/code/slip10/src/App.js +7 -0
  39. fpythons/data/code/slip10/src/index.js +10 -0
  40. fpythons/data/code/slip10/src/slip10/SumOfDigits.js +37 -0
  41. fpythons/data/code/slip11/.gitignore +2 -0
  42. fpythons/data/code/slip11/package.json +31 -0
  43. fpythons/data/code/slip11/public/index.html +12 -0
  44. fpythons/data/code/slip11/src/App.js +7 -0
  45. fpythons/data/code/slip11/src/index.js +10 -0
  46. fpythons/data/code/slip11/src/slip11/StringOperation.js +33 -0
  47. fpythons/data/code/slip12/.gitignore +2 -0
  48. fpythons/data/code/slip12/package.json +33 -0
  49. fpythons/data/code/slip12/public/index.html +12 -0
  50. fpythons/data/code/slip12/src/App.js +7 -0
  51. fpythons/data/code/slip12/src/index.js +14 -0
  52. fpythons/data/code/slip12/src/slip12/NotesManagementApp.js +35 -0
  53. fpythons/data/code/slip12/src/slip12/redux/notesSlice.js +20 -0
  54. fpythons/data/code/slip12/src/slip12/redux/store.js +10 -0
  55. fpythons/data/code/slip13/.gitignore +2 -0
  56. fpythons/data/code/slip13/package.json +33 -0
  57. fpythons/data/code/slip13/public/index.html +12 -0
  58. fpythons/data/code/slip13/src/App.js +7 -0
  59. fpythons/data/code/slip13/src/index.js +14 -0
  60. fpythons/data/code/slip13/src/slip13/Counter.js +20 -0
  61. fpythons/data/code/slip13/src/slip13/redux/counterSlice.js +19 -0
  62. fpythons/data/code/slip13/src/slip13/redux/store.js +10 -0
  63. fpythons/data/code/slip14/.gitignore +2 -0
  64. fpythons/data/code/slip14/package.json +31 -0
  65. fpythons/data/code/slip14/public/index.html +12 -0
  66. fpythons/data/code/slip14/src/App.js +7 -0
  67. fpythons/data/code/slip14/src/index.js +10 -0
  68. fpythons/data/code/slip14/src/slip14/Calculator.js +64 -0
  69. fpythons/data/code/slip15/.gitignore +2 -0
  70. fpythons/data/code/slip15/package.json +31 -0
  71. fpythons/data/code/slip15/public/index.html +12 -0
  72. fpythons/data/code/slip15/src/App.js +7 -0
  73. fpythons/data/code/slip15/src/index.js +10 -0
  74. fpythons/data/code/slip15/src/slip15/Counter.js +24 -0
  75. fpythons/data/code/slip16/.gitignore +2 -0
  76. fpythons/data/code/slip16/package.json +31 -0
  77. fpythons/data/code/slip16/public/index.html +12 -0
  78. fpythons/data/code/slip16/src/App.js +7 -0
  79. fpythons/data/code/slip16/src/index.js +10 -0
  80. fpythons/data/code/slip16/src/slip16/TraditionalDOM.html +24 -0
  81. fpythons/data/code/slip16/src/slip16/VirtualDOM.js +16 -0
  82. fpythons/data/code/slip17/.gitignore +2 -0
  83. fpythons/data/code/slip17/package.json +31 -0
  84. fpythons/data/code/slip17/public/index.html +12 -0
  85. fpythons/data/code/slip17/src/App.js +7 -0
  86. fpythons/data/code/slip17/src/index.js +10 -0
  87. fpythons/data/code/slip17/src/slip17/Sign-in.js +17 -0
  88. fpythons/data/code/slip18/.gitignore +2 -0
  89. fpythons/data/code/slip18/package.json +31 -0
  90. fpythons/data/code/slip18/public/index.html +12 -0
  91. fpythons/data/code/slip18/public/logo192.png +0 -0
  92. fpythons/data/code/slip18/src/App.js +7 -0
  93. fpythons/data/code/slip18/src/index.js +10 -0
  94. fpythons/data/code/slip18/src/slip18/Profile.js +20 -0
  95. fpythons/data/code/slip19/.gitignore +2 -0
  96. fpythons/data/code/slip19/package.json +31 -0
  97. fpythons/data/code/slip19/public/index.html +12 -0
  98. fpythons/data/code/slip19/src/App.js +7 -0
  99. fpythons/data/code/slip19/src/index.js +10 -0
  100. fpythons/data/code/slip19/src/slip19/Movies.js +19 -0
  101. fpythons/data/code/slip2/.gitignore +2 -0
  102. fpythons/data/code/slip2/package.json +31 -0
  103. fpythons/data/code/slip2/public/index.html +12 -0
  104. fpythons/data/code/slip2/src/App.js +7 -0
  105. fpythons/data/code/slip2/src/index.js +10 -0
  106. fpythons/data/code/slip2/src/slip2/useEffect.js +23 -0
  107. fpythons/data/code/slip20/.gitignore +2 -0
  108. fpythons/data/code/slip20/package.json +32 -0
  109. fpythons/data/code/slip20/public/index.html +12 -0
  110. fpythons/data/code/slip20/src/App.js +16 -0
  111. fpythons/data/code/slip20/src/index.js +10 -0
  112. fpythons/data/code/slip20/src/slip20/Login.js +45 -0
  113. fpythons/data/code/slip20/src/slip20/Students.js +27 -0
  114. fpythons/data/code/slip21/.gitignore +2 -0
  115. fpythons/data/code/slip21/package.json +31 -0
  116. fpythons/data/code/slip21/public/index.html +12 -0
  117. fpythons/data/code/slip21/src/App.js +7 -0
  118. fpythons/data/code/slip21/src/index.js +10 -0
  119. fpythons/data/code/slip21/src/slip21/NumberString.js +46 -0
  120. fpythons/data/code/slip3/.gitignore +2 -0
  121. fpythons/data/code/slip3/package.json +31 -0
  122. fpythons/data/code/slip3/public/index.html +12 -0
  123. fpythons/data/code/slip3/src/App.js +7 -0
  124. fpythons/data/code/slip3/src/index.js +10 -0
  125. fpythons/data/code/slip3/src/slip3/toggleBtn.js +16 -0
  126. fpythons/data/code/slip4/.gitignore +2 -0
  127. fpythons/data/code/slip4/package.json +32 -0
  128. fpythons/data/code/slip4/public/index.html +12 -0
  129. fpythons/data/code/slip4/src/App.js +23 -0
  130. fpythons/data/code/slip4/src/index.js +10 -0
  131. fpythons/data/code/slip4/src/slip4/About.js +7 -0
  132. fpythons/data/code/slip4/src/slip4/Contact.js +7 -0
  133. fpythons/data/code/slip4/src/slip4/home.js +7 -0
  134. fpythons/data/code/slip5/.gitignore +2 -0
  135. fpythons/data/code/slip5/package.json +32 -0
  136. fpythons/data/code/slip5/public/index.html +12 -0
  137. fpythons/data/code/slip5/src/App.js +18 -0
  138. fpythons/data/code/slip5/src/index.js +10 -0
  139. fpythons/data/code/slip5/src/slip5/loginValidation.js +30 -0
  140. fpythons/data/code/slip6/.gitignore +2 -0
  141. fpythons/data/code/slip6/package.json +32 -0
  142. fpythons/data/code/slip6/public/index.html +12 -0
  143. fpythons/data/code/slip6/src/App.js +31 -0
  144. fpythons/data/code/slip6/src/index.js +10 -0
  145. fpythons/data/code/slip6/src/slip6/Dashboard.js +12 -0
  146. fpythons/data/code/slip6/src/slip6/Login.js +23 -0
  147. fpythons/data/code/slip6/src/slip6/ProtectedRoute.js +10 -0
  148. fpythons/data/code/slip7/.gitignore +2 -0
  149. fpythons/data/code/slip7/package.json +31 -0
  150. fpythons/data/code/slip7/public/index.html +12 -0
  151. fpythons/data/code/slip7/src/App.js +7 -0
  152. fpythons/data/code/slip7/src/index.js +10 -0
  153. fpythons/data/code/slip7/src/slip7/TodoList.js +42 -0
  154. fpythons/data/code/slip8/.gitignore +2 -0
  155. fpythons/data/code/slip8/package.json +31 -0
  156. fpythons/data/code/slip8/public/index.html +12 -0
  157. fpythons/data/code/slip8/src/App.js +7 -0
  158. fpythons/data/code/slip8/src/index.js +10 -0
  159. fpythons/data/code/slip8/src/slip8/ToggleButton.js +19 -0
  160. fpythons/data/code/slip9/.gitignore +2 -0
  161. fpythons/data/code/slip9/package.json +31 -0
  162. fpythons/data/code/slip9/public/index.html +12 -0
  163. fpythons/data/code/slip9/src/App.js +7 -0
  164. fpythons/data/code/slip9/src/index.js +10 -0
  165. fpythons/data/code/slip9/src/slip9/Counter.js +16 -0
  166. fpythons/main.py +226 -0
  167. fpythons-0.1.0.dist-info/METADATA +64 -0
  168. fpythons-0.1.0.dist-info/RECORD +170 -0
  169. fpythons-0.1.0.dist-info/WHEEL +4 -0
  170. fpythons-0.1.0.dist-info/entry_points.txt +2 -0
fpythons/data/VIVA.md ADDED
@@ -0,0 +1,195 @@
1
+ # Viva questions (all slips)
2
+
3
+ [All slips](README.md)
4
+
5
+ ## From Slip 1: Login form with event handlers
6
+
7
+ **Q. What is a controlled component?**
8
+ An input whose value comes from React state and changes through an event handler.
9
+
10
+ **Q. Why is `preventDefault()` used?**
11
+ It stops the browser's default action, here reloading the page on form submit.
12
+
13
+ **Q. Difference between `onChange` and `onInput` in React?**
14
+ In React both fire on every change of the input. `onChange` is the one normally used.
15
+
16
+ ## From Slip 2: useEffect and fetching a users list
17
+
18
+ **Q. What is `useEffect` used for?**
19
+ Side effects such as API calls, timers and subscriptions.
20
+
21
+ **Q. What does an empty dependency array mean?**
22
+ Run the effect only after the first render (mount).
23
+
24
+ **Q. What does `fetch` return?**
25
+ A Promise that resolves to a Response object.
26
+
27
+ ## From Slip 3: Toggle ON/OFF with background colour
28
+
29
+ **Q. What is state?**
30
+ Data kept inside a component. Changing it re-renders the component.
31
+
32
+ **Q. Why two curly braces in `style={{ }}`?**
33
+ The outer pair means JavaScript inside JSX, the inner pair is the style object.
34
+
35
+ **Q. What is a hook?**
36
+ A function such as `useState` that gives React features to functional components.
37
+
38
+ ## From Slip 4: Multi-page app with react-router-dom
39
+
40
+ **Q. What is a Single Page Application?**
41
+ One HTML page whose content changes with JavaScript, without full reloads.
42
+
43
+ **Q. Difference between `Link` and `<a>`?**
44
+ `<a>` reloads the page. `Link` changes only the route.
45
+
46
+ **Q. What does `path="*"` do?**
47
+ It matches every address that no other route matches.
48
+
49
+ ## From Slip 5: Login validation and 404 route
50
+
51
+ **Q. Difference between `==` and `===`?**
52
+ `===` compares value and type. `==` converts types first.
53
+
54
+ **Q. Is this real authentication?**
55
+ No. The values are fixed in the browser code. Real apps check them on a server.
56
+
57
+ ## From Slip 6: Protected route with mock authentication
58
+
59
+ **Q. What is a protected route?**
60
+ A route shown only when a condition, such as being logged in, is true.
61
+
62
+ **Q. What is `children`?**
63
+ The elements placed between a component's opening and closing tags.
64
+
65
+ **Q. Difference between `Navigate` and `useNavigate`?**
66
+ `Navigate` is a component used while rendering. `useNavigate` returns a function used in event handlers.
67
+
68
+ ## From Slip 7: To-do list
69
+
70
+ **Q. Why not change state directly?**
71
+ React re-renders only when the setter receives a new value.
72
+
73
+ **Q. What is the spread operator?**
74
+ `...` copies the items of an array or object.
75
+
76
+ **Q. Why is a `key` needed?**
77
+ It helps React match list items between renders. A unique id is better than the index when items can be deleted.
78
+
79
+ ## From Slip 8: Toggle button ON/OFF
80
+
81
+ **Q. What is JSX?**
82
+ HTML-like syntax inside JavaScript that React turns into elements.
83
+
84
+ **Q. What is conditional rendering?**
85
+ Showing different output depending on a condition.
86
+
87
+ ## From Slip 9: Counter with initial value as a prop
88
+
89
+ **Q. What are props?**
90
+ Read-only values passed from a parent to a child component.
91
+
92
+ **Q. Difference between props and state?**
93
+ Props come from the parent and cannot be changed by the child. State belongs to the component and can change.
94
+
95
+ ## From Slip 10: Validate a number and sum its digits
96
+
97
+ **Q. What does `/^\d+$/` mean?**
98
+ From start to end, one or more digits.
99
+
100
+ **Q. What does `trim()` do?**
101
+ Removes spaces at both ends of a string.
102
+
103
+ ## From Slip 11: String operations
104
+
105
+ **Q. Are strings mutable in JavaScript?**
106
+ No. String methods return a new string.
107
+
108
+ **Q. Difference between `split` and `join`?**
109
+ `split` turns a string into an array, `join` turns an array into a string.
110
+
111
+ ## From Slip 12: Notes app with Redux Toolkit
112
+
113
+ **Q. What is Redux?**
114
+ A library that keeps application state in one central store.
115
+
116
+ **Q. What does `createSlice` do?**
117
+ Creates the reducer and action creators for one part of the state.
118
+
119
+ **Q. What is `action.payload`?**
120
+ The data sent with an action.
121
+
122
+ ## From Slip 13: Counter with a Redux store
123
+
124
+ **Q. What are the main parts of Redux?**
125
+ Store, actions, reducers and dispatch.
126
+
127
+ **Q. What is a reducer?**
128
+ A function that takes the current state and an action and gives the next state.
129
+
130
+ **Q. Difference between `useSelector` and `useDispatch`?**
131
+ One reads from the store, the other sends actions to it.
132
+
133
+ ## From Slip 14: Calculator
134
+
135
+ **Q. Why is the input value a string?**
136
+ HTML inputs always give text.
137
+
138
+ **Q. What is `NaN`?**
139
+ "Not a Number", the result of an invalid numeric operation.
140
+
141
+ ## From Slip 15: Counter using useReducer
142
+
143
+ **Q. When is `useReducer` better than `useState`?**
144
+ When the state has several related update rules.
145
+
146
+ **Q. Why must a reducer be pure?**
147
+ The same input must give the same output with no side effects.
148
+
149
+ ## From Slip 16: Virtual DOM and traditional DOM
150
+
151
+ **Q. What is the virtual DOM?**
152
+ A lightweight copy of the page structure kept in memory by React.
153
+
154
+ **Q. What is reconciliation?**
155
+ Comparing the new virtual tree with the old one to find the changes.
156
+
157
+ ## From Slip 17: Sign in and sign out
158
+
159
+ **Q. How does `&&` rendering work?**
160
+ The right side is shown only when the left side is true.
161
+
162
+ **Q. What does `useState` return?**
163
+ The current value and a function to change it.
164
+
165
+ ## From Slip 18: Profile page
166
+
167
+ **Q. What is the `public` folder?**
168
+ Files in it are served as they are, from the site root.
169
+
170
+ **Q. What is `alt` for?**
171
+ Text shown or read aloud when the image cannot be seen.
172
+
173
+ ## From Slip 19: List of 10 favourite movies
174
+
175
+ **Q. What is a functional component?**
176
+ A JavaScript function that returns JSX.
177
+
178
+ **Q. Why use `map` instead of `forEach`?**
179
+ `map` returns a new array that JSX can show.
180
+
181
+ ## From Slip 20: Login with route parameters
182
+
183
+ **Q. What is a route parameter?**
184
+ A changing part of the address, written as `:name` in the route.
185
+
186
+ **Q. What does `useParams` return?**
187
+ An object with the parameters of the current route.
188
+
189
+ ## From Slip 21: Even/odd and palindrome
190
+
191
+ **Q. What is a palindrome?**
192
+ Text that reads the same forwards and backwards.
193
+
194
+ **Q. What does the `%` operator give?**
195
+ The remainder of a division.
@@ -0,0 +1,2 @@
1
+ node_modules/
2
+ build/
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "slip1",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "dependencies": {
6
+ "react": "^19.3.1",
7
+ "react-dom": "^19.3.1",
8
+ "react-scripts": "5.0.1"
9
+ },
10
+ "scripts": {
11
+ "start": "react-scripts start",
12
+ "build": "react-scripts build"
13
+ },
14
+ "eslintConfig": {
15
+ "extends": [
16
+ "react-app"
17
+ ]
18
+ },
19
+ "browserslist": {
20
+ "production": [
21
+ ">0.2%",
22
+ "not dead",
23
+ "not op_mini all"
24
+ ],
25
+ "development": [
26
+ "last 1 chrome version",
27
+ "last 1 firefox version",
28
+ "last 1 safari version"
29
+ ]
30
+ }
31
+ }
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>Slip 1</title>
7
+ </head>
8
+ <body>
9
+ <noscript>You need to enable JavaScript to run this app.</noscript>
10
+ <div id="root"></div>
11
+ </body>
12
+ </html>
@@ -0,0 +1,7 @@
1
+ import LoginForm from './slip1/loginForm';
2
+
3
+ function App() {
4
+ return <LoginForm />;
5
+ }
6
+
7
+ export default App;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import ReactDOM from 'react-dom/client';
3
+ import App from './App';
4
+
5
+ const root = ReactDOM.createRoot(document.getElementById('root'));
6
+ root.render(
7
+ <React.StrictMode>
8
+ <App />
9
+ </React.StrictMode>
10
+ );
@@ -0,0 +1,26 @@
1
+ import React, { useState } from 'react'
2
+ import './style.css';
3
+
4
+ const LoginForm = () => {
5
+
6
+ const [username, setUsername] = useState("");
7
+ const [password, setPassword] = useState("");
8
+
9
+ function handleSubmit(e){
10
+ e.preventDefault();
11
+ console.log("Username:", username);
12
+ console.log("Password:", password);
13
+ };
14
+ return (
15
+ <div className="login-container">
16
+ <h2 className="heading">Login Form</h2>
17
+ <form onSubmit={handleSubmit} className="login-form">
18
+ <label>Username<input type='text' placeholder='Enter username' value={username} onInput={(e) => console.log(e.target.value)} onChange={(e) => setUsername(e.target.value)}></input></label><br></br>
19
+ <label>Password<input type='password' placeholder='Enter password' value={password} onInput={(e) => console.log(e.target.value)} onChange={(e) => setPassword(e.target.value)}></input></label><br></br>
20
+ <input type='submit' value="Login"></input>
21
+ </form>
22
+ </div>
23
+ )
24
+ }
25
+
26
+ export default LoginForm
@@ -0,0 +1,46 @@
1
+ body{
2
+ margin: 0;
3
+ padding: 0;
4
+ }
5
+
6
+ .login-container{
7
+ display: flex;
8
+ justify-content: center;
9
+ align-items: center;
10
+ flex-direction: column;
11
+ height: 100vh;
12
+ background-color: rgba(0, 255, 255, 0.263);
13
+ }
14
+
15
+ .heading{
16
+ font-size: 2rem;
17
+ text-align: center;
18
+ }
19
+
20
+ .login-form{
21
+ display: flex;
22
+ flex-direction: column;
23
+ border: 2px solid #ccc;
24
+ border-radius: 8px;
25
+ width: 300px;
26
+ height: 150px;
27
+ padding: 10px;
28
+ gap: 5px;
29
+ }
30
+
31
+ .login-form input {
32
+ padding: 6px;
33
+ border: 1px solid #ccc;
34
+ border-radius: 5px;
35
+ font-size: 14px;
36
+ }
37
+
38
+ .login-form input[type="submit"] {
39
+ background-color: #2563eb;
40
+ color: white;
41
+ border: none;
42
+ padding: 6px;
43
+ border-radius: 5px;
44
+ font-size: 16px;
45
+ cursor: pointer;
46
+ }
@@ -0,0 +1,2 @@
1
+ node_modules/
2
+ build/
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "slip10",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "dependencies": {
6
+ "react": "^19.3.1",
7
+ "react-dom": "^19.3.1",
8
+ "react-scripts": "5.0.1"
9
+ },
10
+ "scripts": {
11
+ "start": "react-scripts start",
12
+ "build": "react-scripts build"
13
+ },
14
+ "eslintConfig": {
15
+ "extends": [
16
+ "react-app"
17
+ ]
18
+ },
19
+ "browserslist": {
20
+ "production": [
21
+ ">0.2%",
22
+ "not dead",
23
+ "not op_mini all"
24
+ ],
25
+ "development": [
26
+ "last 1 chrome version",
27
+ "last 1 firefox version",
28
+ "last 1 safari version"
29
+ ]
30
+ }
31
+ }
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>Slip 10</title>
7
+ </head>
8
+ <body>
9
+ <noscript>You need to enable JavaScript to run this app.</noscript>
10
+ <div id="root"></div>
11
+ </body>
12
+ </html>
@@ -0,0 +1,7 @@
1
+ import SumOfDigits from './slip10/SumOfDigits';
2
+
3
+ function App() {
4
+ return <SumOfDigits />;
5
+ }
6
+
7
+ export default App;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import ReactDOM from 'react-dom/client';
3
+ import App from './App';
4
+
5
+ const root = ReactDOM.createRoot(document.getElementById('root'));
6
+ root.render(
7
+ <React.StrictMode>
8
+ <App />
9
+ </React.StrictMode>
10
+ );
@@ -0,0 +1,37 @@
1
+ import React, { useState } from 'react'
2
+
3
+ const SumOfDigits = () => {
4
+
5
+ const [number, setNumber] = useState('');
6
+ const [result, setResult] = useState('');
7
+
8
+ const handleSubmit = (e) =>{
9
+ e.preventDefault();
10
+ if(number.trim() === ''){
11
+ alert("Please enter a number");
12
+ return;
13
+ }
14
+ if(!/^\d+$/.test(number)){
15
+ alert("Invalid input! Enter only digits");
16
+ return;
17
+ }
18
+ let sum = 0;
19
+ for(let digit of number){
20
+ sum += Number(digit);
21
+ }
22
+ setResult(sum);
23
+ }
24
+
25
+ return (
26
+ <div>
27
+ <h2>Sum Of Digits</h2>
28
+ <form>
29
+ <label>Enter number:<input type='text' value={number} onChange={(e) => setNumber(e.target.value)}></input></label>
30
+ <button type='submit' onClick={handleSubmit}>Calculate Sum</button><br></br>
31
+ <p>Sum of Digits: {result}</p>
32
+ </form>
33
+ </div>
34
+ )
35
+ }
36
+
37
+ export default SumOfDigits
@@ -0,0 +1,2 @@
1
+ node_modules/
2
+ build/
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "slip11",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "dependencies": {
6
+ "react": "^19.3.1",
7
+ "react-dom": "^19.3.1",
8
+ "react-scripts": "5.0.1"
9
+ },
10
+ "scripts": {
11
+ "start": "react-scripts start",
12
+ "build": "react-scripts build"
13
+ },
14
+ "eslintConfig": {
15
+ "extends": [
16
+ "react-app"
17
+ ]
18
+ },
19
+ "browserslist": {
20
+ "production": [
21
+ ">0.2%",
22
+ "not dead",
23
+ "not op_mini all"
24
+ ],
25
+ "development": [
26
+ "last 1 chrome version",
27
+ "last 1 firefox version",
28
+ "last 1 safari version"
29
+ ]
30
+ }
31
+ }
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>Slip 11</title>
7
+ </head>
8
+ <body>
9
+ <noscript>You need to enable JavaScript to run this app.</noscript>
10
+ <div id="root"></div>
11
+ </body>
12
+ </html>
@@ -0,0 +1,7 @@
1
+ import StringOperation from './slip11/StringOperation';
2
+
3
+ function App() {
4
+ return <StringOperation />;
5
+ }
6
+
7
+ export default App;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import ReactDOM from 'react-dom/client';
3
+ import App from './App';
4
+
5
+ const root = ReactDOM.createRoot(document.getElementById('root'));
6
+ root.render(
7
+ <React.StrictMode>
8
+ <App />
9
+ </React.StrictMode>
10
+ );
@@ -0,0 +1,33 @@
1
+ import React, { useState } from 'react'
2
+
3
+ const StringOperation = () => {
4
+
5
+ const [str, setStr] = useState('');
6
+ const [result, setResult] = useState('');
7
+
8
+ const handleSubmit = (e) => {
9
+ e.preventDefault();
10
+ if(str.trim() === ''){
11
+ alert("Enter a string");
12
+ return;
13
+ }
14
+
15
+ setResult(str);
16
+
17
+ }
18
+ return (
19
+ <div>
20
+ <h2>String Operations</h2>
21
+ <form onSubmit={handleSubmit}>
22
+ <label>Enter string<input type='text' value={str} onChange={(e) => setStr(e.target.value)}></input></label>
23
+ <button type='submit'>Submit</button>
24
+ <p>String in UpperCase: {result.toUpperCase()}</p>
25
+ <p>String in LowerCae: {result.toLowerCase()}</p>
26
+ <p>Length of the string: {result.length}</p>
27
+ <p>Reverse string : {result.split('').reverse().join('')}</p>
28
+ </form>
29
+ </div>
30
+ )
31
+ }
32
+
33
+ export default StringOperation
@@ -0,0 +1,2 @@
1
+ node_modules/
2
+ build/
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "slip12",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "dependencies": {
6
+ "@reduxjs/toolkit": "^2.15.0",
7
+ "react": "^19.3.1",
8
+ "react-dom": "^19.3.1",
9
+ "react-redux": "^9.3.1",
10
+ "react-scripts": "5.0.1"
11
+ },
12
+ "scripts": {
13
+ "start": "react-scripts start",
14
+ "build": "react-scripts build"
15
+ },
16
+ "eslintConfig": {
17
+ "extends": [
18
+ "react-app"
19
+ ]
20
+ },
21
+ "browserslist": {
22
+ "production": [
23
+ ">0.2%",
24
+ "not dead",
25
+ "not op_mini all"
26
+ ],
27
+ "development": [
28
+ "last 1 chrome version",
29
+ "last 1 firefox version",
30
+ "last 1 safari version"
31
+ ]
32
+ }
33
+ }
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>Slip 12</title>
7
+ </head>
8
+ <body>
9
+ <noscript>You need to enable JavaScript to run this app.</noscript>
10
+ <div id="root"></div>
11
+ </body>
12
+ </html>
@@ -0,0 +1,7 @@
1
+ import NotesManagementApp from './slip12/NotesManagementApp';
2
+
3
+ function App() {
4
+ return <NotesManagementApp />;
5
+ }
6
+
7
+ export default App;
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import ReactDOM from 'react-dom/client';
3
+ import { Provider } from 'react-redux';
4
+ import App from './App';
5
+ import store from './slip12/redux/store';
6
+
7
+ const root = ReactDOM.createRoot(document.getElementById('root'));
8
+ root.render(
9
+ <React.StrictMode>
10
+ <Provider store={store}>
11
+ <App />
12
+ </Provider>
13
+ </React.StrictMode>
14
+ );
@@ -0,0 +1,35 @@
1
+ import React, { useState } from 'react';
2
+ import { useDispatch, useSelector } from 'react-redux';
3
+ import { addNote, deleteNote } from './redux/notesSlice';
4
+
5
+ const NotesManagementApp = () => {
6
+
7
+ const [note, setNote] = useState('');
8
+ const notes = useSelector((state) => state.notes);
9
+ const dispatch = useDispatch();
10
+
11
+ const handleClick = () =>{
12
+ if(note.trim() === ''){
13
+ return;
14
+ }
15
+ dispatch(addNote(note));
16
+ setNote('');
17
+ }
18
+ return (
19
+ <div>
20
+ <h2>Notes Management App</h2>
21
+ <label>Enter note: <input type='text' value={note} onChange={(e) => setNote(e.target.value)}></input></label>
22
+ <button type='submit' onClick={handleClick}>Add Note</button>
23
+ <ul>
24
+ {notes.map((item, index) =>(
25
+ <li key={index}>
26
+ {item}
27
+ <button type='submit' onClick={() => dispatch(deleteNote(index))}>Delete Note</button>
28
+ </li>
29
+ ))}
30
+ </ul>
31
+ </div>
32
+ )
33
+ }
34
+
35
+ export default NotesManagementApp
@@ -0,0 +1,20 @@
1
+ import {createSlice} from '@reduxjs/toolkit';
2
+
3
+ const notesSlice = createSlice ({
4
+ name : 'notes',
5
+ initialState : [],
6
+ reducers : {
7
+
8
+ addNote: (state, action) => {
9
+ state.push(action.payload);
10
+ },
11
+
12
+ deleteNote: (state, action) =>{
13
+ state.splice(action.payload, 1);
14
+ }
15
+ }
16
+ });
17
+
18
+ export const {addNote, deleteNote} = notesSlice.actions;
19
+
20
+ export default notesSlice.reducer;