Scanner to TextIO question - java.util.scanner

I need to add a value and input it directly into an array using TextIO.
I know that if I was using Scanner I would use the in.nextDouble() function, but how would I do it using TextIO?
TextIO.put("Enter credit hours:");
creditHour[sem][grd]+=in.nextDouble(); //I have to use TextIO here.
Thanks in advance,

Found it.
array [i][r] = TextIO.getlnDouble();

Related

generate date range with calendar as input

is there a way to directly use
from pandas.tseries.holiday import USFederalHolidayCalendar
in order to subsequently generate a DatetimeIndex, which excludes holidays?
it does not seem like pd.bdate_range() can accept such an argument, but surely there must be some convenient way to accomplish this?
edit:
was able to create a frequency parameter with the CustomBusinessDay() class
USBDay = CustomBusinessDay(calendar=USFederalHolidayCalendar())
pd.bdate_range(start=start, end=end, freq=USBDay)
problem solved!
solution:
was able to create a frequency parameter with the CustomBusinessDay() class
USBDay = CustomBusinessDay(calendar=USFederalHolidayCalendar())
pd.bdate_range(start=start, end=end, freq=USBDay)

How do I change the type of a string to a bytestring?

For example, I have '\x87' and I want b'\x87'.
I know, that there exists .encode(), but when I execute ('\x87').encode(), I get b'\xc2\x87' and not b'\x87'.Is there any way to tell python that it should interpret the given string as a bytestring without possibly changing it in any way?
Try this.
my_str = '\x87'
my_str_as_bytes = my_str.encode(encoding='latin')
One possible solution is:
bytes(ord(x) for x in '\x87')

need to use single, double quote and variables in selenium find by xpath (python)

I want to get web data by using selenium find by Xpath function. I need extract multiple information as following:
info1=browser.find_element_by_xpath('//*[#id="res-results-table"]/tbody/tr[1]/td[1]/a')
info2=browser.find_element_by_xpath('//*[#id="res-results-table"]/tbody/tr[2]/td[1]/a')
info3=browser.find_element_by_xpath('//*[#id="res-results-table"]/tbody/tr[3]/td[1]/a')
I want to use variables, but seems something is wrong. what I did was:
info=[]
for i in range (1,4)
info[i] = browser.find_element_by_xpath('\'//*[#id="res-results-table"]/tbody/tr['+str(i)+']/td[1]/a\'')
Can anybody help? thank you!

Formatting user input with .title() method

Currently, I started to learn programming with Python. Currently, I am tackling my first 'real' project.
The most problems that I seem to find, are based around formatting. I am curious if my code is written understandable. For example:
new_customer = input('Name? \n')
customer = new_customer.title()
I want to make sure all the inputs received are saved with the same format.
Is this the correct way to transform a user's input with the .title() method?
Thank you in advance, I hope that these kind of questions are accepted here!
You can use the same variable:
newcustomer = input('Name? \n').title()
Is this what you mean?

Groovy convert list of maps into a map

Hi I know this question has a thread already here but when I applied the answer provided on the thread it didn't work for me. So requesting for help with my exact problem below:
So I am trying to convert: [[xyz:346654], [xyz:343372]] to [xyz:346654, xyz:343372] in groovy. I tried to apply the solution provided on the thread which to use the collectEntries() method or sum() in groovy. But instead of getting [xyz:346654, xyz:343372] which is my desired result, I get [xyz:343372]. Can someone help figure out this please? Thanks in advance!!
[xyz:346654, xyz:343372] in groovy is the same same as [xyz:343372], because of non-unique key
println ( [xyz:346654, xyz:343372] )
prints [xyz:343372]

Resources