# 2o Basic Programming Problems and Solutions in Python

I really wonder how some people can remember everything so well! Maybe the key is PRACTICE? Oh, it is definitely Practice!

Well, I did not get that awareness from my own action. It came when I was yelling at my 5-year-old daughter because she forgot some easy spelling. At home, there is a regular episode of running around, yelling, crying in a recursive way before she writes 10 words. Well, that’s a different story!

I repeat the same words daily. But today, I literally heard myself saying “If you do not practice, you will forget everything”. That very moment it hits me that it applies to me too!

I am quite confident that if I get a problem, I will get a solution. But, there is a key factor called TIME. Sometimes, when I start coding, I feel frustrated because I can not remember some basic syntax.

So today, I practiced some basic programming questions in python and I am sharing the same here.

Disclaimer: I am sure there must be a better and efficient way of solving the problems and I am eager to learn about that. Please share if you have one.

# 20 Easy Programming Problems:

1. Print “Hello World”
2. Ask Name and then greet by that name
3. Modify the above code such that the users Sam and Bob are only greeted with their names
4. Ask the user for a number n and prints the sum of the numbers from 1 to n
5. Modify the previous program such that only multiples of three or five are considered in the sum
6. Ask for a Number and return if it is Odd or Even
7. Print a multiplication table for a given number
8. Find the kth smallest element. I will give an example here. Take input of an array of numbers like [3,5,78,2,89,5,101,0,87] and pass k = 2. that means we are looking for 2nd least number which is 2 for this example.
9. Check If a Number is Prime.
10. Take a number and returns a list of its digits.
11. Write a program that asks the user for a number n and gives them the possibility to choose between computing the sum and computing the product of 1,…,n and return the answer accordingly.
12. Check if a string is palindrome or not
13. Count the occurrence of a given character in a String
14. Write a Function such that given an array A of N integers, returns the smallest positive integer (greater than 0) that does not occur in A. Example: if the input array is A = [1, 3, 6, 4, 1, 2], the function should return 5 which is the smallest missing number in this array.
15. Guess the Number Game
16. Linear Search Algorithm
17. Binary Search Algorithm
18. Check if a Number exist in a Matrix
19. Find the Largest Number in a Matrix
20. Given a full name, Init capitalize the name

Today, I wanted to see how to embed a Jupyter Notebook in a post and I had to give it a try. So, below is the solutions for the above problems. But, if it is annoying to drag the bar below, here is the Github path with the programming problems and the solutions in Python.

## Other Data Science Interview Preparation Questions

If you are looking for some other data science interview preparation questions, below are a few links that you may find useful.

Jargons /Concepts from Probability and Statistics for a Data Science Interview

# Solutions for Programming Exercise:

Please share your solution or any other easy programming exercise that we can add here.

Thank You!

A decade of experience in collecting, cleaning, and visualizing data. But now I am learning and practicing new tools and different techniques. Let’s dig and find out what is the story behind that Data. Let’s do it together! Let’s solve, fail, and try again because discovering something new is always fun.

Originally published at https://oindrilasen.com on July 8, 2020.

--

--