Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1.Given a list of integers, write Python code to create a new list with same num

ID: 3570331 • Letter: 1

Question

1.Given a list of integers, write Python code to create a new list with same number of elements as the original list such that each integer in the new list is the sum of its neighbors and itself in the original list. For example, if listA=[10,20,30,40,50], list B=[30,60,90,120,90].

2.

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.


3.

Write a program that prompts for an integer

Explanation / Answer

#1

#! /bin/python

listA = [10,20,30,40,50]
listB = []
pos = 0
next = 0
post = 0
while (pos < len(listA)):
   if (pos == 0):
      next = pos + 1
      listB.append((listA[pos] + listA[next]))
   elif (pos == (len(listA) - 1)):
      next = pos - 1
      listB.append((listA[pos] + listA[next]))
   else:
      next = pos + 1
      post = pos - 1
      listB.append((listA[pos] + listA[next] + listA[post]))
   pos = pos + 1
print (listB)

#2

#! /bin/python

days = int (input("Enter number of days:"))

sum = 1
i = 1
print ("Day(s)       Dollars")

while (i <= days):
   if (i == 1):
      print(str(i) + "        $" + str(i / 100.0))
   else:
      print (str(i) + "       $" + str((i * 2.0) / 100.0))
   i = i + 1

#3

#! /bin/python

x = int (input("Enter a integer:"))

sum = 0

for i in range(0, (x+1)):
    sum = sum + i

print ("total is " + str(sum))

Dr Jack
Hire Me For All Your Tutoring Needs
Quick quotes • Clear explanations • Study support
Chat Now And Get Quote