Question

Please answer this python questions.Thank you! Question Two      Write a program that calculates the amount...

Please answer this python questions.Thank you!

Question Two

     Write a program that calculates the amount of money a person would earn over a period

of time if his or her salary is one penny the first day, two pennies the second day, and

continues to double each day. The program should ask the user for the number of days.

Display a table showing what the salary was for each day, and then show the total pay at

the end of the period. The output should be displayed in a dollar amount, not the number

of pennies.

Question Three

Encryption:

Write a program in Python or C++ that has TWO functions:

Function One is called: _encrypt

Function Two is called: _decrypt

Function one takes plain text, and assesses the indexed value of each letter in the string. For example, a=1, b=2. It then adds three to the indexed value, and produces encrypted text, based off of the plain text.

Function two reverses this.

Here is sample output:

_encrypt('how do you do')

Unsecured: howdoyoudo

Secured: lsahscsyhs

_decrypt('lsahscsyhs')

Unsecured: lsahscsyhs

Secured: howdoyoudo

Question Four

Sum of consecutive integers

a) Write a program that prompts for an integer—let’s call it X—and then finds the

sum of X consecutive integers starting at 1. That is, if X=5, you will find the sum of

1+2+3+4+5=15.

b) Modify your program by enclosing your loop in another loop so that you can find

consecutive sums. For example , if 5 is entered, you will find five sum of consecutive

numbers:

1 = 1

1+2 = 3

1+2+3 =6

1+2+3+4 =10

1+2+3+4+5 =15

Print only each sum, not the arithmetic expression.

Question Five

Decision Structures and Boolean Logic

1. Write an if statement that assigns 20 to the variable y and assigns 40 to the variable z if

     the variable x is greater than 100.

2. Write an if statement that assigns 0 to the variable b and assigns 1 to the variable c if the

     variable a is less than 10.

3. Write an if-else statement that assigns 0 to the variable b if the variable a is less than 10.

     Otherwise, it should assign 99 to the variable b.

Question Six

Write a function that takes as input an English sentence (a string) and prints the total number

of vowels and the total number of consonants in the sentence. The function returns nothing.

Note that the sentence could have special characters like dots, dashes, and so on.

Question Seven

The Fibonacci sequence is: 1, 1, 2, 3, 5, 8, 13 … You can see that the first and second numbers

are both 1. Thereafter, each number is the sum of the previous two numbers.

(a) Write a function to print the first N numbers of Fibonacci sequence.

(b) Write a function to print the Nth number of the sequence.

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

#Please ask 1 question at a time
#i have done 2nd
days=int(input('Enter number of days: '))
money=0
total=0
print("{:>5s}\t{:10s}".format("day","money"))
for i in range(0,days):
money=2**i
total+=money
print("{:5d}\t${:<10.2f}".format(i+1,money/100))
print('Total pay after {:d} days: ${:.2f}'.format(days,total/100))

Add a comment
Know the answer?
Add Answer to:
Please answer this python questions.Thank you! Question Two      Write a program that calculates the amount...
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
  • Write a program in python or c++ that has two functions: Function one is called: _encrypt...

    Write a program in python or c++ that has two functions: Function one is called: _encrypt Function Two is called: _decrypt Function one takes plain text ,and assesses the indexed value of each letter in the string. For example, a=1,b=2 . It then adds three to the indexed valus , and produces encrypted text , based off of the plain text. Function two reverse this. here is sample output: _encrypt(‘how do you do’) Unsecured: howdoyoudo Secured: lsahscsyhs _decrypt(‘lsahscsyhs’) Unsecured: lsahscsyhs...

  • Project 5 - intro to python Write a program in python that calculates the amount of...

    Project 5 - intro to python Write a program in python that calculates the amount of money a person would earn over a period of time if his or her salary is one penny the first day, two pennies the second day, four pennies the third day, and continues to double each day. Output the amount earned each day .. and the total pay at the end. The Algorithm (Plan) for your program would be: Ask the user for the...

  • PYTHON 3 - please show format Question 2. ) Use the Design Recipe to write a...

    PYTHON 3 - please show format Question 2. ) Use the Design Recipe to write a function yesOrNo which has no parameters. When called, it gets input from the user until the user types either 'yes' or 'no', at which point the function should return True if the user typed 'yes' and False if the user typed 'no'. Any other entries by the user are ignored and another value must be input. For example: Test Input Result print(yesOrNo()) hello blank...

  • Week 5 Project Write a program that calculates the amount of money a person would earn...

    Week 5 Project Write a program that calculates the amount of money a person would earn over a period of time if his or her salary is one penny the first day, two pennies the second day, four pennies the third day, and continues to double each day. Output the amount earned each day .. and the total pay at the end. The Algorithm (Plan) for your program would be: Ask the user for the number of days to be...

  • Please write a MIPS program to print the first thirty numbers in the Fibonacci sequence in which each number is the sum of the two preceding ones, starting from 0 and 1. Note that each number in the Fibonacci sequence should be calculated using MIPS instr

    Please write a MIPS program to print the first thirty numbers in the Fibonacci sequence in which each number is the sum of the two preceding ones, starting from 0 and 1. Note that each number in the Fibonacci sequence should be calculated using MIPS instructions. After that please run your MIPS program using SPIM software to display the result in the output (console) window. Save your execution result in a log file of SPIM.What to submit:  1. Your MIPS...

  • Question 32 (Programming) The Fibonacci sequence of number is defined as: In this question we examine...

    Question 32 (Programming) The Fibonacci sequence of number is defined as: In this question we examine a property of this sequence. a) Write a C function definition with header int fib(int [ ] a, int n) which generates an array, a of the first n Fibonacci numbers. (Hint: You do not have to write this recursively. You just have to generate each array entry from the previous two entries.) b) Two numbers are said to be coprime if they have...

  • Write a program using Python that calculates the amount of money a person would earn over...

    Write a program using Python that calculates the amount of money a person would earn over a period of time if his or her salary is one penny the first day, two pennies the second day, and continues to double each day. The program should ask the user for the number of days. Display a table showing what the salary was for each day, then show the total pay at the end of the period. The output should be displayed...

  • Python Computer Programming Write a program that calculates the amount of money a person would earn...

    Python Computer Programming Write a program that calculates the amount of money a person would earn over a period of time if his or her salary is one penny the first day, two pennies the second day, and continues to double each day. The program should ask the user for the number of days. Display a table showing what the salary was for each day, then show the total pay at the end of the period. The output should be...

  • Write a C program to compute and print Fibonacci values for some integers. You can assume...

    Write a C program to compute and print Fibonacci values for some integers. You can assume that all input numbers are positive integers. The Fibonacci numbers are defined as follows: The first two Fibonacci numbers are 1 and 1. Any Fibonacci number after the first two numbers is the sum of its two predecessors. The Fibonacci numbers can be listed as the following sequence:         1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... It is clear...

  • Python 3 Write a program that calculates the factorial of the greatest odd number in a...

    Python 3 Write a program that calculates the factorial of the greatest odd number in a sequence of positive numbers (separated by spaces). The program must receive sequences of integers, one per line. The end of the input cases will be indicated by the number -1. For each line the program must print the factorial of the greatest odd number in each sequence. Note that for this question, there is always a greatest positive odd number in each line. Sample...

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