Wiki Report for ICP3 - NagaSurendraBethapudi/Python-ICP GitHub Wiki
https://drive.google.com/file/d/1CsrhEKdDcSxuG7JZpuHaQMfKMrlrX9le/view?usp=sharing
Video Link :Question 1 : Create a class Employee and then do the following
- Create a data member to count the number of Employees
- Create a constructor to initialize name, family, salary, department
- Create a function to average salary
- Create a Fulltime Employeeclass and it should inherit the properties of Employee class
- Create the instances of Fulltime Employeeclass and Employee class and call their member functions.
Explanation:
- created a class Employee and requested details about of name, family, salary, department
- created a function for averaging salary by using below lines:
avg_sal = Employee.Total_Salary / Employee.count
- created Full_time_employee class and inherited the properties of Employee by using below lines:
class Full_time_employee(Employee): def init(self): print('Full time employee(sub class)')
- created instances and called the members.
https://en.wikipedia.org/wiki/Deep_learning
Write a simple program that parse a Wiki page mentioned below and follow the instructions:- Print out the title of the page
- Find all thelinks in the page (‘a’ tag)
- Iterate over each tag(above) then return the link using attribute "href" using getSave all the links in the file
Explanation:
- imported beautifulSoup, requests, re
- scrapped the data using "html.parser" with a time interval of 5 seconds.
- initialized a word document and scrapped the data into that word document using below lines:
page_response = requests.get(wiki_link, timeout=5)
wiki_content = BeautifulSoup(page_response.content, "html.parser")
textContent = []
f = open('wiki_data.txt', 'w')
f.write( "title is" + wiki_content.title.string+ '\n')
for links in wiki_content.find_all('a',attrs={'href': re.compile("^http://")}):
textContent.append(links.get('href'))
f.write( repr(links.get('href')) + '\n')
Question 3 : Using NumPy create random vector of size 20having only floatin the range 1-20. Then reshape the array to 4by 5Then replace the max in each row by 0(axis=1)
Explanation:
- imported numpy
- generated random numbers using
np.random.randint(1, 20, 20)
- reshaped the matrix to 4*5 using
Random_Integers.reshape((4,5))
- replaced the maximum with 0 using
np.where(Reshaping == np.amax(Reshaping, axis=1, keepdims=True), 0, Reshaping)