Python for beginners: WORKBOOK WITH QUESTIONS, SOLUTIONS AND PROJECTS. PRACTICE AND LEARN CODING WITH A FAST METHOD (1 2) by Brian Dayton

Python for beginners: WORKBOOK WITH QUESTIONS, SOLUTIONS AND PROJECTS. PRACTICE AND LEARN CODING WITH A FAST METHOD (1 2) by Brian Dayton

Author:Brian Dayton [Dayton, Brian]
Language: eng
Format: azw3
Published: 2020-05-14T16:00:00+00:00


print(py_solution().int_to_Roman(1))

print(py_solution().int_to_Roman(4000))

Exercise 2 :

Now that we have had a chance to write out our first class, it is time for us to look at how to work with something else and make a different class. With this one, we need to write out a class in Python that will help us to find the validity of a few brackets and parentheses. We are going to check for all three types of brackets to see how they work. Using some of the examples that we did before in the last exercise, you should be able to go through here and work on the coding. See if you can complete this and get some good results on your own as well.

Exercise 3:

Next, we move on to another type of Python class that we can work on too. This one will help us to find the elements, in a pair, that are in our given array. We are going to do this to find the indices out of two particular numbers we choose and we want their sum to equal the target number that we pick out. The code we can use to make this one happen includes:

class py_solution:

def twoSum(self, nums, target):

lookup = {}

for i, num in enumerate(nums):

if target - num in lookup:

return (lookup[target - num], i )

lookup[num] = i

print("index1=%d, index2=%d" % py_solution().twoSum((10,20,10,40,50,60,70),50))

Exercise 4:



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.