Answer:
import csv
def Csvreader(filename):
with open("filename", "r") as file:
content = file.csv_reader()
list_content = list(content)
file.close
return list_content
Explanation:
This is a python description of the function that reads the csv file and converts it to a list, from the list, each item can accessed with its index and updated directly. Use this to draw the same conclusion for a java program.
Solution :
class Employee:
#Define the
#constructor.
def __
__(
, ID_number,
, email):
#Set the values of
#the data members of the class.
= name
_number = ID_number
= salary
self.email_address = email
#Define the function
#make_employee_dict().
def make_employee_dict(list_names, list_ID, list_salary, list_email):
#Define the dictionary
#to store the results.
employee_dict = {}
#Store the length
#of the list.
list_len = len(list_ID)
#Run the loop to
#traverse the list.
for i in range(list_len):
#Access the lists to
#get the required details.
name = list_names[i]
id_num = list_ID[i]
salary = list_salary[i]
email = list_email[i]
#Define the employee
#object and store
#it in the dictionary.
employee_dict[id_num] = Employee(name, id_num, salary, email)
#Return the
#resultant dictionary.
return employee_dict
Answer:
Study Python’s help on range to determine the names, positions, and what to do with your function’s parameters.
Use a default value of None for the two optional parameters. If these parameters both equal None, then the function has been called with just the stop value. If just the third parameter equals None, then the function has been called with a start value as well. Thus, the first part of the function’s code establishes what the values of the parameters are or should be. The rest of the code uses those values to build a list by counting up or down.
Answer:
numInsects = 16
while numInsects < 200:
print(str(numInsects) + " ", end="")
numInsects *= 2
Explanation:
*The code is in Python.
Set the numInsects as 16
Create a while loop that iterates while numInsects is smaller than 200. Inside the loop, print the value of numInsects followed by a space. Then, multiply the numInsects by 2.
Answer:
print("first is "+str(first)+" second = "+str(second))
Explanation:
The above written print statement is in python language.If first and second are strings then we need not to use str then we only have to write variable name.This statement prints the given in one line according to the question and it goes to new line after printing.