Ii Python Syntax Ii 1 Variables And Arithmetic 5 Points Each Remember To Remove The Raise Not Implemented Error 1 (37.17 KiB) Viewed 31 times
Ii Python Syntax Ii 1 Variables And Arithmetic 5 Points Each Remember To Remove The Raise Not Implemented Error 2 (29.18 KiB) Viewed 31 times
Ii Python Syntax Ii 1 Variables And Arithmetic 5 Points Each Remember To Remove The Raise Not Implemented Error 3 (68.85 KiB) Viewed 31 times
II. Python syntax II.1: Variables and Arithmetic (5 points each) **Remember to remove the raise Not Implemented Error() line before you type your code and run the cell In the cell below, • assign 2 to the integer variable x. • assign the square root of 5 to the variable y (remember taking the square root is the same as raising to the power of 1/2 √a=dºs) assign the sum of x and y to the variable xy sum assign the product of x and y to the variable xy_prod In [ ]: # YOUR CODE HERE raise NotImplementedError() In []: from math import isclose assert isinstance(x, int) # check that x is an integer assert x==2 # check that x is 21 In []: assert isclose(y, 5(1/2)) # check that y is the square root of 5 In [ ]: assert isclose(xy_sum, 25**(1/2)) In [ ]: assert isclose(xy_prod, 2 5*(1/2))
II.2: Debugging 1 (10 points) The code below does not run. Please fix it to make it do what it was supposed to. It is supposed to print: Hello? How are you? ....who are you? And then assign True to success. In [ ]: # YOUR CODE HERE raise In [ ]: assert success NotImplementedError()
II.3: Debugging 2 (10 points) the code below also does not run, can you fix it too please? It aims to print It also aims to assign My name is: Joe Biden I am 79 years old . 'My name is: Joe Biden' to introduction_1 'I am 79 years old' to introduction_2 . The string Joe Biden' to name, The integer 79 to age. . In [] # YOUR CODE HERE raise NotImplementedError() In [ ]: assert introduction_1 == 'My name is: Joe Biden assert introduction_2 == 'I am 79 years old assert name == Joe Biden assert age == 79 assert success2
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!