Python Basics : Question Bank

Questions for Practice:

  1. What is Python ? Who created Python?
  2. What are the features of Python which makes it more popular?
  3. List out the different jobs available for Python programmer.
  4. What is the role of programmer? Lis two skills required to become good programmer.
  5. Discuss, Why Should you learn to write Programs?
  6. What is Zen of Python?
  7. Discuss, with snapshots how to install latest version of IDLE Python and Jupyter Python.
  8. Illustrate with examples how to interact with IDLE Python.
  9. Explain how mathematical expressions can be executed in interactive shell.
  10. Illustrate with example how write and execute programs in Jupyter Editor.
  11. Explain the different components of Jupyter Editor.
  12. Define Program. Differentiate between Compiler and Interpreter. Give Examples.
  13. What are Python words and sentences? Explain with an example for each.
  14. Classify the following list of items into variables, values, operators, strings, and keywords:
    List of items: *, + , – , **, < ,> , ‘hello’ , ‘ I am ok . How are you’, -88.8, /, 5, and, is , not , while , for, async, x, si, p , time , rate , velocity , speed, acc , % ,&, ! , ||
  15. What are expressions? Illustrate the different types of expressions with examples.
  16. What are data types? Classify the different data types in python with examples.
  17. What are Python Variables? What rules one should follow to name the variables.
  18. Give 5 examples for valid and invalid variables.
  19. Discuss how to store values in a variable.
  20. Write a sample program and dissect the program with explanation.
  21. What are comments? What are the advantages of Comments? Explain the different ways of writing comments.
  22. Give examples for single and multiline comments.
  23. Explain the working and usage of print() function with examples.
  24. Explain the working and usage of input() function with examples.
  25. Give example to read multiple values using input().
  26. Define operands and operators. Discuss PEMDAS rules with examples.
  27. What are keywords? How many keywords are there in current version of Python?
  28. Write a program to display all keywords in the current version of Python.
  29. What are Python comments? Explain their importance with programming examples.
  30. Explain print () , input() and split() functions with example.
  31. Write a program for the following:
  32. To read and print a single value in a single line
  33. To read and print multiple values in a single line
  34. Explain the following different types of errors: Syntax errors, Semantic errors and Logic Errors.
  35. Explain the following functions with example:len() , str() , int() , float()
  36. Predict the out put and justify your answer: (i) -11%9 (ii) 7.7//7 (iii) (200 – 70)10/5 (iv) not “False” (v) 5|**2
  37. List the rules to describe a variable in Python. Demonstrate at least three different types of variables uses with an example program.
  38. Explain the following :
  39. Skills necessary for a programmer
  40. Interactive Mode
  41. Short circuit evaluation of expression
  42. Modulus operator.
  43. Mention three types of errors encountered in python program.
  44. Define the following with example : Values and Types , Variables , Expressions , Keywords , Statements , Operators and Operands, Order of Operations , Modulus Operators , String operations and Comments.
  45. What three functions can be used to get the integer, floating-point number, or string version of a value?

Programs for Practice:
Write and execute python programs for the following :

  1. To prompt a user for their name and then welcomes them.
  2. To prompt a user for days and rate per day to compute gross salary.
  3. To read the following input and display :
    a. Name :
    b. USN:
    c. Roll No:
    d. Mobile No:
    e. E-Mail Id:
    f. Percentage of Marks:
  4. To find the simple interest for a given value of P, T and R. Program should take input from the user.
  5. To find the compound interest.
  6. To read two integers and find the sum,diff, mult and div.
  7. To Convert given Celsius to Fahrenheit temperature.
  8. To print ascii value of a character.
  9. To display all the keywords.
  10. To print the following string in a specific format :””Twinkle, twinkle, little star, How I wonder what you are! Up above the world so high, Like a diamond in the sky. Twinkle, twinkle, little star, How I wonder what you are” .
    Output :
    Twinkle, twinkle, little star,
    How I wonder what you are!
    Up above the world so high,
    Like a diamond in the sky.
    Twinkle, twinkle, little star,
    How I wonder what you are
  11. To get a python version.
  12. To display the current date and time
  13. To accept the radius of a circle from the user and compute the area.
  14. To print the calendar of a given month and year.
  15. To check whether a file exists .
  16. To determine if a Python shell is executing in 32 bit or 64 bit mode on OS.
  17. To get OS name , platform and release information .
  18. To locate Python site packages.
  19. To call an external command in python.
  20. To get path and name of the file that is currently executing.
  21. To parse a string to float or integer.
  22. To list all files in a directory in Python.
  23. To print without newline or space.
  24. To determine profiling of Python programs.
  25. To print to stderr.
  26. To access environment variables.
  27. To get the current username.
  28. To find the local IP addresses using Pythons stdlib.
  29. To get execution time for a python method.
  30. To convert height in meters to centimeters.
  31. To Convert all units of time to seconds
  32. To convert the distance in feet to inches , yards and miles.
  33. To calculate body mass index.
  34. Given variables x = 15 and y = 30 , write a Python program to print “15+30=45”.
  35. To get the identity of the object
  36. To check whether a string is numeric.
  37. To get the system time .
  38. To clear the screen or terminal
  39. To calculate the time runs (difference between start and current time ) of a program.
  40. To input integer if not generate error.
Information shared by : PALGUNI G T