[Solved] COMP1007 Assignment3-String python

$25

File Name: COMP1007_Assignment3-String_python.zip
File Size: 320.28 KB

SKU: [Solved] COMP1007 Assignment3-String python Category: Tag:
5/5 - (1 vote)
  1. Write a Python function to count the number of characters in a string, and return a dictionary. E.g., if the input to the function is google.com, the returned dictionary should be: {g: 2, o: 3, l: 1, e: 1, .: 1, c: 1, m: 1}.
  2. Write a Python function to check if a string contains all letters of the alphabet (case insensitive). For example, if the input string is The quick brown fox jumps over the lazy cat, the function should return True; if the input string is abcdefghijklmnopqrstuvwxy, the function should return False.
  3. Write a Python function that takes a string as input and returns a new string by removing duplicate characters of the input string. E.g., if the input string is Hello, the output string should be Helo; if the input string is Google, the output string should be Gole.
  4. Write a Python function that takes two parameters, a string str and a positive integer n. The function returns a new string which lowercases the first n characters of the input string str. For example, if str is United States and n is 5, the returned string should be united States; if str is United States and n is 8, the returned string should be united states.
  5. Write a Python function that counts the vowels of a given string. Vowels include a, e, i, o, u and their uppercases. E.g., if the string is Internet, the function should return 3.
  6. Write a NumPy program to create an array of all the even integers from 100 to 200. Output the length of your array which should be 51.
  7. Write a NumPy program to create an array of 100 ones followed by 100 fives, and then followed by 100 tens. Please use numpy.ones(), numpy.full(), and numpy.concatenate().

[Self-learning]: Please learn the usage of numpy.concatenate() from https://docs.scipy.org/doc/numpy/reference/generated/numpy.concatenate.html

  1. Write a NumPy function to add a vector to each row of a given matrix. Assume the vector has the same dimension as the row of the given matrix. For example, if the vector is [2, 3, 4] and the given

matrix is [8 9 10], then the matrix should be changed to [10 12 14].

5 6 7 7 9 11

  1. Given a NumPy array that stores a vector of Centigrade values. Write a NumPy function to convert the values of Centigrade degrees into Fahrenheit degrees.

[Remark: find the conversion formula by yourself through Internet.]

  1. Write a NumPy program that generates ten 100100 arrays whose data follows standard normal distribution. Then output the min, max, mean, and standard deviation of the data for each array. Next, sum up the ten 100100 arrays into a single 100100 array. Output the min, max, mean, and standard deviation of this new array.

[Remark: this question helps you understand the sum of normally distributed random variables. For students who are interested in statistics, please check

https://en.wikipedia.org/wiki/Sum_of_normally_distributed_random_variables ]

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] COMP1007 Assignment3-String python
$25