0% found this document useful (0 votes)
2 views

Swapping+Two+Variables

The document contains a Python notebook that demonstrates swapping the values of two strings, 'first string' and 'second string'. After the swap, it prints the new values of both strings, showing 'second string' for v1 and 'first string' for v2. Additionally, there are links and a comment related to CS Dojo at the end of the notebook.

Uploaded by

abisaan2041
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Swapping+Two+Variables

The document contains a Python notebook that demonstrates swapping the values of two strings, 'first string' and 'second string'. After the swap, it prints the new values of both strings, showing 'second string' for v1 and 'first string' for v2. Additionally, there are links and a comment related to CS Dojo at the end of the notebook.

Uploaded by

abisaan2041
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

{

"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"v1 = \"first string\"\n",
"v2 = \"second string\""
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"temp = v1\n",
"v1 = v2\n",
"v2 = temp"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"second string\n"
]
}
],
"source": [
"print(v1)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"first string\n"
]
}
],
"source": [
"print(v2)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"csdojo.io/python1\n",
"csdojo.io/news\n",
"\n",
"comment below\n",
"\n",
"YK from CS Dojo"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.6.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

You might also like