Questions
The following .py script takes a users input of search parameters on command line, creates a...

The following .py script takes a users input of search parameters on command line, creates a custom search URL, then returns top 5 result links from Google Scholar.
Alter the below code so that the script opens up each found link in a separate browser window (or tabbed windows in a single browser).

——.py

import requests, sys, webbrowser
from bs4 import BeautifulSoup
print("Searching for " + "+".join(sys.argv[1:]))
myres = requests.get("https://scholar.google.com/scholar?
hl=en&q=" + "+".join(sys.argv[1:]) + "&*")
soup = BeautifulSoup(myres.text, "html.parser")
elems = soup.select(".gs_rt a")
num = min(len(elems), 5)
for i in range(num):
print(elems[i].get("href"))

In: Computer Science

Re-write all with proper code syntax and conventions Add a while loop that continues to ask...

Re-write all with proper code syntax and conventions

Add a while loop that continues to ask the age until a blank value is entered, or a user presses cancel.


let userage=prompt("enterage");
let userageindays=userage*365;
let userageinmonths=userage*12;
let useragein hours=userageindays*24
get useragein-minutes=userageinhours*60
let userageinseconds=userageinminutes*60;


if userage>=40 {
console.log("You are older than 40";
} else {
console.log("You are younger than 40");
}

switch (true) {
case (userage<5):
console.log("You are between 0 and 5");
break;
case (userage<10):
console.log("You are between 5 and 10");
break;
case (userage<20):
console.log("You are between 5 and 10");
break;

case (userage<10):
console.log("You are between 5 and 10");
break;
case (userage<20):
console.log("You are between 5 and 10");
break;
case (userage<30):
console.log("You are between 5 and 10");
case (userage<40):
console.log("You are between 5 and 10");
case (userage<50):
console.log("You are between 5 and 10");
case (userage<60):
console.log("You are between 5 and 10");
case (userage<70):
console.log("You are between 5 and 10");
case (userage<80):
console.log("You are between 5 and 10");
case (userage<90):
console.log("You are between 5 and 10");
case (userage<100):
console.log("You are between 5 and 10");
case (userage>=100):
console.log("Wow you are older than 100");
break;
}

console log(`You are %userageindays months old, %userageinmonths days old, %userageinhours hours old, %userageinminutes minutes old, and %userageinseconds seconds old`);

In: Computer Science

********************C# C# C#******************** Part A: Create a project with a Program class and write the following...

********************C# C# C#********************

Part A: Create a project with a Program class and write the following two methods(headers provided) as described below:

1. A Method, public static int InputValue(int min, int max), to input an integer number that is between (inclusive) the range of a lower bound and an upper bound. The method should accept the lower bound and the upper bound as two parameters and allow users to re-enter the number if the number is not in the range or a non-numeric value was entered.

2. A Method, public static bool IsValid(string id), to check if an input string satisfies the following conditions: the string’s length is 5, the string starts with 2 uppercase characters and ends with 3 digits. For example, “AS122” is a valid string, “As123” or “AS1234” are not valid strings.

Part B: Create a Book class containing the following:

1. Two public static arrays that hold codes (categoryCodes) and descriptions of the popular book categories (categoryNames) managed in a bookstore. Thesecodes are CS, IS, SE, SO, and MI, corresponding to book categories Computer Science, Information System, Security, Society and Miscellaneous.

2. Data fields for book id (bookId) and book category name   (categoryNameOfBook)

3. Auto-implemented properties that hold a book’s title (BookTitle), book’s number of pages (NumOfPages) and book’s price (Price).

4. Properties for book id and book category name. Assume that the set accessor will always receive a book id of a valid format. For example, “CS125” and “IS334” are of valid format and also refer to known categories “Computer Science” and “Information Systems”. If the book ID does not refer to a known category, then the set accessor must retain the number and assign to the “MI” category. For example, “AS123” will be assigned as “MI123”. The category property is a read-only property that is assigned a value when the book id is set.

5. Two constructors to create a book object:

- one with no parameter:

public Book()

- one with parameter for all data fields:

public Book(string bookId, string bookTitle, int numPages, double price)

6. A ToString method, public override string ToString(), to return information of a book object using the format given in the screen shot under

Information of all Books

Part C:

Extend the application in Part A (i.e., adding code in the Program class) to become a BookStore Application by making use of the Book class and completing the following tasks:

1. Write a Method,

  private static void GetBookData(int num, Book[] books),

to fill an array of books. The method must fill the array with Books which are constructed from user input information (which must be prompted for). Along with the prompt for a book id, it should display a list of valid book categories and call method in Part A.2 to make sure the inputted book id is a valid format. If not the user is prompted to re-enter a valid book id.

2. After the data entry is complete, write a Method,

public static void DisplayAllBooks(Book[] books),

to display information of all books that have been entered including book id, title, number of pages and price. This method should call the ToString methodthat has been created in Book class.

3. After the data entry is complete, write a Method,

private static void GetLists(int num, Book[] books),

to display the valid book categories, and then continuously prompts the user for category codes and displays the information of all books in the category as well as the number of books in this category.

Appropriate messages are displayed if the entered category code is not a valid code.

4. Write the Main method that first prompts the user for the number of books that is between 1 and 30 (inclusive), by calling the method in Part A.1.

Then call method in Part C.1 to create an array of books.

Then call method in Part C.2 to display all books in the array.

Then call method in Part C.3 to allow the user to input a category code and see information of the category.

In: Computer Science

For each of the following assertions, say whether it is true or false. Justify your answers....

For each of the following assertions, say whether it is true or false. Justify your answers.

a) Imagine the next Mars rover stops working upon arrival on Mars. From this we can deduce that Mars rover is not a rational agent. (Note that a rational agent is not necessarily perfect, it's only expected to maximize goal achievement, given the available information.)

b) Every optimal search strategy is necessarily complete.

c) Breadth-first search is optimal if the step cost is positive

In: Computer Science

Factorials in Java: Write out your Program Design for how to automate the testing. The objective...

Factorials in Java: Write out your Program Design for how to automate the testing. The objective is to repeat the factorial calculation for different values of n, as n changes from 2, 3, 4, 5, 6, 7..

1) test for an int

2) test for a long

3)test for a double

In: Computer Science

/** * Write a recursive function that accepts a Queue<Integer>. It * should change every int...

/**

* Write a recursive function that accepts a Queue<Integer>. It

* should change every int in this queue to be double its original

* value. You may NOT use loops or any other data structures besides

* the queue passed in as a parameter. You may use a helper function.

* @param q

*/

public static void doubleElements(Queue<Integer> q) {}

In: Computer Science

. Let BT Node be the class we often use for binary-tree nodes. Write the following...

. Let BT Node be the class we often use for binary-tree nodes. Write the following recursive methods: (a) numLeaves: a method that takes a BT Node T as parameter and returns the number of leaves in the tree rooted at T. (b) isEven: a boolean method that takes a BT Node T and checks whether its tree is strictly binary: every node in the tree has an even number of children.

In: Computer Science

Find the Standard Deviation in Java: Use Arrays and Looping. Calculate the Standard Deviation once you...

Find the Standard Deviation in Java: Use Arrays and Looping. Calculate the Standard Deviation once you have the m numbers in an Array of size m. *Don't use different methods

In: Computer Science

C# Write a console application that takes the following passage and removes every instance of the...

C#

Write a console application that takes the following passage and removes every instance of the word "not" using StringBuilder and prints the result out to the console:

I do not like them
In a house.
I do not like them
With a mouse.
I do not like them
Here or there.
I do not like them
Anywhere.
I do not like green eggs and ham.
I do not like them, Sam-I-am.

Ensure that the resulting output reads normally, in other words, it must maintain the same line breaks and not include double-spaces where there should only be a single space. The output should be identical to this:

I do like them
In a house.
I do like them
With a mouse.
I do like them
Here or there.
I do like them
Anywhere.
I do like green eggs and ham.
I do like them, Sam-I-am.

In: Computer Science

Note: Present results using fprintf()and comment your code throughout. Write a function that will compute the...

Note: Present results using fprintf()and comment your code throughout.

  1. Write a function that will compute the volume and surface area of a rectangular prism when provided with the object’s 3 numerical dimensions. In other words, the function should be given three inputs (height, width and depth) and return two outputs (the volume and surface area, in that order). Show the following test cases:
    1. height: 5   width:3    depth: 2
    2. heignt:1    width:8    depth:4
    3. height: 2   width:2    depth:10

The script should call the function 3 times and store the results of the three test cases in two row vectors called vol and sa.

Function specifications:

Input arguments: length, width, height - all scalars. (Order does not matter)

Output arguments: volume, area - both scalars. (Must be in this order)

OPTIONAL: If you prefer, you can write the function such that the input and output arguments are arrays; in that case, only one call to the function is necessary.

In: Computer Science

** * Write a recursive function that removes the first k even numbers * from the...

**

* Write a recursive function that removes the first k even numbers

* from the stack. If there are less than k even elements in the stack,

* just remove all even elements. Do not use any loops or data structures

* other than the stack passed in as a parameter.

* @param stack

* @param k

* @return Returns the number of elements removed from the stack.

*/

public static int removeEvenNumbers(Stack<Integer> stack, int k) {

return 0;

}

In: Computer Science

Complete class Cow so that it has: (a) an int attribute to hold a number of...

Complete class Cow so that it has:

(a) an int attribute to hold a number of legs,
(b) a constructor that takes one parameter, a number of legs (c) a getter method for the attribute
(d) a method to convert any instance of Cow to a string

    class Cow{
        ____________________________________
        ____________________________________
        Cow(________________________){
        ____________________________________
        ____________________________________
        }
        ____ getNumLegs(){
        ____________________________________
        ____________________________________
        }
        ____________________________________
        ____________________________________
        ____________________________________
        ____________________________________
        ____________________________________

}

public class MinOfSet {

    /**
     * Write a method (use the code provided) that takes
     * a collection of Cows and
     * returns the Cow that has the minimum number of legs.
     * Assume the collection contains at least one cow.
     */

    public static Cow minCow(Collection<Cow> herd){
        Cow answer = null;
        Iterator<Cow> icow = herd.iterator();
         ____________________________________
         ____________________________________
         ____________________________________
         ____________________________________
         ____________________________________
         ____________________________________
         ____________________________________
         ____________________________________

}

public static void main(String[] args) {
//Put two cows in the herd and then print the cow with minimum legs
Collection<Cow> herd = new HashSet<>();
____________________________________
____________________________________
____________________________________
____________________________________

In: Computer Science

*in Java 1.Create a card class with two attributes, suit and rank. 2.In the card class,...

*in Java

1.Create a card class with two attributes, suit and rank.

2.In the card class, create several methods:

a. createDeck – input what type of deck (bridge or pinochle) is to be created and output an array of either 52 or 48 cards.

b.shuffleDeck – input an unshuffled deck array and return a shuffled one.

+ Create a swap method to help shuffle the deck

c. countBridgePoints – inputs a 13-card bridge ‘hand’-array and returns the number of high-card points

d. writeHandOutput – input a bridge-hand and prints it out on the monitor

e. writeDeckOuput – inputs a deck of bridge cards and prints it out on the monitor

  1. main method should:

a. Ask the user what kind of deck he/she wants to create (pinochle or bridge). For this project, have the user input ‘bridge’.

b. Create the user-asked-for deck

c. Print out the unshuffled deck

d. Shuffle the deck

e. Create 4 Bridge hands of 13 cards each, call them North, South, East and West.

+ Deal every fourth card to each of the hands

f. Calculate the high-card-points in each hand

g. Print out each hand and the number of high-card-points associated with each hand

h. Sort the hands from highest to lowest number of points – use Insertion Sort we did before

i. Print out each hands points from highest to lowest.

In: Computer Science

7. Write a function that accepts a sentence as the argument and converts each word to...

7. Write a function that accepts a sentence as the argument and converts each word to “Pig Latin.” In one version, to convert a word to Pig Latin, you remove the first letter and place that letter at the end of the word. Then you append the string “ay” to the word. Here is an example: English: I SLEPT MOST OF THE NIGHTPIG LATIN: IAY LEPTSAY OSTMAY FOAY HETAY IGHTNAY.

In: Computer Science

Jeff needs to make a calculation on data in rows of an Excel spreadsheet. He creates...

  1. Jeff needs to make a calculation on data in rows of an Excel spreadsheet. He creates a new column, and in the first row of this column, he writes a formula. He verifies the resulting number is correct. He then double-clicks the bottom right of the cell to perform the same calculation on all other rows in the column (AutoFill). After he double-clicks, he sees the numbers appear. What would be the next thing Tony should do?
    1. Chart the data in a line graph to make sure the data can be plotted.
    2. Select one random row and perform the calculation manually, to get a level of assurance the formula worked correctly for all rows and the correct data is shown.
    3. Change the formula to put a dollar sign (“$”) on both sides of the column letter to ensure the data is locked.
    4. Nothing further needs to be done except to save the workbook file.

In: Computer Science