Variable Assignment with Type Annotations

Level
Python
Syntax
Find the bug in the code above.
pymain.py — learnpython.today
pymain.py
1
def sum():
2
  a: int = 10
3
  b: float = '12.34'
4
  return a + b

Mission Brief

This exercise focuses on understanding type annotations in variable assignments. Review the given code lines for correct and incorrect uses of type hints according to Python's typing system. Determine the errors in type assignments and recognize properly annotated variables.

Objective

Analyze the code snippet to your left. Identify the line containing the semantic or syntax error. Select the candidate that fixes it without introducing side effects.

Typing
Syntax

© 2024 - 2025 LearnPython.Today. All rights reserved.

Redesigned and Collaborated for experience by MenteE