Skip to content

Latest commit

 

History

History

README.md

0x00. Python - Variable Annotations

Tags

  • Python
  • Backend

Project

Write a type-annotated function add that takes a float a and a float b as arguments and returns their sum as a float.

Write a type-annotated function concat that takes a string str1 and a string str2 as arguments and returns a concatenated string

Write a type-annotated function floor which takes a float n as argument and returns the floor of the float.

Write a type-annotated function to_str that takes a float n as argument and returns the string representation of the float.

Define and annotate the following variables with the specified values

Write a type-annotated function sum_list which takes a list input_list of floats as argument and returns their sum as a float.

Write a type-annotated function sum_mixed_list which takes a list mxd_lst of integers and floats and returns their sum as a float.

Write a type-annotated function to_kv that takes a string k and an int OR float v as arguments and returns a tuple. The first element of the tuple is the string k. The second element is the square of the int/float v and should be annotated as a float.

Write a type-annotated function make_multiplier that takes a float multiplier as argument and returns a function that multiplies a float by multiplier.

Annotate the function with the correct data type