100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Book review

Oswaal CBSE Class 12 Computer Science Question Bank 2023-24 Book, ISBN: 9789356349643

Rating
-
Sold
-
Pages
24
Uploaded on
29-04-2023
Written in
2022/2023

This guide provides you the best queston possible in computer science on chapter functions with solution 100% legit high quality upload

Institution
Course










Whoops! We can’t load your doc right now. Try again or contact support.

Connected book

Written for

Institution
Secondary school
Course
School year
5

Document information

Uploaded on
April 29, 2023
Number of pages
24
Written in
2022/2023
Type
Book review

Subjects

Content preview

CHAPTER



2 FUNCTIONS

Syllabus Functions: Types of function (built-in functions, functions defined in
module, user defined functions), Creating user defined function, arguments
and parameters, default parameters, positional parameters, function
returning value(s), flow of execution, scope of a variable (global scope, local scope)


In this chapter you will study
 At the end of this chapter the students will be able to understand: How Functions are defined in programs, how parameters
are passed in functions, how strings, lists, tuples and dictionaries are passed in functions, using default and positional
parameters, how functions return values. library functions are used.




Revision Notes
A function is a named block of statements that can be [expression] exit a function, optionally passing back
invoked by its name. A function is organized and an expression to the caller. A return statement with
reusable code that is used to perform a single, given no arguments is the same as return None. Defining a
action. Functions provide better modularity for your function only gives a name, specifies the parameters
application and a high degree of code reusability. that are to be included in the function, a structure the
Advantages of functions: blocks of code.
• Program development made easy and fast Example: A simple function that prints the message
• Program testing becomes easy "Hello Python".
• Code sharing becomes possible #function definition
• Code re-usability increases def hello_Python():
• Increases program readability Scan to know print("hello python")
more about
Function blocks begin with the this topic # function calling
keyword def followed by the hello_Python()
function name and parentheses e.g Output:
def sum( ): Any input parameters or hello Python
arguments should be placed within
Functions Advantages of functions:
these parentheses. You can also
• Program development made easy and fast
define parameters inside these parentheses. The first
• Program testing becomes easy
statement of a function can be an optional statement -
the documentation string of the function or docstring, • Code sharing becomes possible
The code block within every function starts with • Code re-usability increases
a colon (:) and is indented. The statement return • Increases program readability

,FUNCTIONS 51

, 52 Oswaal CBSE Question Bank Chapterwise & Topicwise, COMPUTER SCIENCE, Class-XII

Types of functions:





The built-in functions of Python are always •
radians(x): Converts angle x from degrees to
available, one needs not import required module radians.
for them. • ceil(x): Returns the ceiling of x as a float, the
Examples of Some Built-in Functions smallest integer value greater than or equal to x.
(i) print(): It prints objects to the text stream file. • floor(x): Returns floor of x as a float, the largest
(ii) input(): It reads the input, converts it to a integer value less than or equal to x.
string and returns that. • fabs(x): Returns the floating point absolute value
(iii) sorted(): Returns a new of x.
Scan to know
sorted list from the items in more about • String Functions
iterable. this topic (i)  partition(): It splits the string at the first
(iv) bool(): Returns a boolean occurrence of the given argument and
value i.e., True or False. returns a tuple containing three parts.
(v) min(): Returns the smallest (ii) join(): It takes a list of string and joins
of two or more arguments. them as a regular string.
(vi) any(): Returns True if any In-Built
(iii) split(): It splits the whole string into the
Functions
element of the iterable is items with separator as a delimiter.
True.
User-Defined Functions: User defined functions are

Modules: A module is a file containing Python those that we define ourselves in our program and
definitions and statements. A Python module has then call them wherever we need.
.py extension. The Python modules that come
Syntax to create USER DEFINED FUNCTION
preloaded with Python are called "Standard library
modules". Python modules can be imported in a def function_name([comma separated list of
program using import statement. The math module parameters]):
of Python provides mathematical functionality. statements….
• exp(x): Return e**x statements….
•  log(x,(base)): With one argument, returns the Example
natural logarithm of x (to base e). With two
arguments, returns logarithm of x to the given
base calculate as log(x)/ log(base)
• log10(x): Returns logarithm of x at base 10. This is
usually more accurate than log(x,10).
• pow(x, y): Returns x raised to the power y. In
particular, pow(l.0, x) and pow(x, 0.0) always
return 1.0, even when x is a zero or a NaN. If
both x and y are finite, x is negative, and y is
not an integer then pow(x, y) is undefined, and
raises ValueError.
• sqrt(x): Returns the square root of x.
Points to remember:
• cos(x): Returns the cosine of x radians.
• Keyword def marks the start of function header
• sin(x): Returns the sine of x radians.
• Function name must be unique and follows
• tan(x): Returns the tangent of x radians. naming rules same as for identifiers
• degrees(x): Converts angle x from radians to • Function can take arguments. It is optional
degrees.
• A colon(:) marks the end of function header
$7.99
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
aasifkhan1

Get to know the seller

Seller avatar
aasifkhan1
Follow You need to be logged in order to follow users or courses
Sold
0
Member since
2 year
Number of followers
0
Documents
6
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions