Reference no: EM133818995
Introduction to Programming
Purpose of the assessment : This assignment evaluates student's understanding of basic programming principles using Python programming language. In particular, it assesses student's ability to develop algorithms, problem solve, running scripts and write meaningful comments, while being an active member of a team.
Question 1
Save your file for this program as findDuplicates.py
Write a Python function (called findDuplicates()) that takes a list of integers as input and returns a list containing all the duplicate elements from the input list. If there are no duplicates, the function should return an empty list.
For example,
Start by writing an algorithm for solving the problem (i.e. set of steps to the problem). Copy both the algorithm and your script to the answer sheet. You must submit both, your answer sheet and .py file(s).
Question 2
Save your file for this program as maxiLyst.py
Define a function (call it maxiLyst()). maxiLyst takes two arguments: a list of digits D and an integer M. The function returns a list. The function iterates through the first M digits of D, finds the largest number within that set, and appends it to the result list. Then, it shifts one position at a time and repeats the process until the end of the list D. Hire Writer Now!
For example,
Start by writing an algorithm for solving the problem (i.e. set of steps to the problem). Copy both the algorithm and your script to the answer sheet. You must submit both, your answer sheet and .py file(s).
Question 3
Save your file for this program as prime.py
Write a Python function named "prime()" that identifies prime years within a given range of years. The function should prompt the user to input a range of years and then print out which years within that range are prime and which are not. A prime year is defined as a year that is divisible by 4. However, if the year is divisible by 4 and also divisible by 100, then it is not considered prime unless it can be evenly divided by 400. For instance, the function should correctly identify that 2000 and 2004 are prime years, while 1900 and 2100 are not prime years.
For example,
Start by writing an algorithm for solving the problem (i.e. set of steps to the problem). Copy both the algorithm and your script to the answer sheet. You must submit both, your answer sheet and .py file(s).
Question 4
Save your file for this program as gamify.py
Write a Python function (call it gamify()), which implements a number manipulation game.
In this game, the program prompts the user to input an integer number. If the number is even, it is divided by 2. If the number is odd, it is multiplied by 3 and 1 is added to the result. This process is repeated until the number reaches 1. The program then prints each number generated during the process, separated by spaces.
For example,
Given the numbers 24, 176, 21, and 1024, the output would be as follows:
Start by writing an algorithm for solving the problem (i.e. set of steps to the problem). Copy both the algorithm and your script to the answer sheet. You must submit both, your answer sheet and .py file(s).