Write a python function that takes a string as an argument and searches all
the characters having at least three occurrences (except the spaces and
special characters) in that string. Then, prepare and RETURN a dictionary
where the keys will be the characters and values will be summation of the
positions of those characters in the string. (You are not allowed to use
builtin .count() function here)
Popen() and Open() are:
Maria has 4 bags while going to airport, she has been told that she can take an average of 50kg.Tell her to input the weights of each bag and calculate the mean weight.
Demonstrate use of Object Oriented Programming (OOP) principles, data structures and file handling operations to carry out the following tasks:
a) Define a class named Person, with child classes named Daughter and Son who also have have derived classes named GrandSon and GrandDaughter respectively. All child classes have derived genetic features and skills from Person. Create 5 methods for getting and setting genetic features, setting and getting skills and demonstrate the concept of polymorphism.
b) Modify the answer in a) and show how the person features are captured in a file called person.txt. Also create another method to read from the file person.csv and store the data in a list called persondata. Clearly show how exceptions are handled in your program
define a class named person with child classes named daughter and son who also have derived classes named grandson and granddaughter respectively
. Define the following vectors and matrices:
vec1 = np.array([ -1., 4., -9.])
mat1 = np.array([[ 1., 3., 5.], [7., -9., 2.], [4., 6., 8. ]]
Perform the following operations on the vector and matrices given above:
a. You can multiply vectors by constants.
Compute vec2 = (np.pi/4) * vec1
b. The cosine function can be applied to a vector to yield a vector of cosines.
Compute 1 vec2 = np.cos( vec2 )
8 How many nodes are searched in the worst case when the search() method is called on a Linked List?
A Searching a Linked List is done in O(log n) time because you can use tree search
B One of the benefits of a Linked List is that it can be searched in constant time
C In the worst case, the method returns an error if the data to search for is not found
D In the worst case, the data to be found is the last node of the Linked List, so all the nodes must be searched
9 The remove() method we coded in the course removes _________
A All occurences of nodes containing the data to be removed
B Only the last occurrence of a node containing the data to be removed
C The first Occurrence of a node containing the data to be removed
10 The size() and search() mthods of the Doubly-Linked List are the same as the size() and search() methods for the Singly-Linked List
A True
B False
5 What is the main difference between the Doubly-Linked List(DLL) node class and the Singly Linked List(SLL) Node Class?
A The DLL node class has a previous attribute, but the SLL node class does not
B The SLL node class has a next attribute, but the DLL class does not
C The DLL node class stores two data values while the SLL node class stores only one data value
D An instance of the DLL node class can be associated with up to two Linked Lists, but an instance of the SLL node class can only be associated with one Linked List
6 Removing the first node of a Linked List is handled differently than removing other nodes in the Linked List?
A True
B False
7 The time complexity of the size*( method is O(n)
A True
B False
1 How can you tell if a Linked List is empty?
A the head points to Null
B the head points to None
C the head points to a node whose data value is empty
D all the nodes data values are None
2 Which of these is not associated with nodes in a Linked List?
A an edge value
B a data value
C previous pointer
D next pointer
3 Python’s built in list data type is implemented using a ______________.
A simple array
B dynamic linked list
C dynamic array
D simple linked list
4 What are the attributes associated with the Singly-Linked List node class?
A next and previous
B data, next, and previous
C data and next
D next only
Print this pattern consider input as 4
1
1 3 1
1 3 5 3 1
1 3 5 7 5 3 1
1 3 5 3 1
1 3 1
1