10 Intermediate Python Coding Challenges

Python Coding Challenges

As everyone knows, the best way to learn programming isn’t to make notes. But, to make programs in order to grasp the syntax and its concept. In fact, universities and institutions massively focus on getting the students hands-on practicality to make progress. Hence, we are going to discuss 10 Intermediate Python Coding Challenges. All of these 10 python programming problems will help to develop your knowledge and understanding of different areas of Python. We will go in order from the easiest to the hardest for the 10 python programming challenges.

1.Find the sum of all List

First of all, we have a challenge that requires the programmer to make a list and find the sum of all the elements in the list using a for loop. Using a for loop is also known as Iteration. Hopefully, this problem in python programming would help you develop a basic understanding of Iteration.

Specifications

1.Make a list and assign some numbers to it

2.Make another variable, which will be assigned to 0

3.Use a loop to go through a list

4.While going through a loop add each element of the list to the int variable we created in point 2.

2.Multiplication table

Multiplication table wouldn’t be much different from the first python challenge.  Multiplication tables focus on a soft level of critical thinking. We can foresee it as a program that takes the input number and produces its mathematical table for us. We will do that by using a for loop.

Specifications

1.Take input for the number

2.Use a For loop to go through 10 times. So, we have a table of a specific number by 10.

3.Add the number taken in point 1 by itself in the for loop.

4.Every Time, it adds itself. It should print the result. 

You can get help from this Youtube Video Short. However, I recommend you try it yourself and figure out your solution.

3.Generate Random List

In this python coding challenge, we would learn to generate a random list of 10 elements. Moreover, we will also use an append() function. Hence, this challenge is quite an important one. In fact, if you are an intermediate-level python programmer, it would be necessary for you to learn to be able to get this challenge done. Because it covers the key learning concepts that will be used in the majority of the python project you will do as an intermediate-level python programmer. Generate Random List python programmer challenge expects you to randomly generate a list of 10 elements (10 elements must be within the range 0-100). Lastly, I expect you to struggle a bit on this one. It is a tricky one.

Specification: 

1.Write “Import Random” at the top your program to import random library

2.Make an empty list like ListName = []

3.Use for loop to go 10 times through the list

4.Use append() function for adding randomly generated numbers, they will be generated by using random randint function like  “random.randint(low, high)”.

5.Print the list

4.Find the Largest and Smallest Number 

This would be fairly easy for intermediate python programmers. Interestingly, in this python programming problem, programmers are expected to work with if statements and for loop. In fact, you can also add functions if you would like to. Particularly, this program expects the python developer to make a list of 10 elements and find the largest and smallest element in the list.

Specifications

1.Create a list with 10 values

2.Make two variables Min and Max assign them to 0.

3.Write a for loop to go through the list of 10

4.Write an if statement inside the for loop to check each element with the min and max. For example, if the max has less value than the list[element] then assign the list[element] to the max. Repeat this till you find the largest number.  

5.Print Min & Max values

5.Implement Linear Search in Python

Linear Search is a searching algorithm that is used in multiple programming languages including Python. Linear Search is probably the most basic searching algorithm that you can think of. Unfortunately, it is also considered to be one of the slowest for big-size data. However, it is quite promising for small data. 

In brief, the Linear Searching algorithm searches for a value by comparing each element of a list with value one by one. For instance, for loop and if statements can be used for going through the list and finding the value.

Specifications

1.Use a function that takes three parameters: List, SIZEofList and Findingvalue.

2.Make a for loop and if statement to check the value and return the index. Otherwise, you can return -1.

3.Make a List with random numbers

4.Call a function and give it parameter values.

5.Assign the function called above to any variable like Result = LinearSearch(List, SIZEofList, FindingValue)

6.Write another if statement responding to the value that returns from a function and prints the message.

You can visit this Youtube Video Short to find the source code for this python problem.

6.Python File-Handling

Creating, Reading and Writing Files are important for the python programming language. Especially, if you are an intermediate python developer. In this programming python problem, the developer is expected to create a file, write into the file and then read the file. 

Specification

1.Create a file 

2.Write to a file your name

3.Read from the file

If you are confused with creating, writing or reading a file. Visit W3schools website.

7.A Simple Calculator

Making a Calculator challenge works with the inputs and accurate processing. Python Programmers are expected to make a program that takes 2 numbers and the symbol such as multiplication or division sign etc. Calculations would be done by using the if else statement in python. To be honest, it is quite a simple program.

Specifications

1.Take three inputs: 2 values and one symbol for calculation

2.Write if else statements for all the symbols

3.Print the results.

8.Bank Program

The Bank Program would be one of the most complicated ones. It is a basic-level python program that would take an input username and password and log in to your account. Furthermore, the bank program would work with the while loop and nested if-else statements. If you don’t know what the nested if-else statements are. Basically, they are if-else statements within the if-else statement. Moreover, if the password is wrong three times, the program should display the message that the account has been blocked. 

Specifications

1.Make the variables such as username, password as well as counting variable.

2.Write a while loop for checking whether the password has been entered more than three times by using the counting variable and username and passwords altogether are correct. Something like while counting is less than or equal to 3 AND Username AND Passwords are correct.

3.Write if else statement for the username: if the username is correct, the program proceeds to take the password input. Otherwise, it shows an error. If the username is correct, but the password is incorrect, it increments the counting variable and asks for input again only 3 times.

4.Print the message successfully and log in, if the username and password are both correct.

9.Pizza Program

Hopefully, this python program would be simple but quite long compared to all the others that we have done before. Briefly, Pizza Program requires a program to take input on what kind of pizza a customer wants to order. Moreover, it will ask how many of them a customer would like. Any toppings that a customer wants. Ultimately, it would proceed to give a bill to the customer after asking a question about whether the customer is a staff member. If a customer is a staff member, he/she would get a 20% discount on the overall order price. 

Note: You can make up your names for pizzas and toppings.

Specifications

1.Make multiple lists to store the names of pizzas, toppings and their prices. There will be four lists to store all these. 

2.Make variables for the user input for pizzas and toppings.

3.Begin working with if else statements and while loops. For instance, if the user chooses a specific pizza, the program asks for the toppings and makes their bill after asking for anything else a user would like to order.

4.Implement a discount on the overall prices if the user is a staff member.

5.Print out the bill with what the customer has ordered. All the things in the bill should be nicely laid out.

10.Monty Hall Problem

Don’t let the name put you off. Let’s understand the Monty Hall Problem properly. In the monty hall problem: a user has three options, two of them have a goat and one has a car; User chooses one option, hoping that it would be a car; Host opens one option from two left, which has a goat and asks would you like to change your option or stick with what you have chosen before; if the user sticks with the first options, he would have less chance of winning a car as compared to switching options to other.

You can read about the Monty Hall Problem in detail here.

Specifications 

1.Create a list of three elements and assign them to 33. Because there are three options, if we divide them by 100, the answer will be 33.3%. 

2.Program uses a Mixture of while loop, for loop and if else statements to go through this 100 times. 

3.Print out the percentage of users losing and winning the game.

Conclusion

These were the 10 Intermediate Python Coding Challenges. Hopefully, you would go through them all to have a better understanding of the Python programming language. These challenges develop a soft level of critical thinking, structural debugging and problem-solving skills for you that can be used throughout your life.