Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

1.

Python Script and Program: A Python script is a file containing executable Python
code that is intended to be run directly. It performs a series of commands in logical
order to accomplish a task. A Python program can be a script but might also refer to a
larger project consisting of multiple scripts, modules, packages, and libraries designed
to perform complex tasks. A script often contains code outside the scope of any classes
or functions and is designed to do something when executed through the Python
interpreter.
2. Difference Between Syntax and Semantics: Syntax in programming refers to the rules
that define the structure of a language, such as how commands are written and
organized. Semantics, on the other hand, deals with the meaning of those commands
and structures within the context of the language. Syntax errors occur when the code
does not follow the prescribed structure, whereas semantic errors arise when the code
does not do what the programmer intended, even though it follows the correct syntax.
3. Finding Syntax Errors: Syntax errors are usually detected by the programming
environment or during compilation/interpretation. For Python, the interpreter itself will
throw syntax errors when the code is executed if there are any discrepancies in the
structure that violate Python's syntax rules.
4. Semantic Errors: Unlike syntax errors, semantic errors are not caught by the interpreter
because the code is syntactically correct. Detecting semantic errors requires testing and
debugging to ensure that the program behaves as intended. This can involve using print
statements, debugging tools, or writing test cases.
5. Types of Errors in a Program: There are generally three main types of errors in
programming: syntax errors, semantic (logical) errors, and runtime errors. Runtime errors
occur during the execution of a program, such as trying to divide by zero or accessing
an out-of-bounds index in a list.
6. Data Type: A data type specifies the kind of data that a variable can hold, such as
integers, floats (decimal numbers), strings (text), or booleans (true/false). Data types
help ensure that operations on variables are valid and make the code more readable
and maintainable.
7. Variable Declaration Conventions in Python: Variables in Python are declared by
assigning a value to a name without declaring its type explicitly. The convention is to
use lowercase letters for variable names, and if a name contains multiple words, they
should be separated by underscores. For example, my_variable = 10. Python does not
require or allow explicit type declaration for variables.
8. Declaring Variables with Data Types: Python is a dynamically typed language, which
means you do not need to declare variables with data types explicitly. The interpreter
infers the type of a variable at runtime.
9. Python Programming Cycle: The programming cycle for Python involves writing the
code in a text editor or integrated development environment (IDE), running the script
through the Python interpreter, and then testing and debugging the code as needed.
The cycle repeats with modifications and improvements until the program behaves as
desired.
10. What is Python?: Python is a high-level, general-purpose programming language
known for its emphasis on code readability and its support for multiple programming
paradigms, including procedural, object-oriented, and functional programming. It is
dynamically typed and comes with a comprehensive standard library, often described as
a "batteries included" language.

1. What is Python Script and Program?


2. What's the difference between syntax and semantics?
3. How do you find syntax errors?
4. Semantics errors?
5. How many types of errors are present in a Program?
6. What is a data type?
7. What are the conventions and rules for declaring a variable in
Python?
8. Do we need to declare variables with data types in Python?
9. Explain the programming cycle for Python. How Python Works?
10. What is Python?

You might also like