Python 5 Easy Programs

Question Description

A. Write a function that:

1. Takes two arguments and returns the product of the arguments. The return value should be of type integer.

2. Takes two arguments and returns the quotient of the arguments. The return value should be of type float.

3. Takes one argument and squares the argument. It then uses the two values and returns the product of the two arguments.(Reuse function in 1.)

4. Takes one argument and prints the argument. Use this function to return the values in all previous 3 definitions above.

B. Write a Python program to check the validity of password input by users:

Passwords MUST contain the following:

At least 1 letter between [a-z] and 1 letter between [A-Z].
At least 1 number between [0-9].
At least 1 character from [$#@].
Minimum length 6 characters.
Maximum length 16 characters.

C. Function Name: comboLock

Parameters:

num1 – a positive integer representing the first digit in the combination

num2 – a positive integer representing the second digit in the combination

num3 – a positive integer representing the third digit in the combination

num4 – a positive integer representing the fourth digit in the combination

num5 – a positive integer representing the fifth digit in the combination

Description:

You own a combination lock that only opens when presented with the correct sequence of odd and even numbers that are less than 10. Write a function that takes in 5 integers. Check whether they are in this order: odd, even, odd, even, odd. If they are in the correct order and all below 10, then print the string “You opened the lock.” Otherwise, print “You are locked out.”

Enclose function in a while loop and ask user for parameters using input().

Test Cases:

>>>comboLock(9, 2, 5, 4, 1)

You opened the lock.

>>>comboLock(1, 8, 3, 6, 8)

“You are locked out.”

>>>comboLock(2, 2, 5, 6, 4)

“You are locked out.”

>>>comboLock(9, 8, 7, 8, 10)

“You are locked out.”

D.

Weight Lifting
Make a dictionary where the keys are the names of weight lifting exercises, and the values are the number of times you did that exercise.(At least 5 exercises,be creative. Nobody should have same values)
Use a for loop to print out a series of statements such as “I did 10 bench presses”.
Modify one of the values in your dictionary, to represent doing more of that exercise.
Use a for loop to print out a series of statements such as “I did 10 bench presses”.
Add a new key-value pair to your dictionary.
Use a for loop to print out a series of statements such as “I did 10 bench presses”.
Remove one of the key-value pairs from your dictionary.
Use a for loop to print out a series of statements such as “I did 10 bench presses”.
Use a function to do all of the looping and printing in this problem.

E. Follow the instructions below:1. Open a file and write the following to a file:

Your Name
INSS 250
Final

Each should be on a new line.2. With the file open, take input from a user and append it to the file. It can be any input but must be at least 10 words. I suggest do it in a loop. 3. Now as we did in class, use the file as input to count the number of letters in the file and print out a summary. All of this is one program. You will submit the python file(aka ‘your_name_final.py’). Use this naming convention.Research file opening and closing, but to get you started:The code looks like this: with open(‘file_to_save.txt’, ‘w’) as open_file: open_file.write(‘A string to write’)
open_file.close()

How to create Testimonial Carousel using Bootstrap5

Clients' Reviews about Our Services