├── .eslintrc.yml
├── .gitignore
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── build
├── asset-manifest.json
├── favicon.ico
├── index.html
├── manifest.json
├── service-worker.js
└── static
│ ├── css
│ ├── main.827ee0f1.css
│ └── main.827ee0f1.css.map
│ └── js
│ ├── main.7ea798fc.js
│ └── main.7ea798fc.js.map
├── challenges.json
├── challenges
├── 0.1.Intro
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 1.1.Print
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 1.2.Escape_Characters
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 1.3.Input
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 2.1.NumberTypes
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 2.2.Strings
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 2.3.Tuples
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 2.4.Lists
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 2.5.Sets
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 2.6.Dictionaries
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 3.1.Assignment_Operator
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 3.2.Equality_Operator
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 3.3.Inequality_Operator
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 3.4.Strictly_Less_Than_Operator
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 3.5.Less_Than_Equal_To_Operator
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 3.6.Greater_Than_Equal_To_Operator
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 3.7.Strictly_Greater_Than_Operator
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 3.8.False_Operator
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 3.9.True_Operator
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 3.A.Logical_And_Operator
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 3.B.Logical_Not_Operator
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 3.C.Logical_Or_Operator
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 3.D.Is_Operator
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 3.E.Is_Not_Operator
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 3.F.In_Operator
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 3.G.Not_In_Operator
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 4.1.Addition
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 4.2.Subtraction
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 4.3.Multiplication
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 4.4.Float_Division
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 4.5.Integer_Division
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 4.6.Exponents
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 4.7.Remainder
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 4.8.Divmod
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 4.9.Square_Root
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 4.A.Sum
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 4.B.Rounding
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 4.C.Absolute_Value
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 4.D.Min_Value
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 4.E.Max_Value
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 5.1.Variables
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 6.1.Conditionals
│ ├── lesson.md
│ ├── lesson_settings.py
│ ├── lesson_tests.py
│ └── main.py
├── 7.1.Loops
│ ├── lesson.md
│ ├── lesson_settings.py
│ ├── lesson_tests.py
│ └── main.py
├── 8.1.Built_In_Functions
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 8.2.User_Defined_Functions
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 8.3.Function_Documentation_Strings
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 8.4.Arguments_Vs_Parameters
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 8.5.Default_Arguments
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 8.6.Calling_Functions
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 8.7.Keyword_Arguments
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
├── 8.8.Positional_Arguments
│ ├── lesson.md
│ ├── lesson_settings.json
│ ├── lesson_tests.py
│ └── main.py
└── classroom_settings.json
├── favicon.png
├── generate-challenge-json.js
├── package-lock.json
├── package.json
├── public
├── favicon.ico
├── index.html
└── manifest.json
└── src
├── App.js
├── ChallengeNotFound.js
├── ChallengeView.js
├── CurriculumComplete.js
├── GetStarted.js
├── Map.js
├── Navbar.js
├── challenges.json
├── index.js
├── registerServiceWorker.js
└── styles
├── App.css
├── ChallengeView.css
├── CurriculumComplete.css
├── GetStarted.css
├── Map.css
├── Navbar.css
└── index.css
/.eslintrc.yml:
--------------------------------------------------------------------------------
1 | ---
2 | extends:
3 | - plugin:react/recommended
4 |
5 | env:
6 | browser: true
7 | node: true
8 | es6: true
9 |
10 | parserOptions:
11 | ecmaVersion: 6
12 | sourceType: "module"
13 | ecmaFeatures:
14 | jsx: true
15 |
16 | globals:
17 | __DEV__: true
18 | __SERVER__: true
19 |
20 | plugins:
21 | - react
22 |
23 | rules:
24 | react/jsx-uses-vars: 1
25 | react/prop-types: [1, { ignore: [children] }]
26 |
27 | semi: 0
28 | key-spacing: 1
29 | curly: 0
30 | consistent-return: 0
31 | space-infix-ops: 1
32 | camelcase: 0
33 | no-spaced-func: 1
34 | no-alert: 1
35 | eol-last: 1
36 | comma-spacing: 1
37 | eqeqeq: 1
38 |
39 | # possible errors
40 | comma-dangle: 0
41 | no-cond-assign: 2
42 | no-console: 0
43 | no-constant-condition: 2
44 | no-control-regex: 2
45 | no-debugger: 2
46 | no-dupe-args: 2
47 | no-dupe-keys: 2
48 | no-duplicate-case: 2
49 | no-empty-character-class: 2
50 | no-empty: 2
51 | no-ex-assign: 2
52 | no-extra-boolean-cast: 2
53 | no-extra-parens: 0
54 | no-extra-semi: 2
55 | no-func-assign: 2
56 | no-inner-declarations: 2
57 | no-invalid-regexp: 2
58 | no-irregular-whitespace: 2
59 | no-negated-in-lhs: 2
60 | no-obj-calls: 2
61 | no-regex-spaces: 2
62 | no-sparse-arrays: 2
63 | no-unexpected-multiline: 2
64 | no-unreachable: 2
65 | use-isnan: 2
66 | valid-jsdoc: 2
67 | valid-typeof: 2
68 |
69 | no-redeclare: 2
70 |
71 | init-declarations: 2
72 | no-catch-shadow: 2
73 | no-delete-var: 2
74 | no-label-var: 2
75 | no-shadow-restricted-names: 2
76 | no-shadow: 2
77 | no-undef-init: 2
78 | no-undef: 2
79 | no-undefined: 2
80 | no-unused-vars: 2
81 | no-use-before-define: 2
82 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # dependencies
2 | /node_modules
3 |
4 | # testing
5 | /coverage
6 |
7 | # production
8 | /build
9 |
10 | # misc
11 | .DS_Store
12 | .env.local
13 | .env.development.local
14 | .env.test.local
15 | .env.production.local
16 |
17 | npm-debug.log*
18 | yarn-debug.log*
19 | yarn-error.log*
20 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing Guidelines
2 |
3 | Welcome to the FreeCodeCamp Python Curriculum contributing guidelines. Here you will find information on:
4 |
5 | 1. Reporting bugs
6 | 2. Suggesting a new feature
7 | 3. Suggesting a new challenge
8 | 4. Fixing/Updating an existing challenge
9 |
10 | ## Set Up Local Development Environment
11 |
12 | 1. Fork this repo
13 | 2. Clone to your machine
14 | 3. `cd` into repository directory
15 | 4. run `npm install`
16 | 5. ren `npm run start` to start application
17 | 6. Code!
18 |
19 | ## Reporting bugs
20 |
21 | Have you discovered a bug within the application?
22 | - Open a new issue titled: '[Bug] Title/Description of bug'
23 | - Include which machine, browser & version bug was discovered on
24 | - Include steps to reproduce the bug
25 |
26 | ## Suggesting a new feature
27 |
28 | Have an idea for a feature to make the app better?
29 | - Open a new issue titled: '[New Feature] Feature title'
30 | - Include a brief description what it is and how it will benefit application
31 | - Propose some sort of pseudocode for how to potentially implement this feature
32 |
33 | ## Suggesting a new challenge
34 |
35 | Want to add to the curriculum?
36 | - Open a new issue titled: '[New Challenge] Challenge title'
37 | - Include why this would benefit the curriculum
38 | - Include resources needed to write the challenge
39 |
40 | ## Fixing/Updating an existing challenge
41 |
42 | Find a mistake in an existing challenge?
43 | - Open a new issue titled: '[Fix Challenge] Challenge title'
44 | - Indicate whats wrong with the challenge
45 | - Propose what needs to be done to fix it if applicable
46 |
47 | # Thank you for contributing!
48 | We couldn't do this without you :heart:
49 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | BSD 3-Clause License
2 |
3 | Copyright (c) 2016, Free Code Camp
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | * Neither the name of the copyright holder nor the names of its
17 | contributors may be used to endorse or promote products derived from
18 | this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | FreeCodeCamp Python Curriculum
2 | =============
3 |
4 | View live: https://freecodecamp.github.io/python-coding-challenges
5 |
6 | To run locally:
7 | 1. Fork this repo
8 | 2. Run `git clone [your-fork-url]`
9 | 3. Run `npm install`
10 | 4. Run `npm run start`
11 |
12 | Adding a new challenge or fixing an existing one?
13 |
14 | - Generating challenge ID:
15 | 1. Open your terminal
16 | 2. run `mongo`
17 | 3. run `ObjectId()`
18 | 4. copy string and paste into lesson_settings.json
19 |
20 | - Building challenges.json file:
21 | 1. Open your terminal
22 | 2. Navigate to project directory
23 | 3. run `node generate-challenge-json.js`
24 | 4. if no errors are thrown you're good to commit and open a pr
25 |
26 | - Opening a PR
27 | 1. Include a reference to the issue
28 | 2. If its a new challenge, mention the chapter its being added to
29 | 3. continue being awesome and helping us create this curriculum!
30 |
31 |
32 | Maintaining your Fork:
33 | 1. `git remote add upstream https://github.com/freeCodeCamp/python-coding-challenges.git`
34 | 2. `git checkout master`
35 | 3. `git pull upstream`
36 |
--------------------------------------------------------------------------------
/build/asset-manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "main.css": "static/css/main.827ee0f1.css",
3 | "main.css.map": "static/css/main.827ee0f1.css.map",
4 | "main.js": "static/js/main.7ea798fc.js",
5 | "main.js.map": "static/js/main.7ea798fc.js.map"
6 | }
--------------------------------------------------------------------------------
/build/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/freeCodeCamp/python-coding-challenges/b435ab650d85de267eeaa31a55ff77ef5dbff86b/build/favicon.ico
--------------------------------------------------------------------------------
/build/index.html:
--------------------------------------------------------------------------------
1 |
FreeCodeCamp Python Curriculum
--------------------------------------------------------------------------------
/build/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "192x192",
8 | "type": "image/png"
9 | }
10 | ],
11 | "start_url": "./index.html",
12 | "display": "standalone",
13 | "theme_color": "#000000",
14 | "background_color": "#ffffff"
15 | }
16 |
--------------------------------------------------------------------------------
/build/service-worker.js:
--------------------------------------------------------------------------------
1 | "use strict";function setOfCachedUrls(e){return e.keys().then(function(e){return e.map(function(e){return e.url})}).then(function(e){return new Set(e)})}var precacheConfig=[["index.html","cfec8cd7669ab69115f817330aa2ad5c"],["static/css/main.827ee0f1.css","9ec03701ab2baacf76aa4999840db1d3"],["static/js/main.7ea798fc.js","5aebe6e76beeddc41ad85aea9c945379"]],cacheName="sw-precache-v3-sw-precache-webpack-plugin-"+(self.registration?self.registration.scope:""),ignoreUrlParametersMatching=[/^utm_/],addDirectoryIndex=function(e,t){var n=new URL(e);return"/"===n.pathname.slice(-1)&&(n.pathname+=t),n.toString()},cleanResponse=function(e){return e.redirected?("body"in e?Promise.resolve(e.body):e.blob()).then(function(t){return new Response(t,{headers:e.headers,status:e.status,statusText:e.statusText})}):Promise.resolve(e)},createCacheKey=function(e,t,n,r){var a=new URL(e);return r&&a.pathname.match(r)||(a.search+=(a.search?"&":"")+encodeURIComponent(t)+"="+encodeURIComponent(n)),a.toString()},isPathWhitelisted=function(e,t){if(0===e.length)return!0;var n=new URL(t).pathname;return e.some(function(e){return n.match(e)})},stripIgnoredUrlParameters=function(e,t){var n=new URL(e);return n.hash="",n.search=n.search.slice(1).split("&").map(function(e){return e.split("=")}).filter(function(e){return t.every(function(t){return!t.test(e[0])})}).map(function(e){return e.join("=")}).join("&"),n.toString()},hashParamName="_sw-precache",urlsToCacheKeys=new Map(precacheConfig.map(function(e){var t=e[0],n=e[1],r=new URL(t,self.location),a=createCacheKey(r,hashParamName,n,/\.\w{8}\./);return[r.toString(),a]}));self.addEventListener("install",function(e){e.waitUntil(caches.open(cacheName).then(function(e){return setOfCachedUrls(e).then(function(t){return Promise.all(Array.from(urlsToCacheKeys.values()).map(function(n){if(!t.has(n)){var r=new Request(n,{credentials:"same-origin"});return fetch(r).then(function(t){if(!t.ok)throw new Error("Request for "+n+" returned a response with status "+t.status);return cleanResponse(t).then(function(t){return e.put(n,t)})})}}))})}).then(function(){return self.skipWaiting()}))}),self.addEventListener("activate",function(e){var t=new Set(urlsToCacheKeys.values());e.waitUntil(caches.open(cacheName).then(function(e){return e.keys().then(function(n){return Promise.all(n.map(function(n){if(!t.has(n.url))return e.delete(n)}))})}).then(function(){return self.clients.claim()}))}),self.addEventListener("fetch",function(e){if("GET"===e.request.method){var t,n=stripIgnoredUrlParameters(e.request.url,ignoreUrlParametersMatching);t=urlsToCacheKeys.has(n);t||(n=addDirectoryIndex(n,"index.html"),t=urlsToCacheKeys.has(n));!t&&"navigate"===e.request.mode&&isPathWhitelisted(["^(?!\\/__).*"],e.request.url)&&(n=new URL("/python-coding-challenges/index.html",self.location).toString(),t=urlsToCacheKeys.has(n)),t&&e.respondWith(caches.open(cacheName).then(function(e){return e.match(urlsToCacheKeys.get(n)).then(function(e){if(e)return e;throw Error("The cached response that was expected is missing.")})}).catch(function(t){return console.warn('Couldn\'t serve response for "%s" from cache: %O',e.request.url,t),fetch(e.request)}))}});
--------------------------------------------------------------------------------
/build/static/css/main.827ee0f1.css:
--------------------------------------------------------------------------------
1 | .btn{border-radius:10px;margin-top:5px;height:75px;background-color:#006400;border:none;font-family:Lato;font-size:2em;color:#fff;padding-left:20px;padding-right:20px;-webkit-transition:background-color .2s;-o-transition:background-color .2s;transition:background-color .2s}.btn:hover{cursor:pointer;background-color:#024e02}.btn.disabled{cursor:not-allowed;background-color:#e0e0e0}.btn>i{margin:5px}.navbar{padding:5px 30px;-webkit-box-sizing:border-box;box-sizing:border-box;position:relative;width:100%;height:50px;background-color:#006400;-ms-flex-positive:1;flex-grow:1}.navbar div{display:inline-block;position:absolute;right:30px;top:10px;color:#fff;font-size:20px;text-transform:uppercase}.navbar div span{font-weight:700;font-size:25px}#linkback a{position:absolute;color:#fff;text-decoration:none;left:50%;-webkit-transform:translateX(-50%);-ms-transform:translateX(-50%);transform:translateX(-50%);top:25px;font-size:14px}#logo{position:relative;height:100%}.container{margin:auto;margin-top:15px;min-width:900px;-webkit-box-sizing:content-box;box-sizing:content-box;padding:20px;-ms-flex-positive:2;flex-grow:2;max-width:90vw;width:1200px;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-align:start;align-items:flex-start;height:650px}.container,.top{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}.top{-ms-flex-positive:1;flex-grow:1;height:100%;width:100%;margin-bottom:25px}.challenge-title{text-align:center;font-size:1.3rem}.bottom{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-align:end;align-items:flex-end;-ms-flex-pack:justify;justify-content:space-between;height:auto;width:100%}.hidden{display:none}.curriculum-complete{text-align:center}.get-started{padding-left:30px;padding-right:30px;text-align:center;font-size:2rem}.get-started>h1{font-size:2.5rem}.get-started>h2{font-size:2rem}.get-started>h3{font-size:1.5rem}.get-started>.link{text-decoration:none}.map{height:100%;-webkit-box-sizing:border-box;box-sizing:border-box;width:0;position:fixed;z-index:1;top:0;right:0;background-color:#eee;overflow-x:hidden;padding-top:60px;-webkit-transition:.5s;-o-transition:.5s;transition:.5s}.map button{background-color:transparent;border:none;margin:0;padding:0;text-align:left;display:inline-block}.map a{display:block}.map a,.map button{padding:8px 8px 8px 32px;text-decoration:none;font-size:25px;color:#818181;-webkit-transition:.3s;-o-transition:.3s;transition:.3s}.map a:hover,.map button:hover,.offcanvas a:focus{color:#006400}.map .close-map{position:absolute;top:0;right:25px;font-size:36px;margin-left:50px}@media screen and (max-height:450px){.map{padding-top:15px}.map a{font-size:18px}}.challenge-list{border-top:2px solid #006400}.chapter{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-align:start;align-items:flex-start;-ms-flex-pack:start;justify-content:flex-start}.chapter-title{color:#006400;font-size:1.5rem;padding-left:10px}.lesson-list{list-style:none;-ms-flex-item-align:left;align-self:left;padding-left:5px;margin-top:0}.lesson-list-element i{color:#818181}body,html{width:100vw;height:100vh;padding:0;margin:0;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;font-family:Lato,Helvetica,Arial,Sans-serif;font-size:18px;min-width:940px}hr{border:0;padding-bottom:1px;height:0;width:100%;margin:5px 0 25px;background-image:-webkit-gradient(linear,left top,right top,from(transparent),color-stop(rgba(0,0,0,.75)),to(transparent));background-image:-webkit-linear-gradient(left,transparent,rgba(0,0,0,.75),transparent);background-image:-o-linear-gradient(left,transparent,rgba(0,0,0,.75),transparent);background-image:linear-gradient(90deg,transparent,rgba(0,0,0,.75),transparent)}
2 | /*# sourceMappingURL=main.827ee0f1.css.map*/
--------------------------------------------------------------------------------
/build/static/css/main.827ee0f1.css.map:
--------------------------------------------------------------------------------
1 | {"version":3,"sources":["styles/App.css","styles/Navbar.css","styles/ChallengeView.css","styles/CurriculumComplete.css","styles/GetStarted.css","styles/Map.css","styles/index.css"],"names":[],"mappings":"AAAA,KACE,mBACA,eACA,YACA,yBACA,YACA,iBACA,cACA,WACA,kBACA,mBACA,wCACA,mCACA,+BAAkC,CAGpC,WACE,eACA,wBAA0B,CAG5B,cACE,mBACA,wBAA0B,CAG5B,OACE,UAAY,CC3Bd,QACE,iBACA,8BACQ,sBACR,kBACA,WACA,YACA,yBACA,oBACI,WAAa,CAGnB,YACE,qBACA,kBACA,WACA,SACA,WACA,eACA,wBAA0B,CAG5B,iBACE,gBACA,cAAgB,CAGlB,YACE,kBACA,WACA,qBACA,SACA,mCACI,+BACI,2BACR,SACA,cAAgB,CAGlB,MACE,kBACA,WAAa,CCzCf,WACE,YACA,gBACA,gBACA,+BACQ,uBACR,aAKA,oBACI,YACJ,eACA,aACA,sBACI,8BACJ,qBACI,uBACJ,YAAc,CAGhB,gBAfE,oBACA,aACA,0BACI,qBAAuB,CAsB5B,KALC,oBACI,YACJ,YACA,WACA,kBAAoB,CAGtB,iBACE,kBACA,gBAAkB,CAIpB,QACE,oBACA,aACA,uBACI,mBACJ,mBACI,qBACJ,sBACI,8BACJ,YACA,UAAY,CAGd,QACE,YAAc,CCtDhB,qBACE,iBAAmB,CCDrB,aACE,kBACA,mBACA,kBACA,cAAgB,CAGlB,gBACE,gBAAkB,CAGpB,gBACE,cAAgB,CAGlB,gBACE,gBAAkB,CAGpB,mBACE,oBAAsB,CCpBxB,KACE,YACA,8BACQ,sBACR,QACA,eACA,UACA,MACA,QACA,sBACA,kBACA,iBACA,uBACA,kBACA,cAAiB,CAGnB,YACE,6BACA,YACA,SACA,UACA,gBACA,oBAAsB,CAGxB,OACE,aAAe,CAEjB,mBACE,yBACA,qBACA,eACA,cACA,uBACA,kBACA,cAAiB,CAGnB,kDAGE,aAAe,CAGjB,gBACE,kBACA,MACA,WACA,eACA,gBAAkB,CAGpB,qCACI,KAAM,gBAAkB,CACxB,OAAQ,cAAgB,CAAC,CAG7B,gBACE,4BAA8B,CAGhC,SACE,oBACA,aACA,0BACI,sBACJ,qBACI,uBACJ,oBACI,0BAA4B,CAElC,eACE,cACA,iBACA,iBAAmB,CAErB,aACE,gBACA,yBACI,gBACJ,iBACA,YAAc,CAEhB,uBACE,aAAc,CCrFhB,UACE,YACA,aACA,UACA,SACA,oBACA,aACA,0BACI,sBACJ,4CACA,eACA,eAAiB,CAGnB,GACI,SACA,mBACA,SACA,WACA,kBACA,2HACA,uFACA,kFACA,+EAAqG","file":"static/css/main.827ee0f1.css","sourcesContent":[".btn {\n border-radius: 10px;\n margin-top: 5px;\n height: 75px;\n background-color: #006400;\n border: none;\n font-family: Lato;\n font-size: 2em;\n color: white;\n padding-left: 20px;\n padding-right: 20px;\n -webkit-transition: background-color 0.2s;\n -o-transition: background-color 0.2s;\n transition: background-color 0.2s;\n}\n\n.btn:hover {\n cursor: pointer;\n background-color: #024e02;\n}\n\n.btn.disabled {\n cursor: not-allowed;\n background-color: #E0E0E0;\n}\n\n.btn > i {\n margin: 5px;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/styles/App.css",".navbar {\n padding: 5px 30px;\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n position: relative;\n width: 100%;\n height: 50px;\n background-color: #006400;\n -ms-flex-positive: 1;\n flex-grow: 1;\n}\n\n.navbar div {\n display: inline-block;\n position: absolute;\n right: 30px;\n top: 10px;\n color: white;\n font-size: 20px;\n text-transform: uppercase;\n}\n\n.navbar div span {\n font-weight: bold;\n font-size: 25px;\n}\n\n#linkback a {\n position: absolute;\n color: white;\n text-decoration: none;\n left: 50%;\n -webkit-transform: translateX(-50%);\n -ms-transform: translateX(-50%);\n transform: translateX(-50%);\n top: 25px;\n font-size: 14px;\n}\n\n#logo {\n position: relative;\n height: 100%;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/styles/Navbar.css",".container {\n margin: auto;\n margin-top: 15px;\n min-width: 900px;\n -webkit-box-sizing: content-box;\n box-sizing: content-box;\n padding: 20px;\n display: -ms-flexbox;\n display: flex;\n -ms-flex-direction: column;\n flex-direction: column;\n -ms-flex-positive: 2;\n flex-grow: 2;\n max-width: 90vw;\n width: 1200px;\n -ms-flex-pack: justify;\n justify-content: space-between;\n -ms-flex-align: start;\n align-items: flex-start;\n height: 650px;\n}\n\n.top {\n display: -ms-flexbox;\n display: flex;\n -ms-flex-direction: column;\n flex-direction: column;\n -ms-flex-positive: 1;\n flex-grow: 1;\n height: 100%;\n width: 100%;\n margin-bottom: 25px;\n}\n\n.challenge-title {\n text-align: center;\n font-size: 1.3rem;\n}\n\n\n.bottom {\n display: -ms-flexbox;\n display: flex;\n -ms-flex-direction: row;\n flex-direction: row;\n -ms-flex-align: end;\n align-items: flex-end;\n -ms-flex-pack: justify;\n justify-content: space-between;\n height: auto;\n width: 100%;\n}\n\n.hidden {\n display: none;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/styles/ChallengeView.css",".curriculum-complete {\n text-align: center;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/styles/CurriculumComplete.css",".get-started {\n padding-left: 30px;\n padding-right: 30px;\n text-align: center;\n font-size: 2rem;\n}\n\n.get-started > h1 {\n font-size: 2.5rem;\n}\n\n.get-started > h2 {\n font-size: 2rem;\n}\n\n.get-started > h3 {\n font-size: 1.5rem;\n}\n\n.get-started > .link {\n text-decoration: none;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/styles/GetStarted.css",".map {\n height: 100%;\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n width: 0;\n position: fixed;\n z-index: 1;\n top: 0;\n right: 0;\n background-color: #eee;\n overflow-x: hidden;\n padding-top: 60px;\n -webkit-transition: 0.5s;\n -o-transition: 0.5s;\n transition: 0.5s;\n}\n\n.map button {\n background-color: transparent;\n border: none;\n margin: 0;\n padding: 0;\n text-align: left;\n display: inline-block;\n}\n\n.map a {\n display: block;\n}\n.map a, .map button {\n padding: 8px 8px 8px 32px;\n text-decoration: none;\n font-size: 25px;\n color: #818181;\n -webkit-transition: 0.3s;\n -o-transition: 0.3s;\n transition: 0.3s;\n}\n\n.map a:hover, .offcanvas a:focus,\n.map button:hover\n {\n color: #006400;\n}\n\n.map .close-map {\n position: absolute;\n top: 0;\n right: 25px;\n font-size: 36px;\n margin-left: 50px;\n}\n\n@media screen and (max-height: 450px) {\n .map {padding-top: 15px;}\n .map a {font-size: 18px;}\n}\n\n.challenge-list {\n border-top: 2px solid #006400;\n}\n\n.chapter {\n display: -ms-flexbox;\n display: flex;\n -ms-flex-direction: column;\n flex-direction: column;\n -ms-flex-align: start;\n align-items: flex-start;\n -ms-flex-pack: start;\n justify-content: flex-start;\n}\n.chapter-title {\n color: #006400;\n font-size: 1.5rem;\n padding-left: 10px;\n}\n.lesson-list {\n list-style: none;\n -ms-flex-item-align: left;\n align-self: left;\n padding-left: 5px;\n margin-top: 0;\n}\n.lesson-list-element i {\n color: #818181\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/styles/Map.css","html, body {\n width: 100vw;\n height: 100vh;\n padding: 0;\n margin: 0;\n display: -ms-flexbox;\n display: flex;\n -ms-flex-direction: column;\n flex-direction: column;\n font-family: Lato, Helvetica, Arial, Sans-serif;\n font-size: 18px;\n min-width: 940px;\n}\n\nhr {\n border: 0;\n padding-bottom: 1px;\n height: 0px;\n width: 100%;\n margin: 5px 0 25px 0;\n background-image: -webkit-gradient(linear, left top, right top, from(rgba(0, 0, 0, 0)), color-stop(rgba(0, 0, 0, 0.75)), to(rgba(0, 0, 0, 0)));\n background-image: -webkit-linear-gradient(left, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));\n background-image: -o-linear-gradient(left, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));\n background-image: linear-gradient(to right, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/styles/index.css"],"sourceRoot":""}
--------------------------------------------------------------------------------
/challenges.json:
--------------------------------------------------------------------------------
1 | {"name":"Python Beginner Challenges","last_edit":1496934858175,"chapters":["Introduction","Input","Data Types", "Operators","Math"],"challenges":[[],[{"id":"593964e5d230354d7438db33","title":"Print","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":1,"lesson":1},{"id":"593964dad230354d7438db32","title":"Escape Charactesr","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":1,"lesson":2},{"id":"592f1cc969cf862d8a7bb7f2","title":"Input Edit","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":1,"lesson":3}],[{"id":"593964fdd230354d7438db34","title":"Numbers","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":2,"lesson":1},{"id":"5939650ad230354d7438db35","title":"Strings","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":2,"lesson":2},{"id":"59396524d230354d7438db36","title":"Tuples","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":2,"lesson":3},{"id":"593967e6d230354d7438db39","title":"Lists","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":2,"lesson":4},{"id":"593967ddd230354d7438db38","title":"Sets","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":2,"lesson":5},{"id":"593967d4d230354d7438db37","title":"Dictionaries","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":2,"lesson":6}],[{"id":"59381b056f0201972cc968b1","title":"Assignment Operator","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":3,"lesson":1},{"id":"59382d5b5b0de5a15275c053","title":"Equality Operator","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":3,"lesson":2},{"id":"59382dac5b0de5a15275c054","title":"Inequality Operator","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":3,"lesson":3},{"id":"59382e635b0de5a15275c055","title":"Strictly Less Than Operator","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":3,"lesson":4},{"id":"59382eda5b0de5a15275c056","title":"Less Than or Equal to Operator","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":3,"lesson":5},{"id":"59382f645b0de5a15275c057","title":"Greater Than or Equal To Operator","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":3,"lesson":6},{"id":"59382fc85b0de5a15275c058","title":"Strictly Greater Than Operator","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":3,"lesson":7},{"id":"59382ff35b0de5a15275c059","title":"False Operator","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":3,"lesson":8},{"id":"593830b05b0de5a15275c05a","title":"True Operator","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":3,"lesson":9},{"id":"593831095b0de5a15275c05b","title":"Logical And Operator","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":3,"lesson":10},{"id":"593832b25b0de5a15275c05c","title":"Logical Not Operator","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":3,"lesson":11},{"id":"5938330f5b0de5a15275c05d","title":"Logical Or Operator","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":3,"lesson":12},{"id":"593833575b0de5a15275c05e","title":"Is Operator","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":3,"lesson":13},{"id":"593833b65b0de5a15275c05f","title":"Is Not Operator","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":3,"lesson":14},{"id":"593834105b0de5a15275c060","title":"In Operator","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":3,"lesson":15},{"id":"5938346a5b0de5a15275c061","title":"Not In Operator","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":3,"lesson":16}],[{"id":"592893767a194ee412ae2e1f","title":"Addition","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":1},{"id":"592895b87a194ee412ae2e20","title":"Subtraction","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":2},{"id":"592895ef7a194ee412ae2e21","title":"Multiplication","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":3},{"id":"5928961e7a194ee412ae2e22","title":"Float Division","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":4},{"id":"592896397a194ee412ae2e23","title":"Integer Division","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":5},{"id":"5928965a7a194ee412ae2e24","title":"Exponents","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":6},{"id":"592896717a194ee412ae2e25","title":"Remainder","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":7},{"id":"592898c97a194ee412ae2e26","title":"Divmod","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":8},{"id":"592898dc7a194ee412ae2e27","title":"Square Root","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":9},{"id":"592899f67a194ee412ae2e28","title":"Sum","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":10},{"id":"59289a1a7a194ee412ae2e29","title":"Rounding","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":11},{"id":"59289a2f7a194ee412ae2e2a","title":"Absolute Value","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":12},{"id":"59289a477a194ee412ae2e2b","title":"Min Value","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":13},{"id":"59289a5a7a194ee412ae2e2c","title":"Max Value","repl":"https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af","completed":false,"chapter":4,"lesson":14}]]}
2 |
--------------------------------------------------------------------------------
/challenges/0.1.Intro/lesson.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/freeCodeCamp/python-coding-challenges/b435ab650d85de267eeaa31a55ff77ef5dbff86b/challenges/0.1.Intro/lesson.md
--------------------------------------------------------------------------------
/challenges/0.1.Intro/lesson_settings.json:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/freeCodeCamp/python-coding-challenges/b435ab650d85de267eeaa31a55ff77ef5dbff86b/challenges/0.1.Intro/lesson_settings.json
--------------------------------------------------------------------------------
/challenges/0.1.Intro/lesson_tests.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/freeCodeCamp/python-coding-challenges/b435ab650d85de267eeaa31a55ff77ef5dbff86b/challenges/0.1.Intro/lesson_tests.py
--------------------------------------------------------------------------------
/challenges/0.1.Intro/main.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/freeCodeCamp/python-coding-challenges/b435ab650d85de267eeaa31a55ff77ef5dbff86b/challenges/0.1.Intro/main.py
--------------------------------------------------------------------------------
/challenges/1.1.Print/lesson.md:
--------------------------------------------------------------------------------
1 | ## Print
2 | - http://www.python-course.eu/python3_print.php
3 | The print() function is used to present the output of a program.
4 | ```
5 | >>> print(“Hello World”)
6 | Hello World
7 | ```
8 | It can have several parameters.
9 | ```
10 | >>> print(‘Hello’, 12, ‘98’)
11 | Hello 12 98
12 | ```
13 | The arguments of the print function:
14 | sep=’’
15 | Sep is a separator, it is used to divide parameters.
16 | ```
17 | >>> print(‘Hello’, “World’, sep=’-‘)
18 | Hello-World
19 | ```
20 | We can assign an string to the keyword parameter "end". This string will be used for ending the output of the values of a print call.
21 | end=’’
22 | ```
23 | >>> print(‘Hello’, ‘World’, end=’!’)
24 | Hello World?
25 | ```
26 | By redefining the keyword parameter "file" we can send the output into a different stream file.
27 | file=’’
28 | ```
29 | >>> fh = open("data.txt","w")
30 | >> print("no", file=fh)
31 | >>> fh.close()
32 | ```
33 | **_Instructions:_**
34 | **Put your name and sname to appropriate places, change '*' to parameters of separator '_' and in the end of the line '!'.**
35 |
--------------------------------------------------------------------------------
/challenges/1.1.Print/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Print",
3 | "chapter_number": 1,
4 | "lesson_number": 1,
5 | "id": "593964e5d230354d7438db33",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/1.1.Print/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 |
3 |
4 | class PrintTests(unittest.TestCase):
5 | def test_main(self):
6 | f = open('main.py')
7 | lines = str(f.readlines())
8 | f.close()
9 | self.assertRegex(lines, "sep='_'", msg="_ mising")
10 | self.assertRegex(lines, "end='!'", msg="! mising")
--------------------------------------------------------------------------------
/challenges/1.1.Print/main.py:
--------------------------------------------------------------------------------
1 | print('firstname', 'sname', sep='*', end='*') #change this line
2 |
--------------------------------------------------------------------------------
/challenges/1.2.Escape_Characters/lesson.md:
--------------------------------------------------------------------------------
1 | ## Escape Character
2 | The escape character is "\\" and this character is invoked an alternative interpretation in a character sequence.
3 | - https://docs.python.org/2.0/ref/strings.html
4 | ```
5 | >>> print('\\')
6 | \
7 | >>> print('\'')
8 | '
9 | >>> print('Helllo\nWorld')
10 | Hello
11 | World
12 | ```
13 | We can use escape character to print hex value Unicode character.
14 | ```
15 | >>> print('\uxxxx')
16 | Л
17 | ```
18 |
19 | **_Instructions:_**
20 | **Use escape character "new line" in the string_escape**
--------------------------------------------------------------------------------
/challenges/1.2.Escape_Characters/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Escape Charactesr",
3 | "chapter_number": 1,
4 | "lesson_number": 2,
5 | "id": "593964dad230354d7438db32",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/1.2.Escape_Characters/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 |
5 | class EscapeTests(unittest.TestCase):
6 | def test_main(self):
7 | self.assertRegex(repr(string_escape), r'\\n', msg='the string must contain "new line"')
--------------------------------------------------------------------------------
/challenges/1.2.Escape_Characters/main.py:
--------------------------------------------------------------------------------
1 | string_escape = 'Hello, this is escape string' # change this line
2 |
3 | # change the string_escape, the string must contain "new line"
4 | print(string_escape)
--------------------------------------------------------------------------------
/challenges/1.3.Input/lesson.md:
--------------------------------------------------------------------------------
1 | ## Python Input
2 |
3 | In Python 3, to get user input, use the input function and pass a string in as a parameter.
4 | You can assign this function to a variable in order to save input.
5 | - https://docs.python.org/3/library/functions.html#input
6 |
7 | The input() function can take numbers and words as valid answers. All input is saved as a string regardless if they are numbers!
8 | In the example below, the input is saved to the 'school' and 'grade' variables they can be used later!
9 |
10 | ```
11 | >>> school = input('What school do you go to?')
12 | What school do you go to? Harvard
13 | >>> grade = input('What grade are you in?')
14 | What grade are you in? 4th
15 | >>> print (school)
16 | Harvard
17 | >>> print(grade)
18 | 4th
19 | >>>
20 | ```
21 |
22 |
23 | **_Instructions:_**
24 | **Prompt the user for their name and age. Print them out to console!**
25 |
--------------------------------------------------------------------------------
/challenges/1.3.Input/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Input Edit",
3 | "chapter_number": 1,
4 | "lesson_number": 3,
5 | "id":"592f1cc969cf862d8a7bb7f2",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/1.3.Input/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class InputTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsInstance(name, str)
7 | self.assertIsInstance(age, str)
8 | # To run the tests from the console:
9 | # Make sure that you are in the '1.3.Addition' directory
10 | # python3 -m unittest lesson_tests
11 |
--------------------------------------------------------------------------------
/challenges/1.3.Input/main.py:
--------------------------------------------------------------------------------
1 | ### Modify the code below ###
2 |
3 | #Ask the user for their name!
4 | Name = ''
5 |
6 | #Ask the user for their age!
7 | Age = ''
8 |
9 | print(Name)
10 | print(Age)
11 |
12 | ### Modify the code above ###
13 |
--------------------------------------------------------------------------------
/challenges/2.1.NumberTypes/lesson.md:
--------------------------------------------------------------------------------
1 | ## Python Numbers
2 |
3 | There are 3 distinct numeric types in python.
4 | - int
5 | - float
6 | - complex
7 | - https://docs.python.org/3.6/library/stdtypes.html#numeric-types-int-float-complex
8 |
9 | **Integers** have _unlimited precision_; thus, they can be as large as you need them to be.
10 |
11 | Example: `myInt = 789456123`
12 |
13 | **Floats** are limited to the precision of a C _double_ value. You can check your systems _float precision_ by using the following commands:
14 | ```
15 | import sys
16 | sys.float_info
17 | ```
18 |
19 | Example: `myFloat = 123.4567`
20 |
21 | **Complex** numbers are broken into two parts, a real and imaginary part. Both are floating point numbers and can be accessed using the `.real` and `.imag` properties. You can create a complex number using the `complex(real, imag)` command. In Python, the _imaginary constant_ usually dictated with an `i` is replaced with a `j`.
22 |
23 | Example: `myComplex = complex(2, 3.4) # myComplex = (2+3.4j)`
24 |
25 | **_Instructions:_**
26 | - Assign an integer value to the `myInteger` variable
27 | - Assign a float value to the `myFloat` variable
28 | - Assign a complex value to the `myComplex` variable. Make sure it has both a real and imaginary part.
29 |
--------------------------------------------------------------------------------
/challenges/2.1.NumberTypes/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Numbers",
3 | "chapter_number": 2,
4 | "lesson_number": 1,
5 | "id": "593964fdd230354d7438db34",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/2.1.NumberTypes/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class NumbersTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsInstance(myInteger, int)
7 | self.assertIsInstance(myFloat, float)
8 | self.assertIsInstance(myComplex, complex)
9 |
--------------------------------------------------------------------------------
/challenges/2.1.NumberTypes/main.py:
--------------------------------------------------------------------------------
1 | ### Modify the code below ###
2 |
3 | myInteger = null
4 |
5 | myFloat = null
6 |
7 | myComplex = null
8 |
9 | ### Modify the code above ###
10 |
--------------------------------------------------------------------------------
/challenges/2.2.Strings/lesson.md:
--------------------------------------------------------------------------------
1 | ## Python Strings
2 |
3 | The simplest form of text sequences in Python is a `str` or _strings_.
4 |
5 | To write a string in Python you have 4 options:
6 | 1. Using single quotes: `myStr = 'this allows "double" quotes inside'`
7 | 2. using double quotes: `myStr = "this allows 'single' quotes inside"`
8 | 3. Using triple single quotes:
9 | ```
10 | myStr = '''Three quotes allows
11 | for multiline strings.
12 | Cool right?'''
13 | ```
14 | 4. Using triple double quotes:
15 | ```
16 | myStr = """Three quotes allows
17 | for multiline strings.
18 | Isn't that even cooler?"""
19 | ```
20 |
21 | Strings are considered 'immutable' meaning they can not be changed; however, two strings can be concatenated together using the `+` operator.
22 |
23 | Example:
24 | ```
25 | firstName = 'Jane'
26 | lastName = 'Doe'
27 | fullName = "My full name is: " + firstName + " " + lastName + "."
28 | ```
29 |
30 | **_Instructions:_**
31 | Mini-Mad-Lib:
32 | - Assign strings to each variable.
33 | - Then concatenate everything together in the `mySentence` variable
34 |
--------------------------------------------------------------------------------
/challenges/2.2.Strings/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Strings",
3 | "chapter_number": 2,
4 | "lesson_number": 2,
5 | "id": "5939650ad230354d7438db35",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/2.2.Strings/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class StringsTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsInstance(myName, str)
7 | self.assertIsInstance(myAge, str)
8 | self.assertIsInstance(favoriteActivity, str)
9 | self.assertIsInstance(mySentence, str)
10 |
--------------------------------------------------------------------------------
/challenges/2.2.Strings/main.py:
--------------------------------------------------------------------------------
1 | ### Modify the code below ###
2 |
3 | myName = null
4 |
5 | myAge = null
6 |
7 | favoriteActivity = null
8 |
9 | mySentence = null
10 |
11 | ### Modify the code above ###
12 |
--------------------------------------------------------------------------------
/challenges/2.3.Tuples/lesson.md:
--------------------------------------------------------------------------------
1 | ## Python Tuples
2 |
3 | A tuple is an immutable (cannot be changed) sequence of data.
4 |
5 | Tuples can be constructed in multiple ways:
6 | - Using a pair of parentheses to denote an empty tuple: `()`
7 | - Using a trailing comma for a singleton tuple (one value): `a,` or `(a,)`
8 | - Separating items with commas: `a, b, c` or `(a, b, c)`
9 | - Using the built-in `tuple()`: `tuple('abc') # = ('a', 'b', 'c')`
10 |
11 | When referencing tuples, you say the 'n-tuple' where 'n' is the number of elements.
12 | For example: `myTuple = a, b, c, d, e` myTuple is a 5-tuple.
13 |
14 | **Note** the comma `,` is actually what makes a tuple, not the parentheses `()`.
15 | The parentheses are optional except when they are needed such as for an empty tuple or to avoid ambiguity.
16 | Example: `f(a, b, c)` is a function call with three arguments. `f((a, b, c))` is a function call with one 3-tuple argument.
17 |
18 | **_Instructions_**
19 | - Assign the appropriate length tuples to the given variables
20 | For example: `twoTuple = a, b` and `threeTuple = a, b, c`
21 |
--------------------------------------------------------------------------------
/challenges/2.3.Tuples/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Tuples",
3 | "chapter_number": 2,
4 | "lesson_number": 3,
5 | "id": "59396524d230354d7438db36",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/2.3.Tuples/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class StringsTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsInstance(twoTuple, tuple)
7 | self.assertIsInstance(threeTuple, tuple)
8 | self.assertIsInstance(fiveTuple, tuple)
9 | self.assertIsInstance(tenTuple, tuple)
10 | self.assertEqual(len(twoTuple), 2)
11 | self.assertEqual(len(threeTuple), 3)
12 | self.assertEqual(len(fiveTuple), 5)
13 | self.assertEqual(len(tenTuple), 10)
14 |
--------------------------------------------------------------------------------
/challenges/2.3.Tuples/main.py:
--------------------------------------------------------------------------------
1 | ### Modify the code below ###
2 |
3 | twoTuple = null
4 |
5 | threeTuple = null
6 |
7 | fiveTuple = null
8 |
9 | tenTuple = null
10 |
11 | ### Modify the code above ###
12 |
--------------------------------------------------------------------------------
/challenges/2.4.Lists/lesson.md:
--------------------------------------------------------------------------------
1 | ## Python Lists
2 |
3 | Similar to JavaScript array notation, a python list is written as a list of comma-separated values between square brackets. They can contain items of different types, but usually don't.
4 |
5 | `myList = [ 11, 4, 35, 96 ]`
6 |
7 | Lists are very similar to strings, but have one very important difference. Lists are **mutable**, strings are immutable. This means the contents of a list can change.
8 |
9 | `myList[3] = 64 # = [ 11, 4, 35, 64 ]`
10 |
11 | Lists are similar to strings because they can be indexed, sequenced, and concatenated.
12 | `myList[0] # = 11`
13 |
14 | `myList[0:2] # = [11, 4]`
15 |
16 | `myList + [ 342, 598 ] # = [ 11, 4, 35, 64, 342, 598 ]`
17 |
18 | Finally, lists can even contain other lists! This is called "multidimensional":
19 |
20 | `my2by2 = [ [ 5, 6 ], [ 4, 2 ] ]`
21 |
22 | **_Instructions_**
23 | - Assign a list of numbers, length 5 to the variable `mediumList`
24 | - Assign a list of numbers, length 2 to the variable `shortList`
25 | - Concatenate the two lists together and assign it to the variable `longList`
26 |
--------------------------------------------------------------------------------
/challenges/2.4.Lists/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Lists",
3 | "chapter_number": 2,
4 | "lesson_number": 4,
5 | "id": "593967e6d230354d7438db39",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/2.4.Lists/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class StringsTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsInstance(mediumList, list)
7 | self.assertIsInstance(shortList, list)
8 | self.assertIsInstance(longList, list)
9 | self.assertEqual(len(mediumList), 5)
10 | self.assertEqual(len(shortList), 2)
11 | self.assertEqual(len(longList), 7)
12 |
--------------------------------------------------------------------------------
/challenges/2.4.Lists/main.py:
--------------------------------------------------------------------------------
1 | ### Modify the code below ###
2 |
3 | mediumList = null
4 |
5 | shortList = null
6 |
7 | longList = null
8 |
9 | ### Modify the code above ###
10 |
--------------------------------------------------------------------------------
/challenges/2.5.Sets/lesson.md:
--------------------------------------------------------------------------------
1 | ## Python Sets
2 |
3 | Python is filled with list-like data structures. **Sets** are unordered collections with no duplicate entries. Useful for membership management (no duplication usernames/emails) or discrete mathematics, sets support many mathematical operations such as union, intersection, difference, and symmetric difference.
4 |
5 | You can use the set() function or a pair of `{}` curly braces to create a set. Empty sets must be created using the set() function only as an empty set of curly braces results in an empty dictionary (up next).
6 |
7 | `mySet = { 1, 4, 6, 9 }`
8 |
9 | By passing a string to the `set()` function, it will generate a set and remove all duplicate letters in the string.
10 |
11 | `x = set('mississippi') # { 'm', 'i', 's', 'p' }`
12 |
13 | Here are some of the mathematical operations mentioned earlier:
14 | ```
15 | a = { 1, 2, 3, 4, 5 }
16 | b = { 4, 5, 6 }
17 |
18 | a - b # {1, 2, 3} letters in a not in b
19 | a | b # { 1, 2, 3, 4, 5, 6 } letters in a or b or both
20 | a & b # { 4, 5 } letters in both a and b
21 | a ^ b # { 1, 2, 3, 6 } letters in a or b but not both
22 | ```
23 |
24 | **_Instructions_**
25 | - Remove all duplicates from the string 'FreeCodeCamp Rulez' using the `set()` function. Assign it to the `fccSet` variable.
26 |
--------------------------------------------------------------------------------
/challenges/2.5.Sets/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Sets",
3 | "chapter_number": 2,
4 | "lesson_number": 5,
5 | "id": "593967ddd230354d7438db38",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/2.5.Sets/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class StringsTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsInstance(fccSet, set)
7 | self.assertEqual(len(fccSet), 14)
8 |
--------------------------------------------------------------------------------
/challenges/2.5.Sets/main.py:
--------------------------------------------------------------------------------
1 | ### Modify the code below ###
2 |
3 | fccSet = null
4 |
5 | ### Modify the code above ###
6 |
--------------------------------------------------------------------------------
/challenges/2.6.Dictionaries/lesson.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/freeCodeCamp/python-coding-challenges/b435ab650d85de267eeaa31a55ff77ef5dbff86b/challenges/2.6.Dictionaries/lesson.md
--------------------------------------------------------------------------------
/challenges/2.6.Dictionaries/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Dictionaries",
3 | "chapter_number": 2,
4 | "lesson_number": 6,
5 | "id": "593967d4d230354d7438db37",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/2.6.Dictionaries/lesson_tests.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/freeCodeCamp/python-coding-challenges/b435ab650d85de267eeaa31a55ff77ef5dbff86b/challenges/2.6.Dictionaries/lesson_tests.py
--------------------------------------------------------------------------------
/challenges/2.6.Dictionaries/main.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/freeCodeCamp/python-coding-challenges/b435ab650d85de267eeaa31a55ff77ef5dbff86b/challenges/2.6.Dictionaries/main.py
--------------------------------------------------------------------------------
/challenges/3.1.Assignment_Operator/lesson.md:
--------------------------------------------------------------------------------
1 | ## Python Assignment Operator
2 |
3 | In Python the assignment operator is represented by a single equal sign (=).
4 | The assignment operator assigns a value on the right side of the equal sign to a variable on the left.
5 | Python reads this line from left to right, and it is called an assignment statement.
6 | - https://docs.python.org/3.6/reference/simple_stmts.html#assignment-statements
7 | ```
8 | >>> letter = 'a'
9 | >>> print(letter)
10 | a
11 | >>> number = 42
12 | >>> print(number)
13 | 42
14 | >>> number = 3.14
15 | >>> print(number)
16 | 3.14
17 | ```
18 |
19 | **_Instructions:_**
20 | **Time to introduce yourself, fledgling Pythonista!**
21 | **In the console, create a variable called my_name.**
22 | **Assign a string containing your name to the variable my_name.**
23 |
--------------------------------------------------------------------------------
/challenges/3.1.Assignment_Operator/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Assignment Operator",
3 | "chapter_number": 3,
4 | "lesson_number": 1,
5 | "id":"59381b056f0201972cc968b1",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/3.1.Assignment_Operator/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class AssignmentOperatorTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsNotNone(my_name)
7 | self.assertIsInstance(my_name, str)
8 |
--------------------------------------------------------------------------------
/challenges/3.1.Assignment_Operator/main.py:
--------------------------------------------------------------------------------
1 | ### Write your code below this line. ###
2 |
3 |
4 |
5 | ### Write your code above this line. ###
6 |
7 | print("Hello, my name is " + my_name)
8 |
--------------------------------------------------------------------------------
/challenges/3.2.Equality_Operator/lesson.md:
--------------------------------------------------------------------------------
1 | ## Python Equality Operator
2 |
3 | The equality operator (==) compares two values and returns True if they're equivalent or False if they are not.
4 | Note that equality is different from assignment (=), which assigns the value at the right of the operator to a variable in the left.
5 | - https://docs.python.org/3/reference/expressions.html#comparisons
6 | - https://docs.python.org/3/reference/expressions.html#value-comparisons
7 | - https://docs.python.org/3/library/operator.html#mapping-operators-to-functions
8 | - https://docs.python.org/3/library/operator.html#operator.eq
9 | ```
10 | >>> a = 3
11 | >>> b = 3
12 | >>> a == b
13 | True
14 | >>> a == 4
15 | False
16 | >>> b == 3
17 | True
18 | ```
19 |
20 | **_Instructions:_**
21 | **In the console there is a function named equality with a single argument named value.**
22 | **The function contains an incomplete if/else statement.**
23 | **Complete the if statement so that the string "Equal to 12" will be returned when the variable value is equivalent to 12.**
24 |
--------------------------------------------------------------------------------
/challenges/3.2.Equality_Operator/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Equality Operator",
3 | "chapter_number": 3,
4 | "lesson_number": 2,
5 | "id":"59382d5b5b0de5a15275c053",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/3.2.Equality_Operator/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class EqualityOperatorTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsNotNone(equality(12))
7 | self.assertIsInstance(equality(12), str)
8 | self.assertEqual(equality(12), 'Equal to 12')
9 | self.assertNotEqual(equality(12), 'Not Equal to 12')
10 |
11 | def test_operator_presence(self):
12 | f = open('main.py')
13 | lines = str(f.readlines())
14 | f.close()
15 | self.assertRegex(lines, '==', msg="The == operator is not in the function definition")
16 |
--------------------------------------------------------------------------------
/challenges/3.2.Equality_Operator/main.py:
--------------------------------------------------------------------------------
1 | def equality(value):
2 | # Complete the if statement on the next line using value, the equality operator (==), and the number 12.
3 | if :
4 | ### Your code goes above this line ###
5 | return "Equal to 12"
6 | else:
7 | return "Not Equal to 12"
8 |
9 | print(equality(12))
10 |
--------------------------------------------------------------------------------
/challenges/3.3.Inequality_Operator/lesson.md:
--------------------------------------------------------------------------------
1 | ## Python Inequality Operator
2 |
3 | The inequality operator (!=) does the opposite of the equality operator, as you may have already guessed.
4 | It means "Not Equal" and returns False where the equality operator would return True and vice versa.
5 | - https://docs.python.org/3/reference/expressions.html#comparisons
6 | - https://docs.python.org/3/reference/expressions.html#value-comparisons
7 | - https://docs.python.org/3/library/operator.html#mapping-operators-to-functions
8 | - https://docs.python.org/3/library/operator.html#operator.ne
9 | ```
10 | >>> a = 1
11 | >>> b = 2
12 | >>> a != b
13 | True
14 | >>> a != 1
15 | False
16 | >>> a != 2
17 | True
18 | ```
19 |
20 | **_Instructions:_**
21 | **In the console there is a function named inequality with a single argument named value.**
22 | **The function contains an incomplete if/else statement.**
23 | **Complete the if statement so that the string "Not Equal to 13" will be returned when the variable is equivalent to 13.**
24 |
--------------------------------------------------------------------------------
/challenges/3.3.Inequality_Operator/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Inequality Operator",
3 | "chapter_number": 3,
4 | "lesson_number": 3,
5 | "id":"59382dac5b0de5a15275c054",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/3.3.Inequality_Operator/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class InEqualityOperatorTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsNotNone(inequality(13))
7 | self.assertIsInstance(inequality(13), str)
8 | self.assertEqual(inequality(13), 'Equal to 13')
9 | self.assertNotEqual(inequality(13), 'Not Equal to 13')
10 |
11 | def test_operator_presence(self):
12 | f = open('main.py')
13 | lines = str(f.readlines())
14 | f.close()
15 | self.assertRegex(lines, '!=', msg="The != operator is not in the function definition")
16 |
--------------------------------------------------------------------------------
/challenges/3.3.Inequality_Operator/main.py:
--------------------------------------------------------------------------------
1 | def inequality(value):
2 | # Complete the if statement on the next line using value, the inequality operator (!=), and the number 13.
3 | if value != 13:
4 | ### Your code goes above this line ###
5 | return "Not Equal to 13"
6 | else:
7 | return "Equal to 13"
8 |
9 | print(inequality(100))
10 |
--------------------------------------------------------------------------------
/challenges/3.4.Strictly_Less_Than_Operator/lesson.md:
--------------------------------------------------------------------------------
1 | ## Python Strictly Less Than Operator
2 |
3 | The less than operator (<) compares the values of two numbers.
4 | If the number to the left is less than the number to the right, it returns True.
5 | Otherwise, it returns False.
6 | - https://docs.python.org/3/reference/expressions.html#comparisons
7 | - https://docs.python.org/3/reference/expressions.html#value-comparisons
8 | - https://docs.python.org/3/library/operator.html#mapping-operators-to-functions
9 | - https://docs.python.org/3/library/operator.html#operator.lt
10 | ```
11 | >>> a = 3
12 | >>> b = 13
13 | >>> a < b
14 | True
15 | >>> b < a
16 | False
17 | >>> b < 20
18 | True
19 | ```
20 |
21 | **_Instructions:_**
22 | **In the console, there is a function named strictly_less_than() that has an if-elif-else statement.**
23 | **In the lines with the 'if' and 'elif' clauses, fill in the less than operator and the appropriate values to make the function run properly.**
24 |
--------------------------------------------------------------------------------
/challenges/3.4.Strictly_Less_Than_Operator/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Strictly Less Than Operator",
3 | "chapter_number": 3,
4 | "lesson_number": 4,
5 | "id":"59382e635b0de5a15275c055",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/3.4.Strictly_Less_Than_Operator/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class StrictlyLessThanOperatorTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsNotNone(strictly_less_than(1))
7 | self.assertIsInstance(strictly_less_than(1), str)
8 | self.assertEqual(strictly_less_than(1), "Less than 10")
9 | self.assertEqual(strictly_less_than(9), "Less than 10")
10 | self.assertEqual(strictly_less_than(10), "Less than 100")
11 | self.assertEqual(strictly_less_than(99), "Less than 100")
12 | self.assertEqual(strictly_less_than(100), "100 or more")
13 | self.assertEqual(strictly_less_than(110), "100 or more")
14 |
15 | def test_operator_presence(self):
16 | f = open('main.py')
17 | lines = str(f.readlines())
18 | f.close()
19 | self.assertRegex(lines, '<', msg="The < operator is not in the function definition")
20 |
--------------------------------------------------------------------------------
/challenges/3.4.Strictly_Less_Than_Operator/main.py:
--------------------------------------------------------------------------------
1 | def strictly_less_than(value):
2 | if value : # Change this line
3 | return "Less than 10"
4 | elif value : # Change this line
5 | return "Less than 100"
6 | else:
7 | return "100 or more"
8 |
9 | # Change the value 1 below to experiment with different values
10 | print(strictly_less_than(1))
11 |
--------------------------------------------------------------------------------
/challenges/3.5.Less_Than_Equal_To_Operator/lesson.md:
--------------------------------------------------------------------------------
1 | ## Python Less Than or Equal To Operator
2 |
3 | The less than or equal to operator (<=) compares the values of two numbers.
4 | If the number to the left is less than or equal the number to the right, it returns True.
5 | If the number on the left is greater than the number on the right, it returns False.
6 | - https://docs.python.org/3/reference/expressions.html#comparisons
7 | - https://docs.python.org/3/reference/expressions.html#value-comparisons
8 | - https://docs.python.org/3/library/operator.html#mapping-operators-to-functions
9 | - https://docs.python.org/3/library/operator.html#operator.le
10 | ```
11 | >>> a = 2
12 | >>> b = 2
13 | >>> c = 3
14 | >>> a <= b
15 | True
16 | >>> c <= a
17 | False
18 | >>> b <= c
19 | True
20 | ```
21 |
22 | **_Instructions:_**
23 | **In the console, there is a function named less_or_equal() that has an if-elif-else statement.**
24 | **In the lines with the 'if' and 'elif' clauses, fill in the less-than-equal-to operator and the appropriate values to make the function run properly.**
25 |
--------------------------------------------------------------------------------
/challenges/3.5.Less_Than_Equal_To_Operator/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Less Than or Equal to Operator",
3 | "chapter_number": 3,
4 | "lesson_number": 5,
5 | "id":"59382eda5b0de5a15275c056",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/3.5.Less_Than_Equal_To_Operator/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class GreaterThanEqualToOperatorTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsNotNone(less_or_equal(1))
7 | self.assertIsInstance(less_or_equal(1), str)
8 | self.assertEqual(less_or_equal(1), "25 or less")
9 | self.assertEqual(less_or_equal(25), "25 or less")
10 | self.assertEqual(less_or_equal(26), "75 or less")
11 | self.assertEqual(less_or_equal(75), "75 or less")
12 | self.assertEqual(less_or_equal(76), "More than 75")
13 | self.assertEqual(less_or_equal(100), "More than 75")
14 |
15 | def test_operator_presence(self):
16 | f = open('main.py')
17 | lines = str(f.readlines())
18 | f.close()
19 | self.assertRegex(lines, '<=', msg="The <= operator is not in the function definition")
20 |
--------------------------------------------------------------------------------
/challenges/3.5.Less_Than_Equal_To_Operator/main.py:
--------------------------------------------------------------------------------
1 | def less_or_equal(value):
2 | if value : # Change this line
3 | return "25 or less"
4 | elif value : # Change this line
5 | return "75 or less"
6 | else:
7 | return "More than 75"
8 |
9 | # Change the value 1 below to experiment with different values
10 | print(less_or_equal(1))
11 |
--------------------------------------------------------------------------------
/challenges/3.6.Greater_Than_Equal_To_Operator/lesson.md:
--------------------------------------------------------------------------------
1 | ## Python Greater Than or Equal To Operator
2 |
3 | The greater than or equal to operator (>=) compares the values of two numbers.
4 | If the number to the left is greater than or equal to the number to the right, it returns True.
5 | Otherwise, it returns False.
6 | - https://docs.python.org/3/reference/expressions.html#comparisons
7 | - https://docs.python.org/3/reference/expressions.html#value-comparisons
8 | - https://docs.python.org/3/library/operator.html#mapping-operators-to-functions
9 | - https://docs.python.org/3/library/operator.html#operator.ge
10 | ```
11 | >>> a = 2
12 | >>> b = 2
13 | >>> c = 3
14 | >>> a >= b
15 | True
16 | >>> a >= c
17 | False
18 | >>> c >= b
19 | True
20 | ```
21 |
22 | **_Instructions:_**
23 | **In the console, there is a function named greater_or_equal() that has an if-elif-else statement.**
24 | **In the lines with the 'if' and 'elif' clauses, fill in the greater-than-equal-to operator and the appropriate values to make the function run properly.**
25 |
--------------------------------------------------------------------------------
/challenges/3.6.Greater_Than_Equal_To_Operator/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Greater Than or Equal To Operator",
3 | "chapter_number": 3,
4 | "lesson_number": 6,
5 | "id":"59382f645b0de5a15275c057",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/3.6.Greater_Than_Equal_To_Operator/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class GreaterThanEqualToOperatorTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsNotNone(greater_or_equal(1))
7 | self.assertIsInstance(greater_or_equal(1), str)
8 | self.assertEqual(greater_or_equal(1), "Less than 20")
9 | self.assertEqual(greater_or_equal(19), "Less than 20")
10 | self.assertEqual(greater_or_equal(20), "20 or more")
11 | self.assertEqual(greater_or_equal(49), "20 or more")
12 | self.assertEqual(greater_or_equal(50), "50 or more")
13 | self.assertEqual(greater_or_equal(51), "50 or more")
14 |
15 | def test_operator_presence(self):
16 | f = open('main.py')
17 | lines = str(f.readlines())
18 | f.close()
19 | self.assertRegex(lines, '>=', msg="The >= operator is not in the function definition")
20 |
--------------------------------------------------------------------------------
/challenges/3.6.Greater_Than_Equal_To_Operator/main.py:
--------------------------------------------------------------------------------
1 | def greater_or_equal(value):
2 | if value : # Change this line
3 | return "50 or more"
4 | elif value : # Change this line
5 | return "20 or more"
6 | else:
7 | return "Less than 20"
8 |
9 | # Change the value 1 below to experiment with different values
10 | print(greater_or_equal(1))
11 |
--------------------------------------------------------------------------------
/challenges/3.7.Strictly_Greater_Than_Operator/lesson.md:
--------------------------------------------------------------------------------
1 | ## Python Strictly Greater Than Operator
2 |
3 | The greater than operator (>) compares the values of two numbers.
4 | If the number to the left is greater than the number to the right, it returns True.
5 | Otherwise, it returns False.
6 | - https://docs.python.org/3/reference/expressions.html#comparisons
7 | - https://docs.python.org/3/reference/expressions.html#value-comparisons
8 | - https://docs.python.org/3/library/operator.html#mapping-operators-to-functions
9 | - https://docs.python.org/3/library/operator.html#operator.gt
10 | ```
11 | >>> a = 7
12 | >>> b = 17
13 | >>> a > b
14 | False
15 | >>> b > a
16 | True
17 | >>> b > 10
18 | True
19 | ```
20 |
21 | **_Instructions:_**
22 | **Time to fill in the blanks!**
23 | **In the console, there is a function named strictly_greater_than() that has an if-elif-else statement.**
24 | **In the lines with the 'if' and 'elif' clauses, fill in the greater than operator and the appropriate values to make the function run properly.**
25 |
--------------------------------------------------------------------------------
/challenges/3.7.Strictly_Greater_Than_Operator/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Strictly Greater Than Operator",
3 | "chapter_number": 3,
4 | "lesson_number": 7,
5 | "id":"59382fc85b0de5a15275c058",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/3.7.Strictly_Greater_Than_Operator/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class StrictlyGreaterThanOperatorTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsNotNone(strictly_greater_than(1))
7 | self.assertIsInstance(strictly_greater_than(1), str)
8 | self.assertEqual(strictly_greater_than(1), "10 or less")
9 | self.assertEqual(strictly_greater_than(10), "10 or less")
10 | self.assertEqual(strictly_greater_than(11), "Greater than 10")
11 | self.assertEqual(strictly_greater_than(99), "Greater than 10")
12 | self.assertEqual(strictly_greater_than(100), "Greater than 10")
13 | self.assertEqual(strictly_greater_than(101), "Greater than 100")
14 | self.assertEqual(strictly_greater_than(111), "Greater than 100")
15 |
16 | def test_operator_presence(self):
17 | f = open('main.py')
18 | lines = str(f.readlines())
19 | f.close()
20 | self.assertRegex(lines, '>', msg="The > operator is not in the function definition")
21 |
--------------------------------------------------------------------------------
/challenges/3.7.Strictly_Greater_Than_Operator/main.py:
--------------------------------------------------------------------------------
1 | def strictly_greater_than(value):
2 | if value : # Change this line
3 | return "Greater than 100"
4 | elif value : # Change this line
5 | return "Greater than 10"
6 | else:
7 | return "10 or less"
8 |
9 | # Change the value 1 below to experiment with different values
10 | print(strictly_greater_than(1))
11 |
--------------------------------------------------------------------------------
/challenges/3.8.False_Operator/lesson.md:
--------------------------------------------------------------------------------
1 | ## Python `False` Operator
2 |
3 | In Python, the `False` keyword is the False value of type `bool` and can be used to directly assign boolean values.
4 | Assignments to `False` are illegal and raise a `SyntaxError`.
5 | Any Python object can be tested for truth value, and the following values are considered false:
6 | - None
7 | - False
8 | - zero of any numeric type, for example, 0, 0.0, 0j.
9 | - any empty sequence, for example, '', (), [].
10 | - any empty mapping, for example, {}.
11 | - instances of user-defined classes, if the class defines a \_\_bool\_\_() or \_\_len\_\_() method, when that method returns the integer zero or bool value False.
12 |
13 | All other values are considered true — so objects of many types are always true.
14 |
15 | - https://docs.python.org/3/library/constants.html
16 | - https://docs.python.org/3/library/stdtypes.html#truth
17 | - https://docs.python.org/3/library/operator.html?highlight=true#operator.truth
18 | - https://docs.python.org/3/library/functions.html#bool
19 | - https://docs.python.org/3/library/stdtypes.html#boolean-values
20 | - https://docs.python.org/3/reference/expressions.html#boolean-operations
21 | ```
22 | >>> False
23 | False
24 | >>> not True
25 | False
26 | >>> 1 > 2
27 | False
28 | >>> bool('')
29 | False
30 | ```
31 |
32 | **_Instructions:_**
33 | **In the console there is a function named boolean_false() that returns an undefined variable named value.**
34 | **Running the function as it is will result in a NameError.**
35 | **Change the variable named value so that the function returns the boolean value False.**
36 |
--------------------------------------------------------------------------------
/challenges/3.8.False_Operator/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "False Operator",
3 | "chapter_number": 3,
4 | "lesson_number": 8,
5 | "id":"59382ff35b0de5a15275c059",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/3.8.False_Operator/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class BooleanFalseKeywordTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsNotNone(boolean_false())
7 | self.assertIsInstance(boolean_false(), bool)
8 | self.assertFalse(boolean_false())
9 | self.assertEqual(boolean_false(), False)
10 |
--------------------------------------------------------------------------------
/challenges/3.8.False_Operator/main.py:
--------------------------------------------------------------------------------
1 | def boolean_false():
2 | return value # Change the variable named value to the correct answer
3 |
4 | print(boolean_false())
5 |
--------------------------------------------------------------------------------
/challenges/3.9.True_Operator/lesson.md:
--------------------------------------------------------------------------------
1 | ## Python `True` Operator
2 |
3 | In Python, the `True` keyword is the true value of type `bool` and can be used to directly assign boolean values.
4 | Assignments to `True` are illegal and raise a `SyntaxError`.
5 | Any Python object can be tested for truth value, so objects of many types can have a boolean context of true, including any nonzero number, nonempty strings and lists, and so on.
6 | - https://docs.python.org/3/library/constants.html
7 | - https://docs.python.org/3/library/stdtypes.html#truth
8 | - https://docs.python.org/3/library/operator.html?highlight=true#operator.truth
9 | - https://docs.python.org/3/library/functions.html#bool
10 | - https://docs.python.org/3/library/stdtypes.html#boolean-values
11 | - https://docs.python.org/3/reference/expressions.html#boolean-operations
12 | ```
13 | >>> True
14 | True
15 | >>> not False
16 | True
17 | >>> 1 < 2
18 | True
19 | >>> bool('any non-empty string')
20 | True
21 | ```
22 |
23 | **_Instructions:_**
24 | **In the console there is a function named boolean_true() that returns an undefined variable named value.**
25 | **Running the function as it is will result in a NameError.**
26 | **Change the variable named value so that the function returns the boolean value True.**
27 |
--------------------------------------------------------------------------------
/challenges/3.9.True_Operator/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "True Operator",
3 | "chapter_number": 3,
4 | "lesson_number": 9,
5 | "id":"593830b05b0de5a15275c05a",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/3.9.True_Operator/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class BooleanTrueKeywordTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsNotNone(boolean_true())
7 | self.assertIsInstance(boolean_true(), bool)
8 | self.assertTrue(boolean_true())
9 | self.assertEqual(boolean_true(), True)
10 |
--------------------------------------------------------------------------------
/challenges/3.9.True_Operator/main.py:
--------------------------------------------------------------------------------
1 | def boolean_true():
2 | return value # Change the varable named value to the correct answer
3 |
4 | print(boolean_true())
5 |
--------------------------------------------------------------------------------
/challenges/3.A.Logical_And_Operator/lesson.md:
--------------------------------------------------------------------------------
1 | ## Python Logical `and` Operator
2 |
3 | The `and` operator is used in the context of boolean operations to determine whether a statement is true or false.
4 | If both arguments (or all if there are more than two) in a statement are true, then the entire statement is true.
5 | If any of the arguments in the statement are false, the operation short-circuits (stops) at the first false argument and returns that value.
6 | For example, the expression `x and y` first evaluates x and proceeds from left to right.
7 | If x is false, the operation stops (short-circuits), and its value (False) is returned.
8 | Otherwise, y is evaluated and the resulting value (True or False) is returned.
9 | Either way, the `and` operator returns the boolean value of the last evaluated argument.
10 | - https://docs.python.org/3/reference/expressions.html#boolean-operations
11 | - https://docs.python.org/3.6/library/stdtypes.html#boolean-operations-and-or-not
12 | - https://docs.python.org/3/library/stdtypes.html#boolean-values
13 | - https://docs.python.org/3/library/functions.html#bool
14 | ```
15 | >>> False and True
16 | False
17 | >>> True and True
18 | True
19 | >>> True and True and False
20 | False
21 | ```
22 |
23 | **_Instructions:_**
24 | **In the console there is a function named boolean_and() which has a single parameter named value.**
25 | **Inside of boolean_and() there is an if-else statement with an incomplete if clause.**
26 | **Fill in the if clause so that if value is greater than or equal to 25 AND less than or equal to 50, then the function will return "Pass".**
27 |
--------------------------------------------------------------------------------
/challenges/3.A.Logical_And_Operator/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Logical And Operator",
3 | "chapter_number": 3,
4 | "lesson_number": 10,
5 | "id":"593831095b0de5a15275c05b",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/3.A.Logical_And_Operator/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class BooleanAndOperatorTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsNotNone(boolean_and(30))
7 | self.assertEqual(boolean_and(1), "Try Again")
8 | self.assertEqual(boolean_and(24), "Try Again")
9 | self.assertEqual(boolean_and(25), "Pass")
10 | self.assertEqual(boolean_and(45), "Pass")
11 | self.assertEqual(boolean_and(50), "Pass")
12 | self.assertEqual(boolean_and(51), "Try Again")
13 |
--------------------------------------------------------------------------------
/challenges/3.A.Logical_And_Operator/main.py:
--------------------------------------------------------------------------------
1 | def boolean_and(value):
2 | if value: # Complete the if clause on this line
3 | return "Pass"
4 | else:
5 | return "Try Again"
6 |
7 | print(boolean_and(40)) # Change this value to test
8 |
--------------------------------------------------------------------------------
/challenges/3.B.Logical_Not_Operator/lesson.md:
--------------------------------------------------------------------------------
1 | ## Python Logical `not` Operator
2 |
3 | The `not` operator is used in the context of boolean operations to determine whether a statement is true or false.
4 | The `not` operator yields True if its argument is false, and False otherwise.
5 | In other words, `not` reverses the logical state of the object it is referring to.
6 | - https://docs.python.org/3/reference/expressions.html#boolean-operations
7 | - https://docs.python.org/3.6/library/stdtypes.html#boolean-operations-and-or-not
8 | - https://docs.python.org/3/library/stdtypes.html#boolean-values
9 | - https://docs.python.org/3/library/functions.html#bool
10 | ```
11 | >>> True
12 | True
13 | >>> not True
14 | False
15 | >>> not False
16 | True
17 | ```
18 |
19 | **_Instructions:_**
20 | **In the console, there is a function named boolean_not with a single parameter named value.**
21 | **Replace the pass statement with a line of code that will return the opposite boolean expression of value.**
22 |
--------------------------------------------------------------------------------
/challenges/3.B.Logical_Not_Operator/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Logical Not Operator",
3 | "chapter_number": 3,
4 | "lesson_number": 11,
5 | "id":"593832b25b0de5a15275c05c",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/3.B.Logical_Not_Operator/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class BooleanNotOperatorTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsNotNone(boolean_not(True))
7 | self.assertIsInstance(boolean_not('any object'), bool)
8 | self.assertEqual(boolean_not(True), False)
9 | self.assertEqual(boolean_not('True'), False)
10 | self.assertFalse(boolean_not(True))
11 |
--------------------------------------------------------------------------------
/challenges/3.B.Logical_Not_Operator/main.py:
--------------------------------------------------------------------------------
1 | def boolean_not(value):
2 | pass # replace the pass statement with the correct code
3 |
4 | print(boolean_not(True))
5 |
--------------------------------------------------------------------------------
/challenges/3.C.Logical_Or_Operator/lesson.md:
--------------------------------------------------------------------------------
1 | ## Python Logical `or` Operator
2 |
3 | The `or` operator is used in the context of boolean operations to determine whether a statement is true or false.
4 | The `or` operator is [inclusive](https://en.wiktionary.org/wiki/inclusive_or), meaning that the statement is true if any or all of the arguments are true, and the statement is false if and only if all of the arguments are false.
5 | For example, the expression `x or y` first evaluates x and proceeds from left to right.
6 | If x is true, the operation stops (short-circuits), and its value (True) is returned.
7 | If x is false, then y is evaluated and the resulting value (True or False) is returned.
8 | - https://docs.python.org/3/reference/expressions.html#boolean-operations
9 | - https://docs.python.org/3.6/library/stdtypes.html#boolean-operations-and-or-not
10 | - https://docs.python.org/3/library/stdtypes.html#boolean-values
11 | - https://docs.python.org/3/library/functions.html#bool
12 | ```
13 | >>> True or True
14 | True
15 | >>> True or False
16 | True
17 | >>> True or True or False
18 | True
19 | >>> True or False or False
20 | True
21 | >>> False or False or False
22 | False
23 | ```
24 |
25 | **_Instructions:_**
26 | **In the console there is a function named boolean_or() which has a single parameter named value.**
27 | **Inside of boolean_or() there is an if-else statement with an incomplete if clause.**
28 | **Fill in the if clause so that if value is between 50 and 100 (inclusive, meaning both 50 and 100 are valid answers), then the function will return "Pass".**
29 |
--------------------------------------------------------------------------------
/challenges/3.C.Logical_Or_Operator/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Logical Or Operator",
3 | "chapter_number": 3,
4 | "lesson_number": 12,
5 | "id":"5938330f5b0de5a15275c05d",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/3.C.Logical_Or_Operator/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class BooleanOrOperatorTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsNotNone(boolean_or(75))
7 | self.assertEqual(boolean_or(1), "Try Again")
8 | self.assertEqual(boolean_or(49), "Try Again")
9 | self.assertEqual(boolean_or(50), "Pass")
10 | self.assertEqual(boolean_or(75), "Pass")
11 | self.assertEqual(boolean_or(100), "Pass")
12 | self.assertEqual(boolean_or(101), "Try Again")
13 |
--------------------------------------------------------------------------------
/challenges/3.C.Logical_Or_Operator/main.py:
--------------------------------------------------------------------------------
1 | def boolean_or(value):
2 | if value: # Complete the if clause on this line
3 | return "Try Again"
4 | else:
5 | return "Pass"
6 |
7 | print(boolean_or(75)) # Change this value to test
8 |
--------------------------------------------------------------------------------
/challenges/3.D.Is_Operator/lesson.md:
--------------------------------------------------------------------------------
1 | ## Python is Operator
2 |
3 | Python's is operator tests for object identity, or whether two different variables are pointing to the same object.
4 | In other words, the statement 'x is y' is true if and only if x and y are the same object.
5 | Object identity is determined using the id() function.
6 | This is different from the equality operator (==), which tests only if two objects are equivalent.
7 | - https://docs.python.org/3.6/reference/expressions.html#is-not
8 | - https://docs.python.org/3.6/library/functions.html#id
9 | - https://docs.python.org/3.6/library/stdtypes.html#comparisons
10 | - https://docs.python.org/3/reference/expressions.html#operator-precedence
11 | ```
12 | >>> a = 1
13 | >>> b = 1
14 | >>> c = 1.0
15 | >>> id(a)
16 | 4472656448
17 | >>> id(b)
18 | 4472656448
19 | >>> id(c)
20 | 4474138816
21 | >>> a is b
22 | True
23 | >>> a is c
24 | False
25 | >>> a == c
26 | True
27 | ```
28 |
29 | **_Instructions:_**
30 | **In the console, there is a function named identity_test that contains an if-else statement.**
31 | **Fill in the missing code in the 'if' clause that will make the function run properly.**
32 |
--------------------------------------------------------------------------------
/challenges/3.D.Is_Operator/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Is Operator",
3 | "chapter_number": 3,
4 | "lesson_number": 13,
5 | "id":"593833575b0de5a15275c05e",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/3.D.Is_Operator/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class IdentityOperatorTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsNotNone(identity_test(42))
7 | self.assertIsInstance(identity_test(42), str)
8 | self.assertEqual(identity_test(42), "Same object")
9 | self.assertEqual(identity_test(1), "Different object")
10 | self.assertNotEqual(identity_test(42), "Different object")
11 |
--------------------------------------------------------------------------------
/challenges/3.D.Is_Operator/main.py:
--------------------------------------------------------------------------------
1 | def identity_test(value):
2 | if value : # Change this line
3 | return "Same object"
4 | else:
5 | return "Different object"
6 |
7 | # Change the value 42 below to experiment with different values
8 | print(identity_test(42))
9 |
--------------------------------------------------------------------------------
/challenges/3.E.Is_Not_Operator/lesson.md:
--------------------------------------------------------------------------------
1 | ## Python is not Operator
2 |
3 | Python's is not operator tests for _negative_ object identity, or whether two different variables are pointing to different objects.
4 | In other words, the statement 'x is not y' is true if and only if x and y are _not_ the same object.
5 | Object identity is determined using the id() function.
6 | This is different from the inequality operator (!=), which compares two values and returns False if they're equivalent or True if they are not.
7 | - https://docs.python.org/3.6/reference/expressions.html#is-not
8 | - https://docs.python.org/3.6/library/functions.html#id
9 | - https://docs.python.org/3.6/library/stdtypes.html#comparisons
10 | - https://docs.python.org/3/reference/expressions.html#operator-precedence
11 | ```
12 | >>> a = 1
13 | >>> b = 1
14 | >>> c = 1.0
15 | >>> id(a)
16 | 4363379264
17 | >>> id(b)
18 | 4363379264
19 | >>> id(c)
20 | 4364861632
21 | >>> a is not b
22 | False
23 | >>> a is not c
24 | True
25 | >>> b is not c
26 | True
27 | ```
28 |
29 | **_Instructions:_**
30 | **In the console, there is a function named negative_identity_test that contains an if-else statement.**
31 | **Fill in the missing code in the 'if' clause that will make the function run properly.**
32 |
--------------------------------------------------------------------------------
/challenges/3.E.Is_Not_Operator/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Is Not Operator",
3 | "chapter_number": 3,
4 | "lesson_number": 14,
5 | "id":"593833b65b0de5a15275c05f",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/3.E.Is_Not_Operator/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class NegativeIdentityOperatorTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsNotNone(negative_identity_test(84))
7 | self.assertIsInstance(negative_identity_test(84), str)
8 | self.assertEqual(negative_identity_test(84), "Same object")
9 | self.assertEqual(negative_identity_test("Anything other than 84"), "Different object")
10 | self.assertEqual(negative_identity_test(1), "Different object")
11 |
--------------------------------------------------------------------------------
/challenges/3.E.Is_Not_Operator/main.py:
--------------------------------------------------------------------------------
1 | def negative_identity_test(value):
2 | if value : # Change this line
3 | return "Different object"
4 | else:
5 | return "Same object"
6 |
7 | # Change the value 84 below to experiment with different values
8 | print(negative_identity_test(84))
9 |
--------------------------------------------------------------------------------
/challenges/3.F.In_Operator/lesson.md:
--------------------------------------------------------------------------------
1 | ## Python in Operator
2 |
3 | Python's in operator is a type of comparison operator that tests for membership.
4 | The in operator evaluates to True if it finds a variable in the specified sequence and False otherwise.
5 | In other words, the statement 'x in y' is true if and only if the object x is found in the object y.
6 |
7 | - https://docs.python.org/3/reference/expressions.html#comparisons
8 | - https://docs.python.org/3/reference/expressions.html#membership-test-operations
9 | - https://docs.python.org/3/library/operator.html#operator.contains
10 | - https://docs.python.org/3/library/operator.html#mapping-operators-to-functions
11 | ```
12 | >>> x = 3
13 | >>> y = [0, 1, 2, 3, 4]
14 | >>> z = [5, 6, 7, 8, 9]
15 | >>> x in y
16 | True
17 | >>> x in z
18 | False
19 | ```
20 |
21 | **_Instructions:_**
22 | **In the console, there are two variables defined for you, as well as a function named membership_test().**
23 | **Change the variable named word from the wrong answer to one of the correct answers that will make membership_test() return True.**
24 |
--------------------------------------------------------------------------------
/challenges/3.F.In_Operator/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "In Operator",
3 | "chapter_number": 3,
4 | "lesson_number": 15,
5 | "id":"593834105b0de5a15275c060",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/3.F.In_Operator/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class TestMembership(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsNotNone(membership_test())
7 | self.assertEqual(membership_test(), True)
8 | self.assertTrue(membership_test())
9 | self.assertIn(word, sentence)
10 |
--------------------------------------------------------------------------------
/challenges/3.F.In_Operator/main.py:
--------------------------------------------------------------------------------
1 | word = "wrong answer"
2 | sentence = "The quick brown fox jumped over the lazy dog."
3 |
4 | def membership_test():
5 | return word in sentence
6 |
7 | print(membership_test())
8 |
--------------------------------------------------------------------------------
/challenges/3.G.Not_In_Operator/lesson.md:
--------------------------------------------------------------------------------
1 | ## Python not in Operator
2 |
3 | Python's not in operator is a type of comparison operator that tests for membership, or, in this case, non-membership.
4 | The operator not in is defined to have the inverse true value of in.
5 | The not in operator evaluates to False if it finds a variable in the specified sequence and True otherwise.
6 | In other words, the statement 'x in y' is true if and only if the object x is NOT found in the object y.
7 | - https://docs.python.org/3/reference/expressions.html#not-in
8 | - https://docs.python.org/3/reference/expressions.html#comparisons
9 | - https://docs.python.org/3/reference/expressions.html#membership-test-operations
10 | - https://docs.python.org/3/library/operator.html#mapping-operators-to-functions
11 | ```
12 | >>> x = 3
13 | >>> y = [0, 1, 2, 3, 4]
14 | >>> z = [5, 6, 7, 8, 9]
15 | >>> x not in y
16 | False
17 | >>> x not in z
18 | True
19 | ```
20 |
21 | **_Instructions:_**
22 | **In the console, there are two variables defined for you, as well as a function named non_membership_test().**
23 | **Change the variable named letter from the wrong answer to one of the correct answers that will make non_membership_test() return True.**
24 |
--------------------------------------------------------------------------------
/challenges/3.G.Not_In_Operator/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Not In Operator",
3 | "chapter_number": 3,
4 | "lesson_number": 16,
5 | "id":"5938346a5b0de5a15275c061",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/3.G.Not_In_Operator/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class TestNonMembership(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsNotNone(non_membership_test())
7 | self.assertEqual(non_membership_test(), True)
8 | self.assertTrue(non_membership_test())
9 | self.assertNotIn(letter, alphabet)
10 |
--------------------------------------------------------------------------------
/challenges/3.G.Not_In_Operator/main.py:
--------------------------------------------------------------------------------
1 | letter = 'a'
2 | alphabet = 'abcdefghijklomnopqrstuvwxyz'
3 |
4 | def non_membership_test():
5 | return letter not in alphabet
6 |
7 | print(non_membership_test())
8 |
--------------------------------------------------------------------------------
/challenges/4.1.Addition/lesson.md:
--------------------------------------------------------------------------------
1 | ## Python Addition
2 |
3 | In Python, an integer (int) is one of 3 distinct numeric types.
4 | - https://docs.python.org/3.6/library/stdtypes.html#numeric-types-int-float-complex
5 |
6 | In this exercise, you will add two integers using the plus (+) operator.
7 | - https://docs.python.org/3.6/library/operator.html#operator.add
8 | - https://docs.python.org/3/library/operator.html#mapping-operators-to-functions
9 | ```
10 | >>> 2 + 2
11 | 4
12 | ```
13 |
14 | **_Instructions:_**
15 | **Change the 0 so that total will equal 20.**
16 |
--------------------------------------------------------------------------------
/challenges/4.1.Addition/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Addition",
3 | "chapter_number": 4,
4 | "lesson_number": 1,
5 | "id":"592893767a194ee412ae2e1f",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/4.1.Addition/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class AdditionTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsInstance(total, int)
7 | self.assertEqual(total, 20)
8 |
9 | # To run the tests from the console:
10 | # Make sure that you are in the '4.1.Addition' directory
11 | # ⇒ python3 -m unittest lesson_tests
12 |
--------------------------------------------------------------------------------
/challenges/4.1.Addition/main.py:
--------------------------------------------------------------------------------
1 | ### Modify the code below ###
2 |
3 | total = 10 + 0
4 |
5 | ### Modify the code above ###
6 |
7 | print(total)
8 |
--------------------------------------------------------------------------------
/challenges/4.2.Subtraction/lesson.md:
--------------------------------------------------------------------------------
1 | ## Python Subtraction
2 |
3 | In Python, an integer (int) is one of 3 distinct numeric types.
4 | - https://docs.python.org/3.6/library/stdtypes.html#numeric-types-int-float-complex
5 |
6 | In this exercise, you will subtract two integers using the minus (-) operator.
7 | - https://docs.python.org/3.6/library/operator.html#operator.sub
8 | - https://docs.python.org/3/library/operator.html#mapping-operators-to-functions
9 |
10 | ```
11 | >>> 4 - 2
12 | 2
13 | ```
14 |
15 | **_Instructions:_**
16 | **Change the 0 so that total will equal 10.**
17 |
--------------------------------------------------------------------------------
/challenges/4.2.Subtraction/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Subtraction",
3 | "chapter_number": 4,
4 | "lesson_number": 2,
5 | "id":"592895b87a194ee412ae2e20",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/4.2.Subtraction/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class SubtractionTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsInstance(total, int)
7 | self.assertEqual(total, 10)
8 |
9 | # To run the tests from the console:
10 | # Make sure that you are in the '4.2.Subtraction' directory
11 | # ⇒ python3 -m unittest lesson_tests
12 |
--------------------------------------------------------------------------------
/challenges/4.2.Subtraction/main.py:
--------------------------------------------------------------------------------
1 | ### Modify the code below ###
2 |
3 | total = 20 - 0
4 |
5 | ### Modify the code above ###
6 |
7 | print(total)
8 |
--------------------------------------------------------------------------------
/challenges/4.3.Multiplication/lesson.md:
--------------------------------------------------------------------------------
1 | ## Python Multiplication
2 |
3 | Python uses the asterisk (\*) operator for multiplication.
4 | If any or all of the numbers being multiplied are floating point numbers, then the product will be a float.
5 | - https://docs.python.org/3/library/operator.html#operator.mul
6 | - https://docs.python.org/3/library/operator.html#mapping-operators-to-functions
7 | - https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex
8 | ```
9 | >>> 3 * 3
10 | 9
11 | >>> 4.0 * 4
12 | 16.0
13 | ```
14 |
15 | **_Instructions:_**
16 | **Change the 0 so that product will equal 80.**
17 |
--------------------------------------------------------------------------------
/challenges/4.3.Multiplication/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Multiplication",
3 | "chapter_number": 4,
4 | "lesson_number": 3,
5 | "id":"592895ef7a194ee412ae2e21",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/4.3.Multiplication/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class MultiplicationTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsInstance(product, int)
7 | self.assertEqual(product, 80)
8 |
--------------------------------------------------------------------------------
/challenges/4.3.Multiplication/main.py:
--------------------------------------------------------------------------------
1 | ### Modify the code below ###
2 |
3 | product = 8 * 0
4 |
5 | ### Modify the code above ###
6 |
7 | print(product)
8 |
--------------------------------------------------------------------------------
/challenges/4.4.Float_Division/lesson.md:
--------------------------------------------------------------------------------
1 | ## Python Float Division
2 |
3 | Python 3 distinguishes between integer (floor) division and float (true) division.
4 | Python uses a single forward slash (/) operator for float division.
5 | When using float division, even if the quotient (result) is a whole number like 1 or 2, a floating point number will be returned instead of an int.
6 | - https://docs.python.org/3/library/operator.html#operator.truediv
7 | - https://docs.python.org/3/library/operator.html#mapping-operators-to-functions
8 | - https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex
9 | ```
10 | >>> 1 / 1
11 | 1.0
12 | >>> 3 / 2
13 | 1.5
14 | ```
15 |
16 | **_Instructions:_**
17 | **When you run the existing code, the variable named quotient will have a value of 1.0**
18 | **Change the the second number (the denominator) so that quotient has a value of 2.5**
19 |
--------------------------------------------------------------------------------
/challenges/4.4.Float_Division/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Float Division",
3 | "chapter_number": 4,
4 | "lesson_number": 4,
5 | "id":"5928961e7a194ee412ae2e22",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/4.4.Float_Division/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class FloatDivisionTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsInstance(quotient, float)
7 | self.assertEqual(quotient, 2.5)
8 |
--------------------------------------------------------------------------------
/challenges/4.4.Float_Division/main.py:
--------------------------------------------------------------------------------
1 | ### Modify the code below ###
2 |
3 | quotient = 5 / 5
4 |
5 | ### Modify the code above ###
6 |
7 | print(quotient)
8 |
--------------------------------------------------------------------------------
/challenges/4.5.Integer_Division/lesson.md:
--------------------------------------------------------------------------------
1 | ## Python Integer Division
2 |
3 | Python 3 distinguishes between integer (floor) division and float (true) division.
4 | Python uses a double forward slash (//) operator for integer division.
5 | When using integer division, Python will round the quotient down to the nearest whole number.
6 | - https://docs.python.org/3/library/operator.html#operator.floordiv
7 | - https://docs.python.org/3/library/operator.html#mapping-operators-to-functions
8 | - https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex
9 | ```
10 | >>> 1 // 1
11 | 1
12 | >>> 3 // 2
13 | 1
14 | ```
15 |
16 | **_Instructions:_**
17 | **When you run the existing code, the variable named quotient will have a value of 1.**
18 | **Change the the second number (the denominator) so that quotient has a value of 2.**
19 |
--------------------------------------------------------------------------------
/challenges/4.5.Integer_Division/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Integer Division",
3 | "chapter_number": 4,
4 | "lesson_number": 5,
5 | "id":"592896397a194ee412ae2e23",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/4.5.Integer_Division/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class IntegerDivisionTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsInstance(quotient, int)
7 | self.assertEqual(quotient, 2)
8 |
--------------------------------------------------------------------------------
/challenges/4.5.Integer_Division/main.py:
--------------------------------------------------------------------------------
1 | ### Modify the code below ###
2 |
3 | quotient = 5 // 5
4 |
5 | ### Modify the code above ###
6 |
7 | print(quotient)
8 |
--------------------------------------------------------------------------------
/challenges/4.6.Exponents/lesson.md:
--------------------------------------------------------------------------------
1 | ## Python Exponents
2 |
3 | Python uses the double asterisk (\**) operator to handle exponentiation.
4 | The number before the asterisks is the base, and the number after is the exponent.
5 | Python also lets you use the built-in function pow(x, y), which gives you x to the power of y.
6 | - https://docs.python.org/3/reference/expressions.html#the-power-operator
7 | - https://docs.python.org/3.6/library/operator.html?highlight=operations#operator.pow
8 | - https://docs.python.org/3/library/functions.html#pow
9 | - https://docs.python.org/3/library/operator.html#mapping-operators-to-functions
10 | - https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex
11 | ```
12 | >>> 2 ** 2
13 | 4
14 | >>> pow(2, 4)
15 | 16
16 | >>> pow(2.0, 4)
17 | 16.0
18 | ```
19 |
20 | **_Instructions:_**
21 | **In the console, you are given two variables, a and b.**
22 | **Using either method described in this lesson, define a variable named power that equals a to the power of b.**
23 |
--------------------------------------------------------------------------------
/challenges/4.6.Exponents/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Exponents",
3 | "chapter_number": 4,
4 | "lesson_number": 6,
5 | "id":"5928965a7a194ee412ae2e24",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/4.6.Exponents/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class ExponentsTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsInstance(power, int)
7 | self.assertEqual(power, 81)
8 |
--------------------------------------------------------------------------------
/challenges/4.6.Exponents/main.py:
--------------------------------------------------------------------------------
1 | a = 3
2 | b = 4
3 |
4 | ### Write your code below this line ###
5 |
6 |
7 |
8 | ### Write your code above this line ###
9 |
10 | print(power)
11 |
--------------------------------------------------------------------------------
/challenges/4.7.Remainder/lesson.md:
--------------------------------------------------------------------------------
1 | ## Python Remainder
2 |
3 | The % (modulo) operator yields the remainder from the division of the first argument by the second.
4 | The numeric arguments are first converted to a common type.
5 | - https://docs.python.org/3/library/operator.html#operator.mod
6 | - https://docs.python.org/3.6/reference/expressions.html#index-59
7 | - https://docs.python.org/3/library/operator.html#mapping-operators-to-functions
8 | - https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex
9 | ```
10 | >>> 3 % 2
11 | 1
12 | >>> 3.0 % 2
13 | 1.0
14 | >>> 3 % 2.0
15 | 1.0
16 | ```
17 |
18 | A simple way to determine if a number is odd or even is to check the remainder when that number is divided by 2.
19 | For odd numbers, the remainder is 1.
20 | For even numbers, the remainder is 0.
21 | ```
22 | >>> 3 % 2
23 | 1
24 | >>> 4 % 2
25 | 0
26 | ```
27 |
28 | **_Instructions:_**
29 | **Delete the string assigned to the variable named remainder.**
30 | **Assign remainder a value equal to the remainder of 11 divided by 3 using the modulo (%) operator.**
31 |
--------------------------------------------------------------------------------
/challenges/4.7.Remainder/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Remainder",
3 | "chapter_number": 4,
4 | "lesson_number": 7,
5 | "id":"592896717a194ee412ae2e25",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/4.7.Remainder/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class RemainderTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsInstance(remainder, int)
7 | self.assertEqual(remainder, 2)
8 |
--------------------------------------------------------------------------------
/challenges/4.7.Remainder/main.py:
--------------------------------------------------------------------------------
1 | ### Write your code below this line ###
2 |
3 |
4 |
5 | ### Write your code above this line ###
6 |
7 | print(remainder)
8 |
--------------------------------------------------------------------------------
/challenges/4.8.Divmod/lesson.md:
--------------------------------------------------------------------------------
1 | ## Python divmod() Function
2 |
3 | Compute quotient and remainder using the divmod() function.
4 | The divmod() function takes two (non-complex) numbers as arguments and returns a pair of numbers consisting of their quotient and remainder when using integer division.
5 | For integers, the result is the same as (a // b, a % b).
6 | - https://docs.python.org/3/library/functions.html#divmod
7 | - https://forum.freecodecamp.com/t/python-function-divmod/75415
8 | - https://docs.python.org/3.6/reference/expressions.html#index-59
9 | - https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex
10 | ```
11 | >>> divmod(1, 1)
12 | (1, 0)
13 | >>> divmod(3, 2)
14 | (1, 1)
15 | >>> divmod(3.0, 2)
16 | (1.0, 1.0)
17 | ```
18 |
19 | **_Instructions:_**
20 | **In this exercise, variables a and b are defined for you.**
21 | **Define a variable named result that calls the divmod() function on variables a and b (in that order).**
22 |
--------------------------------------------------------------------------------
/challenges/4.8.Divmod/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Divmod",
3 | "chapter_number": 4,
4 | "lesson_number": 8,
5 | "id":"592898c97a194ee412ae2e26",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/4.8.Divmod/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class DivmodTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsInstance(result, tuple)
7 | self.assertEqual(result, (3, 2))
8 |
--------------------------------------------------------------------------------
/challenges/4.8.Divmod/main.py:
--------------------------------------------------------------------------------
1 | a = 11
2 | b = 3
3 | ### Write your code below this line ###
4 |
5 |
6 |
7 | ### Write your code above this line ###
8 |
9 | print(result)
10 |
--------------------------------------------------------------------------------
/challenges/4.9.Square_Root/lesson.md:
--------------------------------------------------------------------------------
1 | ## Python Square Root
2 |
3 | The math.sqrt() function is a part of Python's math module, which is always available but must be imported.
4 | Math.sqrt(x) returns the square root of x as a floating-point number.
5 | - https://docs.python.org/3/library/math.html
6 | - https://docs.python.org/3.6/library/math.html?highlight=sqrt#math.sqrt
7 | ```
8 | >>> import math
9 | >>> math.sqrt(1)
10 | 1.0
11 | >>> math.sqrt(2)
12 | 1.4142135623730951
13 | >>> math.sqrt(4)
14 | 2.0
15 | ```
16 |
17 | **_Instructions:_**
18 | **The variable square_root is defined as the number 81.**
19 | **Change square_root so that it equals the square root of 81.**
20 | **The math module has been imported for you.**
21 |
--------------------------------------------------------------------------------
/challenges/4.9.Square_Root/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Square Root",
3 | "chapter_number": 4,
4 | "lesson_number": 9,
5 | "id":"592898dc7a194ee412ae2e27",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/4.9.Square_Root/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class SquareRootTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsInstance(square_root, float)
7 | self.assertEqual(square_root, 9.0)
8 |
--------------------------------------------------------------------------------
/challenges/4.9.Square_Root/main.py:
--------------------------------------------------------------------------------
1 | import math
2 |
3 | ### Modify the code below ###
4 |
5 | square_root = 81
6 |
7 | ### Modify the code above ###
8 |
9 | print(square_root)
10 |
--------------------------------------------------------------------------------
/challenges/4.A.Sum/lesson.md:
--------------------------------------------------------------------------------
1 | ## Python Sum
2 |
3 | The function sum(iterable) adds all of the items in a Python iterable (list, tuple, and so on) from left to right and returns the total.
4 | There is an optional second argument, start, that defaults to 0 and is added to the total.
5 | The iterable‘s items are normally numbers, and the start value is not allowed to be a string.
6 | - https://docs.python.org/3/library/functions.html#sum
7 | ```
8 | >>> numbers = [1, 2, 3, 4, 5]
9 | >>> sum(numbers)
10 | 15
11 | >>> sum(numbers, 1)
12 | 16
13 | >>> sum(numbers, 10)
14 | 25
15 | ```
16 |
17 | **_Instructions:_**
18 | **There are two lists of numbers.**
19 | **Find the sum of all of the items in both lists and assign that value to a variable named total.**
20 |
--------------------------------------------------------------------------------
/challenges/4.A.Sum/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Sum",
3 | "chapter_number": 4,
4 | "lesson_number": 10,
5 | "id":"592899f67a194ee412ae2e28",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/4.A.Sum/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class SumTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsInstance(total, int)
7 | self.assertEqual(total, 55)
8 |
--------------------------------------------------------------------------------
/challenges/4.A.Sum/main.py:
--------------------------------------------------------------------------------
1 | list1 = [1, 3, 5, 7, 9]
2 | list2 = [2, 4, 6, 8, 10]
3 |
4 | ### Write your code below this line ###
5 |
6 |
7 |
8 | ### Write your code above this line ###
9 |
10 | print(total)
11 |
--------------------------------------------------------------------------------
/challenges/4.B.Rounding/lesson.md:
--------------------------------------------------------------------------------
1 | ## Python Rounding
2 |
3 | The function round(number, n-digits) returns a given number rounded to n-digits precision after the decimal point.
4 | If n-digits is omitted or is None, it returns the nearest integer to its input.
5 | The return value is an integer if called with one argument, otherwise it is of the same type as the given number.
6 | - https://docs.python.org/3/library/functions.html#round
7 | ```
8 | >>> round(5)
9 | 5
10 | >>> round(5.5)
11 | 6
12 | >>> round(5.555, 1)
13 | 5.6
14 | ```
15 |
16 | **_Instructions:_**
17 | **The variable longer_pi has too many digits after the decimal place.**
18 | **Create a variable named shorter_pi that we can use instead.**
19 | **Use the round() function to display just the first 2 digits after the decimal point, and assign that value to shorter_pi.**
20 |
--------------------------------------------------------------------------------
/challenges/4.B.Rounding/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Rounding",
3 | "chapter_number": 4,
4 | "lesson_number": 11,
5 | "id":"59289a1a7a194ee412ae2e29",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/4.B.Rounding/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class RoundingTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsInstance(shorter_pi, float)
7 | self.assertEqual(shorter_pi, 3.14)
8 |
--------------------------------------------------------------------------------
/challenges/4.B.Rounding/main.py:
--------------------------------------------------------------------------------
1 | longer_pi = 3.14159265358979323846
2 |
3 | ### Write your code below this line ###
4 |
5 |
6 |
7 | ### Write your code above this line ###
8 |
9 | print(shorter_pi)
10 |
--------------------------------------------------------------------------------
/challenges/4.C.Absolute_Value/lesson.md:
--------------------------------------------------------------------------------
1 | ## Python Absolute Value
2 |
3 | Absolute value refers to how far a number is from zero.
4 | If a number is negative, abs() will convert it to positive.
5 | In abs(x), x may be an integer, float, or complex number.
6 | - https://docs.python.org/3/library/functions.html#abs
7 | - https://forum.freecodecamp.com/t/python-abs-x-function/19212
8 | - https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex
9 | ```
10 | >>> abs(2)
11 | 2
12 | >>> abs(-2)
13 | 2
14 | >>> abs(-2.0)
15 | 2.0
16 | ```
17 |
18 | **_Instructions:_**
19 | **The variable absolute_value equals -42.**
20 | **Change absolute_value so that it equals the absolute value of -42.**
21 |
--------------------------------------------------------------------------------
/challenges/4.C.Absolute_Value/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Absolute Value",
3 | "chapter_number": 4,
4 | "lesson_number": 12,
5 | "id":"59289a2f7a194ee412ae2e2a",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/4.C.Absolute_Value/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class AbsoluteValueTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsInstance(absolute_value, int)
7 | self.assertEqual(absolute_value, 42)
8 |
--------------------------------------------------------------------------------
/challenges/4.C.Absolute_Value/main.py:
--------------------------------------------------------------------------------
1 | ### Modify the code below ###
2 |
3 | absolute_value = -42
4 |
5 | ### Modify the code above ###
6 |
7 | print(absolute_value)
8 |
--------------------------------------------------------------------------------
/challenges/4.D.Min_Value/lesson.md:
--------------------------------------------------------------------------------
1 | ## Python Minimum Value
2 |
3 | The function min() returns the smallest item in an iterable (like a list or string), or the smallest of two or more arguments.
4 | This lesson is in the math section, so we will focus on using min() to find the smallest number in a list.
5 | - https://docs.python.org/3/library/functions.html#min
6 | ```
7 | >>> min(2, 5, 1, 4, 3)
8 | 1
9 | >>> min(2, 5.0, 1.0, 4, 3)
10 | 1.0
11 | ```
12 |
13 | **_Instructions:_**
14 | **The starter code has a list of numbers named, well, numbers.**
15 | **The variable lowest is initialized to numbers.**
16 | **Make the value of lowest equal the smallest number in numbers.**
17 |
--------------------------------------------------------------------------------
/challenges/4.D.Min_Value/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Min Value",
3 | "chapter_number": 4,
4 | "lesson_number": 13,
5 | "id":"59289a477a194ee412ae2e2b",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/4.D.Min_Value/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class MinValueTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsInstance(lowest, int)
7 | self.assertEqual(lowest, 1)
8 |
--------------------------------------------------------------------------------
/challenges/4.D.Min_Value/main.py:
--------------------------------------------------------------------------------
1 | numbers = [8, 2, 4, 3, 6, 5, 9, 1]
2 |
3 | ### Modify the code below ###
4 |
5 | lowest = numbers
6 |
7 | ### Modify the code above ###
8 |
9 | print(lowest)
10 |
--------------------------------------------------------------------------------
/challenges/4.E.Max_Value/lesson.md:
--------------------------------------------------------------------------------
1 | ## Python Maximum Value
2 |
3 | The function max() returns the largest item in an iterable (like a list or string), or the largest of two or more arguments.
4 | This lesson is in the math section, so we will focus on using max() to find the largest number in a list.
5 | - https://docs.python.org/3/library/functions.html#max
6 | ```
7 | >>> max(2, 5, 1, 4, 3)
8 | 5
9 | >>> max(2, 5.0, 1, 4.0, 3.0)
10 | 5.0
11 | ```
12 |
13 | **_Instructions:_**
14 | **The starter code has a list of numbers named, well, numbers.**
15 | **The variable highest is initialized to numbers.**
16 | **Make the value of highest equal the largest number in numbers.**
17 |
--------------------------------------------------------------------------------
/challenges/4.E.Max_Value/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Max Value",
3 | "chapter_number": 4,
4 | "lesson_number": 14,
5 | "id":"59289a5a7a194ee412ae2e2c",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/4.E.Max_Value/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class MaxValueTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsInstance(highest, int)
7 | self.assertEqual(highest, 9)
8 |
--------------------------------------------------------------------------------
/challenges/4.E.Max_Value/main.py:
--------------------------------------------------------------------------------
1 | numbers = [8, 2, 4, 3, 6, 5, 9, 1]
2 |
3 | ### Modify the code below ###
4 |
5 | highest = numbers
6 |
7 | ### Modify the code above ###
8 |
9 | print(highest)
10 |
--------------------------------------------------------------------------------
/challenges/5.1.Variables/lesson.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/freeCodeCamp/python-coding-challenges/b435ab650d85de267eeaa31a55ff77ef5dbff86b/challenges/5.1.Variables/lesson.md
--------------------------------------------------------------------------------
/challenges/5.1.Variables/lesson_settings.json:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/freeCodeCamp/python-coding-challenges/b435ab650d85de267eeaa31a55ff77ef5dbff86b/challenges/5.1.Variables/lesson_settings.json
--------------------------------------------------------------------------------
/challenges/5.1.Variables/lesson_tests.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/freeCodeCamp/python-coding-challenges/b435ab650d85de267eeaa31a55ff77ef5dbff86b/challenges/5.1.Variables/lesson_tests.py
--------------------------------------------------------------------------------
/challenges/5.1.Variables/main.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/freeCodeCamp/python-coding-challenges/b435ab650d85de267eeaa31a55ff77ef5dbff86b/challenges/5.1.Variables/main.py
--------------------------------------------------------------------------------
/challenges/6.1.Conditionals/lesson.md:
--------------------------------------------------------------------------------
1 | ## if elif else
2 |
3 | - https://docs.python.org/3/tutorial/controlflow.html
4 |
5 | Decision structures evaluate multiple expressions which produce TRUE or FALSE as outcome. You need to determine which action to take and which statements to execute if outcome is TRUE or FALSE otherwise. In Python zero and null is assumed as FALSE value.
6 | ```
7 | if value == 'some':
8 | print('yes')
9 | ```
10 | An else statement contains the block of code that executes if the conditional expression in the if statement resolves to 0 or a FALSE value.
11 | ```
12 | if value == 'some':
13 | print('yes')
14 | else:
15 | print('no')
16 | ```
17 |
18 | The elif statement allows you to check multiple expressions for TRUE and execute a block of code as soon as one of the conditions evaluates to TRUE.
19 |
20 | ```
21 | if value == 'some':
22 | print('yes')
23 | elif value = 'value':
24 | print('maybe')
25 | else:
26 | print('no')
27 | ```
28 |
29 | **_Instructions_**
30 | **Modify the value, so that program must print 'yes'.**
31 |
--------------------------------------------------------------------------------
/challenges/6.1.Conditionals/lesson_settings.py:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Conditionals",
3 | "chapter_number": 6,
4 | "lesson_number": 1,
5 | "id":"5965e5fd60d67217f0ce232f",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/6.1.Conditionals/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class ConditionalsTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsInstance(value, str)
7 | self.assertIs(value, 'y', "program must print 'yes'")
--------------------------------------------------------------------------------
/challenges/6.1.Conditionals/main.py:
--------------------------------------------------------------------------------
1 | value = 'some' #modify this line
2 |
3 | if value == 'Y' or value == 'y':
4 | print('yes')
5 | elif value == 'N' or value == 'n':
6 | print('no')
7 | else:
8 | print('error')
9 |
--------------------------------------------------------------------------------
/challenges/7.1.Loops/lesson.md:
--------------------------------------------------------------------------------
1 | ## Loops (While)
2 |
3 | - https://docs.python.org/3/tutorial/controlflow.html
4 |
5 | A loop statement allows to execute a block of code multiple times. Python supplies two type of loops:
6 | * while
7 | * for
8 |
9 | The syntax of a while loop is:
10 |
11 | ```
12 | while condition:
13 | statement
14 | ```
15 |
16 | While loops repeat a target statement as long as a given condition is true.
17 |
18 | ```
19 | count = 0
20 | while count < 9:
21 | print('Loop iteration: ', count)
22 | count = count + 1
23 | ```
24 |
25 | Python supports to have an else statement associated with a loop statement. The else statement is executed when the condition becomes false.
26 |
27 | ```
28 | count = 0
29 | while count < 9:
30 | print('Loop iteration ', count)
31 | count = count + 1
32 | else:
33 | print('loop end')
34 | ```
35 |
36 | **_Instructions_**
37 | **Modify the count, so that condition and switch_loop must become true.**
38 | **Use else statement, to mark the end of a program and switch switch_end to value true.**
39 |
--------------------------------------------------------------------------------
/challenges/7.1.Loops/lesson_settings.py:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Loops",
3 | "chapter_number": 7,
4 | "lesson_number": 1,
5 | "id":"597e1a1a634a36abfebcda38",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/7.1.Loops/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class LoopsTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertTrue(switch_end)
7 | self.assertTrue(switch_loop)
8 |
--------------------------------------------------------------------------------
/challenges/7.1.Loops/main.py:
--------------------------------------------------------------------------------
1 | count = 10 # Change this count
2 | switch_loop = False
3 | switch_end = False
4 |
5 | while count < 9:
6 | print('step ', count)
7 | count = count + 1
8 | switch_loop = True
9 | # use else statements
10 | print('loop end')
11 | switch_end = True;
12 |
13 |
--------------------------------------------------------------------------------
/challenges/8.1.Built_In_Functions/lesson.md:
--------------------------------------------------------------------------------
1 | ## Built-in Functions
2 |
3 | The Python interpreter has a number of functions and types built into it that are always available.
4 | They are listed [here](https://docs.python.org/3/library/functions.html) in alphabetical order.
5 | Python 3's builtins module provides direct access to all of the built-in functions.
6 | You don't need to import any modules when using a built-in function, just call the function with the appropriate arguments.
7 | - https://docs.python.org/3/library/functions.html#built-in-functions
8 | - https://docs.python.org/3/library/builtins.html#module-builtins
9 | - https://github.com/python/cpython/blob/3.6/Python/bltinmodule.c
10 | ```
11 | >>> print("print() is a built-in function in Python 3")
12 | print() is a built-in function in Python 3
13 | >>> type([1,2,3,4,5])
14 |
15 | >>> sum([1,2,3,4,5])
16 | 15
17 | >>> id(sum([1,2,3,4,5]))
18 | 4412662784
19 | ```
20 | **_Instructions:_**
21 | **In the console you will find a list of numbers.**
22 | **There is a built-in function that will return a new sorted list from the items in numbers.**
23 | **Find this function, call it using the variable named numbers as the argument, and assign this function call to the variable named result.**
24 |
--------------------------------------------------------------------------------
/challenges/8.1.Built_In_Functions/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Built In Functions",
3 | "chapter_number": 8,
4 | "lesson_number": 1,
5 | "id": "595ca15cddca05761bc04efa",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/8.1.Built_In_Functions/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class BuiltInFunctionsTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsInstance(result, list)
7 | self.assertNotIsInstance(result, str)
8 | self.assertEqual(result, [1, 2, 3, 4, 5, 6, 7, 8])
9 | self.assertNotEqual(result, [6, 3, 1, 8, 5, 2, 4, 7])
10 | self.assertNotEqual(result, numbers)
11 |
--------------------------------------------------------------------------------
/challenges/8.1.Built_In_Functions/main.py:
--------------------------------------------------------------------------------
1 | numbers = [6, 3, 1, 8, 5, 2, 4, 7]
2 |
3 | ### Assign the correct built-in function to the variable named result below: ###
4 |
5 | result = "Replace this string with the correct answer"
6 |
7 | ### Write your code above this line
8 | print(result)
9 |
--------------------------------------------------------------------------------
/challenges/8.2.User_Defined_Functions/lesson.md:
--------------------------------------------------------------------------------
1 | ## User Defined Functions
2 |
3 | The keyword `def` introduces a function definition.
4 | It must be followed by the function name and a parenthesized list of formal parameters (if any).
5 | The statements that form the body of the function start at the next line, and must be indented.
6 | After a function has been defined, it can be called by typing the function name immediately followed by parentheses that contain the function's arguments (if any).
7 | - https://docs.python.org/3/glossary.html#term-function
8 | - https://docs.python.org/3/glossary.html#term-parameter
9 | - https://docs.python.org/3/glossary.html#term-argument
10 | - https://docs.python.org/3/tutorial/controlflow.html#defining-functions
11 | - https://docs.python.org/3/reference/compound_stmts.html#def
12 | - https://docs.python.org/3/reference/expressions.html#calls
13 | - https://www.python.org/dev/peps/pep-0008/#function-names
14 | ```
15 | >>> def the_truth():
16 | ... return True
17 | ...
18 | >>> the_truth()
19 | True
20 | ```
21 |
22 | **_Instructions:_**
23 | **Define a function named say_hello() that has no parameters and prints the string "Hello World!" to the console.**
24 | **Your function should not contain a return statement, only a print statement.**
25 | **After you have defined the function, call it.**
26 |
--------------------------------------------------------------------------------
/challenges/8.2.User_Defined_Functions/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "User Defined Functions",
3 | "chapter_number": 8,
4 | "lesson_number": 2,
5 | "id": "595ca17addca05761bc04efb",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/8.2.User_Defined_Functions/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import sys
3 | from io import StringIO
4 | from main import *
5 |
6 | class UserDefinedFunctionsTests(unittest.TestCase):
7 | def test_main(self):
8 | # Make sure there is no return statement.
9 | self.assertIsNone(say_hello())
10 |
11 | def test_function_name(self):
12 | # Make sure that the function has the correct name.
13 | f = open('main.py')
14 | lines = str(f.readlines())
15 | f.close()
16 | self.assertRegex(lines, 'say_hello()', msg="The name of the function is incorrect.")
17 |
18 | def test_output(self):
19 | # Make sure that calling say_hello() outputs the correct string.
20 | saved_stdout = sys.stdout
21 | try:
22 | out = StringIO()
23 | sys.stdout = out
24 | say_hello()
25 | output = out.getvalue().strip()
26 | assert output == "Hello World!"
27 | finally:
28 | sys.stdout = saved_stdout
29 |
--------------------------------------------------------------------------------
/challenges/8.2.User_Defined_Functions/main.py:
--------------------------------------------------------------------------------
1 | ### Define the say_hello() function and fill in the function body below this line: ###
2 |
3 |
4 |
5 | ### Call the say_hello() function below this line: ###
6 | say_hello()
7 |
--------------------------------------------------------------------------------
/challenges/8.3.Function_Documentation_Strings/lesson.md:
--------------------------------------------------------------------------------
1 | ## Function Documentation Strings
2 |
3 | Function documentation strings (docstrings) offer a way to provide additional information about a function and its properties.
4 | A docstring is a string literal that occurs as the first statement in a module, function, class, or method definition.
5 | Such a docstring becomes the \_\_doc\_\_ special attribute of that object.
6 | The docstring for a function or method should summarize its behavior and document its arguments, return value(s), side effects, exceptions raised, and restrictions on when it can be called (all if applicable).
7 | Optional arguments should be indicated.
8 | There are two forms of docstrings: one-liners and multi-line docstrings.
9 | For consistency, always use """triple double quotes""" around docstrings.
10 |
11 | - https://docs.python.org/3/tutorial/controlflow.html#documentation-strings
12 | - https://www.python.org/dev/peps/pep-0257/
13 | ```
14 | >>> def some_function():
15 | ... """
16 | ... This function does nothing, but it's documented.
17 | ...
18 | ... Multiline docstrings are for more detailed descriptions.
19 | ... """
20 | ... pass
21 | ...
22 | >>> print(some_function.__doc__)
23 |
24 | This function does nothing, but it's documented.
25 |
26 | Multiline docstrings are for more detailed descriptions.
27 | ```
28 |
29 | **_Instructions:_**
30 | **In the console you will find a function named docstring\_function().**
31 | **In the space between the function definition and the `pass` keyword, write any string you like using the docstring triple-double quotes convention.**
32 |
--------------------------------------------------------------------------------
/challenges/8.3.Function_Documentation_Strings/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Function Documentation Strings",
3 | "chapter_number": 8,
4 | "lesson_number": 3,
5 | "id": "595ca194ddca05761bc04efc",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/8.3.Function_Documentation_Strings/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class FunctionDocumentationStringsTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsNone(docstring_function())
7 | self.assertIsNotNone(docstring_function.__doc__)
8 | self.assertIsInstance(docstring_function.__doc__, str)
9 |
--------------------------------------------------------------------------------
/challenges/8.3.Function_Documentation_Strings/main.py:
--------------------------------------------------------------------------------
1 | def docstring_function():
2 | ### Write your docstring below this line. ###
3 |
4 |
5 |
6 | ### Write your docstring above this line. ###
7 | pass
8 |
9 | print(docstring_function.__doc__)
10 |
--------------------------------------------------------------------------------
/challenges/8.4.Arguments_Vs_Parameters/lesson.md:
--------------------------------------------------------------------------------
1 | ## Arguments vs Parameters
2 |
3 | When dealing with functions, the terms argument and parameter are sometimes used interchangeably, but they do NOT mean the same thing.
4 | The difference between arguments and parameters can cause some confusion, especially for novice programmers.
5 | Parameters are defined by the names that appear in a function definition and define what types of arguments a function can accept.
6 | Arguments are the values actually passed to a function when calling it.
7 | When you DEFINE a function after the `def` keyword, the parameters are named inside the parentheses that follow.
8 | When you CALL a function, the arguments are assigned inside the parentheses that follow.
9 | - https://docs.python.org/3/faq/programming.html#what-is-the-difference-between-arguments-and-parameters
10 | - https://docs.python.org/3/glossary.html#term-argument
11 | - https://docs.python.org/3/glossary.html#term-parameter
12 | ```
13 | # The parameters are inside the parentheses in the function definition.
14 | >>> def some_function(foo, bar=None):
15 | ... return foo, bar
16 | ...
17 | # The arguments are inside the parentheses in the function call.
18 | >>> some_function(42, bar='baz')
19 | (42, 'baz')
20 | ```
21 | **_Instructions:_**
22 | **In the console, above the variable named result, define a function named my_function that has a single parameter named parameter.**
23 | **In the function body, tell the function to return parameter.**
24 | **After the equal sign for the variable named result, call my_function() and set the argument as the string 'argument'.**
25 | **When finished, you will have assigned the result of the my_function() call to the variable named result.**
26 |
--------------------------------------------------------------------------------
/challenges/8.4.Arguments_Vs_Parameters/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Arguments vs Parameters",
3 | "chapter_number": 8,
4 | "lesson_number": 4,
5 | "id": "595ca1aaddca05761bc04efd",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/8.4.Arguments_Vs_Parameters/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class ArgumentsVsParametersTests(unittest.TestCase):
5 | def test_output(self):
6 | self.assertIsNotNone(result)
7 | self.assertIsInstance(result, str)
8 | self.assertEqual(result, 'argument')
9 |
10 | def test_names_for_function_parameter_and_argument(self):
11 | f = open('main.py')
12 | lines = str(f.readlines())
13 | f.close()
14 | # The following tests only ensure that the named strings exist somewhere in the file, not that they are where they should be or have the correct values assigned.
15 | self.assertRegex(lines, 'my_function()', msg="The name of the function is incorrect.")
16 | self.assertRegex(lines, 'parameter', msg="The parameter must have the correct name.")
17 | self.assertRegex(lines, 'argument', msg="The argument must have the correct name.")
18 |
--------------------------------------------------------------------------------
/challenges/8.4.Arguments_Vs_Parameters/main.py:
--------------------------------------------------------------------------------
1 | ### Define your function with the appropriate parameter below this line: ###
2 |
3 |
4 |
5 | ### Assign the function call with the appropriate argument to the variable named result below this line: ###
6 |
7 | result = "Replace this string with the correct answer"
8 |
9 | print(result)
10 |
--------------------------------------------------------------------------------
/challenges/8.5.Default_Arguments/lesson.md:
--------------------------------------------------------------------------------
1 | ## Default Arguments
2 |
3 | When a function is defined in Python, you can specify formal parameters inside of the trailing parentheses.
4 | If any of those parameters are declared using the "argument=value" format, then you don't necessarily have to specify a value for those arguments when the function is called.
5 | If a value is not specified, then that parameter uses the default argument value when the function executes.
6 | A default value can be specified for any or all of the arguments, which creates a function that can be called with fewer arguments than it is defined to allow.
7 | - https://docs.python.org/3.6/tutorial/controlflow.html#default-argument-values
8 | ```
9 | >>> def greeting(number=1, message='Hello'):
10 | ... print(number, message)
11 | ...
12 | >>> greeting()
13 | 1 Hello
14 | >>> greeting(2, message='Ahoy There!')
15 | 2 Ahoy There!
16 | >>> greeting(number='Three')
17 | Three Hello
18 | ```
19 | **_Instructions:_**
20 | **In the console there is a function named favorite_python() with a single parameter named member that has a default argument of None.**
21 | **Call the function and change the default argument to a string containing the name of your favorite Monty Python member.**
22 | **Assign that function call to the variable named my_choice.**
23 |
--------------------------------------------------------------------------------
/challenges/8.5.Default_Arguments/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Default Arguments",
3 | "chapter_number": 8,
4 | "lesson_number": 5,
5 | "id": "595ca1c5ddca05761bc04efe",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/8.5.Default_Arguments/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class DefaultArgumentsTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsNotNone(my_choice)
7 | self.assertTrue(my_choice)
8 | self.assertIsInstance(my_choice, str)
9 | self.assertNotEqual(my_choice, "Replace this string with the correct function call.")
10 |
--------------------------------------------------------------------------------
/challenges/8.5.Default_Arguments/main.py:
--------------------------------------------------------------------------------
1 | def favorite_python(member=None):
2 | print(member)
3 | return member
4 |
5 | ### Call the favorite_python() function with the default argument changed to
6 | ### the name of your favorite Monty Python member, and assign that function
7 | ### call to the variable named my_choice.
8 |
9 | my_choice = "Replace this string with the correct function call."
10 |
11 | ### Call the function above this line.
12 |
--------------------------------------------------------------------------------
/challenges/8.6.Calling_Functions/lesson.md:
--------------------------------------------------------------------------------
1 | ## Calling Functions
2 |
3 | Once a function has been defined, it must be called in order to be executed.
4 | A function is a callable object that can execute when its `__call__()` method is invoked.
5 | A function can be called by appending the arguments in parentheses to the function name.
6 | If a function has no parameters, or if the parameters have default arguments that you do not want to change, then you can invoke the call method by appending empty parentheses to the function name.
7 | - https://docs.python.org/3/reference/datamodel.html#object.\_\_call\_\_
8 | - https://docs.python.org/3.6/tutorial/controlflow.html#defining-functions
9 | - https://docs.python.org/3/library/functions.html#callable
10 | ```
11 | # Define the function:
12 | >>> def call_something(something=None):
13 | ... return something
14 | ...
15 | # Call the function with the parameter's default argument of None:
16 | >>> call_something()
17 | # Nothing is returned.
18 | # Now call the function with an argument that changes the default:
19 | >>> call_something(something="Here's something")
20 | "Here's something"
21 | ```
22 | **_Instructions:_**
23 | **In the console, there is a function named say_hello() that returns a greeting.**
24 | **Call the function and put any string you want as the greeting argument inside of the parentheses.**
25 | **Assign the function call to the variable named result in the console.**
26 |
--------------------------------------------------------------------------------
/challenges/8.6.Calling_Functions/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Calling Functions",
3 | "chapter_number": 8,
4 | "lesson_number": 6,
5 | "id": "595ca1d9ddca05761bc04eff",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/8.6.Calling_Functions/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class CallingFunctionsTests(unittest.TestCase):
5 | def test_output(self):
6 | self.assertIsNotNone(result)
7 | self.assertIsInstance(result, str)
8 | self.assertNotEqual(result, "Replace this string with the correct function call.")
9 |
--------------------------------------------------------------------------------
/challenges/8.6.Calling_Functions/main.py:
--------------------------------------------------------------------------------
1 | def say_hello(greeting):
2 | return greeting
3 |
4 | ### Call the say_hello function below this line: ###
5 |
6 | result = "Replace this string with the correct function call."
7 |
8 | ### Call the say_hello function above this line: ###
9 | print(result)
10 |
--------------------------------------------------------------------------------
/challenges/8.7.Keyword_Arguments/lesson.md:
--------------------------------------------------------------------------------
1 | ## Keyword and Variable Keyword Arguments
2 |
3 | A keyword argument can be an argument preceded by an identifier in a function call using the form `kwarg=value`.
4 | Variable keyword arguments can be passed as values in a dictionary preceded by `**`, like this:
5 | `def example(default_arguments, *args, **kwargs):`
6 | In a function call, keyword arguments must follow positional arguments, and all keyword arguments passed must match one of the arguments accepted by the function.
7 | [Here is a detailed explanation](https://docs.python.org/3/reference/expressions.html#calls) of how keyword arguments are dealt with when the function is called.
8 | - https://docs.python.org/3.6/tutorial/controlflow.html#keyword-arguments
9 | - https://docs.python.org/3.6/glossary.html#term-argument
10 | - https://docs.python.org/3/reference/expressions.html#grammar-token-keywords_arguments
11 | - https://docs.python.org/3/glossary.html#term-parameter
12 | - https://www.python.org/dev/peps/pep-0362/
13 | - https://www.python.org/dev/peps/pep-0448/
14 | - https://docs.python.org/3/reference/expressions.html#calls
15 | - https://docs.python.org/3/reference/compound_stmts.html#function-definitions
16 | ```
17 | >>> # 3 and 5 are both keyword arguments in the following calls to complex()
18 | ...
19 | >>> complex(real=3, imag=5)
20 | (3+5j)
21 | >>> complex(**{'real': 3, 'imag': 5})
22 | (3+5j)
23 | ```
24 | ```
25 | >>> # arg1 and arg2 are keyword arguments, **kwargs is for variable keyword arguments
26 | ...
27 | >>> >>> def some_dr_seuss(arg1='arg1', arg2='arg2', **kwargs):
28 | ... return arg1, arg2, kwargs
29 | ...
30 | >>> print(some_dr_seuss(**{'arg3': 'arg_red', 'arg4': 'arg_blue'}))
31 | ('arg1', 'arg2', {'arg3': 'arg_red', 'arg4': 'arg_blue'})
32 | ```
33 | **_Instructions:_**
34 | **In the console there is a function named keyword_argument_example() that takes a default argument an an unspecified number of keyword arguments.**
35 | **When you call the function:**
36 | - **Enter an integer, your age, as the value for the default argument named your_age.**
37 | - **Create two keyword arguments named first and last.**
38 | - **Assign a string with your first name to first, and your last name to last.**
39 |
40 | **Assign your function call to the variable named about_me.**
41 |
--------------------------------------------------------------------------------
/challenges/8.7.Keyword_Arguments/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Keyword Arguments",
3 | "chapter_number": 8,
4 | "lesson_number": 7,
5 | "id": "595ca1f2ddca05761bc04f00",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/8.7.Keyword_Arguments/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class KeywordArgumentsTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsNotNone(about_me)
7 | self.assertTrue(about_me)
8 | self.assertNotEqual(about_me, "Replace this string with the correct function call.")
9 |
10 | def test_about_me_variable_has_correct_types(self):
11 | self.assertIsInstance(about_me, tuple)
12 | self.assertIsInstance(about_me[0], int)
13 | self.assertIsInstance(about_me[1], dict)
14 |
15 | def test_correct_keyword_arguments(self):
16 | self.assertIn("first", about_me[1].keys())
17 | self.assertIn("last", about_me[1].keys())
18 |
--------------------------------------------------------------------------------
/challenges/8.7.Keyword_Arguments/main.py:
--------------------------------------------------------------------------------
1 | def keyword_argument_example(your_age, **kwargs):
2 | return your_age, kwargs
3 |
4 | ### Write your code below this line ###
5 |
6 | about_me = "Replace this string with the correct function call."
7 |
8 | ### Write your code above this line ###
9 |
10 | print(about_me)
11 |
--------------------------------------------------------------------------------
/challenges/8.8.Positional_Arguments/lesson.md:
--------------------------------------------------------------------------------
1 | ## Positional and Variable Positional Arguments
2 |
3 | A positional argument is, simply put, any argument that is not a keyword argument.
4 | Positional refers to the fact that the relative position, or order, of the arguments is significant when they are stored in their corresponding tuple.
5 | Positional arguments can be used to form [arbitrary argument lists](https://docs.python.org/3.6/tutorial/controlflow.html#arbitrary-argument-lists).
6 | Functions can accept a variable number of (optional) positional arguments by using the `*args` syntax in the def statement, like this:
7 | `def example(default_arguments, *args, **kwargs):`
8 | The `*` operator instructs Python to pass argument inputs to a tuple that receives any excess positional parameters, defaulting to the empty tuple.
9 | When a function is defined and the parameters are declared, variable positional arguments must follow normal/default arguments (if any) and precede any variable keyword arguments (if any).
10 | - https://docs.python.org/3.6/tutorial/controlflow.html#arbitrary-argument-lists
11 | - https://docs.python.org/3/glossary.html#term-argument
12 | - https://docs.python.org/3/reference/expressions.html#grammar-token-positional_arguments
13 | - https://www.python.org/dev/peps/pep-0362/
14 | - https://www.python.org/dev/peps/pep-0448/
15 | - https://docs.python.org/3/reference/expressions.html#calls
16 | - https://docs.python.org/3/reference/compound_stmts.html#function-definitions
17 | ```
18 | >>> # 3 and 5 are both positional arguments in the following calls to complex()
19 | ...
20 | >>> complex(3, 5)
21 | (3+5j)
22 | >>> complex(*(3, 5))
23 | (3+5j)
24 | ```
25 | ```
26 | >>> # arg1 and arg2 are positional arguments, *args is for variable positional arguments
27 | ...
28 | >>> def some_dr_seuss(arg1, arg2, *args):
29 | ... return arg1, arg2, args
30 | ...
31 | >>> print(some_dr_seuss('arg1', 'arg2', 'arg_red', 'arg_blue'))
32 | ('arg1', 'arg2', ('arg_red', 'arg_blue'))
33 | ```
34 | **_Instructions:_**
35 | **In the console there is a function named positional_argument_example() that takes a default argument and an unspecified number of positional arguments.**
36 | **When you call the function:**
37 | - **Enter an integer, your age, as the value for the default argument named your_age.**
38 | - **Assign two strings, the first with your first name, the second with your last name, as the variable positional arguments**.
39 |
40 | **Assign your function call to the variable named about_me.*
41 |
--------------------------------------------------------------------------------
/challenges/8.8.Positional_Arguments/lesson_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "lesson_title": "Positional Arguments",
3 | "chapter_number": 8,
4 | "lesson_number": 8,
5 | "id": "595ca20addca05761bc04f01",
6 | "repl": ""
7 | }
8 |
--------------------------------------------------------------------------------
/challenges/8.8.Positional_Arguments/lesson_tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from main import *
3 |
4 | class PositionalArgumentsTests(unittest.TestCase):
5 | def test_main(self):
6 | self.assertIsNotNone(about_me)
7 | self.assertTrue(about_me)
8 | self.assertNotEqual(about_me, "Replace this string with the correct function call.")
9 |
10 | def test_correct_types(self):
11 | self.assertIsInstance(about_me, tuple)
12 | self.assertIsInstance(about_me[0], int)
13 | self.assertIsInstance(about_me[1], tuple)
14 | self.assertIsInstance(about_me[1][0], str)
15 | self.assertIsInstance(about_me[1][1], str)
16 |
--------------------------------------------------------------------------------
/challenges/8.8.Positional_Arguments/main.py:
--------------------------------------------------------------------------------
1 | def positional_argument_example(your_age, *args):
2 | return your_age, args
3 |
4 | ### Write your code below this line ###
5 |
6 | about_me = "Replace this string with the correct function call."
7 |
8 | ### Write your code above this line ###
9 |
10 | print(about_me)
11 |
--------------------------------------------------------------------------------
/challenges/classroom_settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "classroom_name": "FreeCodeCamp Python Curriculum",
3 | "language": "Python"
4 | }
5 |
--------------------------------------------------------------------------------
/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/freeCodeCamp/python-coding-challenges/b435ab650d85de267eeaa31a55ff77ef5dbff86b/favicon.png
--------------------------------------------------------------------------------
/generate-challenge-json.js:
--------------------------------------------------------------------------------
1 | var fs = require('file-system');
2 |
3 | function printList(list) {
4 | list.forEach((v) => console.log(v));
5 | }
6 |
7 | let dir_list = fs.readdirSync('challenges');
8 |
9 | //keep directories only
10 | dir_list = dir_list.filter((val) => {
11 | return fs.statSync(`challenges/${val}`).isDirectory();
12 | });
13 |
14 | // get the current challenge object, parse it, save the challenge list
15 | const challenges_string = fs.readFileSync('./challenges.json', 'utf-8');
16 | let challenges_json = JSON.parse(challenges_string);
17 |
18 | let challenges_list = challenges_json.challenges;
19 |
20 | // create a dictionary where challenges ids are keys
21 | // and their index in the challenges_list is the val
22 | let challenges_id_list = [];
23 | challenges_list.forEach((chapter) => {
24 | chapter.forEach((c) => {
25 | challenges_id_list.push(c.id);
26 | });
27 | });
28 |
29 | // loop through dir_list
30 | dir_list.forEach((dir) => {
31 | const path = `challenges/${dir}/lesson_settings.json`;
32 | let data = fs.readFileSync(path, 'utf-8');
33 |
34 | if (data.length === 0) return null;
35 |
36 | const challenge = JSON.parse(data);
37 | const {
38 | id,
39 | lesson_title,
40 | repl,
41 | chapter_number,
42 | lesson_number
43 | } = challenge;
44 |
45 | const default_repl = "https://repl.it/student_embed/assignment/136137/d860e0ad34862a709895f54706dcf9af";
46 |
47 | const lesson_obj = {
48 | id,
49 | "title": lesson_title,
50 | "repl": repl.length === 0 ? default_repl : repl,
51 | "completed": false,
52 | "chapter": chapter_number,
53 | "lesson": lesson_number
54 | };
55 |
56 | // attempt to autofill 'missing' challenges
57 | //
58 | // const blank_lesson_obj = {
59 | // "id": null,
60 | // "title": "NA",
61 | // "repl": default_repl,
62 | // "completed": false,
63 | // "chapter": null,
64 | // "lesson": null
65 | // }
66 |
67 | if (!challenges_id_list.includes(id)) {
68 | let chapter = challenges_list[chapter_number];
69 | // if ( lesson_number !== 1 && chapter.length < lesson_number ) {
70 | // for (let i = 1; i < lesson_number; i++ ) {
71 | // blank_lesson_obj.chapter = chapter_number;
72 | // blank_lesson_obj.lesson = i;
73 | // chapter.push(blank_lesson_obj);
74 | // }
75 | // }
76 | let a = chapter.slice(0, lesson_number);
77 | let b = chapter.slice(lesson_number + 1, chapter.length);
78 | a.push(lesson_obj);
79 | challenges_list[chapter_number] = a.concat(b);
80 | challenges_id_list.push(id);
81 | } else {
82 | challenges_list[chapter_number][lesson_number - 1] = lesson_obj;
83 | }
84 | });
85 | challenges_json.challenges = challenges_list;
86 | challenges_json.last_edit = Date.now();
87 | fs.writeFile('./challenges.json', JSON.stringify(challenges_json), (err) => {
88 | if (err) throw err;
89 | console.log('The file has been saved!');
90 | printList(challenges_list);
91 | });
92 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "python-coding-challenges",
3 | "description": "FCC Python Curriculum",
4 | "version": "1.0.0",
5 | "homepage": "https://freecodecamp.github.io/python-coding-challenges/",
6 | "bugs": {
7 | "url": "https://github.com/FreeCodeCamp/python-coding-challenges/issues"
8 | },
9 | "devDependencies": {
10 | "gh-pages": "^1.0.0",
11 | "react-scripts": "1.0.7"
12 | },
13 | "dependencies": {
14 | "react": "^15.6.1",
15 | "react-dom": "^15.6.1",
16 | "react-router": "^4.1.1",
17 | "react-router-dom": "^4.1.1"
18 | },
19 | "scripts": {
20 | "start": "react-scripts start",
21 | "build": "react-scripts build",
22 | "test": "react-scripts test --env=jsdom",
23 | "eject": "react-scripts eject",
24 | "predeploy": "npm run build",
25 | "deploy": "gh-pages -d build"
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/freeCodeCamp/python-coding-challenges/b435ab650d85de267eeaa31a55ff77ef5dbff86b/public/favicon.ico
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
11 |
12 |
13 |
14 |
15 |
24 | FreeCodeCamp Python Curriculum
25 |
26 |
27 |
30 |
31 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "192x192",
8 | "type": "image/png"
9 | }
10 | ],
11 | "start_url": "./index.html",
12 | "display": "standalone",
13 | "theme_color": "#000000",
14 | "background_color": "#ffffff"
15 | }
16 |
--------------------------------------------------------------------------------
/src/App.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 | import { Route, Switch, Redirect } from 'react-router-dom';
3 | import {withRouter} from 'react-router';
4 |
5 | import './styles/App.css';
6 |
7 | // Component imports
8 | import Navbar from './Navbar';
9 | import ChallengeView from './ChallengeView';
10 | import CurriculumComplete from './CurriculumComplete';
11 | import GetStarted from './GetStarted';
12 | import Map from './Map';
13 |
14 | // data
15 | import ChallengesJSON from './challenges.json';
16 |
17 | class App extends Component {
18 | constructor(props) {
19 | super(props);
20 |
21 | // get the JSON file challenges list
22 | const { challenges, last_edit, chapters } = ChallengesJSON;
23 |
24 | // if the localStorage does not exists or the challenges list is not authentic
25 | // set the localStorage with the challenges list from the JSON File.
26 | if ( !localStorage.getItem('fcc-python-challenges') || !this.isChallengesAuthentic(last_edit) ) {
27 | localStorage.setItem('fcc-python-challenges-last-edit', last_edit);
28 | localStorage.setItem('fcc-python-challenges-chapters', JSON.stringify(chapters))
29 | this.setChallengeList(this.flatten(challenges));
30 | }
31 |
32 | // set the challenges list state
33 | this.state = {
34 | challenges: this.getChallengeList(),
35 | mapWidth: "0"
36 | }
37 | }
38 |
39 | // helper function to condense the multidimensional challenges list
40 | flatten = list => list.reduce((a, b) => a.concat(b), []);
41 |
42 | // setter and getter for localStorage challenge object
43 | setChallengeList = challenges => localStorage.setItem('fcc-python-challenges', JSON.stringify(challenges));
44 | getChallengeList = () => JSON.parse(localStorage.getItem('fcc-python-challenges'));
45 |
46 | // check if last_edit dates differ
47 | isChallengesAuthentic = (last_edit) => {
48 | const date = localStorage.getItem('fcc-python-challenges-last-edit');
49 | return parseInt(date, 10) === last_edit;
50 | }
51 |
52 | // given a new list of challenges updates localStorage and state
53 | // note: setState triggers a rerender
54 | handleUpdateChallenges = (newChallengesList) => {
55 | this.setChallengeList(newChallengesList);
56 | this.setState({
57 | challenges: newChallengesList
58 | });
59 | }
60 |
61 | // click event attached to 'Next Button'
62 | handleAdvanceToNextChallenge = (currentChallengeIndex) => {
63 | // get challenges list from state
64 | const { challenges } = this.state;
65 | // set the next index by incrementing current index
66 | const nextChallengeIndex = currentChallengeIndex + 1;
67 | // if this is the last challenge
68 | if ( nextChallengeIndex === challenges.length ) {
69 | // curriculum complete page
70 | this.props.history.push('/curriculum-complete');
71 | } else {
72 | // get next challenge Object
73 | const nextChallenge = challenges[nextChallengeIndex];
74 | // determine the next path
75 | const nextPath = nextChallenge.title.toLowerCase().replace(" ", "-");
76 | // push the path to router with a custom state object
77 | this.props.history.push(nextPath, { completedChallenge: currentChallengeIndex });
78 | }
79 | }
80 |
81 | // click event attached to 'Prev Button'
82 | handleAdvanceToPrevChallenge = (currentChallengeIndex) => {
83 | // get challenges list from state
84 | const { challenges } = this.state;
85 | // set the prev index by decrementing current index
86 | const prevChallengeIndex = currentChallengeIndex - 1;
87 | // get the prev challenge
88 | const prevChallenge = challenges[prevChallengeIndex];
89 | // get the prev path
90 | const prevPath = prevChallenge.title.toLowerCase().replace(" ", "-");
91 |
92 | // push to history, no custom state needed
93 | this.props.history.push(prevPath);
94 | }
95 |
96 | // when the history is pushed we are pushing new props to the App component
97 | componentWillReceiveProps(nextProps) {
98 | // get the next title ( this is the path )
99 | const nextChallengeTitle = nextProps.match.params.challengeTitle;
100 | // get the challenge Array[]
101 | let nextChallenges = this.state.challenges;
102 | // get the index of the next challenge
103 | const nextChallengeIndex = this.getIndex(nextChallenges, nextChallengeTitle);
104 |
105 | // complete the current challenge if nextProps was clicked
106 | // this is the custom state object passed to the history.push(...) method
107 | if ( nextProps.location.state ) {
108 | const completedChallengeIndex = nextProps.location.state.completedChallenge;
109 | // if the index exists set the completed value to true
110 | if ( completedChallengeIndex ) {
111 | nextChallenges[completedChallengeIndex].completed = true;
112 | }
113 | // if we update the challenge list,
114 | // setState with the handleUpdateChallenges method
115 | this.handleUpdateChallenges(nextChallenges);
116 | }
117 |
118 | }
119 |
120 | // helper method for finding the index of an element
121 | getIndex = ( challenges, challengeTitle ) => (
122 | challenges.findIndex(c => (
123 | c.title.toLowerCase().replace(" ", "-") === challengeTitle
124 | ))
125 | )
126 |
127 | // used to open and close the map
128 | toggleMap = () => {
129 | const { mapWidth } = this.state;
130 | this.setState({
131 | mapWidth: mapWidth === "250px" ? "0" : "250px"
132 | });
133 | }
134 |
135 | render() {
136 | return (
137 |
Your progress is stored directly in your browser (using localStorage).
10 |
Happy coding!
11 |
12 |
13 | Start
14 |
15 | );
16 | };
17 |
18 | export default GetStarted;
19 |
--------------------------------------------------------------------------------
/src/Map.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { withRouter } from 'react-router';
3 | import ChallengesJSON from './challenges.json';
4 | import './styles/Map.css';
5 |
6 | // Rendering is broken up into multiple functions. Don't let them intimdate you.
7 | // Essentially each one returns a list of DOM elements.
8 | // Menu > ChallengeList > Chapter > Lesson > Link
9 | // Start component flow at bottom of file
10 |
11 |
12 | /* 4. Render the list of lessons with a link that pushes the history to that particular challenge
13 |
14 | Also check the current challenge list to see if the challenge is completed.
15 | If so add a check mark!
16 |
17 | */
18 | function renderLesson({title, id}, history, challengesList) {
19 | const url = title.toLowerCase().replace(" ", "-");
20 | const challenge = challengesList.find(c => c.title === title);
21 | const completed = challenge.completed;
22 | return (
23 |
24 |
25 |
31 |
32 | )
33 | }
34 |
35 | /* 3. make sure to add a key to each chapter element */
36 | function renderChapter(title, lessons, history, challengesList) {
37 | return (
38 |
39 | {title}
40 |
41 | {/* nesting lessons under chapter name */}
42 | {lessons.map(lesson => renderLesson(lesson, history, challengesList))}
43 |
44 |
45 | )
46 | }
47 |
48 | /* 2. Destructure challenges and chapters from JSON data
49 | Continue to pass the history and challengesList args through the functions
50 | */
51 | function renderChallengeList({challenges, chapters}, history, challengesList) {
52 | return challenges.map((lessons, i) => {
53 | const title = chapters[i];
54 | return renderChapter(title, lessons, history, challengesList);
55 | });
56 | }
57 |
58 |
59 | // Start here
60 | /* 1. Destructure variables from props object */
61 | const Map = ({ challengesList, history, toggleMap, width }) => {
62 | return (
63 |
64 |
65 | {/* Pass the raw JSON object, the history object, and the current challengesList (inherited from App.js) */}
66 | {renderChallengeList(ChallengesJSON, history, challengesList)}
67 |