100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Book review Python Oswaal CBSE Class 12 Computer Science Question Bank 2023-24 Book, ISBN: 9789356349643 $6.59   Add to cart

Book review

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

 10 views  0 purchase
  • Course
  • Institution
  • Book

This contains best questions in chapter function (python)

Preview 3 out of 24  pages

  • April 29, 2023
  • 24
  • 2022/2023
  • Book review
  • Unknown
  • Secondary school
  • 5
avatar-seller
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

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller aasifkhan1. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $6.59. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

77764 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$6.59
  • (0)
  Add to cart