Basic python-3 (QNA)

Q1: How are floating constants represented in Python? Give examples to support your answer.
A1: Floating constants, or floating-point numbers, are represented in Python by including a decimal point in the number. Python allows for a compact representation of floating-point numbers when the numbers are too large or too small. This is done using scientific notation. For example, `3.14`, `0.99`, and `1.0e-4` (which represents 0.0001) are all floating constants in Python.
Q2: How are string-literals represented and implemented in Python?
A2: String literals in Python are represented by enclosing a sequence of characters within quotes. Python allows the use of either single quotes (`’`) or double quotes (`”`), and also triple quotes (`”’` or `”””`) for multi-line strings. For example, `”Hello, World!”`, `’Python’` and `”’This is a multiline string.”’` are all string literals.
Q3: What are operators? What is their function? Give examples of some unary and binary operators.
A3: Operators are special symbols in Python that carry out arithmetic or logical computation. The value or variable that the operator operates on is called the operand. Unary operators operate on a single operand, while binary operators operate on two operands. Unary operators in Python include unary plus (`+x`), unary minus (`-x`), and logical negation (`not x`). Binary operators include addition (`x + y`), subtraction (`x – y`), multiplication (`x * y`), division (`x / y`), and many others.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top