0% found this document useful (0 votes)
6 views3 pages

Python Programming Challenges and Solutions

The document outlines a series of programming tasks and statistical questions, including data manipulation, encoding, palindrome checking, and statistical analysis. It covers operations on CSV files, matrix searching, sampling, and data visualization, as well as inferential statistics concepts like hypothesis testing and confidence intervals. Each task requires specific coding solutions or explanations related to data analysis and probability.

Uploaded by

Suhas Siddarth
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

Python Programming Challenges and Solutions

The document outlines a series of programming tasks and statistical questions, including data manipulation, encoding, palindrome checking, and statistical analysis. It covers operations on CSV files, matrix searching, sampling, and data visualization, as well as inferential statistics concepts like hypothesis testing and confidence intervals. Each task requires specific coding solutions or explanations related to data analysis and probability.

Uploaded by

Suhas Siddarth
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Programming Questions:

1.​ Write code to find the maximum, avarage, and minimum price value for each category
given a .csv file with the columns “Price”, “Category_SubCategory”
a.​ Example:
i.​ Price ​ ​ Category_SubCategory
ii.​ 234 ​ ​ Tops_croptop
iii.​ 282 ​ ​ Tops_croptop
iv.​ 222 ​ ​ Tops_tshirt
v.​ 382 ​ ​ Tops_tshirt
vi.​ 2382 ​ ​ BottomWear_jeans
vii.​ 2212 ​ ​ BottomWear_jeans
viii.​ 1282 ​ ​ BottomWear_leggings
ix.​ 212 ​ ​ BottomWear_leggings
b.​ You need to print the minimum value of Tops and BottomWear
2.​ Run a Python program to do run length encoding example “abbcdd --> a1b3c1d2“
3.​ Check if a string is palindrome or not
4.​ Given a csv file with [Link] with columns “time”, “category”, “price”
a.​ time ​ ​ category ​ ​ price
b.​ 12.00 ​ ​ 1-2-3 ​ ​ ​ 23
c.​ 12.40 ​ ​ 2-3 ​ ​ ​ 25
d.​ 12.45 ​ ​ 2​ ​ ​ 29
e.​ 13.25 ​ ​ 2-5-6 ​ ​ ​ 29
​ Can you fix this formatting error to
a.​ time ​ ​ category ​ ​ price
b.​ 12.00 ​ ​ 1​ ​ ​ 23
c.​ 12.00 ​ ​ 2​ ​ ​ 23
d.​ 12.00 ​ ​ 3​ ​ ​ 23
e.​ 12.40 ​ ​ 2​ ​ ​ 25
f.​ 12.40 ​ ​ 3​ ​ ​ 25
g.​ 12.45 ​ ​ 2​ ​ ​ 29
h.​ 13.25 ​ ​ 2​ ​ ​ 29
i.​ 13.25 ​ ​ 5​ ​ ​ 29
j.​ 13.25 ​ ​ 6​ ​ ​ 29
5. Write a Python program to search for an element in a 2D matrix, given that the matrix
elements are arranged in sorted order in both row-wise and column-wise
​ [1 4 7 10 15]
​ [3 5 8 15 19]
​ [6 9 11 16 20]
​ [12 19 21 26 30]
​ Note: Assume each element is unique in the matrix

6. given a csv file with columns “order_id”, “price”, and “user_id” can you compute the sum of
prices of users whose id is an odd number?
7. Given a list of N numbers, can you sample 10 elements from them, while sampling an
element at an even index with 0.4 and an element at an odd index with a probability of 0.6

8. Can you plot a histogram of average ages of different genders across multiple counties
​ Assume you have the data
​ Age | Gender ​| City
​ 45 | F ​ | Hyd
​ 25 | M ​ | Hyd
​ 42 | M ​ | Blr
​ 12 | F ​ | Blr
​ 21 | F ​ | Kolkata
​ 22 | M ​ | Kolkata

9. Given a list of N elements and a number K, check if there is any sub-array whose sum is
exactly K
​ A = [1, 4, 2, 7, 9, 10] K=18 output: Yes, as the sum of sub array [2,7,9] is 18

10. Assume you have given a dict with the following structure

​ ​ {
​ ​ ​ “elements_type1”: {
​ “element_1”:[{“length”:200, “width”:400, “id”:1},
{“length”:120, “width”:450, “id”:2},
{“length”:203, “width”:470, “id”:3}]
​ “element_2”:[{“length”:260, “width”:405, “id”:1},
{“length”:178, “width”:147, “id”:5}]
​ “element_3”:[{“length”:128, “width”:145, “id”:7},
{“length”:178, “width”:147, “id”:2}]

}
​ ​ ​ “elements_type2”: {
​ “element_1”:[{“length”:123, “width”:221, “id”:6},
{“length”:127, “width”:415, “id”:8},
{“length”:203, “width”:170, “id”:1}]
​ “element_2”:[{“length”:260, “width”:405, “id”:1},
{“length”:189, “width”:147, “id”:15}]
​ “element_3”:[{“length”:128, “width”:375, “id”:7},
{“length”:108, “width”:368, “id”:10}]

}

}
​ Write a program to print all the elements whose with is more than 400, for the above
input the output should be
​ elements_type1 → element_1 → 1
​ elements_type1 → element_1 → 2
​ elements_type1 → element_1 → 3
​ elements_type1 → element_2 → 1
​ elements_type2 → element_1 → 8
​ elements_type2 → element_2 → 1
​ elements_type2 → element_2 → 1

Probability & Inferential Statistics

1.​ Suppose you're analyzing impact of a new color that is added to home page of your
website. how can you confirm if the increase of the 2% page visits is because of the
color change.
2.​ In a dataset with potentially fraudulent transactions, how would you detect and handle
outliers that might be indicative of fraud?
3.​ How would you assess the normality of a variable's distribution during EDA, and why is
this important?
4.​ while performing EDA, how will you check if the data spread is very abnormal note that
the variance will be still high even if the data is spread uniformly across large access.
5.​ Explain what a confidence interval is and how you would interpret a 85% confidence
interval for a parameter estimate.
6.​ Can you explain the concepts of p-value and significance level in hypothesis testing?
How are they related?
7.​ Describe the difference between Type I and Type II errors in hypothesis testing. How
might adjusting the significance level impact the occurrence of these errors?
8.​ Describe situations where the Poisson distribution is commonly used and how you would
model data using this distribution.
9.​ Can you explain about few scaling methodologies, why we need to apply scaling and is
there any thumb rule for choosing the appropriate scaling methodology give a random
variable.
10.​Given a dataset with 4 features, and it is given that one is feature is a categorical
variable, one is numerical and continuous, one is ordinal features and the final one is a
categorical variable with huge number of unique values, given this data you want to find
the relationship between these 4 variables, what will be your approach while analyizing
this.

You might also like