Neural Sync Active
Jan 2026 - Python - Week 6 - Strings 1 - Graded
Registry Synced
Jan 2026 - Python - Week 6 - Strings 1 - Graded
559 words
3 min read
Strings 1 - Graded
Course: Jan 2026 - Python
Strings 1 - Graded
Submission deadline has passed for this assignment
Due Mar 25, 2026 at 11:59 PM IST
Instructions
Use "Test Run" to verify your code with public test cases.
Press "Submit" to have your assignment evaluated.
You can submit your assignment multiple times up until the deadline.
Make sure to submit your final code by the deadline to receive your score.
Summary
100 out of100
Score
Public Tests
3/3 Passed
Submitted on Mar 25, 2026 at 2:25 PM IST
Private Tests
3/3 Passed
Submitted on Mar 25, 2026 at 2:25 PM IST
**Change in eligibility criteria to write oppe2 exam: A5>=40/100 AND A6>=40/100 AND A7>=40/100 AND A8>=40/100. and becoming eligible to give the end term exam.
Format Elements in tuple as "second, first"**
Given a tuple of length two create a string in the format of "second, first" where first and second are the first and second elements in the tuple.
The elements can be of any data type.
Change in eligibility criteria to write oppe2 exam: A5>=40/100 AND A6>=40/100 AND A7>=40/100 AND A8>=40/100. and becoming eligible to give the end term exam.
Example
>>> format_as_second_comma_first(('hello', 'python')) 'python, hello' >>> format_as_second_comma_first((1, 2)) '2, 1'
Template Code(Click to Expand)
def format_as_second_comma_first(t: tuple) -> str: '''Formats the two elements in a tuple as "second, first". Arguments: t: tuple - a tuple two elements Return: str - a formatted string "second, first" Example: >>> format_as_second_comma_first(('hello', 'python')) 'python, hello' >>> format_as_second_comma_first((1, 2)) '2, 1' ''' ...
NOTE: You can use the below tools for working out and debugging. Click to open them in new tab.
Public Tests ( 3/3 )
Case 1
Input:
textis_equal( format_as_second_comma_first(('hello', 'python')), 'python, hello' )
Expected Output:
text'python, hello'
Actual Output:
text'python, hello'
Case 2
Input:
textis_equal( format_as_second_comma_first((1, 2)), '2, 1' )
Expected Output:
text'2, 1'
Actual Output:
text'2, 1'
Case 3
Input:
textis_equal( format_as_second_comma_first((1.2, 3.4)), '3.4, 1.2' )
Expected Output:
text'3.4, 1.2'
Actual Output:
text'3.4, 1.2'
Private Tests ( 3/3 )
Case 1
Input:
textis_equal( format_as_second_comma_first(('.', '')), ', .' )
Expected Output:
text', .'
Actual Output:
text', .'
Case 2
Input:
textis_equal( format_as_second_comma_first((1.45, 2.56)), '2.56, 1.45' )
Expected Output:
text'2.56, 1.45'
Actual Output:
text'2.56, 1.45'
Case 3
Input:
textis_equal( format_as_second_comma_first((True, False)), 'False, True' )
Expected Output:
text'False, True'
Actual Output:
text'False, True'
💻 IITM Official Solution
pythondef format_as_second_comma_first(t: tuple) -> str: '''Formats the two elements in a tuple as "second, first". Arguments: t: tuple - a tuple two elements Return: str - a formatted string "second, first" Example: >>> format_as_second_comma_first(('hello', 'python')) 'python, hello' >>> format_as_second_comma_first((1, 2)) '2, 1' ''' return f"{t[1]}, {t[0]}"
💻 My Submitted Code
pythondef format_as_second_comma_first(t: tuple) -> str: '''Formats the two elements in a tuple as "second, first". Arguments: t: tuple - a tuple two elements Return: str - a formatted string "second, first" Example: >>> format_as_second_comma_first(('hello', 'python')) 'python, hello' >>> format_as_second_comma_first((1, 2)) '2, 1' ''' ... first_elem,second_elem = t return f"{second_elem}, {first_elem}"