r = range(10, 40, 3)
def print_lv(strings):
strings = strings if isinstance(strings, list) else [strings]
for string in strings:
st = "f'" + string + ": {" + string + "}'"
print_stmt = 'print(' + st + ', end="; ")'
# Uncomment the following print statement to see the statement to be executed.
# Each will appear on a separate line.
# print(f'\n{print_stmt}')
exec(print_stmt)
print()
print_lv(['list(r)', 'r[-2:3:-1]', 'list(r[-2:3:-1])'])
OUTPUT:
list(r): [10, 13, 16, 19, 22, 25, 28, 31, 34, 37]; r[-2:3:-1]: range(34, 19, -3); list(r[-2:3:-1]): [34, 31, 28, 25, 22];
I need help explaining this bit of code. Particularly why r[-2:3:-1] is range(34, 19, -3).
The slice starts at position -2 and stops at position 3 in increments of step -1.
YET the range that results from taking that slice starts at value 34 and stops at value 19 in increments of step -3
In: Computer Science
Case study:
JD is a 58-year-old male patient who is suffering from latent TB. The treating physician is choosing a prophylactic regimen for JD and evaluating treatment with rifampin for a 4 months course. Please evaluate if rifampin is a good drug choice for JD and what potential complications this treatment option will pose for JD.
JD’s current medication list includes:
▪Warfarin 5 mg daily
▪Oxcarbazepine 2 g daily
▪Metoprolol succinate 50 mg daily
▪Lisinopril 20 mg daily
▪Simvastatin 20 mg daily
Questions based on the case study:
1) List each drug-drug interaction with existing regimen and pharmacology of interaction
2. List the medical risks due to each drug interaction
3. List any potential dose adjustments I.e. dose should be increased/decreased
4. List any required monitoring I.e. lab values, drug levels, side effects, etc.
you just need to answer the question below given the information in the case study.
In: Nursing
language: python
Create a text file in your project folder with at least 20 "quirky sayings"/fortunes (the only requirement is that they be appropriate for display in class), If I use my own file though, you should handle as many fortunes as I put in. Make each fortune its own line,
•in your main function ask the user for the name of the fortunes file.•Create a function which takes the name of the fortunes file as a parameter, open that file, read all the lines into a list of strings Create a list by reading those 20+ fortunes from your file, then return that list from this functions•back in the main function call the display_fortunes passing the list of strings that you got from the previous functions•display_fortunes should•repeat as often as the user wants:
•ask the user if they want another fortune, •if the user’s answer begins with any variation in capitalization of the word ‘yes, then•select a random line from your list of fortunes and display it •if the users answer begins with no (in any capitalization) then quit the program
In: Computer Science
Times are slow for your company right now, and with the rising costs of materials and wages, your profits are at an all-time low. Because of this unfortunate situation, you will need to let some employees go. The senior management team has already compiled the list of people whose employment will be terminated two weeks from today. However, the people on the list will not know until the day of the termination.
You have called a meeting with your department managers and supervisors. The managers and supervisors do not know that a list has been created, so you will need to let them know this at some point in the conversation. Also, they will not be able to see the list until the day of the terminations. Obviously, this is a very confidential topic and should not be shared with anybody outside of this meeting. The purpose of your meeting today is to confide in this group and assure them that none of them are on the list. You also want to get their feedback on how the general employee base will react to the news.
Devise and elaborate on an action plan for the day of the event.
Complexity index: Level 5: Detailing your argument to support the statement.
In: Operations Management
Answer using Jupyter Python #Prompt the user to enter a passing grade and store the value from #the input() into a variable. #Refer to the variable in problem 2 to complete the following: #Use the if statement to evaluate the only the first element in the #grades list using index notation. #If the grade is passing, display PASSED, otherwise display FAILED. """Problem 1d""" #Use the for statement to iterate on each element in the #grades list (from problem 1a) and displays each value. #Specifically, for each grade in the grades list, if the grade is #passing (referring to problem 1b), then display PASSED, otherwise display FAILED. """Problem 2a""" #Create a function that will evaluate if each grade in a list is considered #passing or failing. [hint: use the for statement and if...else together] #Store the total number of passing and failing grades in their own respective variables. #The function should return a dictionary with two key-value pairs where the keys are # the words PASSED and FAILED mapped to their total counts variable. """Problem 2b""" #Call the function and pass in the grades list (from problem 1a) as an argument.
In: Computer Science
In: Computer Science
Answer using Jupyter Python
#Prompt the user to enter a passing grade and store the value
from
#the input() into a variable.
#Refer to the variable in problem 2 to complete the
following:
#Use the if statement to evaluate the only the first element in
the
#grades list using index notation.
#If the grade is passing, display PASSED, otherwise display
FAILED.
"""Problem 1d"""
#Use the for statement to iterate on each element in the
#grades list (from problem 1a) and displays each value.
#Specifically, for each grade in the grades list, if the grade
is
#passing (referring to problem 1b), then display PASSED, otherwise
display FAILED.
"""Problem 2a"""
#Create a function that will evaluate if each grade in a list is
considered
#passing or failing. [hint: use the for statement and if...else
together]
#Store the total number of passing and failing grades in their own
respective variables.
#The function should return a dictionary with two key-value pairs
where the keys are
# the words PASSED and FAILED mapped to their total counts
variable.
"""Problem 2b"""
#Call the function and pass in the grades list (from problem 1a) as
an argument.
In: Computer Science
1. Implement the function calculate_score that consumes three parameters, two strings and a list. The strings will each be ONE character and will represent a nucleotide. The list will be a nested int list representing a 4x4 score matrix. This function will return the value (int) from the nested int list at the location of the two referenced nucleotides.
a. An example call to calculate_score would be calculate_score(“A”, “T”, score_matrix). If we look at the alignment score table in the background section we can see that the cell at column “A” and row “T” holds the value 6. Similarly, if we consider this location via the indexes in score_matrix, we can use the index call score_matrix[1][2] to reach the value.
b. We can assume that the score matrix will always be a 4x4 nested int list in the same order as the matrix shown above.
c. You can use this index dictionary in your code for reference, or implement some other way to associate the string arguments to the appropriate index locations: {"G":0, "A":1, "T":2, "C":3}
d. Write three assert_equal statements.
In Python language
In: Computer Science
Write in Java! (Not Javascript)
Consider the LinkedList class we discussed in class (see the slides for lecture 8). Add the following methods to the class and submit the completed LinkedList class.
your file to be submitted to Gradescope should be named LinkedList.java. and here is the skeleton:
class Link
{
public int data; // assuming integer data
public Link next; // reference to the next Link
//--------------------------------------------------------------
// Constructor
public Link(int data)
{
this.data = data;
next = null;
}
}
public class LinkedList
{
// implement this class
}
In: Computer Science
The following tables form part of a database held in a relational DBMS:
Hotel (hotelNo, hotelName, hotelAddress, country)
Room (roomNo, hotelNo, type, price)
Guest (guestNo, guestName, guestAddress, country)
Booking (hotelNo, guestNo, dateFrom, dateTo, roomNo)
Write the SQL statements for the following questions:
1. List the rooms that are currently unoccupied at the Grosvenor Hotel, for:
(a) Use 2019-10-01 as today's date. Include all 'Grosvenor' hotels. List in hotelNo, roomNo order. Use NOT IN to perform the difference operation
(b) Use 2019-10-01 as today's date. Include all 'Grosvenor' hotels. List in hotelNo, roomNo order. Use NOT EXISTS to perform the difference operation.
(c) Use 2019-10-01 as today's date. Include all 'Grosvenor' hotels. List in hotelNo, roomNo order. Use LEFT JOIN to perform the difference operation.
(d) Use 2019-10-01 as today's date. Include all 'Grosvenor' hotels. List in hotelNo, roomNo order. Use MINUS to perform the difference operation.
In: Computer Science