You work in XYZ Company as a Python. The company officials want you to write code for reducing the dimensions of a dataset
Tasks to be performed: -
- Using load_digits function from sklearn import wines data
- Take a look at the shape of image data
- Import PCA, LDA and FactorAnalysis from Sklearn
- Project data in 2 D space using the PCA, LDA and FactorAnalysis algorithm form sklearn
- Take a look at the new data
There are N intermediate stations between two places A and B. Find the number of ways in which a train can be made to stop at S number of these intermediate stations so that no two stopping stations are consecutive. Write a python module Station.py for above and import the module in RollNo_W12B_3.py. In RollNo_W12B_3.py, define a function Get_Stations(N, S) which takes value of N & S and return integer result as shown in example by calling the appropriate function implemented in Station.py module. Also handle the possible exceptions and display the exception message in form of string.
Example-1
Example-2
Example-3
Input:
12
4
Output:
126
Input:
16
5
Output:
792
Input:
2
4
Output:
Earthquake python program. shreya is learing about earthquakes and stumbles accroess an interesting fact: the magnitude of on earthquake is a logarithmic scale of the energy realeased by the earthquake. it is known that each time the magnitude increases by 1, the amount of energy ets multiplied by 32. your tas is to help shreya by determining, how many times is the amount of energy of a magnitude a earthquake compared to that of a magnitude B earthquake?
I/p : a=6 & b=4, 6 is 2 greater than 4, so a magnitude 6 earthquake has 32*32=1024 times as much energy as a magnitude 4 earthquake has. so, the output is 1024
Input : 6 4
O/p: 1024
I/p: 5 5
O/p: 1
Kalinjar Fort is a popular tourist place in Bundelkhand, Utter Pradesh. Everyday peoples registered to visit Fort as token provided based on first come basis. Everyday limited numbers of peoples are allowed to visit. The management selects a number N1 randomly every day and generates another number N2 as count of the total number of set bits (i.e., total no. of 1s) in binary representation of all numbers from 1 to N1. For example, N1=3 then N2=4 [1(01) +2(10) +3(11)]. So, write a python module CountBit.py to find N2 using N1. You need to import this module in RollNo_W12B_2.py. In RollNo_W12B_2.py, define a function Get_Token(n) which takes a number and return value as shown in example by calling the appropriate function implemented in CountBit.py module.
Example-1
Example-2
Example-3
Input:
3
Output:
4
Input:
7
Output:
12Input:
8
Output:
13
Given a string of numbers S, the task is to find the maximum value from the string S, you can add a ‘+’ or ‘*’ sign between any two numbers.
For example, S=891. As 8*9*1 = 72 and 8*9+1 = 73. So, 73 is maximum.
Write a python module MaxValue.py for solve the above task. You need to import this module in RollNo_W12B_1.py. In RollNo_W12B_1.py, define a function Find_Max(n) which takes a string and return maximum value or error message as shown in example by calling the appropriate function implemented in MaxValue.py module. Also handle the possible exceptions and display the exception message in form of string.
Example-1
Example-2
Example-3
Example-4
Input:
01231
Output:
10
Input:
891
Output:
73
Input:
0000
Output:
Input:
45f
Output:
Invalid Number
Create a simple Python Program about concert ticketing system that allows users who are 18 years old to buy tickets. The ticket prices are as follows.
VIP- 4,500
Patron- 3500
Box regular- 2500
Friend and Enemy
A group of F friends went to a haunted house.Each member was given a shirt with a number on it ranging from 1 to F. As they entered the haunted house, one of them was kidnapped and an enemy joined them.But unfortunately, the enemy didn't wear the shirt with the same number as the kidnapped one, instead wore the same as some other person.Find the numbers on the shirts of the enemy and the kidnapped person.
Input
The input is a single line containing space-separated positive integers from 1 to F.
Output
The output should be a single line containing the shirt numbers of the enemy and kidnapped person separated by a space.
Explanation
The given array is 3 1 5 2 1.
In the range from 1 to 5, the number 1 has occured twice and 4 is the missing number. So, 1 belongs to the enemy's shirt, and 4 belongs to kidnapped.Hence, the output should be 1 4.
Sample Input1
3 1 5 2 1
Sample Output1
1 4
Sample Input2
1 2 2 4
Sample Output2
2 3
Sum of Non-Diagonals
As the creative content member of your newspaper company, you are given the task to publish a puzzle in your local newspaper. For a given MxM integer matrix, the task is to print the sum of all elements other than the diagonal elements,Both the diagonals are to be excluded.
Input
The first line of input is a positive integer M.
The next M lines of input contain M space-separated integers.
Output
The output is an integer that represents the sum of all the numbers in the matrix as mentioned above.
Sample Input1
3
4 1 3
2 5 6
1 2 3
Sample Output1
11
Sample Input2
5
1 2 2 3 3
4 4 5 6 7
9 8 7 6 5
9 2 3 8 8
-4 -2 -2 4 -7
Sample Output2
63
question: highest investor
ramsay is a stock broker , and N people have given him money to invest in stocks. some one may invest more money in an year. To than the person who invested most with ramsay he will send a gift at the end of the year . In case of a tie he will pick the person with the smallest lexicographic name.
Note:-
input :-
5
Harry 500
Andrew 300
Mary 1000
Jane 400
Tobey 1000
output:-
Mary 2
explanation output:- both tobey and mary have the biggest investment . as mary is smallest in lexicographic name than tobey and found at index 2 the output is "mary 2"
a square matrix A of dimensions NxN. You need to apply the below given 3 operations on matrix A.
Rotation: It represented as R S where S is integer in {90, 180, 270, 360, 450, .} which denotes the number of degrees to rotate. You need to rotate matrix A by angle S in the clockwise angle of rotation(S) will always be in multiples of 90 degrees.
Update: It is represented as U X Y Z. In initial matrix A (as given in input), you need to update the element at row index X and column index Y with value Z.
After the update, all the previous rotation operations have to be applied to the updated initial matrix.
Query: It is represented as Q K L. need to print the value at row index K and column index L of the matrix A.
Next N lines contain N space-separated integers Aij (i - index row, j - index of column)
-1 will represent the end of input.
S Input:
2
5 6
7 8
R 90
Q 0 1
R 270
Q 1 1
R 180
U 0 0 4
Q 0 0
-1
op:
5
8
8