Consider the following Python statement:
F = open('CONTENT.TXT')
Which of the following is an invalid statement in Python?
F.seek(1, 0)
F.seek(0, 1)
F.seek(0, -1)
F.seek(0, 2)
The seek() method in Python is used to change the file’s current position.
It takes two arguments:
1. offset: The position (in bytes) to move the file pointer to.
2. whence: The reference point for offset.
Valid values for whence are:
0: Beginning of the file.
1: Current file position.
2: End of the file.
A value of -1 for whence is invalid, making F.seek(0, -1) incorrect.
Write a user-defined function in Python named showGrades(S) which takes the dictionary S
as an argument. The dictionary S
contains Name: [Eng, Math, Science] as key:value pairs.
The function displays the corresponding grade obtained by the students according to the following grading rules:
\[ \begin{array}{|c|c|} \hline \textbf{Average of Eng, Math, Science} & \textbf{Grade} \\ \hline \geq 90 & A \\ \hline < 90 \text{ but } \geq 60 & B \\ \hline < 60 & C \\ \hline \end{array} \]
Example: Consider the following dictionary: \[ S = \{\text{"AMIT"}: [92, 86, 64], \text{"NAGMA"}: [65, 42, 43], \text{"DAVID"}: [92, 90, 88]\} \] The output should be: \[ \text{AMIT} - B \\ \text{NAGMA} - C \\ \text{DAVID} - A \]
myStr[:4]
extracts the first 4 characters, which are "MISS"
.myStr[-5:]
extracts the last 5 characters, which are "SIPPI"
."#"
in between, resulting in "MISS#SIPPI"
.
event = "G20 Presidency@2023"
L = event.split(' ')
print(L[::-2])
Rupal, Shanu and Trisha were partners in a firm sharing profits and losses in the ratio of 4:3:1. Their Balance Sheet as at 31st March, 2024 was as follows:
(i) Trisha's share of profit was entirely taken by Shanu.
(ii) Fixed assets were found to be undervalued by Rs 2,40,000.
(iii) Stock was revalued at Rs 2,00,000.
(iv) Goodwill of the firm was valued at Rs 8,00,000 on Trisha's retirement.
(v) The total capital of the new firm was fixed at Rs 16,00,000 which was adjusted according to the new profit sharing ratio of the partners. For this necessary cash was paid off or brought in by the partners as the case may be.
Prepare Revaluation Account and Partners' Capital Accounts.