TN Board 12th Computer Science Important Questions Chapter 5 Python -Variables and Operators

TN State Board 12th Computer Science Important Questions Chapter 5 Python -Variables and Operators

Question 1.
Write the short notes on Python IDLE.
Answer:

  1. The python IDLE (Integrated Development Learning Environment) is used to develop and run python code.
  2. IDLE is working in interactive mode, so python code can be directly typed and the displays the results immediately.

Question 2.
Write the short note on script mode programming.
Answer:

  1. Python script is a text file containing its statements.
  2. Python scripts are reusable code.
  3. Once the script is created, it can be executed again and again.

Samacheer Kalvi TN State Board 12th Computer Science Important Questions Chapter 5 Python -Variables and Operators

Question 3.
Rewrite the following identifiers are valid or invalid.
(i) TOTAL
(ii) 50 students
(iii) student#
(iv) SALARY
(v) GRANDTOTAL
(vi) Break
Answer:

Valid Identifiers:
(i) TOTAL,
(iv) SALARY,
(v) GRANDTOTAL

Invalid Identifiers:
(ii) 50 students,
(iii) student#,
(vi) Break

Question 4.
What is the keywords?
Answer:
Keywords are special words used by python interpreter to recognize the structure of program.
They cannot be used for any other purpose.
Eg:break, while, class etc..

Samacheer Kalvi TN State Board 12th Computer Science Important Questions Chapter 5 Python -Variables and Operators

Question 5.
Write the python fundamental data types.
Answer:
Python has Built-in or fundamental data types such as Numbers, String, Boolean, Tuples, Lists and Dictionaries.

Question 6.
What is a number Data type?
Answer:
The built-in number objects in python supports integers, floating point numbers and complex numbers.,
Eg: 100, 2056, 78656
256.75, 2008.06

Question 7.
What is a Boolean Data type?
Answer:
Boolean means Tme or False. A Boolean data can have any of the two values, True or False.
Eg: Bool _ var 1 = True
Bool _ var 2 = False.

Samacheer Kalvi TN State Board 12th Computer Science Important Questions Chapter 5 Python -Variables and Operators

Question 8.
What is a string data type?
Answer:
String data can be enclosed with single quote or double quote or triple quote.
Eg: String data = “computer Science”

Question 9.
What is a conditional operator?
Answer:
Ternary operator is also known as conditional operator that evaluates something based on a condition being true or false.

It simply allows, testing a condition in a single line replacing the multiline of if-else making the code.

Question 10.
Write the key features of python.
Answer:

  1. Python is a general purpose programming language which can be used for both scientific and non-scientific programming.
  2. Python platform is a independent programming language.
  3. Python programs are easily readable and understandable.

Samacheer Kalvi TN State Board 12th Computer Science Important Questions Chapter 5 Python -Variables and Operators

Question 11.
Write the comments in python.
Answer:

  1. In Python, comments begin with hash symbol (#). ,
  2. The lines that begins with # are considered as comments.
  3. Python comments may be single line or multilines.
  4. The multiline comments should be enclosed within a set of #.

Question 12.
What is Indentation?
Answer:

  1. Python uses whitespace such as spaces and tabs to define program blocks.
  2. The number of whitespaces (spaces and tabs) in the indentation is not fixed.
  3. But all statements within the block must be indented with same amount of spaces.

Samacheer Kalvi TN State Board 12th Computer Science Important Questions Chapter 5 Python -Variables and Operators

Question 13.
Define:
(a) Operators
(b) Operands.
Answer:
(a) Operators:
Operators are special symbols which represent computations, conditional matching etc.

(b) Operands :
Value and variables when used with operator are known as operands.

Question 14.
What are the logical operators are used in python?
Answer:
There are three logical operators they are AND, OR and NOT.
Logical operators are used to perform logical operations on the given relational expressions.
Eg: (i) >>> x > y or x = = y
(ii) >>> x > y and x = = y
(iii) >>> not x > y

Samacheer Kalvi TN State Board 12th Computer Science Important Questions Chapter 5 Python -Variables and Operators

Question 15.
Write a program using Relational operators.
Answer:
# Program using Relational operators
x = int (input (“Type the value for X :”))
y = int (input (“type the value for Y:”))
print (“X=”,x, “and Y=”,y)
print (“The x = = y=”, x = = y)
print (“The x > y=”, x > y)
print (“The x < y=”, x < y)
print (“The x >= y=”, x >= y)
print (“The x <= y=”, x <= 0)
print (“The x !- y – ”, x !- y)

Question 16.
Write a python program using different assignment operators.
Answer:
# Program for using Assignment operators
X = int (input (“Type a value for X :”))
print (“X=”,x)
print (“The x += 20 is =”, x += 20
print (“The x- = 5 is =”, x- = 5)
print (“the x *= 5 is x *- 5)
print (“the x /= 2 is x/=2)
print (“The x %- 3 is x %= 3)
print (“The x **= 2 is =”, x **= 2)
print (“The x //—3 is=”,x//=3)

Samacheer Kalvi TN State Board 12th Computer Science Important Questions Chapter 5 Python -Variables and Operators

Question 17.
What are the rules should follow while writing Identifier with example?
Answer:
(i) An identifier must start with an alphabet (A..Z or a..z) or underscore (_).
(ii) Identifiers may contain digits (0.. 9)
(iii) Python identifiers are case sensitive i.e., uppercase and lowercase letters are distinct.
(iv) Identifiers must not be a python keyword.
(v) Python does not allow punctuation character such as %, $, @ etc., within identifiers.
Example of valid identifiers:
Sum, totaljnarks, regno, numl

Example of invalid identifiers:
12Name, name$, total-mark, continue

Samacheer Kalvi TN State Board 12th Computer Science Important Questions Chapter 5 Python -Variables and Operators

Question 18.
Write any ten keywords used in python?
Answer:

  1. True
  2. false
  3. return
  4. class
  5. for
  6. if
  7. elif
  8. continue
  9. break
  10. pass

Question 19.
Write a python program to add, subtract, multiply, divide for any two number using Input statement?
Answer:
# python program to add, sub, mul, divide any two numbers.
X = int (input (“Type number 1 ”))
Y = int (input (“Type number 2”))
print (“Sum = “, x+y)
print (“Difference x-y)
print (“Quotient – “, x/y)
print (“Product = “, x*y).

Samacheer Kalvi TN State Board 12th Computer Science Important Questions Chapter 5 Python -Variables and Operators

Question 20.
What are the different modes that can be used to test Python Program?
Answer:
There are two modes that can be used to test python program.

  • Interactive mode – using python IDLE window.
  • Script mode – using python Shell window.

Question 21.
Write short notes on Tokens.
Answer:

  1. Python breaks each logical line into a sequence of elementary lexical components known as Tokens.
  2. The normal Token types are Identifiers, keywords, operators, Delimiters and literals.

Question 22.
What are the different operators that can be used in Python?
Answer:
The different operators that can be used in python are Arithmetic, Relational, logical, Assignment and conditional.

Samacheer Kalvi TN State Board 12th Computer Science Important Questions Chapter 5 Python -Variables and Operators

Question 23.
What is a literal? Explain the types of literals.
Answer:
Literal is a raw data given in a variable or constant. In python, there are various types of Literals. –

  1. Numeric
  2. String and
  3. Boolean.

Question 24.
Write short notes on Exponent data.
Answer:
An Exponent data contains decimal digit part, decimal point, exponent part followed by one or more digits.
Eg: 12.E04,41.e04

Question 25.
Write short notes on Arithmetic operators with examples.
Answer:

  1. An arithmetic operator is a mathematical operator that takes two operands and performs a calculation on them.
  2. They are used for simple arithmetic calculations.
  3. Python supports the arithmetic operators are +, -, *, /, %, (modules), ** (Exponent) and // (Floor Division).

Samacheer Kalvi TN State Board 12th Computer Science Important Questions Chapter 5 Python -Variables and Operators

Question 26.
What are the assignment operators that can be used in Python?
Answer:

  1. = (equal to) is the python simple assignment operator to assign values to variable.
  2. Let a, b=5, 10 assign the value 5 and 10 on the right to the variables a and b respectively.
  3. There are various compound operators in python like +=, – =, *=, /=, %=, **= and = are also available.

Question 27.
Explain Ternary operator with examples.
Answer:
(i) Ternary operator is also known as conditional operator that evaluates something based on a condition being true or false.
(ii) It simply allows testing a condition in a single line replacing the multiline if-else making the code.
(iii) The syntax is
Variable Name = [on-true] if [Text expression] else [on-false].
Eg:
min = 100 if 99 <100 else # min =100
min = 100 if 99 >100 else # min =150

Samacheer Kalvi TN State Board 12th Computer Science Important Questions Chapter 5 Python -Variables and Operators

Question 28.
Write short notes on Escape sequences with examples.
Answer:
(i) “/” (back slash) is a special character called the escape character in python strings.
(ii) It is used in representing certain whitespace characters are “\t” is a tab, “\n” is a newline, and “\r” is a carriage return.
Eg:
>>> print (“DonVt”)
>>> print (“python”, “\n”, “Language”)
The output will be printed as
Don’t
Python
Language

Question 29.
What are string literals? Explain.
Answer:
(i) Python supports single, double and triple quotes for a string.
(ii) A character literal is a single character surrounded by single or double quotes.
(iii) The value with triple-quote “‘ “‘ is used to give multiline string literal.
Eg:
char = “A”
print (char)
C will be printed
strings = “SCHOOL”
The output is SCHOOL
multiline_str=“TWELTH STANDARD”
The output is TWELTH STANDARD.

Samacheer Kalvi TN State Board 12th Computer Science Important Questions Chapter 5 Python -Variables and Operators

Question 30.
Describe in detail the procedure Script mode programming.
Answer:

  1. Python script mode is a text file containing statements.
  2. Python scripts are reusable code. Once the script is created, it can be executed again and again without retyping.
  3. Choose File → New file or press ctrl+N in python shell window to create scripts.
  4. An untitled blank script text editor will be displayed on the screen, now type python coding.
  5. Choose File → save or press ctrl+S for saving the python typed script.
  6. Choose Run → Run module or press F5 to execute the python script.
  7. If your script has any error, for correct all error, that is free code.
  8. The output will appear in the IDLE window of python.

Samacheer Kalvi TN State Board 12th Computer Science Important Questions Chapter 5 Python -Variables and Operators

Question 31.
Explain input() and print() functions with examples.
Answer:
(i) Input ( ) function is used to accept data as input at run time in python.
(ii) The syntax is variable = input (“prompt string”)
prompt string → statement or message.
(iii) The input ( ) accept all data as string or characters but not as numbers. If a numerical value is entered, the input values converted into numeric data type.
Eg:
(1) >>> Name = input (“Enter your
name”)
(2) >>> Name = input ()
(iv) The print () function is used to display result on the screen.
(v) The syntax is print (variable)
Eg:
(1) print (“The sum=”, a)
(2) print (a)
(vi) The print () displays an entire statement which is specified within print ().
(vii) Comma (,) is used as a separator in print ( ) to print more than one item.

Question 32.
Discuss in detail about Tokens in Python.
Answer:

  1. Python breaks each logical line into a sequence of elementary lexical components known as Tokens.
  2. The normal token types are identifier, keywords, operators, Delimiters and Literals.
  3. An identifier is a name used to identify a variable, function, class, module or object.
  4. An identifier must start with an alphabet (A…Z/ a..z) or underscore (_).
  5. Identifier may contain digit (0…9), and are case sensitive.
  6. Identifiers must not be a python keyword and does not allow punctuation character such as %, $, @ etc., within identifiers.

Samacheer Kalvi TN State Board 12th Computer Science Important Questions Chapter 5 Python -Variables and Operators

Choose the best answer:

Question 1.
Which name is the extension file name in python language?
(a) -pi
(b) .py
(c) .bi
(d) .phi
Answer:
(b) .py

Question 2.
How many types are Numeric Literals in python?
(a) 2
(b) 3
(c) 4
(d) 5
Answer:
(b) 3

Question 3.
Which is the character to support carriage return in python?
(a) “\r”
(b) “\t”
(c) “\n”
(d) “\c”
Answer:
(a) “\r”

Samacheer Kalvi TN State Board 12th Computer Science Important Questions Chapter 5 Python -Variables and Operators

Question 4.
How many values are made up of complex number in python?
(a) 3
(b) 4
(c) 2
(d) 5
Answer:
(c) 2

Question 5.
Match the following:

(i) #(hash)  (A) multiline string
(ii) {} (curly braces)  (B) more item single line
(iii) , (comma)  (C) blocks of code
(iv) “‘ “‘(triple – quote)  (D) comments

(a) (i) – B, (ii) – C, (iii) – D, (iv) – A
(b) (i)- D, (ii) – C, (iii) – B, (iv) – A
(c) (i) – B, (ii) – D, (iii) – A, (iv) – C
(d) (i) – D, (ii) – B, (iii) – A, (iv) – C
Answer:
(b) (i)- D, (ii) – C, (iii) – B, (iv) – A

Question 6.
Match the following:

(i) “\” (back slash)  (A) tab
(ii) “\t”  (B) escape character
(iii) “\n”  (C) carriage return
(iv) “\r”  (D)  newline

(a) (i) – B, (ii) – A, (iiij – D, (iv) – C
(b) (i) – B, (ii) – C, (iii) – D, (iv) – A
(c) (i) – C, (ii) – D, (iii) – A, (iv) – B
(d) (i) – C, (ii) – B, (iii) – A, (iv) – D
Answer:
(a) (i) – B, (ii) – A, (iiij – D, (iv) – C

Samacheer Kalvi TN State Board 12th Computer Science Important Questions Chapter 5 Python -Variables and Operators

Question 7.
Match the following:

(i) >>>  (A) Create new python program
(d) ctrl+N  (B) python prompt
(iii) continue  (C) conditional operator
(iv) Ternary  (D) keyword

(a) (i) – C, (ii) – D, (iii) – B, (iv) – A
(b) (i) – C, (ii) – B, (iii) – A, (iv) – D
(c) (i) – B, (ii) – A, (iii) – D, (iv) – C
(d) (1)- B, (ii) – D, (iii) – C, (iv) – A
Answer:
(c) (i) – B, (ii) – A, (iii) – D, (iv) – C

Question 8.
Assertion (A):
Python is a programming language which can be used for both scientific and non-scientific programming.
Reason (R):
It has independent programming language and are easily readable and understandable.
(a) Both A and R are true, and R is the correct explanation for A.
(b) Both A and R are true, but R is not the correct explanation for A.
(c) A is true, but R is false.
(d) A is false, but R is true.
Answer:
(a) Both A and R are true, and R is the correct explanation for A.

Samacheer Kalvi TN State Board 12th Computer Science Important Questions Chapter 5 Python -Variables and Operators

Question 9.
Assertion (A):
In python, the prompt (»>) indicates that interpreter is ready to accept instructions.
Reason (R):
In python, programs can be written in two namely interactive mode and script mode.
(a) Both A and R are true, and R is the correct explanation for A.
(b) Both A and R are true, but R is not the correct explanation for A.
(c) A is true, but R is false.
(d) A is false, but R is true.
Answer:
(b) Both A and R are true, but R is not the correct explanation for A.

Question 10.
Assertion (A):
In python, comments begin with * (asterisk).
Reason (R):
The lines begins with * are * considered as comments.
(a) Both A and R are true, and R is the correct explanation for A.
(b) Both A and R are true, but R is not the correct explanation for A.
(c) A is true, but R is false.
(d) Both A and R are false.
Answer:
(d) Both A and R are false.

Samacheer Kalvi TN State Board 12th Computer Science Important Questions Chapter 5 Python -Variables and Operators

Question 11.
Assertion (A):
An identifier is a name used to identify a variable or object.
Reason (R):
Python identifier are not case sensitive.
(a) Both A and R are true, and R is the correct explanation for A.
(b) Both A and R are true, but R is the not correct explanation for A.
(c) A is true, but R is false.
(d) A is false, but R is true.
Answer:
(c) A is true, but R is false.

Question 12.
Assertion (A):
Complex numbers is made up of only integer values.
Reason (R):
A Boolean data can live any of the two values.
(a) Both A and R are true, and R is the correct explanation for A.
(b) Both A and R are true, but R is not the correct explanation for A.
(c) A is true, but R is false.
(d) A is false, but R is true.
Answer:
(d) A is false, but R is true.

Question 13.
Choose the incorrect pair:
(a) IDLE – Python window
(b) %- Python prompt
(c) .py * Python file extension
(d) # * Single line comment
Answer:
(b) %- Python prompt

Samacheer Kalvi TN State Board 12th Computer Science Important Questions Chapter 5 Python -Variables and Operators

Question 14.
Choose the correct pair:
(a) Identifiers – Spaces
(b) Delimiters – Operators
(c) Literal – Variable
(d) Data types – Tab
Answer:
(c) Literal – Variable

Question 15.
Choose the incorrect statement:
(a) A text file containing the python statements.
(b) Python scripts are reusable code.
(c) Python scripts are editable.
(d) Python scripts is created, it cannot be executed.
Answer:
(d) Python scripts is created, it cannot be executed.

Question 16.
Choose the correct statement:
(a) Octal integer use O to denote octal digits.
(b) Hexadecimal integer use HX to denote Hexadecimal digits.
(c) An exponent data contains integer data.
(d) Complex number is made up of three floating point values.
Answer:
(a) Octal integer use O to denote octal digits.

Samacheer Kalvi TN State Board 12th Computer Science Important Questions Chapter 5 Python -Variables and Operators

Question 17.
Pick the odd one out:
(a) Integer
(b) String
(c) Floating
(d) Complex
Answer:
(b) String

Question 18.
Pick the odd one out:
(a) Python
(b) MS-Excel
(c) Starcalc
(d) Lotus 1-2-3
Answer:
(a) Python

Question 19.
Pick the odd one out:
(a) Identifiers
(b) Keywords
(c) Operators
(d) Prompt
Answer:
(d) Prompt

Samacheer Kalvi TN State Board 12th Computer Science Important Questions Chapter 5 Python -Variables and Operators

Question 20.
Pick odd one out:
(a) “\t”
(b) “\n”
(c) »>
(d) ‘ V’
Answer:
(c) »>

Question 21.
Expand IDLE:
(a) Information Development Learning Environment
(b) Integrated Development Learning Environment
(c) Information Development Language Environment
(d) Integrated Development Logical Environment
Answer:
(b) Integrated Development Learning Environment

Samacheer Kalvi TN State Board 12th Computer Science Important Questions Chapter 5 Python -Variables and Operators

Question 22.
Which python mode allows to write code in command prompt?
(a) Script mode
(b) Edit mode
(c) Program mode
(d) Interactive mode
Answer:
(d) Interactive mode

Question 23.
Which mode can be used as a simple calculator in python?
(a) Script mode
(b) Edit mode
(c) Program mode
(d) Interactive mode
Answer:
(d) Interactive mode

Question 24.
Which is indicates in python that interpreter is ready to accept instructions?
(a) »>
(b) «<
(c) »
(d) «
Answer:
(a) »>

Samacheer Kalvi TN State Board 12th Computer Science Important Questions Chapter 5 Python -Variables and Operators

Question 25.
Who was created python Language?
(a) Guido Van Rossum
(b) John Maxwell
(c) Guido Wan Rouske
(d) Guido Maxwells
Answer:
(c) Guido Wan Rouske

Question 26.
Which of the following is not a identifier?
(a) Input
(b) City
(c) School
(d) Student
Answer:
(a) Input

Question 27.
Which of the following is not a immutable?
(a) Integer
(b) Float
(c) Complex
(d) Keyword
Answer:
(d) Keyword

Samacheer Kalvi TN State Board 12th Computer Science Important Questions Chapter 5 Python -Variables and Operators

Question 28.
Which of the following is used as multiple line string?
(a) ‘ ‘
(b) ” ”
(c) ‘” ‘”
(d) All of these
Answer:
(c) ‘” ‘”

Question 29.
Which of the following character is used as escape character?
(a) /
(b) \
(c) $
(d) #
Answer:
(b) \

Question 30.
Which of the following statement are ignored by the python interpreter?
(a) input ( )
(b) print ( )
(c) comments
(d) write ( )
Answer:
(c) comments

Samacheer Kalvi TN State Board 12th Computer Science Important Questions Chapter 5 Python -Variables and Operators

Question 31.
Who developed Python?
(a) Ritche
(b) Guido Van Rossum
(c) Bill Gates
(d) Sunder Pitchai
Answer:
(b) Guido Van Rossum

Question 32.
The Python prompt indicates that Interpreter is ready to accept instruction.
(a) >>>
(b) <<<
(c) #
(d) <<
Answer:
(a) >>>

Question 33.
Which of the following shortcut is used to create new Python Program ?
(a) Ctrl + C
(b) Ctrl + F
(c) Ctrl + B
(d) Ctrl + N
Answer:
(d) Ctrl + N

Samacheer Kalvi TN State Board 12th Computer Science Important Questions Chapter 5 Python -Variables and Operators

Question 34.
Which of the following character is used to give comments in Python Program ?
(a) #
(b) &
(c) @
(d) $
Answer:
(a) #

Question 35.
This symbol is used to print more than one item on a single line:
(a) Semicolon(;)
(b) Dollor($)
(c) comma(,)
(d) Colon(:)
Answer:
(c) comma(,)

Question 36.
Which of the following is not a token ?
(a) Interpreter
(b) Identifiers
(c) Keyword
(d) Operators
Answer:
(a) Interpreter

Samacheer Kalvi TN State Board 12th Computer Science Important Questions Chapter 5 Python -Variables and Operators

Question 37.
Which of the following is not a Keyword in Python ?
(a) break
(b) while
(c) continue
(d) operators
Answer:
(d) operators

Question 38.
Which operator is also called as Comparative operator? .
(a) Arithmetic
(b) Relational
(c) Logical
(d) Assignment
Answer:
(b) Relational

Question 39.
Which of the following is not Logical operator?
(a) and .
(b) or
(c) not
(d) Assignment
Answer:
(d) Assignment

Samacheer Kalvi TN State Board 12th Computer Science Important Questions Chapter 5 Python -Variables and Operators

Question 40.
Which operator is also called as Conditional operator?
(a) Ternary
(b) Relational
(c) Logical
(d) Assignment
Answer:
(a) Ternary

TN Board 12th Computer Science Important Questions