Skip to content

Commit

Permalink
achieved five star
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushi7rawat committed Jul 2, 2020
1 parent 767f1b8 commit f7f5528
Show file tree
Hide file tree
Showing 8 changed files with 1,062 additions and 5 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,72 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### diff21 Challange Solution | Warmup-2 | CodingBat | Python"
"### front_times Challange Solution | Warmup-2 | CodingBat | Python"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": []
"outputs": [
{
"data": {
"text/plain": [
"'ChoCho'"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#Given a string and a non-negative int n,the front of the string is first 3 chars, or whatever is there \n",
"#if the string is less than length 3. Return n copies of the front\n",
"\n",
"def front_times(str, n):\n",
" return str[:3]*n\n",
"\n",
"front_times('Chocolate', 2)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### string_times Challange Solution | Warmup-2 | CodingBat | Python"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'HiHiHi'"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#Given a string and a non-negative int n, return a larger string that is n copies of the original string.\n",
"\n",
"def string_times(str, n):\n",
" return str*n\n",
" \n",
"string_times('Hi', 3)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### diff21 Challange Solution | Warmup-2 | CodingBat | Python"
"### string_times Challange Solution | Warmup-2 | CodingBat | Python"
]
},
{
Expand Down
144 changes: 144 additions & 0 deletions 03 String 1 CodingBat Python.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### hello_name Challange Solution | String-1 | CodingBat | Python"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'Hello Bob!'"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#Given a string name, e.g. \"Bob\", return a greeting of the form \"Hello Bob!\".\n",
"\n",
"def hello_name(name):\n",
" return 'Hello '+name+'!'\n",
"\n",
"hello_name('Bob')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### first_half Challange Solution | String-1 | CodingBat | Python"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"#Given a string of even length, return the first half. So the string \"WooHoo\" yields \"Woo\".\n",
"\n",
"str='HelloThere'\n",
"\n",
"def first_half(str):\n",
" return str[ :len(str)/2]\n",
"\n",
"first_half(str)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### first_two Challange Solution | String-1 | CodingBat | Python"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'he'"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#Given a string,return string made of its first 2 chars, so the String \"Hello\" yields \"He\".If the string is shorter than \n",
"#length 2, return whatever there is, so \"X\" yields \"X\", and the empty string \"\" yields the empty string \"\".\n",
"\n",
"def first_two(str):\n",
" if len(str)<3:\n",
" return str\n",
" else:\n",
" return str[:2]\n",
" \n",
"first_two('hello')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"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.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Loading

0 comments on commit f7f5528

Please sign in to comment.