Sale!

36-650 HW5 Statistical Computing solved

Original price was: $35.00.Current price is: $30.00. $25.50

Category:

Description

5/5 - (3 votes)

Question 1 (10 points)
Write a python function to transpose a matrix. Your function should accept the
matrix as input and output the transposed matrix.
Example Input:
X = [[10,8],
[2 ,4],
[1 ,7]]
Output
[10, 2, 1]
[8, 4, 7]
Question 2 (10 points)
Write a python function to remove punctations from string attributes. Use for
loop only and don’t use out-of-the box functions to remove the punctations. Your
function should accept an input string and output another string without
punctations. Use the following variable to define all possible punctations:
punctuations = ”’!()-[]{};:'”\,<>./?@#$%^&*_~”’
Example:
Input: Hello in 36-650, & other MSP courses.
Output: Hello in 36650 other MSP courses
Question 3 (10 points)
One Away: There are three types of edits that can be performed on strings: insert
a character, remove a character, or replace a character. Given two strings, write a
function to check if they are one edit (or zero edits) away.
Examples:
Input: pale, pIe Output: true
Input: pales, pale Output: true
Input: pale, bale Output: true
Input: pale, bake Output: false
Question 4 (10 points)
Write python function that prints triangles in the following form on the screen.
Your function should accept the number of rows to be printed from the triangle
on the screen. Hint: you may find “while” loops useful in solving this problem.
Example Input: 3
Example Output:
Example Input: 6
Example Output:
Your function should print “Invalid Input” if you input negative numbers or
decimal numbers.
Question 5 (10 points)
Write python function to print the following pyramid. Your python function
should accept the number of rows that will be printed on the screen. Below is an
example for the function with input as 5.
Question 6 (10 points)
Develop Python function that creates employees table in your Postgres database.
Your employee table should have three columns (id: serial, fname: varchar(10),
lname: varchar (10))
Question 7 (10 points)
Develop Python function that populates the employees table in your Postgres
database with 500 dummy records. Your code/script should create the dummy
data and not import them from external files.
Question 8 (10 points)
Develop Python function that displays 10 records from your employees table. You
don’t need to specify an order for displaying the data.
Question 9 (10 points)
A string is said to be palindrome if it reads the same backward as forward. For e.g.
“Kayak” is a palindrome because if we try to read it from backward, it is same as
forward. One approach to check if a string is palindrome is to iterate through the
string till middle of string and compare a character from back and forth.
Use recursion to develop a python function (or functions) that checks if a string is
palindrome. The main function should accept a string and returns true/false. You
may assume all strings have lower-case letters.
Example Input: kayak Output: true
Example Input: hello Output: false
Common Penalties:
▪ Your GitHub repository is not public: 100% reduction (won’t be graded)
▪ Late submissions on Canvas or GitHub: 100% reduction (won’t be graded)