CBSE Class 11 Computer Science: Chapter 10 - Functions NCERT Solutions
This chapter delves into essential Python programming concepts, focusing on functions and their applications. Students will explore command-line arguments using `sys.argv`, understand the utility of the `eval()` function for dynamic expression evaluation, and learn about various mathematical functions provided by the `math` module. Key functions covered include `ceil()`, `floor()`, `fabs()`, `exp()`, `log10()`, `sqrt()`, `cos()`, `sin()`, `tan()`, `degrees()`, and `radians()`. The solutions also touch upon handling `NameError` exceptions, which occur when a variable or function is not defined. These detailed explanations and solutions are designed to help Class 11 students grasp these fundamental programming tools, clarify doubts, and prepare effectively for their examinations by reinforcing theoretical knowledge with practical examples.
Quick info
| Board | CBSE |
|---|---|
| Class | Class 11 |
| Subject | Computer Science |
| Session | 2026 |
| Language | English |
| Type | NCERT Solutions |
| Chapter | Chapter 10 |
Chapter summary
Chapter 10 of the CBSE Class 11 Computer Science syllabus focuses on 'Functions'. This section provides NCERT Solutions that explain command-line arguments, the `eval()` function, and a variety of mathematical functions available in Python's `math` module. It covers functions for rounding (`ceil`, `floor`), absolute value (`fabs`), exponentiation (`exp`), logarithms (`log10`), square roots (`sqrt`), trigonometric operations (`cos`, `sin`, `tan`), and angle conversions (`degrees`, `radians`). Additionally, it addresses the `NameError` exception. These solutions aim to provide clear, step-by-step understanding for students.
Learning outcomes
- Understand the purpose and usage of `sys.argv` for command-line arguments.
- Explain the functionality of the `eval()` function in Python.
- Identify and describe various mathematical functions like `ceil`, `floor`, `fabs`, `exp`, `log10`, `sqrt`, `cos`, `sin`, `tan`.
- Differentiate between `degrees()` and `radians()` for angle conversions.
- Recognize the `NameError` exception and its common causes.
- Apply mathematical functions to solve computational problems.
Topics covered
Paper topics
- Command-line arguments (`sys.argv`)
- Expression evaluation (`eval()` function)
- Mathematical functions (`math` module)
- Ceiling function (`math.ceil`)
- Floor function (`math.floor`)
- Absolute value function (`math.fabs`)
- Exponential function (`math.exp`)
- Logarithm function (`math.log10`)
- Square root function (`math.sqrt`)
- Trigonometric functions (`math.cos`, `math.sin`, `math.tan`)
- Angle conversion functions (`math.degrees`, `math.radians`)
- Error handling (`NameError`)
Important topics
- Command-line arguments (`sys.argv`)
- Expression evaluation (`eval()` function)
- Core mathematical functions (`ceil`, `floor`, `sqrt`, `log10`)
- Trigonometric and angle conversion functions
- Understanding and handling `NameError`
PDF preview
Read page by page below. PDF is streamed from the official NCERT website — no download button on this page.
Questions and Solutions
Question 1
Question 2
Question 3
Question 4
Question 5
Question 6
Question 7
Question 8
Question 9
Question 10
Question 11
Question 12
Question 13
Question 14
Question 15
Common mistakes
- Confusing `sys.argv` with list indexing for arguments.
- Misunderstanding the return type or behavior of `eval()`.
- Incorrectly applying rounding functions (`ceil` vs. `floor`).
- Not specifying the correct unit (radians/degrees) for trigonometric functions.
- Assuming variables or functions are defined when they are not, leading to `NameError`.
Revision tips
- Practice using `sys.argv` by running Python scripts with different command-line inputs.
- Experiment with the `eval()` function to see how it handles various string expressions.
- Work through examples for each `math` module function to solidify understanding of their outputs.
- Pay close attention to the units (radians vs. degrees) when using trigonometric and conversion functions.
- Review common error types like `NameError` and understand how to prevent them.
Practice MCQs
Q1. What does `sys.argv` represent in a Python script?
Explanation: `sys.argv` is a list in Python that contains the command-line arguments passed to a script. The first element (`sys.argv[0]`) is the script name itself.
Q2. Which function evaluates a string as a Python expression?
Explanation: The `eval()` function takes a string as input, interprets it as a Python expression, evaluates it, and returns the result.
Q3. What is the primary purpose of the `math.ceil(x)` function?
Explanation: `math.ceil(x)` returns the ceiling of x, which is the smallest integer value that is greater than or equal to x.
Q4. Which function returns the base-10 logarithm of a number?
Explanation: `math.log10(x)` is specifically designed to return the base-10 logarithm of x, often providing better accuracy than `math.log(x, 10)`.
Q5. A `NameError` typically occurs when:
Explanation: A `NameError` is raised when Python encounters a name (like a variable or function name) that it does not recognize in the current scope, usually because it hasn't been defined yet.
Q6. To convert an angle from radians to degrees, which function should be used?
Explanation: The `math.degrees(x)` function is used to convert an angle `x` from radians into degrees.
Frequently asked questions
What are command-line arguments in Python and how are they accessed?
Command-line arguments are values passed to a Python script when it is executed from the terminal. They are accessed using the `sys.argv` list, where `sys.argv[0]` is the script name and subsequent elements are the arguments.
How does the `eval()` function work?
The `eval(s)` function takes a string `s` containing a Python expression, evaluates that expression, and returns the resulting object. It's powerful but should be used cautiously due to security implications.
What is the difference between `math.ceil()` and `math.floor()`?
`math.ceil(x)` returns the smallest integer greater than or equal to `x`, while `math.floor(x)` returns the largest integer less than or equal to `x`.
When does a `NameError` occur in Python?
A `NameError` occurs when you try to use a variable or function name that has not been defined or is not accessible in the current scope. This often happens due to typos or forgetting to initialize a variable.
How can I convert angles between radians and degrees in Python?
You can use the `math.degrees(x)` function to convert an angle `x` from radians to degrees, and `math.radians(x)` to convert an angle `x` from degrees to radians.
Are the trigonometric functions in Python's `math` module based on degrees or radians?
The trigonometric functions like `cos()`, `sin()`, and `tan()` in Python's `math` module expect the input angle `x` to be in radians.
Content reviewed by the NCERT Help team. Editorial Team and update policy
NCERT Solutions PDF PDF on NCERT Help. URL unchanged for search indexing.