Chapter 4 – Very Able Variables | Python Class 7 MCQs, Exercises & Programs – Set 2

CHAPTER 4 – VERY ABLE VARIABLES

MULTIPLE CHOICE QUESTIONS

  1. Which of the following is not a correct assignment in Python?
    a. x = 10
    b. _value = 25
    c. 1st_number = 50
    d. name = “Arjun”

  1. What will be the output of the following code?
a = 5
b = 2
print(a // b)

a. 2.5
b. 2
c. 3
d. Error


  1. If the input is 3 for the following program, what is displayed?
num = int(input("Enter a number: "))
print(num ** 2)

a. 3
b. 6
c. 9
d. Error


  1. What will the following program print?
x = "Hello"
y = "World"
print(x + " " + y)

a. HelloWorld
b. Hello World
c. “Hello” + “World”
d. Error


  1. Which function is used to check the data type of a variable?
    a. datatype()
    b. typeof()
    c. print()
    d. type()


FILL IN THE BLANKS

  1. Variables are used to store __________ in a program.
  2. The operator ** is used for __________ in Python.
  3. A string is always enclosed in __________ or __________.
  4. The function int() is used to perform __________ casting.
  5. Python is a __________ typed language, meaning variable types can change at runtime.


DESCRIPTIVE QUESTIONS

  1. Write a Python program to input two numbers and print their average.

  1. Explain the difference between = (assignment operator) and == (comparison operator) with examples.

  1. Write a program that accepts the user’s name and age, then prints a message:
Hello <name>, you are <age> years old.

  1. What is the difference between int, float, and str data types? Give one example of each.

  1. Explain why my-variable is not a valid variable name in Python. Rewrite it correctly in two valid ways.

Answer Key

ANSWER KEY

MULTIPLE CHOICE QUESTIONS

  1. c. 1st_number = 50 (variable names cannot start with a digit)
  2. b. 2 (5 // 2 gives floor division result = 2)
  3. c. 9 (3 ** 2 = 9)
  4. b. Hello World (+ with strings performs concatenation, " " adds space)
  5. d. type()

FILL IN THE BLANKS

  1. data / values
  2. exponentiation / power
  3. single quotes (‘ ’) or double quotes (“ ”)
  4. type / data type (string → integer)
  5. dynamically

DESCRIPTIVE QUESTIONS

  1. Program for average of two numbers
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
avg = (a + b) / 2
print("Average =", avg)

  1. Difference between = and ==
  • = is the assignment operator. Example: x = 10 assigns 10 to x.
  • == is the comparison operator. Example: x == 10 checks if x is equal to 10, returns True or False.

  1. Program for name and age message
name = input("Enter your name: ")
age = input("Enter your age: ")
print("Hello", name + ", you are", age, "years old.")

  1. Difference between int, float, str
  • int: whole numbers (e.g., age = 25)
  • float: decimal numbers (e.g., temperature = 36.7)
  • str: text (e.g., name = "Arun")

  1. Invalid variable name correction
  • my-variable is invalid because - is not allowed in variable names.
  • Valid alternatives: my_variable, myVariable

Leave a Reply

Discover more from Abhyas

Subscribe now to keep reading and get access to the full archive.

Continue reading