Introduction
Welcome to Unit 2!
One of the most powerful features of a programming language is its ability to manipulate variables, expressions, compositions, etc. Another fantastic aspect of computer programming is the use of functions to increase programming efficiency. You will learn about both of these concepts as you read through the resources provided in this unit. You will be introduced to effective programming, including variables, expressions, statements, order of operations, functions, composition, and debugging.
The reading for Unit 2 offers a comprehensive study concentrating on:
the use of arguments and parameters in Python functions
the integration of Python variables, operators, and expressions
the development of arguments-taking Python functions
the use of nested functions.
You will advance to the next level of programming skills once you write Python programs with nested functions.
Atribution”Computer Program Language Text” by Jorge Jesus is licensed under CC BY-NC 2.0. To view a copy of this license, visit https://creativecommons.org/licenses/by-nc/2.0/?ref=openverse.
Reading Assignment
Reading Assignments are designed to expand your knowledge of the topics introduced in the Overview and provide the knowledge you will need to successfully complete the assignments in this unit. As you read through the learning resource and watch the videos consider the following:
Why do we use functions?
How do you distinguish between fruitful and void functions?
Think Python: How to think like a computer scientistChapter 2 – Variables, expressions, and statements Chapter 3 – Functions
Watch: Introduction to programs data types and variables
Watch: Fun with strings
ReferencesDowney, A. (2015). Think Python: How to think like a computer scientist. Green Tea Press. https://greenteapress.com/thinkpython2/thinkpython2.pdf
Khan Academy. (2011, June 30). Introduction to programs data types and variables [Video]. YouTube. http://youtu.be/husPzLE6sZc
Khan Academy. (2011, June 30). Fun with strings [Video]. YouTube. http://youtu.be/iZAtkS0F-Zo
Discussion Assignment
Welcome to the Unit 2 Discussion Forum.
Write your own Python code examples that demonstrate each of the following. Do not copy examples from the book or any other source. Try to be creative with your examples to demonstrate that you invented them yourself.
Example 1: Define a function that takes an argument. Call the function. Identify what code is the argument and what code is the parameter.
Example 2: Call your function from Example 1 three times with different kinds of arguments: a value, a variable, and an expression. Identify which kind of argument is which.
Example 3: Construct a function with a local variable. Show what happens when you try to use that variable outside the function. Explain the results.
Example 4: Construct a function that takes an argument. Give the function parameter a unique name. Show what happens when you try to use that parameter name outside the function. Explain the results.
Example 5: Show what happens when a variable defined outside a function has the same name as a local variable inside a function. Explain what happens to the value of each variable as the program runs.
The code and its output must be explained technically whenever asked. The explanation can be provided before or after the code, or in the form of code comments within the code. For any descriptive type question, Your answer must be at least 150 words.
End your discussion post with one question related to programming fundamentals learned in this unit from which your colleagues can formulate a response or generate further discussion. Remember to post your initial response as early as possible, preferably by Sunday evening, to allow time for you and your classmates to have a discussion.
Your instructor will grade this assignment using this rubric.
Programming Assignment
Assignment instructionsIn this unit, we explored the basic concepts of Python variables, operators, and expressions in Python and construct Python functions that take arguments. Before completing this assignment, review the reading material listed below:
Think Python: How to think like a computer scientist Chapter 2 and 3
Ensure that you go through all the topics in chapters 2 and 3, including the examples and solving the questions in the exercises.
Part 1
The circumference of a circle is calculated by 2πr, where π = 3.14159 (rounded to five decimal places). Write a function called print_circum that takes an argument for the circle’s radius and prints the circle’s circumference.
Call your print_circum function three times with different values for radius.
Include the following in your part 1 submission:
The code for your print_circum function.
The inputs and outputs to three calls of your print_circum.
Part 2
Welcome to your first project. Develop a catalog for a company. Assume that this company sells three different Items. The seller can sell individual items or a combination of any two items. A gift pack is a special combination that contains all three items. Here are some special considerations:
A. If a customer purchases individual items, he does not receive any discount.
B. If a customer purchases a combo pack with two unique items, he gets a 10% discount.
C. If the customer purchases a gift pack, he gets a 25% discount.
Write a function for the above scenario. Perform the calculations in code wherever applicable. The function should be your own creation, not copied from any other source. The final output should look like:
Include the following in your part 2 submission:
The code for the function that you created.
The Output of the code.
A description of what feature(s) your function illustrates.
The code and its output must be explained technically. The explanation can be provided before or after the code, or in the form of comments within the code.
If you use an informational source, be sure to identify the source and share the link to the source you used.
Submission Instructions: Submit the solutions to both part 1 and part 2 in one-word document.
Make sure your submission is double-spaced, using Times New Roman, 12-point font, with 1” margins.
The descriptive part of your response must be at least 200 words.
Use sources to support your arguments. Use high-quality, credible, relevant sources to develop ideas that are appropriate for the discipline and genre of the writing.
Use APA citations and references to support your work. Add a reference list at the end of the submission. For assistance with APA formatting, view the Learning Resource Center: Academic Writing.
Your submission should be clearly written, concise, and well organized, and free of spelling and grammar errors. The grading will be based on accurate solution of the problem and the quality of your writing.
This assignment will be assessed by your instructor using the rubric available on the assignment page located on the course main page.
Reference Downey, A. (2015). Think Python: How to think like a computer scientist. Green Tree Press.
https://greenteapress.com/thinkpython2/thinkpython2.pdf
Place this order or similar order and get an amazing discount. USE Discount code “GET20” for 20% discount