You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"Ex 2: Check the number of times \"python\" (regardless of cases: PYTHON, python, Python\" appears in the paragraph : \"Floating-point values in Python are always done in double precision; hence, Python float types correspond to doubles in a C-like language.\""
"my_str = \"Floating-point values in Python are always done in double precision; hence, Python float types correspond to doubles in a C-like language.\"\n",
82
+
"my_str.count(\"Python\")"
83
+
]
84
+
},
85
+
{
86
+
"cell_type": "markdown",
87
+
"metadata": {
88
+
"id": "irUaOorkTemh"
89
+
},
90
+
"source": [
91
+
"Ex 3: Combine two lists : ls1 = [\"apple\", \"banana\", \"cherry\"] and ls2 = [\"apple\", \"banana\", \"cherry\", \"apple\", \"cherry\"]. Print the number of elements in new list."
"Ex 6: Write a program that asks the user to enter a string. The program should create a new string called new_string from the user's string such that the second character is changed to an asterisk and three exclamation points are attached to the end of the string. Finally, print new_string."
"Ex 7: Write a program that converts the given string 's' to lowercase, removes all Punctuation marks such as period, hyphen, and commas from 's', and prints the resulting string."
"floating-point values in python are always done in double precision; hence, python float types correspond to doubles in a c-like language\n",
231
+
"floatingpoint values in python are always done in double precision; hence, python float types correspond to doubles in a clike language\n",
232
+
"floatingpoint values in python are always done in double precision; hence python float types correspond to doubles in a clike language\n"
233
+
]
234
+
}
235
+
],
236
+
"source": [
237
+
"s = \"Floating-point values in Python are always done in double precision; hence, Python float types correspond to doubles in a C-like language.\"\n",
238
+
"s = s.lower()\n",
239
+
"for char in ['.', '-', ',']:\n",
240
+
" s = s.replace(char, '')\n",
241
+
" print(s)\n",
242
+
"\n",
243
+
"\n"
244
+
]
245
+
},
246
+
{
247
+
"cell_type": "markdown",
248
+
"metadata": {
249
+
"id": "5kAI7D8HTemk"
250
+
},
251
+
"source": [
252
+
"Ex 8: L1 and L2 should be identical. Write a program that finds the missing number in L2."
253
+
]
254
+
},
255
+
{
256
+
"cell_type": "code",
257
+
"execution_count": 105,
258
+
"metadata": {
259
+
"id": "y_YJB3MsTemk"
260
+
},
261
+
"outputs": [],
262
+
"source": [
263
+
"from random import randint\n",
264
+
"L1 = list(range(1,101))\n",
265
+
"L2 = L1.copy()\n",
266
+
"L2.remove(randint(1,101))\n",
267
+
"\n"
268
+
]
269
+
},
270
+
{
271
+
"cell_type": "markdown",
272
+
"metadata": {
273
+
"id": "MLCtlSaxTeml"
274
+
},
275
+
"source": [
276
+
"Ex 9: Write a program to copy the ls1 = [\"apple\", \"banana\", \"cherry\"] to a new list. Add the element \"blueberry\" to the new list, but keep the original list the same."
0 commit comments