Python Integer Programs | 95 Interview Questions with Solutions | Beginner to Advanced | 2026

 Python is one of the most popular programming languages used in interviews today. If you are preparing for a Python interview then integer programs are one of the most important topics you need to practice.

In this post you will find 95 Python integer interview programs covering all important topics. We have covered everything from basic programs to advanced programs including all int methods and built-in functions.

Each question has a separate solution post with complete code, output and step by step explanation. Click on any question to open the solution.

Let's get started!


Section 1 : Basic Int Programs

These are the most basic and most asked Python integer programs in interviews. If you are a fresher this is the best place to start.

Q1. Write a Python program to declare an integer variable and print its value and type. 👉 Click here for [Solution]

Q2. Write a Python program to perform all arithmetic operations on two integers. 👉 Click here for[Solution]

Q3. Write a Python program to check if a number is even or odd. 👉 Click here for [Solution]

Q4. Write a Python program to check if a number is positive, negative or zero. 

👉 Click here for[Solution]

Q5. Write a Python program to find the largest of three numbers. 👉 Click here for [Solution]

Q6. Write a Python program to swap two numbers without using a third variable. 👉 Click here for [Solution]

Q7. Write a Python program to find the sum of digits of a number. 👉 Click here for [Solution]

Q8. Write a Python program to reverse a number without converting to string. 👉 Click here for [Solution]

Q9. Write a Python program to check if a number is palindrome or not. 👉 ClickSolution

Q10. Write a Python program to count the number of digits in a number. 👉 Click here for Solution


Section 2 : Built-in Functions on Int

Python has many built-in functions that work on integers. These are very commonly asked in interviews. Make sure you practice all of them.

Q11. Write a Python program to demonstrate int() function with different data types. 👉 Click here for Solution

Q12. Write a Python program to find absolute value of a number using abs(). 👉 Click here for Solution

Q13. Write a Python program to round a float number using round(). 👉 Click here for Solution

Q14. Write a Python program to find quotient and remainder using divmod(). 👉 Click here for Solution

Q15. Write a Python program to find power of a number using pow(). 👉 Click here for Solution

Q16. Write a Python program to find maximum and minimum using max() and min(). 👉 Click here for Solution

Q17. Write a Python program to find sum of a list of numbers using sum(). 👉 Click here for Solution

Q18. Write a Python program to check the data type of a variable using type(). 👉 Click here for Solution

Q19. Write a Python program to check if a variable is integer using isinstance(). 👉 Click here for Solution

Q20. Write a Python program to find memory address of a variable using id(). 👉 Click here for Solution


Section 3 : Type Conversion

Type conversion is a very important concept in Python. Interviewers often ask questions about converting between different data types. Here are the most important ones.

Q21. Write a Python program to convert integer to float using float(). 👉 Click here for Solution

Q22. Write a Python program to convert float to integer using int(). 👉 Click here for Solution

Q23. Write a Python program to convert integer to string using str(). 👉 Click here for Solution

Q24. Write a Python program to convert string to integer using int(). 👉 Click here for Solution

Q25. Write a Python program to convert integer to boolean using bool(). 👉 Click here for Solution

Q26. Write a Python program to convert integer to binary using bin(). 👉 Click here for Solution

Q27. Write a Python program to convert integer to octal using oct(). 👉 Click here for Solution

Q28. Write a Python program to convert integer to hexadecimal using hex(). 👉 Click here for Solution

Q29. Write a Python program to convert binary string to integer using int() with base 2. 👉 Click here for Solution

Q30. Write a Python program to convert hexadecimal string to integer using int() with base 16. 👉 Click here for Solution


Section 4 : Number Base Programs

Number base conversion is another important topic. Questions on binary, octal and hexadecimal are commonly asked in written tests of companies like TCS and Infosys.

Q31. Write a Python program to convert decimal to binary without prefix using format(). 👉 Click here for Solution

Q32. Write a Python program to convert decimal to octal without prefix using format(). 👉 Click here for Solution

Q33. Write a Python program to convert decimal to hexadecimal without prefix using format(). 👉 Click here for Solution

Q34. Write a Python program to convert a number to all bases at once. 👉 Click here for Solution

Q35. Write a Python program to print binary with leading zeros using f-string. 👉 Click here for Solution

Q36. Write a Python program to convert binary to hexadecimal. 👉 Click here for Solution

Q37. Write a Python program to convert hexadecimal to binary. 👉 Click here for Solution

Q38. Write a Python program to convert octal to binary. 👉 Click here for Solution

Q39. Write a Python program to print numbers 1 to 10 in all bases. 👉 Click here for Solution

Q40. Write a Python program to convert hex string to int using int() with base 16. 👉 Click here for Solution


Section 5 : Int Built-in Methods

Python integer has several built-in methods that are very useful. These are asked in advanced interviews. Make sure you know all of them.

Q41. Write a Python program to find number of bits required using bit_length(). 👉 Click here for Solution

Q42. Write a Python program to count number of 1s in binary using bit_count(). 👉 Click here for Solution

Q43. Write a Python program to convert integer to bytes using to_bytes(). 👉 Click here for Solution

Q44. Write a Python program to convert bytes to integer using from_bytes(). 👉 Click here for Solution

Q45. Write a Python program to demonstrate as_integer_ratio() method. 👉 Click here for Solution

Q46. Write a Python program to demonstrate conjugate() method on integer. 👉 Click here for Solution

Q47. Write a Python program to access real and imag properties of integer. 👉 Click here for Solution

Q48. Write a Python program to access numerator and denominator of integer. 👉 Click here for Solution

Q49. Write a Python program to demonstrate to_bytes() in big-endian format. 👉 Click here for Solution

Q50. Write a Python program to demonstrate to_bytes() in little-endian format. 👉 Click here for Solution


Section 6 : Math Module

The math module in Python has many useful functions for integer operations. These are very commonly used in real world programs and interviews.

Q51. Write a Python program to find square root of a number using math.sqrt(). 👉 Click here for Solution

Q52. Write a Python program to find floor value of a float using math.floor(). 👉 Click here for Solution

Q53. Write a Python program to find ceiling value of a float using math.ceil(). 👉 Click here for Solution

Q54. Write a Python program to find GCD of two numbers using math.gcd(). 👉 Click here for Solution

Q55. Write a Python program to find LCM of two numbers using math.lcm(). 👉 Click here for Solution

Q56. Write a Python program to find factorial of a number using math.factorial(). 👉 Click here for Solution

Q57. Write a Python program to find power of a number using math.pow(). 👉 Click here for Solution

Q58. Write a Python program to find logarithm of a number using math.log(). 👉 Click here for Solution

Q59. Write a Python program to find value of pi and calculate area of circle. 👉 Click here for Solution

Q60. Write a Python program to check if a value is infinity using math.isinf(). 👉 Click here for Solution


Section 7 : Important Number Programs

These are the most popular and most asked Python number programs in interviews. Every fresher must know these programs.

Q61. Write a Python program to check if a number is prime or not. 👉 Click here for Solution

Q62. Write a Python program to print all prime numbers between 1 to 100. 👉 Click here for Solution

Q63. Write a Python program to find factorial of a number using recursion. 👉 Click here for Solution

Q64. Write a Python program to print Fibonacci series up to N terms. 👉 Click here for Solution

Q65. Write a Python program to check if a number is Armstrong number or not. 👉 Click here for Solution

Q66. Write a Python program to print all Armstrong numbers between 1 to 1000. 👉 Click here for Solution

Q67. Write a Python program to check if a number is perfect number or not. 👉 Click here for Solution

Q68. Write a Python program to find GCD of two numbers using Euclidean algorithm. 👉 Click here for Solution

Q69. Write a Python program to find LCM of two numbers without using math module. 👉 Click here for Solution

Q70. Write a Python program to find sum of first N natural numbers. 👉 Click here for Solution


Section 8 : Random Module

The random module is used to generate random numbers in Python. These programs are commonly asked in interviews and are also very useful in real world projects.

Q71. Write a Python program to generate a random integer using random.randint(). 👉 Click here for Solution

Q72. Write a Python program to generate random number in a range using random.randrange(). 👉 Click here for Solution

Q73. Write a Python program to pick a random element from a list using random.choice(). 👉 Click here for Solution

Q74. Write a Python program to shuffle a list of numbers using random.shuffle(). 👉 Click here for Solution

Q75. Write a Python program to generate same random numbers every time using random.seed(). 👉 Click here for Solution


Section 9 : Advanced Number Programs

These are advanced level programs that are asked in senior level interviews and product based companies. Practice these carefully.

Q76. Write a Python program to check if a number is strong number or not. 👉 Click here for Solution

Q77. Write a Python program to check if a number is Neon number or not. 👉 Click here for Solution

Q78. Write a Python program to check if a number is Harshad number or not. 👉 Click here for Solution

Q79. Write a Python program to check if a number is Disarium number or not. 👉 Click here for Solution

Q80. Write a Python program to find the digital root of a number. 👉 Click here for Solution

Q81. Write a Python program to find all prime factors of a number. 👉 Click here for Solution

Q82. Write a Python program to find the largest prime factor of a number. 👉 Click here for Solution

Q83. Write a Python program to find the missing number in a list from 1 to N. 👉 Click here for Solution

Q84. Write a Python program to check if a number is power of 2 using bit_count(). 👉 Click here for Solution

Q85. Write a Python program to check if a number is power of 2 using bitwise AND. 👉 Click here for Solution


Section 10 : Advanced Math Programs

These are the most advanced integer programs that require strong knowledge of mathematics and Python. These are asked in product based companies and senior level interviews.

Q86. Write a Python program to find sum of series 1 + 1/2 + 1/3 + ... + 1/N. 👉 Click here for Solution

Q87. Write a Python program to find sum of squares of first N natural numbers. 👉 Click here for Solution

Q88. Write a Python program to find sum of cubes of first N natural numbers. 👉 Click here for Solution

Q89. Write a Python program to check if a number is perfect square using math.sqrt(). 👉 Click here for Solution

Q90. Write a Python program to print all perfect numbers between 1 to 1000. 👉 Click here for Solution

Q91. Write a Python program to find all prime numbers using Sieve of Eratosthenes. 👉 Click here for Solution

Q92. Write a Python program for modular exponentiation using pow(x, y, z). 👉 Click here for Solution

Q93. Write a Python program to convert total seconds to hours minutes and seconds using divmod(). 👉 Click here for Solution

Q94. Write a Python program to find all divisors of a number. 👉 Click here for Solution

Q95. Write a Python program to check if a number is abundant, deficient or perfect. 👉 Click here for Solution


We hope you found these Python integer programs helpful. Practice all 95 programs to become confident in Python integer programming.

All solution posts are available on our website. Click on any question above to open the solution with complete code, output and explanation.

If you have any questions or suggestions feel free to leave a comment below. We will be happy to help you.

Keep practicing and happy coding!

Happy Coding ❤️ DailyCodeHub — dailycodehub.blogspot.com

No comments:

Post a Comment