Questions
IN PYTHON Create a function called biochild.  The function has as parameters the number m...

IN PYTHON

Create a function called biochild.
 The function has as parameters the number m and the lists biomother and biofather.
 The biomother and biofather lists contain 0’s and 1’s.
 For example: biomother = [1,0,0,1,0,1] and biofather = [1,1,1,0,0,1]
 Both lists have the same length n.
 The 0's and 1's represent bits of information (remember that a bit is 0 or 1).
 The function has to generate a new list (child).
 The child list must have the same length n.
 child is generated by randomly combining part of the child's information
biomother and biofather.
 The first part of the child list will be made up of the first b bits of biomother
and the second part by the last n-b bits of the biofather.
 For example, if b = 3, biomother = [1, 0, 0, 1,0,1] and biofather = [1,1,1, 0, 0, 1],
then child = [1,0,0,0,0,1].
 The value b has to be chosen randomly by the function.
 After generating child, each bit in the list is considered for mutation.
 For each bit of child, with probability m the bit is “mutated” by being replaced by its inverse
(If the bit is 0 it is replaced by 1, and if it is 1 it is replaced by 0).

 Finally, the function returns the list child.

In: Computer Science

Write the following Python script: Imagine you live in a world without modules in Python! No...

Write the following Python script:

Imagine you live in a world without modules in Python! No numpy! No scipy! Write a Python script that defines a function called mat_mult() that takes two lists of lists as parameters and, when possible, returns a list of lists representing the matrix product of the two inputs. Your function should make sure the lists are of the appropriate size first - if not, your program should print “Invalid sizes” and return None. Note: it is actually tricky to make a useful list of zeros. For instance, if you need to start with a 5 row, 6 column double list of 0, you might be tempted to try:

'''

thing = [ [ 0 ] ∗ 6 ] ∗ 5

'''

and if you look at it in the console window, it would appear to be a 5 by 6 list of lists containing all zeros! However - try the following and see what happens:

'''

thing [ 2 ] [ 5 ]

thing

'''

Notice that the item in index 5 of every row has changed, not just the row with index 2! Given the difficulty, I will give you the line of code that will create a list of lists that is num_rows by num_cols:

'''

ans = [ [ 0 for col in range ( num_cols ) ] for row in range ( num_rows ) ]

'''

In: Computer Science

This is an intro to python question. #Write a function called search_for_string() that takes two #parameters,...

This is an intro to python question.

#Write a function called search_for_string() that takes two
#parameters, a list of strings, and a string. This function
#should return a list of all the indices at which the
#string is found within the list.
#
#You may assume that you do not need to search inside the
#items in the list; for examples:
#
# search_for_string(["bob", "burgers", "tina", "bob"], "bob")
# -> [0,3]
# search_for_string(["bob", "burgers", "tina", "bob"], "bae")
# -> []
# search_for_string(["bob", "bobby", "bob"])
# -> [0, 2]
#
#Use a linear search algorithm to achieve this. Do not
#use the list method index.
#
#Recall also that one benefit of Python's general leniency
#with types is that algorithms written for integers easily
#work for strings. In writing search_for_string(), make sure
#it will work on integers as well -- we'll test it on
#both.


#Write your code here!

#Below are some lines of code that will test your function.
#You can change the value of the variable(s) to test your
#function with different inputs.
#
#If your function works correctly, this will originally
#print: [1, 4, 5]
sample_list = ["artichoke", "turnip", "tomato", "potato", "turnip", "turnip", "artichoke"]
print(search_for_string(sample_list, "turnip"))

In: Computer Science

Question 1: Processing Compound Data: Binary Trees A binary tree is a tuple with the following...

Question 1:

Processing Compound Data: Binary Trees

A binary tree is a tuple with the following recursive structure  

("btree", [val, left_tree, right_tree])

where first part of the tuple is a string "btree" and second part of the tuple is a list in which val is the value at the root and left_tree and right_tree are the binary trees for the left and right children or

("btree",[]) for the empty tree.  

(A)

Implement a binary tree ADT.

Type Name Description

Create the following tree in python. Use this tree to test the above functions of the tree ADT.

(B)

Implement the functions preorder,inorder and postorder.

Function preorder takes a tree as an argument and returns a list with the root value being the first element in the list followed by the elements of the left tree and then right tree. Function inorder takes a tree as an argument and returns a list with the elements of the left tree, followed by the root value and then right tree.

Function postorder takes a tree as an argument and returns a list with the elements of the left tree, followed by the elements of the right tree and then root value.

For example

preorder(t1) => [7, 5, 11, 9]

inorder(t1) => [5, 7, 9, 11]

postorder(t1) =>[5, 9, 11, 7]

In: Computer Science

Write the following Python script: Imagine you live in a world without modules in Python! No...

Write the following Python script:

Imagine you live in a world without modules in Python! No numpy! No scipy! Write a Python script that defines a function called mat_mult() that takes two lists of lists as parameters and, when possible, returns a list of lists representing the matrix product of the two inputs. Your function should make sure the lists are of the appropriate size first - if not, your program should print “Invalid sizes” and return None. Note: it is actually tricky to make a useful list of zeros. For instance, if you need to start with a 5 row, 6 column double list of 0, you might be tempted to try:

'''

thing = [ [ 0 ] ∗ 6 ] ∗ 5

'''

and if you look at it in the console window, it would appear to be a 5 by 6 list of lists containing all zeros! However - try the following and see what happens:

'''

thing [ 2 ] [ 5 ]

thing

'''

Notice that the item in index 5 of every row has changed, not just the row with index 2! Given the difficulty, I will give you the line of code that will create a list of lists that is num_rows by num_cols:

'''

ans = [ [ 0 for col in range ( num_cols ) ] for row in range ( num_rows ) ]

'''

In: Computer Science

Student Loan Debt should be forgiven for all College Students. 1. How convinced are you that...

Student Loan Debt should be forgiven for all College Students.

1. How convinced are you that the argument is "valid" (on a scale of 1-100%)? Why?

2. What would it take for you to change your mind?

In: Economics

Briefly explain how business and government represent a clash of ethical systems (belief systems). With which...

Briefly explain how business and government represent a clash of ethical systems (belief systems). With which do you find yourself identifying most? Explain. With which would most business students identify? Explain.

In: Economics

11. A random sample of 50 college student students shows that the score of a College...

11. A random sample of 50 college student students shows that the score of a College Statistics is normally distributed with its mean, 83 and standard deviation, 7.5. Find 95 % confidence interval estimate for the true mean.

In: Statistics and Probability

When preparing for an interview students may have concerns with interviewing patients. Describe 2 challenges to...

When preparing for an interview students may have concerns with interviewing patients. Describe 2 challenges to obtaining health history information from your patient. Explain a technique that you could use to overcome this barrier

In: Nursing

If there is a non-profit center that provides free after school and low-cost summer programs for...

If there is a non-profit center that provides free after school and low-cost summer programs for students from grades 3-12 then should it use an organic or mechanistic organisational structure?

How can it implement the structure?

In: Economics