Write a Python function that takes a list of string as arguments.
When the function is called it should ask the user to make a selection from the options listed in the given list.
The it should get input from the user. Place " >" in front of user input.
if the user doesn't input one of the given choices, then the program should repeatedly ask the user to pick from the list.
Finally, the function should return the word the user selected.
Important Note:
DO NOT USE INPUT AND PRINT INSIDE THE FUNCTION AT
ALL
MAKE THEM OUTSIDE THE FUNCTION PLEASE!
Example:
myList = myFunction(["yes","no","maybe"])
select one of the following please:
yes
no
maybe
# user input example
> could be
select one of the following please:
> perhaps
select one of the following please:
> yes
print(myList)
In: Computer Science
Write a C program to blink two LEDs connected to Raspberry pi. One must blink at a rate of 1 Hz and the other at a rate of 2 HZ.
In: Computer Science
C++
Text file contains numbers 92 87 65 49 92 100 100 100 82 75 64 55 100 98 -99
Modify your program from Exercise 1 so that it reads the information from the gradfile.txt file, reading until the end of file is encountered. You will need to first retrieve this file from the Lab 7 folder and place it in the same folder as your C++ source code. Run the program
#include <iostream>
using namespace std;
typedef int GradeType[100]; // declares a new data type:
float findAverage (const GradeType, int); // finds average of all
grades
int findHighest (const GradeType, int); // finds highest of all
grades
int findLowest (const GradeType, int); // finds lowest of all
grades
int main()
{
GradeType grades; // the array holding the grades.
int numberOfGrades; // the number of grades read.
int pos; // index to the array.
float avgOfGrades; // contains the average of the grades.
int highestGrade; // contains the highest grade.
int lowestGrade; // contains the lowest grade.
// Read in the values into the array
pos = 0;
cout << "Please input a grade from 1 to 100, (or -99 to
stop)" << endl;
cin >> grades[pos];
while (grades[pos] != -99)
{
pos++;
cin >> grades[pos];
}
numberOfGrades = pos--;
// call to the function to find average
avgOfGrades = findAverage(grades, numberOfGrades);
cout << endl << "The average of all the grades is "
<< avgOfGrades << endl;
highestGrade = findHighest(grades, numberOfGrades);
cout << endl << "The highest grade is " <<
highestGrade << endl;
lowestGrade = findLowest(grades, numberOfGrades);
cout << "The lowest grade is " << lowestGrade <<
endl;
return 0;
}
float findAverage (const GradeType array, int size)
{
float sum = 0; // holds the sum of all the numbers
for (int pos = 0; pos < size; pos++)
sum = sum + array[pos];
return (sum / size); //returns the average
}
int findHighest (const GradeType array, int size)
{
int highest = array[0];
for (int pos = 0; pos < size; pos++)
{
if ( highest < array[pos])
{
highest = array[pos];
}
}
return highest;
}
int findLowest (const GradeType array, int size)
{
int lowest = array[0];
for (int pos = 0; pos < size; pos++)
{
if ( lowest > array[pos])
{
lowest = array[pos];
}
}
return lowest;
}
In: Computer Science
(Language: c++)Write a program that displays a question and 4 possible
answers numbered 1 through 4. . The program should
ask the user to answer 1, 2, 3, or 4 and tell them if they
are correct or not. If the user enters anything besides 1, 2,
3, or 4 the program should return an error message
example outout: whats 2+5?
1. 4
2. 7
3. 1
4. 0
// if user inputs anything other then option 2 the screen should display "incorrect"
// if the user inputs anything other then 1,2,3,or 4 the screen should display "error invalid answer given"
//, when the correct answer is given computer, should display "correct".
In: Computer Science
In: Computer Science
Discuss the characteristics of graph data structure; use three examples to demonstrate the kinds of questions that graph can solve.
In: Computer Science
Number guessing Game
Write a C program that implements the “guess my number” game. The computer chooses a random number using the following random generator function
srand(time(NULL));
int r = rand() % 100 + 1;
that creates a random number between 1 and 100 and puts it in the variable r. (Note that you have to include <time.h>) Then it asks the user to make a guess. Each time the user makes a guess, the program tells the user if the entered number is larger or smaller than its number. The user then keeps guessing till he/she finds the number.
If the user doesn’t find the number after 10 guesses, a proper game over message will be shown and the actual guess is revealed. If the user makes a correct guess in its allowed 10 guesses, then a proper message will be shown and the number of guesses the user made to get the correct answer is also printed.
After each correct guess or game over, the user decides to play again or quit and based on the user choice, the computer will make another guess and goes on or prints a proper goodbye message and quits A sample run is as follows (user inputs are in red):
Welcome to the Number Guess Game!
I choose a number between 1 and 100 and you have only 10 chanced to
guess it!
OK, I made my mind!
What is your guess? > 5
My number is larger than 5!
9 guesses left.
What is your guess? > 75
My number is smaller than 75!
8 guesses left.
What is your guess? > 40
My number is smaller than 40!
7 guesses left.
What is your guess? > 23
My number is larger than 23!
6 guesses left.
What is your guess? > 30
My number is larger than 30!
5 guesses left.
What is your guess? > 35
You did it! My number is 35!
You found it with just 6 guesses.
Do you want to play again? (Y/N) > Y
OK, I made my mind!
What is your guess? > 15
My number is larger than 15!
9 guesses left.
…
And if the user makes 10 guesses without a success
…
What is your guess? > 405
Please enter a number between 1 and 100
What is your guess? > 45
My number is larger than 45!
1 guess left.
What is your guess? > 47
SORRY! You couldn’t find it with 10 guesses!
My number was 46. Maybe next time!
Do you want to play again? (Y/N) > N
Thanks for playing! See you later.
In: Computer Science
Programming in C (not C++)
## Requirements
Only need to edit the challenge.c
You have one function to implement: void fork_exec(char**
argv):
This takes in an array of strings representing arguments.
The first argument is the filename of an executable (which will be
given as a relative filepath, such as "./a")
The remaining terms would be arguments for said executable.
The array is null terminated
You need to fork your process.
The child needs to call exec (rather, a variant thereof) to execute
the specified file with the specified arguments.
challenge.c
#include "challenge.h"
// goal: fork the process and have the child execute a
process
// param argv: the argument vector for the process to be
executed
// assumptions:
// the first argument of argv is the file name of the
executable
// argv is null terminated
//
// TODO: complete the function
// fork
// exec (child), probably most convenient to use
execvp
// have the parent wait on the child
void fork_exec(char** argv)
{
}
challenge.h
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
#ifndef CH_HEAD
#define CH_HEAD
// goal: fork the process and have the child execute a
process
// param argv: the argument vector for the process to be
executed
// assumptions:
// the first argument of argv is the file name of the
executable
// argv is null terminated
void fork_exec(char** argv);
#endif
In: Computer Science
Assignment 2- 9 USING A FOR LOOP
Create a PL/SQL block using a FOR loop to generate a payment schedule for a donor’s pledge, which is to be paid monthly in equal increments. The values variable for the block is starting payment due date, monthly payment amount, and a number of total monthly payments for the pledge. The list that’s generated should display a line for each monthly payment showing payment number, date due, payment amount, and donation balance (remaining amount of pledge owed).
Assignment 2 – 10 USING A BASIC LOOP
Accomplish the task in Assignment 2-9 above by using a basic loop structure.
Assignment 2 – 11 USING A WHILE LOOP
Accomplish the task in Assignment 2-9 by using a WHILE loop structure. Instead of displaying the donation balance (remaining amount of pledge owed) on each line of output, display the total paid to date.
Assignment 2 – 12 USING A CASE EXPRESSION
Donors can select one of three payment plans for a pledge indicated by the following codes: 0 = one-time (lump sum) payment, 1 = monthly payments over one year, and 2 = monthly payments over two years. A local business has agreed to pay matching amounts on pledge payments during the current month. A PL/SQL block is needed to identify the matching amount for a pledge payment. Create a block using the input values of a payment plan code and a payment amount. Use a CASE expression to calculate the matching amount, based on the payment plan codes 0 = 25%, 1 = 50%, 2 = 100%, and other = 0. Display the calculated amount.
Assignment 2 – 13 USING NESTED IF STATEMENTS
An organization has committed to matching pledge amounts based on the donor type and pledge amount. Donor types include I = Individual, B = Business organization, and G = Grant funds. The matching percents are to be applied as follows:
Donor Type |
Pledge Amount |
Matching (%) |
I |
$100-$249 |
50% |
I |
$250-$499 |
30% |
I |
$500 or more |
20% |
B |
$100-$499 |
20% |
B |
$500-$999 |
10% |
B |
$1,000 or more |
5% |
G |
$100 or more |
5% |
Create a PL/SQL block using nested IF statements to accomplish the task. The input value for the block is the donor type code and the pledge amount.
In: Computer Science
Create a new SQL table in your phpMyAdmin account that collects the following fields (columns) -
1) The name of a medicine, sanitizer, or tip/trick for protecting yourself against transmission or fight the disease - STRING
2) The amount of money the item costs - NUMBER
3) The UPC code of the item - NUMBER
4) Manufacturing country of the item - STRING
Connect to the SQL database with your HTML code, and make sure to show the results of ALL columns show! -
Create a form where the user can insert their items into the 4 columns mentioned above -
Build the HTML site with at least 5 pictures and a few paragraphs explaining your creativity (and how important it is to be safe this flu season!) - make sure to use proper APA guidelines for your in-text citations and a bibliography section! -
In: Computer Science
Use Java
(Geometry: point in a rectangle?)
Write a program that prompts the user to enter a point (x, y) and
checks whether the point is within the rectangle centered at (0, 0)
with width 10 and height 5.
For example, (2, 2) is inside the rectangle and (6, 4) is outside
the rectangle.
(Hint: A point is in the rectangle if its horizontal distance to
(0, 0) is less than or equal to10 / 2 and its vertical distance to
(0, 0) is less than or equal to 5.0 / 2. Test your program to cover
all cases.)
Sample Run 1
Enter a point with two coordinates: 2 2
Point (2.0, 2.0) is in the rectangle
Sample run 2
Enter a point with two coordinates: 6 4
Point (6.0, 4.0) is not in the rectangle
Sample Run 3
Enter a point with two coordinates: -5.1 -2.4
Point (-5.1, -2.4) is not in the rectangle
Sample Run 4
Enter a point with two coordinates: -4.9 2.49
Point (-4.9, 2.49) is in the rectangle
Sample Run 5
Enter a point with two coordinates: -4.99 -2.499
Point (-4.99, -2.499) is in the rectangle
Class Name: Exercise03_23
If you get a logical or runtime error, please refer
https://liveexample.pearsoncmg.com/faq.html.
In: Computer Science
hello everyone
can anybody provide me an light weight elliptic curve cryptography algorithm full coded in any programming language you want, that works with ns2(network simulator)
thanks
In: Computer Science
This is a C++ assignment
The necessary implementations:
Requirements to meet:
Write a program that asks the user to enter 5 numbers. The numbers will be stored in an array. The program should then display the numbers back to the user, sorted in ascending order.
Include in your program the following functions:
Main calls each function once, in turn and passes the array and it's size to each function. Creates the array. Does not interact with the user itself.
Note: You must implement the sorting algorithm yourself, either selection sort or bubble sort
In: Computer Science
The Study of Instructional Improvement (SII; Hill, Rowan, and Ball, 2004) was carried out by researchers at the University of Michigan to study the math achievement scores of first- and third-grade students in randomly selected classrooms from a national U.S. sample of elementary schools.
Using the information above answer the following question using excel and show work.
1.
Format:
A data frame with 1190 observations on the following 12 variables.
a. sex
: Indicator variable (0 = boys, 1 = girls)
b. minority
: Indicator variable (0 = non-minority students, 1 = minority students)
c. mathkind
: Student math score in the spring of their kindergarten year
d. mathgain
: Student gain in math achievement score from the spring of kindergarten to the spring of first grade (the dependent variable)
e. ses
: Student socioeconomic status
f. yearsteach
: First grade teacher years of teaching experience
In: Computer Science
I DID STEP 1-2 AND 3 I JUST NEED A STEP 4 ANSWERS AND THIS IS SO EMERGENCY(DUE DATE TONIGHT) PLEASE HELP (I WILL GIVE UPVOTE AND GOOD COMMENT THANK YOU) if you need to see step 1-2-3 I can add on the comment.
Step 1 - WhoIs
Step 2 - TCP Port Scanning
Step 3 - UDP Port Scanning
Step 4 - Analysis ---- Answer these questions:
In: Computer Science