Question

"PYTHON" 1. a. Create a file (module) named camera_picture.py. b. Write a function, take_picture_effect, that takes...

"PYTHON"

1. a. Create a file (module) named camera_picture.py.

b. Write a function, take_picture_effect, that takes two parameters, the filename and an effect.

c. Take a picture with the filename and effect. Use camera.effect to set the effect. Use help(PiCamera) to find the effects which you can apply.

d. Create a second file use_camera.py.

e. Import the take_picture_effect function from the camera_picture module.

f. Prompt the user for the filename.

g. Prompt the user for the image_effect. help(PiCamera) to see the list of image effects.

h. Call the function with the filename and the effect as arguments.

2. Write a function that prints a menu that allows the user to select an effect with a letter. Call the take_picture_effect function with the appropriate arguments.

a. cartoon

b. pastel

c. emboss etc.

(BONUS) a. Create a new file (module) named light_sound.py. b. Write a function, alert_fun that takes three parameters, the GPIO pin for the LED, the GPIO pin for the Buzzer, and the duration of the light to be on and the buzzer to sound. c. Create a second file use_light_sound.py. d. Import the alert_fun function from the light_sound module. e. Prompt the user for the GPIO pin for the LED, the GPIO pin for the Buzzer, and the duration. d. Call the function with the duration as an argument.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Ans)






from datetime import *
def compute_discount(cost,ismember):
    '''
     Function defining here, Accepting two values from main , and calculate the discount based on the condition.
    '''
    if ismember==True:
        final_cost=cost+cost*10/100
    else:
        final_cost=cost
    '''
  ,please change this date, i took cyber  monday. 
    '''
    if date.today()==date(2020,11,30):
        final_cost=final_cost+final_cost*5/100
    '''
     finally returning the calculated amount
    '''
    return final_cost
discount_cost1=compute_discount(150.78,True)
discount_cost2=compute_discount(98.23,False)
print("final discounted cost for 150.78 is "+str(round(discount_cost1,2)))
print("final discounted cost for 98.23 is "+str(round(discount_cost2,2)))
output

final discounted cost for 150.78 is 165.86 final discounted cost for 98.23 is 98.23

2) The second question is a part of first question we can give annotation and comment in our defined function as follows and can print that annotation in main, here is the code for printing annotation and comments(doc string) in that function. here is the code for that.

just modify the code above as follows,

from datetime import *
def compute_discount(cost:'float',ismember:'bool')->'float':
    '''
     Function defining here, Accepting two values from main , and calculate the discount based on the condition.
    '''
    if ismember==True:
        final_cost=cost+cost*10/100
    else:
        final_cost=cost
    '''
  ,please change this date, i took cyber  monday. 
    '''
    if date.today()==date(2020,11,30):
        final_cost=final_cost+final_cost*5/100
    '''
     finally returning the calculated amount
    '''
    return final_cost
discount_cost1=compute_discount(150.78,True)
discount_cost2=compute_discount(98.23,False)
print("final discounted cost for 150.78 is "+str(round(discount_cost1,2)))
print("final discounted cost for 98.23 is "+str(round(discount_cost2,2)))
print(compute_discount.__doc__) 
print(compute_discount.__annotations__) 


Output

final discounted cost for 150.78 is 165.86 final discounted cost for 98.23 is 98.23 Function defining here, Accepting two val if your satisfy above answer please give positive rating or like?

please don't dislike

Thank you!

Add a comment
Know the answer?
Add Answer to:
"PYTHON" 1. a. Create a file (module) named camera_picture.py. b. Write a function, take_picture_effect, that takes...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please Use Python and provide explanations!!!! 1. Write a function called multiply_and_print that takes two numbers,...

    Please Use Python and provide explanations!!!! 1. Write a function called multiply_and_print that takes two numbers, multiplies them together, and prints out the sentence '____ times ____ is ____'. Ask the user for two numbers, and call multiply_and_print with their two numbers as arguments. 2.Write a function called roll_dice that rolls two six-sided dice and prints out the result of each die. Call it three times. (Remember, you can import the random module with the statement import random, and then...

  • 2. Write a function file_copy() that takes two string parameters: in file and out_file and copies...

    2. Write a function file_copy() that takes two string parameters: in file and out_file and copies the contents of in_file into out file. Assume that in_file exists before file_copy is called. For example, the following would be correct input and output. 1 >>> file_copy( created equal.txt', 'copy.txt) 2 >>> open fopen ( copy.txt') 3 >>> equal-f = open( 'created-equal . txt') 4 >>equal_f.read () 5 'We hold these truths to be self-evident, Inthat all men are created equalIn' 3. Write:...

  • Python Language Create a module (1 mark) a) Create a function that takes three (3) arguments...

    Python Language Create a module (1 mark) a) Create a function that takes three (3) arguments (1 mark) i) Name it whatever you’d like (1 mark) ii) It will return a dictionary with the following keys (1 mark) (1) Error => gives error message or empty string if not (1 mark) (2) Result => gives result or empty string if no result (1 mark) b) Ensure that all three arguments are of String (str) datatype (1 mark) i) Return an...

  • Using python create function that: The stars.txt dataset1 consists of temperatures and magnitudes for 7860 nearby...

    Using python create function that: The stars.txt dataset1 consists of temperatures and magnitudes for 7860 nearby stars. The magnitude of stars corresponds to a star’s brightness. A star’s temperature is estimated by the color of light the star emits. Write functions that read the stars.txt file and: • find the hottest star • find the coldest star • find the brightest star • find the darkest star Function name: find_hottest_star() Parameters/arguments: filename Returns: temperature Function name: find_coldest_star() Parameters/arguments: filename Returns:...

  • Python 3.6 Question 12 (20 points) Write a function named wordLengths. The function wordLengths takes two...

    Python 3.6 Question 12 (20 points) Write a function named wordLengths. The function wordLengths takes two parameters: 1. inFile, a string that is the name of an input file 2. outFile, a string that is the name of an output file The input file exists when wordLengths is called; wordLengths must create the file outFile. The input file contains only letters and white space For each line of the input file, wordLengths should identify the length of the longest word...

  • You must create a Java class named TenArrayMethods in a file named TenArrayMethods.java. This class must...

    You must create a Java class named TenArrayMethods in a file named TenArrayMethods.java. This class must include all the following described methods. Each of these methods should be public and static.Write a method named getFirst, that takes an Array of int as an argument and returns the value of the first element of the array. NO array lists. Write a method named getLast, that takes an Array of int as an argument and returns the value of the last element...

  • Write a function named "loadStateDict(filename) that takes a filename and returns a dictionary of 2-character state...

    Write a function named "loadStateDict(filename) that takes a filename and returns a dictionary of 2-character state codes and state names. The file has four columns and they are separated by commas. The first column is the state full name and the second column is the state code. You don't have to worry about column 3 & 4. You should eliminate any row that is without a state code. Save the two columns into a dictionary with key = state code...

  • 1. Write a function named findTarget that takes three parameters: numbers, an array of integers -...

    1. Write a function named findTarget that takes three parameters: numbers, an array of integers - size, an integer representing the size of array target, a number The function returns true if the target is inside array and false otherwise 2. Write a function minValue that takes two parameters: myArray, an array of doubles size, an integer representing the size of array The function returns the smallest value in the array 3. Write a function fillAndFind that takes two parameters:...

  • Write a function named "write_string" that takes no parameters and doesn't return a value. This function...

    Write a function named "write_string" that takes no parameters and doesn't return a value. This function will write the string "hockey" to a file named "sacrifice.txt". If a named "sacrifice.txt" already exists it should be overwritten. (Python) Can you help me?

  • In c++ 1. Write a function named findTarget that takes three parameters - numbers: an array...

    In c++ 1. Write a function named findTarget that takes three parameters - numbers: an array of integers size: an integer representing the size of array target: a number The function returns true if the target is inside the array and false otherwise 2. Write a function min Valve that takes two parameters: myArray an array of doubles - size: an integer representing the size of array The function returns the smallest value in the array 3 Wrile a funcion...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT