Quiz Space

Programming in Python OPPE 1: January 2025, Set 4 (January 2025 term)

Question 1

+10 marksProgramming

Given two angles of a triangle (theta_1 and theta_2) in degrees, determine if the triangle is obtuse. A triangle is obtuse if it has one angle greater than 90 degrees.

Examples

>>> is_obtuse(30, 60) # other angle is 90 so right triangle
False
>>> is_obtuse(100, 40) # has an angle 100, so obtuse
True
>>> is_obtuse(30, 30) # other angle is 120, so obtuse
True
>>> is_obtuse(60, 45) # other angle is 75, so acute
False

Your task

Implement this function:

def is_obtuse(theta_1: int, theta_2: int) -> bool:

Write the function only — the arguments are read for you and the return value is printed automatically.

Arguments arrive as one Python literal per line, in this order: theta_1, theta_2.

Example

Input

30
60

Output

False

Question 2

+10 marksProgramming

Given a string containing a Markdown image link of the format alt text, convert it to a proper HTML image tag of the format <img src="image_url" alt="alt text">.

Examples

>>> markdown_to_html_image("![awesome dog](dog.jpg)")
'<img src="dog.jpg" alt="awesome dog">'
>>> markdown_to_html_image("![python logo](python.png)")
'<img src="python.png" alt="python logo">'

Your task

Implement this function:

def markdown_to_html_image(markdown_image: str) -> str:

Write the function only — the arguments are read for you and the return value is printed automatically.

Arguments arrive as one Python literal per line, in this order: markdown_image.

Example

Input

"![awesome dog](dog.jpg)"

Output

'<img src="dog.jpg" alt="awesome dog">'

Question 3

+10 marksProgramming

Write a function remove_n_elems_from_index that takes a tuple t, an integer n, and an index i as input. The function should return a new tuple with the n elements starting at index i removed. If the index i is out of bounds, return the original tuple.

NOTE: This is a function type question, you don't have to take input or print the output, just have to complete the required function definition.

Examples

>>> remove_n_elems_from_index((1, 2, 3, 4, 5), 2, 1)
(1, 4, 5)
>>> remove_n_elems_from_index((10, 20, 30, 40, 50), 3, 2)
(10, 20, 30)
>>> remove_n_elems_from_index((1, 2, 3, 4, 5), 5, 0)
()

Your task

Implement this function:

def remove_n_elems_from_index(t: tuple, n: int, i: int) -> tuple:

Write the function only — the arguments are read for you and the return value is printed automatically.

Arguments arrive as one Python literal per line, in this order: t, n, i.

Example

Input

(1, 2, 3, 4, 5)
2
1

Output

(1, 4, 5)

4 more questions in this paper

Sign in with Google — it is free — to see every question with its answer and explanation, practise it in learning mode, or take it as a timed mock test.

More on the Python OPPE 1 Jan 2025 Set 4 paper

The IIT Madras BS Programming in Python (Python) OPPE 1 paper sat on Jan 2025, in the January 2025 term (T1 2025), set 4: 7 questions for 100 marks in 180 minutes. The first 3 questions are below. Sign in with Google — it is free — to see the whole paper with its answers and explanations, in learning mode or as a timed mock test.

FeaturePython OPPE 1 Jan 2025 Set 4 at a glance
TermJanuary 2025 term (T1 2025)
SubjectProgramming in Python
Course codeBSCS1002
Questions7
Marks100
Duration180 min
Programming7
Official paperOPPE 1, Jan 2025 Set 4
Negative markingNo negative marking.
Updated

Other sets that day

More Python