本次CS代写的主要涉及如下领域: Python代写,北美程序代写,美国程序代写,University of Illinois at Chicago代写,MCS260代写

MCS 260 Project 1due Wednesday, February 19, 2020 at 11:59 PM Spring 2020

## MCS 260 Project 1 : Solving Basic Problems With Python

# Assignments

Assignment 1.[10 Points] We can approximate

### √

xof a real number x by repeatedly computing the next termfi+1in the approximation scheme, given by the relation

```
fi+1=
```

### 1

### 2

```
(fi+
```

```
x
fi
```

### )

You may set the initial valuef 0 = 1 in order to initialize the computation. Your function must take two arguments on inputxandn. The numberxis the number you want to compute the square root of and the integernspecifies how many iteration are to be performed. Here are the first few lines of the function you are asked to complete.

def assignment1(x, n): tmp = 1 # here temporary variable tmp = 1 stands for f0 = 1.

A call of this function would look likea=assignment1(2,30) if we wanted to compute thesqrt(2) using 30 iterations of the computational scheme above. Theprint(a) statement would result in something resembling 1. 414213 ....

Assignment 2.[10 Points] Consider a Python list L, which contains an arbitrary but finite number of characters ’H’ and T. The characters ’H’ and ’T’ stand for heads and tails outcomes of a repeated coin toss process. Write a Python function which takes such a list L as its argument on input and computes the heads-to-tails counts. For example, if L = [’T’,’H’,’T’,’H’,’H’,’H’,’H’,’T’,’H’], the function would print to screen exactly ”the (H,T) count is (6,3)”, listing the heads count first and then the tails counts.

Assignment 3.[10 Points] Consider now the same setup as inAssignment 2. Write a Python function which takes a list L as its argument on input and computes the counts divided (normalized) by their greatest common divisor (GCD). In addition, if heads count is larger than tails count or they are equal, it prints ”(H,T) count is (heads-count, tails-count)”. If the tails count is larger, it prints ”(T,H) count is (tails-count, heads-count)”. The termsheads-countandtails-countare the actual counts, normalized by theirGCDand of typeinteger. The Pythonmathmodule contains a function, calledgcd(). In order to compute theGCD, for example, of 4 and 6, the syntax ismath.gcd(4,6). The order of the integers does not matter.

Assignment 4.[10 Points] Write a Python function which takes two strings on input. The first string is a person’s first name and the second string is the person’s last name. This Python function then creates a UIC style user name ID, which consists of the first letter of the first name and first 5 letters of the last name, and we will take the digit to be the length of the person’s last name. If a person’s full name is ”Julius Caesar”, the user name would be ”jcaesa6”. If a person’s last name is less than or equal to five letters, the whole last name is taken. For example, ”Jane Doe” would result in a user name ”jdoe3”. The function prints each user name to screen.

Assignment 5.[10 Points] Write a Python function, which takes no arguments on input, that is capable of generating and printing to screen a random password that is 8 characters long. Specifically, each password consists of 6 letters and 2 digits, not necessarily in that order. For the sake of simplicity, the characters in the password can only be ’a,b,c,d,e,f,g,h,i,j’ and digits 1,2,3,4,5. In addition, one of the letters must appear as a capital letter and it must appear at random spots when a new password is generated, i.e. it cannot have a fixed spot. All other letters must remain lower case and each letter,

UIC, Department of Mathematics, Statistics and Computer Science page 1

MCS 260 Project 1due Wednesday, February 19, 2020 at 11:59 PM Spring 2020

capitalized or not, can only occur once. For example, ’E’ and ’e’ cannot both occur in the password. The digits must also occur only once. Some examples of passwords are: jF4bga5d or 3agbh2Ec.

# Project Guidelines and Submission Details

Your solution to each assignment must consist of a complete Python function that solves the assignment. If the assignment requires an additional worded answer, include the answer as a Python comment below the function definition. Name all your functionsassgnment1(),assgnment 2 ..., etc. Place all func- tions and worded answers in atext filecalledproject1.txtwith the Python syntax in tact and upload it through Blackboard.No other format will be accepted.

This project must be solvedindividually. Under no circumstances are you allowed to copy or to col- laborate with anyone else. All submitted files will be automatically checked for plagiarism. Regardless of who copied from whom, all caught in the act of plagiarism will be penalized.

If you have questions, comments, or difficulties, to come to my office for help.

UIC, Department of Mathematics, Statistics and Computer Science page 2