Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SciProg2024
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pclark3
SciProg2024
Commits
4e345a82
Commit
4e345a82
authored
1 year ago
by
cprutean
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
3b8f2e98
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
CodeExamples/AppendFunction.ipynb
+70
-0
70 additions, 0 deletions
CodeExamples/AppendFunction.ipynb
with
70 additions
and
0 deletions
CodeExamples/AppendFunction.ipynb
0 → 100644
+
70
−
0
View file @
4e345a82
{
"cells": [
{
"cell_type": "markdown",
"id": "059058d7",
"metadata": {},
"source": [
"# Append Function"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d0b2e63b",
"metadata": {},
"outputs": [],
"source": [
"\"\"\"\n",
" Demonstration of Append function that works for any variable type\n",
"\"\"\"\n",
"\n",
"def append(first,second):\n",
" \"\"\"\n",
" A generic append function\n",
" \"\"\"\n",
" l = first + second\n",
" return l\n",
"\n",
"def main():\n",
" # Form two lists\n",
" fl = [1,2,3,5]\n",
" sl = [6,7,8,9,10]\n",
" # Append with a function\n",
" nl = append(fl,sl)\n",
" print(str(fl))\n",
" print(sl)\n",
" print(str(nl))\n",
"\n",
" # Can also be used to append any variable type\n",
" x = 10.0\n",
" y = 11.0\n",
" z = append(x,y)\n",
" print(\"Value of z is : \" + str(z))\n",
"\n",
"main()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
%% Cell type:markdown id:059058d7 tags:
# Append Function
%% Cell type:code id:d0b2e63b tags:
```
python
"""
Demonstration of Append function that works for any variable type
"""
def
append
(
first
,
second
):
"""
A generic append function
"""
l
=
first
+
second
return
l
def
main
():
# Form two lists
fl
=
[
1
,
2
,
3
,
5
]
sl
=
[
6
,
7
,
8
,
9
,
10
]
# Append with a function
nl
=
append
(
fl
,
sl
)
print
(
str
(
fl
))
print
(
sl
)
print
(
str
(
nl
))
# Can also be used to append any variable type
x
=
10.0
y
=
11.0
z
=
append
(
x
,
y
)
print
(
"
Value of z is :
"
+
str
(
z
))
main
()
```
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment