Quiz Space

Programming in Python OPPE 1: May 2026, Set 1 (May 2026 term)

Question 1

+10 marksProgramming

Write a function traffic_signal(vehicle_type, signal, emergency) that tells a road user what to do.

  • If emergency is True and vehicle_type is "ambulance", return "Proceed Carefully".
  • Otherwise it depends on signal:
    • "red": return "Stop".
    • "yellow": return "Slow Down".
    • "green": return "Cross" if vehicle_type is "pedestrian", and "Go" for any other vehicle type.
  • For any other signal, return "Invalid Signal".

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.

Example

traffic_signal("car", "red", False) -> 'Stop'
traffic_signal("pedestrian", "green", False) -> 'Cross'

Your task

Implement this function:

def traffic_signal(vehicle_type: str, signal: str, emergency: bool) -> 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: vehicle_type, signal, emergency.

Example

Input

"car"
"red"
False

Output

'Stop'

Question 2

+10 marksProgramming

The list words has exactly four strings. Write a function join_even_index_strings(words) that returns one string made by joining the strings at the even indices, which are index 0 and index 2, in this order, with nothing in between.

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.

Example

join_even_index_strings(["apple", "banana", "cherry", "mango"]) -> 'applecherry'
join_even_index_strings(["red", "green", "blue", "yellow"]) -> 'redblue'

Your task

Implement this function:

def join_even_index_strings(words: list) -> 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: words.

Example

Input

["apple", "banana", "cherry", "mango"]

Output

'applecherry'

Question 3

+10 marksProgramming

Write a function make_dict_from_elems_in_index(keys, values, index) that returns a dictionary with just one entry: the key is the element of keys at position index and the value is the element of values at position index. The index is valid for both lists, and it can be negative. The two lists can have different lengths.

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.

Example

make_dict_from_elems_in_index(['apple', 'banana', 'cherry'], [10, 20, 30, 40], 1) -> {'banana': 20}
make_dict_from_elems_in_index(['apple', 'banana', 'cherry'], [10, 20, 30, 40], -1) -> {'cherry': 40}

Your task

Implement this function:

def make_dict_from_elems_in_index(keys: list, values: list, index: int) -> dict:

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: keys, values, index.

Example

Input

['apple', 'banana', 'cherry']
[10, 20, 30, 40]
1

Output

{'banana': 20}

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 May 2026 Set 1 paper

The IIT Madras BS Programming in Python (Python) OPPE 1 paper sat on May 2026, in the May 2026 term (T2 2026), set 1: 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 May 2026 Set 1 at a glance
TermMay 2026 term (T2 2026)
SubjectProgramming in Python
Course codeBSCS1002
Questions7
Marks100
Duration180 min
Programming7
Official paperOPPE 1, May 2026 Set 1
Negative markingNo negative marking.
Updated

Other sets that day

Same OPPE 1, other subjects

More Python