Python Programming
1. Write a function name split_name which takes one parameter called name. If the name parameter value is a name in the form LastName, FirstName(e.g., ”Grounds, Nic”) then the function should return a list of two elements where FirstName is the first element and LastName is the second element. If the name parameter value is a name in the form FirstName LastName(e.g., ”Nic Grounds”) then the function should return a list of two elements where FirstName is the first element and LastName is the second element.
2. Repeatedly prompt the user for a name (which the user may give in Last-name, FirstName form or FirstName LastName form). If the user’s response is an empty string (i.e., they simply press Return) cease looping. If the user’s response is not the empty string, call the split_name function you wrote and append the returned value to a list (initially empty).
3. Using the sorted function (which can take a single parameter, a list) and returns a copy of the list in sorted order) sort the list of names once the loop has finished. Print the sorted list of names, one name per line in LastName, FirstName form.
4. Observe the sorted list of names, are they sorted alphabetically by first name or last name? Leave your answer in a comment within the Python file you submit. Also, how do you think we could potentially modify the program to sort by last name instead of first (or first name instead of last, whichever is opposite of what you observed)? Leave your answer in a comment within the Python file you submit.
5. At the top of your file must be a comment that contains a brief explanation of how you determined which portion of each name was the first name vs. the last name.
In: Computer Science
In this python script find any bugs and errors which would cause the code to crash. The code must be re-written correctly.
After debugging make a separate list of all the errors
you found in the script.
contacts_list=[] # global variable, list of contacts_list, one string per contact
def pause()
""" pauses program e.g. to view data or message
"""
input("press enter to continue")
def load():
""" populate list with data
"""
contacts_list.append(('Milo ',
'063847489373'))
contacts_list.append(('Tony', '46483848')
contacts_list.append(('Betty'
'03747384043'))
print("%s records have been loaded"
%(len(contacts_list)))
add():
""" adds contact to list """
name = input("enter name : ")
phone_no = int(input("enter phone number :
"))
contacts_list.append(((phone_no, name)))
def view():
""" displays contacts_list """
index = 0
for contact in contacts_list:
print(index,"
",contact[0], " ", contact[2])
index += 1
pause()
def delete():
""" removes contact based upon index """
index=input("enter index of contact to delete
")
del contacts_list[index-1]
def menu():
""" loops menu of options and does these until
user quits """
while True:
print("")
print(" enter for
option")
print(" =
==========")
print(" v
view contacts_list")
print(" a
add contact")
print(" d
delete contact")
print(" q
quit")
option=input("your
option: ")
optoin=option.lower() #
always lower case
if option == "v":
#view()
elif option ==
"d":
delete()
elif option ==
"a":
add()
elif option ==
"q":
return # exit while loop and menu function
else:
print("invalid menu option")
pause()
def main():
""" entry point if module imported or run as
script """
load()
menu()
if __name__ == "__main__":
# runs program if executed as a script
main()
In: Computer Science
Questions: 1) // declare integer variable sum equal to zero // declare variable integer i // declare while loop condition where i is less then 25 // inside of brackets calculate the sum of i (addition) // increment i // outside the loop print the sum of values =============================================
2) Create a sentinel value example if I press number 0 it will display the sum of data // create a scanner // prompt the user to to enter the numbers // declare variable integer and relate that to input scanner // declare variable sum equals to zero // declare while loop condition where the variable you just created above is not equal to 0 // inside of the bracket of while condition sum the data with addition // prompt the user to enter integer unless its not zero // again the same variable that you created outside the while condition will ask to input value through scanner // outside the bracket display the sum of values
3) Declare the do while loop // declare the variable integer which is equal to zero // declare do-while loop and inside of brackets prompt the user to print word "Hello" // increment the variable integer that you declared outside the loop // outside brackets declare while condition where variable that you declared in the beginning is less then 25
4) Continue the same process as exercise number 3, but this time use for loop
5) Create break command in while loop // declare integer variables sum and number and both of them are equal to zero // create while condition where number is less then 25 // inside of brackets increment number // declare if condition where number is equal to 10 // write continue ++ // sum the number (addition) // outside of brackets display sum in console
6) In this exercise do the same thing like number 5 exercise but instead of continue ++ write break;
In: Computer Science
C Program only - MUST USE MALLOC IN CODE
Research and implement the Sieve of Eratosthenes.
Example Program Session (implement some linefeed ‘\n’ formatting):
Enter the limit: 1000
Primes up to 1000
2 3
5 7 11 13
17 19 23 29
31 37 41 43
47 53
59 61 67 71
73 79 83 89 97 101
103 107 109 113 127 131
137 139 149 151 157 163 167 173 179 181 191 193 197 199 211
223
227 229 233 239 241 251 257 263 269 271 277 281 283 293 307
311
313 317 331 337 347 349 353 359 367 373 379 383 389 397 401
409
419 421 431 433 439 443 449 457 461 463 467 479 487 491 499
503
509 521 523 541 547 557 563 569 571 577 587 593 599 601 607
613
617 619 631 641 643 647 653 659 661 673 677 683 691 701 709
719
727 733 739 743 751 757 761 769 773 787 797 809 811 821 823
827
829 839 853 857 859 863 877 881 883 887 907 911 919 929 937
941
947 953 967 971 977 983 991 997
Number of primes: 168
Press any key to continue . . .
In: Computer Science
The following phrases are the six purposes of our Federal government found in the Preamble of the Constitution.
We the People of the United States, (1) in order to form a more perfect Union, (2) establish justice, (3) ensure domestic Tranquility, (4) provide for the common defense, (5) promote general Welfare, and (6) secure the Blessings of Liberty to ourselves and our Posterity, do ordain and establish this Constitution for the United States of America.
The statements below describe actions that may be taken by the US government. Using the information above regarding the Preamble of the Constitution, match the statements below with the number associated (1,2,3,4,5, or 6) with the purpose of government that BEST fits the situation. Place your answer in the space beside the statement.
|
1. |
The President negotiates a nuclear arms deal with North Korea. |
|
|
2. |
The US government gives emergency aid to tornado victims in Charlotte, NC. |
|
|
3. |
The police catch and arrest three people suspected of robbing a bank. |
|
|
4. |
The President asks Congress for money to build 100 additional stealth bombers. |
|
|
5. |
The first amendment was added to the Constitution in 1791. It protects citizens’ rights to freedom of speech, religion, press, assembly, and petition. |
|
|
6. |
Congress passes a law saying that no state can stop a US citizen from freely traveling from one state to another. |
|
|
7. |
Congress passes a law providing universal healthcare to all citizens. |
|
|
8. |
Congress decides to provide more funds to the FBI’s “War on Crime” |
|
|
9. |
The president signs a measure providing for the first peacetime draft in US history shortly before the attack on Pearl Harbor. |
|
|
10. |
A federal court orders a chemical company to make payments to workers who were injured in a spill. |
|
|
11. |
The government pays unemployment benefits to workers who lose their jobs during a recession. |
In: Economics
Stock Valuation and Analysis :
Vivint Solar, Inc. (VSLR)
NYSE - Nasdaq Real Time Price. Currency in USD
Assignment Content
Top of Form
Resource
Purpose of Assignment
The purpose of this assignment is to allow students the opportunity to research a Fortune 500 company stock using the popular online research tool, Yahoo Finance. The tool allows the student to review analyst reports and other key financial information necessary to evaluate the stock value and make an educated decision on whether to invest.
Assignment Steps
Select a Fortune 500 company from one of the following industries:
Access Yahoo Finance and enter the company name.
Review the financial information and statistics provided for the stock you selected and answer the following:
Explain in 700 words why you would or would not recommend investing in this stock.
Submit your assignment.
In: Finance
Write a program that generates a random number between 1 and 50 and asks the user to guess it. As a hint, it tells the user how many divisors it has, (excluding 1 and the number itself). Each time the user makes a wrong guess, it displays "Wrong" and says if the guess was too low or too high, until the user gets it right, in which case it says "Right" and says how many trials it took to guess it. Then, the program asks the user if he or she wants to continue. If the answer is 'y' or 'Y', it generates another number between 1 and 50 and repeats the game. If not, it prints the average of all trials with one decimal place and ends.
Example:
I've picked a number between 1 and 50 that has 0 divisor(s).
Guess the number: 23
Too low!
Guess the number: 37
Too low!
Guess the number: 43
Too high!
Guess the number: 41
Right! It took you 4 trials.
Play again? [y/n]: y
I've picked a number between 1 and 50 that has 1 divisor(s).
Guess the number: 25
Too low!
Guess the number: 49
Right! It took you 2 trials.
Play again? [y/n]: y
I've picked a number between 1 and 50 that has 3 divisor(s).
Guess the number: 30
Too high!
Guess the number: 24
Right! It took you 2 trials.
Play again? [y/n]: n
You averaged 2.7 trials in 3 games.
Press any key to continue.
Im stuck with the loops and if you can explain the steps would be great. At the end I need to show the average in where the user guessed the correct number and how many games they played
In: Computer Science
Programming Language = JAVA
I wanna make menu -driven using these items.
1. one
2. two
3. three
4. four
5. exit
This program will read a txt data and will display them in console.
text.txt
98765432,C,John,Smith,23 Church Ave,Central,2123,8,Valid
98765431,C,Joe,Smith,55 Church Street,Genzi,2323,0,Valid
98765430,C,Bob,Smith,23 Gong Road,Warambull,2443,0,Valid
98765429,C,Mike,Smith,42 Mike Street,Waterloo,2222,0,Valid
98765428,C,Juan,Smith,522 Banana steet,Bank,2423,2,Valid
98765427,C,Mike,Jones,232 Milemium
lane,Sumrise,2753,13,Suspended
98765426,C,David,Smith,551 Russian Mountain
ave,Kogara,2121,0,Valid
98765425,C,Sarah,Smith,123 Straight
Street,Cronulla,2232,3,Valid
98765424,C,James,Smith,23 lane,Coroloa,2345,7,Valid
98765423,C,Mike,White,4 Loman Lane,Orange,2665,14,Suspended
98765422,C,Brendon,Fei,55 bal bay,sate,2757,0,Valid
98765421,C,Jian,Zhang,62 london Street,mango,2553,0,Valid
98765420,C,Choi,Saraha,11 hamberguer
Street,kefece,2753,0,Valid
98765432,C,Godam,City,32 Kent Street,Maccus,2876,0,Valid
when user press 1, this program will display a report about this txt file.
a report will include number(98765420), family name, first name, suburb, point(0,3,2,,,), status(valid).
please display well-organized format, and also please provide special option which displays this report in the decending order of point(0,3,2).
In: Computer Science
David E. Brown is an expert in wildlife conservation. In his book The Wolf in the Southwest: The Making of an Endangered Species (University of Arizona Press), he records the following weights of adult grey wolves from two regions in Old Mexico.
Chihuahua region: x1 variable in pounds
| 86 | 75 | 91 | 70 | 79 |
| 80 | 68 | 71 | 74 | 64 |
Durango region: x2 variable in pounds
| 68 | 72 | 79 | 68 | 77 | 89 | 62 | 55 | 68 |
| 68 | 59 | 63 | 66 | 58 | 54 | 71 | 59 | 67 |
(a) Use a calculator with mean and standard deviation keys to calculate x1, s1, x2, and s2. (Use 2 decimal places.)
| x1 | |
| s1 | |
| x2 | |
| s2 |
(b) Let μ1 be the mean weight of the population
of all grey wolves in the Chihuahua region. Let
μ2 be the mean weight of the population of all
grey wolves in the Durango region. Find a 99% confidence interval
for μ1 – μ2. (Use 2 decimal
places.)
| lower limit | |
| upper limit |
(c) Examine the confidence interval and explain what it means in the context of this problem. Does the interval consist of numbers that are all positive? all negative? of different signs? At the 99% level of confidence, what can you say about the comparison of the average weight of grey wolves in the Chihuahua region with the average weight of grey wolves in the Durango region?
Because the interval contains only positive numbers, we can say that the mean weight of grey wolves is greater in the Chihuahua region.Because the interval contains only negative numbers, we can say that the mean weight of grey wolves is greater in the Durango region. Because the interval contains both positive and negative numbers, we can not say that the mean weight of grey wolves is greater in the Chihuahua region.We can not make any conclusions using this confidence interval.
In: Math
Locate the star Betelgeuse and click on it. Information on Betelgeuse should appear in the top left of your screen. What is its azimuth and altitude?
Az (1 pt) = ________________
Alt (1 pt) = ________________
Now let’s switch to a different coordinate system. Press “E” or
click on the globe in your bottom menu bar to turn on some new
coordinates, and press “Z” or click on the radar icon (to the right
of the globe) in the menu bar to turn off the altitude and azimuth
grid.
This new grid should be tilted relative to the horizon. You are now looking at the Right Ascension (RA) / Declination (DE) coordinate system. This system is very similar to longitude and latitude on the Earth. If you look to the north, you will see that the lines converge near a moderately bright star. This is Polaris, the North Star. Its declination is +90 degrees, just like Earth’s north pole has a latitude of +90 degrees. If we could see through the ground, the grid would converge again in the south at declination –90 degrees; this spot would be directly over the Earth’s south pole.
If you look at the RA/DE coordinates of Betelgeuse, you will notice that RA is given in units of “h m s”. These stand for “hours”, “minutes” and “seconds”. There are 24 hours in one full circle (so each hour of RA is 15 degrees of angle), 60 minutes in one hour, and 60 seconds in one minute. (We astronomers have our nefarious reasons for using this arcane system, but it isn’t important for now.)
What is the RA and DE of Betelgeuse (to the nearest degree ignoring arc mins and arc secs)?
RA (1 pt) = ________________
DE (1 pt) = ________________
For Betelgeuse, record both its Az/Alt coordinates and RA/DE in the
table below (record all values should be to the nearest degree,
i.e., don’t include the arc mins and arc secs). Keeping the time at
22:00, record the new positions for the dates specified. Note that
even when the star dips below your viewing horizon (alt < 0°),
its position is still displayed. Continue to advance in four-month
increments for an entire year (for time 22:00 at each date). (1
point each totaling 16 pts)
Date Az Alt RA
DE
2019-01-28
2019-05-28
2019-09-28
2020-01-28
Using the answers above answer the following:
Which coordinates change (1 pt)?
Which remain the same (1 pt)?
Do the changing coordinates ever come close to repeating (1
pt)?
If so, after roughly how long (1pt)?
Next, keeping the time, date, and location the same, find Polaris.
What is the altitude of Polaris to the nearest degree?
Let’s go somewhere else on the Earth. Open the Location Window (see
point 1 at the start of the lab) and type “Greenwich” into the
search box. Select the “Royal Observatory (Greenwich), United
Kingdom” from the list. Change the date and time to 2019-01-27 at
03:00PM (15:00) – this accounts for the 6-hour difference in time
between Texas and England (your clock is showing Dallas time even
though you changed positions).
Answer the following for Betelgeuse:
What are the Az/Alt (1pt)
What are the RA/DE? (1 pt)
Compare answers for a and b to the first row in your table for 3.
Which numbers are different? (1 pt)
Which are the same? (1 pt)
Let’s say you are studying a new star and you need to get some
pictures soon. You email all your friends who are at big
telescopes, since it doesn’t matter from which telescope, nor what
time of night you get the pictures.
Should you send your friends the star’s current Az/Alt or its
current RA/DE? (1 pt)
Why? (1 pt)
What is the altitude of Polaris as seen from Greenwich (to the
nearest degree)?
Polaris is used in navigation because of the fact that its altitude
is always the same as the latitude of the observer. Using your
answers for the altitude of Polaris from Dallas and Greenwich, how
do these values compare with the latitude of those locations?
Part III: Sunrise and Sunset
We all know that the sun rises in the east and sets in the west, right? Let’s examine the position and time of the rising and setting sun over the course of the year, and see how true that is.
Toggle back to Az/Alt coordinates (press Z) for this exercise, and return your location to Dallas, United States. (and make sure to check the enable daylight savings time in the location screen) Use the arrow keys to look toward the eastern horizon.
Set your date for 2019-01-21 and change the time until you see the sun. Click on the sun to get its coordinates. Then change the time of day until the sun has an altitude as close as you can to 0 degrees, 0 arcminutes, and 0 arcseconds. Since its altitude is zero, this means that the sun is just starting to rise in the east. Get the altitude as close as you can, but because you cannot adjust time in smaller than 1 second increments, understand that you will probably not be able to get an altitude of precisely 0°0’0”. (Note that with the online version of Stellarium, the coordinates do not update with each time change unless you re-select the Sun with each time change).
Find the sunrise and sunset times, and the positions to the nearest
degree, i.e., don’t include the arc mins and arc secs) on the dates
specified and fill in the table. Note to be sure to turn on the
setting to account for daylight savings time. (1 pt each, or 16
total pts)
Date Sunrise Sunset
Time Az Time
Az
2019-09-21
2019-12-21
2019-03-21
2019-06-21
What azimuth values correspond to precisely East and West?
East azimuth: _____________________ (1 pt)
West azimuth: _____________________ (1 pt)
Which dates does the sun rise/set on these azimuths?
On which day does the sun rise farthest to the north (smallest azimuth)? (1 pt)
Calculate the length of the day for each of the dates. Which date has the longest daytime?
In: Civil Engineering