Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Code the following using python idle and be sure not to use the constructs in the prohibited list at the bottom unless specified in the

Code the following using python idle and be sure not to use the constructs in the prohibited list at the bottom unless specified in the question.

Note: 0 is neither positive or negative, so if a function requires a positive input and does not explicitly state zero, then zero is invalid. Also, many of these problems accept a percentage as one of their arguments. All of these problems will expect the percentage to be an integer on the interval [0, 100]. For example, 6% would be represented as 6. You will probably need to convert this to .06 by dividing by 100 within the function itself before performing any calculations.

image text in transcribedimage text in transcribedimage text in transcribed

Stock Profit The profit from the sale of a stock can be calculated as follows, profit =((NSSP)SC)((NSPP)+PC) Where NS is the number of shares purchase, SP is the sale price per share, SC is the commission paid, PP is the purchase price per share, and PC is the purchase commission paid. Write a function called stock_profit which takes the number of shares, the purchase price per share, the purchase commission paid, the sale price per share, and the sale commission paid as five arguments. The function should return the profit (or loss) from the sale of stock. stock_profit (100,25,100,30,75)# output: 525 Write a function named is_odd which takes no parameters. Your function should use a for loop to find all the odd numbers from 1 through 10 . If the number is an odd number, your function should print this number. If the number is an even number, your function should print "xxx is not an odd number" (you need to replace "xxx" with that number). is odd () # output (via print) 1 2 is not odd number 3 4 is not odd number 5 6 is not odd number 7 8 is not odd number 9 10 is not odd number 10 is not odd number directions. Using the following constructs will result in 0 (zero) for the entire submission (assignment, timed test, etc.). The restricted items are as follows: - Concepts not discussed in lectures yet - String functions - Member functions - Exceptions (can use) : /en () and x=x+[y1,y2,y3] - Built-in functions \& types - Exceptions (can use): str( ), readline( ), open(), close( ), write(), read(), range( ), .split() - Cannot use .append, .sort, etc. - Cannot use "Slicing" - Cannot use "list comprehension" - Cannot use "not in" (together) - Cannot use "in" - not allowed with conditionals - Exception (can use): with range () - Cannot use and \{\} - Exception (can use): mathematical operations (multiply \& exponents) - Data type functions - Exceptions (can use): int (), str (), float () - Break - Continue - Nested Constructs - Exceptions (can use): 2-D list - Multiple returns \& Multiple assignments - Recursion (not allowed unless the question explicitly states otherwise) - Functions within functions (Definitions) -- invocation is fine - Default Parameters - Global variables - Keyword as variable names

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 Universal Database V7.1 Application Development Certification Guide

Authors: Steve Sanyal, David Martineau, Kevin Gashyna, Michael Kyprianou

1st Edition

0130913677, 978-0130913678

More Books

Students also viewed these Databases questions

Question

Determine miller indices of plane A Z a/2 X a/2 a/2 Y

Answered: 1 week ago