Professional Documents
Culture Documents
(ii) math.floor(x):
The math.floor(x) function is used to return the
largest integer value less than or equal to x. It
rounds down a floating-point number x to the nearest
integer towards negative infinity.
(iii) math.pow(x, y):
The math.pow(x, y) function is used to compute the
value of x raised to the power of y. It returns the
result as a floating-point number.
B) Write a program to plot sine wave using
matplotlib. matplotlib.
Ans-
Output-
C)List out various file accessing modes and explain
each of them.
Ans-
the various file accessing modes in Python and their
explanations:
=>r (read):
Opens the file for reading only. The file pointer is
positioned at the beginning of the file. If the file
does not exist, a FileNotFoundError is raised. This
is the default mode for opening files.
=>w (write):
Opens the file for writing only. The file pointer is
positioned at the beginning of the file. If the file
exists, its contents are overwritten. If the file
does not exist, it is created.
Mode Description
r Opens the file for reading only.
r+ Opens the file for both reading and writing.
w Opens the file for writing only.
w+ Opens the file for both writing and reading.
a Opens the file for appending only.
a+ Opens the file for both appending and reading.
OR
A) List out functions for writing to file operation
and explain each.
Ans-
some of the functions for writing to file operation
in Python:
Example
-> find:
The find function is used to locate the first
occurrence of a substring within a string. It returns
the index of the first character of the substring if
found, and -1 if the substring is not present in the
string.
The general syntax of find is as follows:
Example-
C) Write a program to read a date in the format
DD/MM/YYYY and print the same date in MM-DD-YYYY
format.
Ans-
Output-