This article aims to provide you with an approachable collection of the most commonly asked **Python basic programming questions**. These questions require no prior programming knowledge and will help you identify what areas need more practice.

Introduced in 1991, Python has emerged as one of the world’s most famous high-level programming languages. Naturally, it has become a go-to weapon of choice for many new and professional programmers due to a syntax thatâs easy to read, learn and write.

However, having a good understanding of mathematics or an accessible syntax can only get you so far if the logic behind the solution is flawed. The difference between a mediocre programmer and a great one is the ability to think logically and apply reasoning to find the most efficient solution to a given problem, no matter the coding language.

Thankfully, like everything else in programming, applying logic while coding is a learnable skill where practice makes perfect.

Let us look at some complex yet rewarding **Python basic programming questions** to flex those logic muscles in your mind.

## 10 Python Basic Programming Questions to Practice

**Python program to check given number is even or odd**

As all even numbers are perfectly divisible by two and leave âzeroâ as a reminder, those that donât can be classified as odd. Our program simply divides the number by â2â and checks the remainder to classify the input number.

#taking input from the user |

num = int(input(“Enter a number to check even/odd “)) |

#if number is divisible by 2 |

if num%2 == 0: |

Â print(num,”is even number”) |

else: |

Â print(num,”is odd number”) |

**Python basic programming questions** to calculate the square of a number

**Python basic programming questions**to calculate the square of a number

This one simply multiples the number by itself to give us the square of the input.

#take input from the user |

num = int(input(“Enter a number to calculate square : “)) |

print(“square =”,num*num) |

**Python program to calculate the cube of a number**

Here, the number is multiplied by itself twice to get the cube of the input as the output.

#take input from the user |

num = int(input(“Enter a number to calculate cube : “)) |

print(“cube =”,num*num*num) |

**Python program to check given character is a vowel or consonant**

This python program will use an array that stores all vowels and then deploy an if-else loop condition to determine whether the input character is a vowel or a consonant.

Ch=input(âEnter a character to check vowel or consonant :â) |

if(ch == ‘a’ or ch == ‘e’ or ch == ‘i’ or ch == ‘o’ or ch == ‘u’ or ch == ‘A’ or ch == ‘E’ or ch == ‘I’ or ch == ‘O’ or ch == ‘U’): |

#if âifâ condition satisfy |

print(âGiven characterâ, ch ,âis vowelâ) |

else: |

#if âifâ condition does not satisfy the condition |

print(âGiven characterâ,ch, âisÂ consonantâ) |

**Python program to count vowels and consonants in the string**

This program employs the use of variables to store the occurrence of vowels and consonants in a string by looping through the entire string.

#taking input from the user |

string = input(“Enter a String : “) |

vowels = 0Â #variable to count number of vowels |

consonants = 0 #variable to count number of consonants |

for i in string:Â #string iteration |

Â if i in (‘a’, ‘e’, ‘i’, ‘o’, ‘u’,’A’, ‘E’, ‘I’, ‘O’, ‘U’):Â #if character in string is vowel |

Â Â Â vowels+=1 #if vowel increment variable âvowelâ with one |

Â elif i.isalpha():Â #checking if the character is alphabet |

Â Â Â consonants+=1Â #if consonant increment variable âconsonantsâ with one |

print(“Vowels :”,vowels,”Consonants:”,consonants) |

**Python program to remove spaces from string without inbuilt function**

This program achieves string concatenation and removes all spaces from a given string without using the Pythonâs inbuilt function to achieve the same.

#taking input from the user |

string = input(“Enter a String : “) |

result=” |

#iterating the string |

for i in string: |

Â #if the character is not a space |

Â if i!=’ ‘: |

Â Â Â result += i |

print(“String after removing the spaces :”,result) |

**Python program to convert Fahrenheit into Celsius**

This program uses the formula( ( Fahrenheit â 32)*5 ) / 9 ) to convert input temperature from Fahrenheit to Celsius.

#taking input from the user |

fahrenheit = float(input(“Please give the Fahrenheit Temperature : “)) |

#converting Celsius into Fahrenheit |

celsius = ((fahrenheit-32)*5)/9 |

print(“Celcius= “,celsius) |

**Python program to find smallest number among three**

This program compares three input numbers to find the smallest.

a = int(input(“Enter the value for a :”)) |

b = int(input(“Enter the value for b :”)) |

c = int(input(“Enter the value for c :”)) |

#comparing integer âaâ with other two integer |

if a<=b and a<=c: |

print(“a is smallest”) |

#comparing integer âbâ with other two integer |

elif b<=a and b<=c: |

print(“b is smallest”) |

#comparing integer âcâ with other two integer |

elif c<=a and c<=b: |

print(“c is smallest”) |

**Python program to calculate Factorial using recursionÂ **

This program calculates the factorial of the input number using recursion including explanation.

def fact(n): |

Â if n == 1: |

Â Â Â return n |

Â else: |

#recursion |

Â Â Â return n*fact(n-1) |

num = int(input(“Enter a whole number to find Factorial: “)) |

if num < 0: |

Â print(“Factorial can’t be calculated for negative number”) |

elif num == 0: |

Â print(“Factorial of 0 is 1”) |

else: |

Â print(“Factorial of”,num,”is”,fact(num)) |

**Python program to find L.C.M. of two numbersÂ **

This program calculates the L.C.M. of two given numbers by employing comparison and calculation.

num1 = int(input(“Enter first number: “)) |

num2 = int(input(“Enter second number: “)) |

if num1 > num2: |

Â greater = num1 |

else: |

Â greater = num2 |

while(True): |

Â if((greater % num1 == 0) and (greater % num2 == 0)): |

Â Â Â lcm = greater |

Â Â Â break |

Â greater += 1 |

print(“LCM of”,num1,”and”,num2,”=”,greater) |

These were a few helpful questions to enhance your logical thinking while coding and help you write more efficient code which solves complex problems logically.

Practising these questions is a sure-shot way to enhance your logical thinking while writing code in any language, as this skill is transferable to almost all fields of programming.

If you want to learn more, you can join paid internship program that focuses on project-based learning and becomes a skilled, logical, full-stack developer. Check out CodeQuotient.