CBSE Class 11 Computer Science Chapter 10: Functions NCERT Solutions
CBSE Class 11 Computer Science Chapter 10, 'Functions', introduces students to essential programming concepts. This chapter covers how to utilize command-line arguments with `sys.argv` and evaluate string expressions using the `eval()` function, while also addressing error handling for issues like `NameError`. Furthermore, it explores a variety of mathematical functions available in Python's `math` module. Students will learn about functions such as `ceil()`, `floor()`, `fabs()`, `exp()`, `log10()`, and `sqrt()`. The chapter also includes trigonometric functions like `cos()`, `sin()`, `tan()`, and functions for angle conversion, namely `degrees()` and `radians()`. These solutions aim to provide a clear understanding of function usage and their practical applications, aiding students in their exam preparation.
Quick info
| Board | CBSE |
|---|---|
| Class | Class 11 |
| Subject | Computer Science |
| Session | 2026 |
| Language | English |
| Type | NCERT Solutions |
| Chapter | 10. Functions |
Chapter summary
Chapter 10 on Functions for CBSE Class 11 Computer Science covers the practical usage of Python's built-in functions and modules. It explains command-line arguments, string evaluation, and common mathematical and trigonometric functions. The solutions clarify the purpose and output of functions like `sys.argv`, `eval()`, `ceil()`, `floor()`, `fabs()`, `exp()`, `log10()`, `sqrt()`, `cos()`, `sin()`, `tan()`, `degrees()`, and `radians()`, along with error types like `NameError`. This chapter focuses on applying these functions to solve programming problems.
Learning outcomes
- Understand the purpose and usage of `sys.argv` for command-line arguments.
- Explain the functionality of the `eval()` function for string expression evaluation.
- Identify and describe various mathematical functions like `ceil()`, `floor()`, `fabs()`, `exp()`, `log10()`, and `sqrt()`.
- Apply trigonometric functions (`cos()`, `sin()`, `tan()`) in Python.
- Convert angles between radians and degrees using `degrees()` and `radians()`.
- Recognize the `NameError` exception and its common causes.
Topics covered
Paper topics
- sys.argv
- Command-line arguments
- eval() function
- String evaluation
- NameError exception
- math module
- ceil()
- floor()
- fabs()
- exp()
- log10()
- sqrt()
- Trigonometric functions (cos, sin, tan)
- Angle conversion (degrees, radians)
Important topics
- sys.argv and command-line arguments
- eval() function usage and implications
- Core math functions (ceil, floor, fabs, sqrt, exp, log10)
- Trigonometric and angle conversion functions
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 the purpose of `sys.argv` and `sys.argv[1:]`.
- Misunderstanding the return values of `ceil()` and `floor()` functions.
- Incorrectly applying trigonometric functions without considering radian input.
- Assuming `eval()` can safely execute any arbitrary string without security risks.
Revision tips
- Practice using `sys.argv` by running Python scripts with different command-line arguments.
- Experiment with the `math` module functions in an interactive Python session to observe their outputs.
- Review the definitions of ceiling and floor values to avoid confusion.
- Understand the difference between degree and radian measures for angles and their conversion.
Practice MCQs
Q1. What does `sys.argv` represent in Python?
Explanation: `sys.argv` is a list in Python that contains the script name as the first element, followed by all the command-line arguments passed to the script.
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, and returns the result of that expression.
Q3. What is the primary use of the `ceil(x)` function?
Explanation: The `ceil(x)` function returns the smallest integer value that is greater than or equal to x. For example, `ceil(4.2)` is 5.0.
Q4. The `NameError` exception typically occurs when:
Explanation: `NameError` is raised when you try to use a variable or call a function that has not been defined in the current scope, often due to a typo or forgetting to initialize it.
Q5. Which function returns the base-10 logarithm of a number?
Explanation: The `log10(x)` function from the `math` module specifically calculates and returns the logarithm of x to the base 10.
Q6. To convert an angle from radians to degrees, which function is used?
Explanation: The `degrees(x)` function takes an angle `x` in radians and converts it into its equivalent value in degrees.
Frequently asked questions
What is `sys.argv` used for in Python?
`sys.argv` is a list that holds the command-line arguments passed to a Python script. The first element (`sys.argv[0]`) is the script's name, and subsequent elements are the arguments provided.
How does the `eval()` function work?
The `eval()` function takes a string as input, interprets it as a Python expression, executes it, and returns the result. It's powerful but should be used cautiously due to security risks with untrusted input.
What is the difference between `ceil(x)` and `floor(x)`?
`ceil(x)` returns the smallest integer greater than or equal to x (rounds up), while `floor(x)` returns the largest integer less than or equal to x (rounds down).
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 assigned a value in the current scope. This often happens due to typos or forgetting to initialize a variable.
What are the `math` module functions covered in this chapter?
This chapter covers several `math` module functions including `ceil()`, `floor()`, `fabs()` (absolute value), `exp()` (e^x), `log10()` (base-10 logarithm), `sqrt()` (square root), trigonometric functions (`cos()`, `sin()`, `tan()`), and angle conversion functions (`degrees()`, `radians()`).
How can I use the trigonometric functions like `cos(x)`?
The trigonometric functions in Python's `math` module, such as `cos(x)`, expect the angle `x` to be in radians. You can use `math.degrees()` to convert from degrees to radians if needed.
Content reviewed by the NCERT Help team. Editorial Team and update policy
NCERT Solutions PDF PDF on NCERT Help. URL unchanged for search indexing.