Using the knowledge of the computational language in python it is possible to write a code that write a program that first invites the user to input a natural number n.
Writting the code:def func(n):
# Base cases:
# When n reaches 1 then return 2 as X1 = 2.
if(n == 1):
return 2
# When n reaches 2 then return 3 as X2 = 3.
if(n == 2):
return 3
ans = 2 * func(n-1) + func(n-2)
return ans
n = int(input("Enter a natural number: "))
print("The" ,n,"-th number of the sequence is: " ,func(n))
See more about python at brainly.com/question/18502436
#SPJ1
Write the following short piece of code in python:
Programmers refer to a brief section of reusable source code, machine code, or text as a “snippet.” These are typically explicitly defined operational units that are integrated into bigger programming modules.
What are the short piece of code in python?Guido van Rossum created Python, an interpreted, object-oriented, high-level programming language with dynamic semantics. It was first made available in 1991.
The syntax of Python is straightforward and resembles that of English. Python's syntax differs from various other programming languages in that it enables programmers to construct applications with fewer lines of code.
Therefore, Python operates on an interpreter system, allowing for the immediate execution of written code. As a result, prototyping can proceed quickly.
Learn more about python here:
https://brainly.com/question/10718830
#SPJ1
Q: Define the following terms:
(i) Computer
(ii) Program
(iii) Data
List questions you would be asking to software developers about the form.
List potential risks if there are any with the form.
Write an expression using Boolean operators that prints "Special number" if special_num is -99, 0, or 44.
A sample expression that uses Boolean operators that prints "Special number" if special_num is -99, 0, or 44 is given below:
The Programimport java.util.Scanner;
import java.io.*;
public class Test
{
public static void main(String[]args) throws IOException
{
File file = new File("SNUMS.INP");
Scanner inputFile = new Scanner(file);
int order = 1;
int i = 1;
int[] special = new int[1000000+1];
// Write all 10^6 special numbers into an array named "special"
while (order <= 1000000)
{
if (specialNumber(i) == true)
{
special[order] = i;
order++;
}
i++;
}
// Write the result to file
PrintWriter outputFile = new PrintWriter("SNUMS.OUT");
outputFile.println(special[inputFile.nextInt()]);
while (inputFile.hasNext())
outputFile.println(special[inputFile.nextInt()]);
outputFile.close();
}
public static boolean specialNumber(int i)
{
// This method check whether the number is a special number
boolean specialNumber = false;
byte count=0;
long sum=0;
while (i != 0)
{
sum = sum + (i % 10);
count++;
i = i / 10;
}
if (sum % count == 0) return true;
else return false;
}
}
Read more about boolean operators here:
https://brainly.com/question/5029736
#SPJ1
*IN JAVA*
Write a program whose inputs are four integers, and whose outputs are the maximum and the minimum of the four values.
Ex: If the input is:
12 18 4 9
the output is:
Maximum is 18
Minimum is 4
The program must define and call the following two methods. Define a method named maxNumber that takes four integer parameters and returns an integer representing the maximum of the four integers. Define a method named minNumber that takes four integer parameters and returns an integer representing the minimum of the four integers.
public static int maxNumber(int num1, int num2, int num3, int num4)
public static int minNumber(int num1, int num2, int num3, int num4)
import java.util.Scanner;
public class LabProgram {
/* Define your method here */
public static void main(String[] args) {
/* Type your code here. */
}
}
The program whose inputs are four integers is illustrated:
#include <iostream>
using namespace std;
int MaxNumber(int a,int b,int c,int d){
int max=a;
if (b > max) {
max = b;}
if(c>max){
max=c;
}
if(d>max){
max=d;
}
return max;
}
int MinNumber(int a,int b,int c,int d){
int min=a;
if(b<min){
min=b;
}
if(c<min){
min=c;
}
if(d<min){
min=d;
}
return min;
}
int main(void){
int a,b,c,d;
cin>>a>>b>>c>>d;
cout<<"Maximum is "<<MaxNumber(a,b,c,d)<<endl;
cout<<"Minimum is "<<MinNumber(a,b,c,d)<<endl;
}
What is Java?Java is a general-purpose, category, object-oriented programming language with low implementation dependencies.
Java is a popular object-oriented programming language and software platform that powers billions of devices such as notebook computers, mobile devices, gaming consoles, medical devices, and many more. Java's rules and syntax are based on the C and C++ programming languages.
Learn more about program on:
https://brainly.com/question/26642771
#SPJ1
uses of computer in communication
Uses of computers in communication:
1) Transfer of data
2)Transfer of information
3) Wireless message communication
4)Video service
5)E-mail
6) Internet and Fax
What is the use of computers in communication?
The mainstay of information technology, computers are essential for communication. Early in the 1990s, the first homes began to utilize the Internet, which eventually led to the widespread use of email, websites, blogs, social networking, and Voice-Over-Internet Protocol.
Above listed ones are the uses of computers in communication.
To know more about the information about computers in communication
https://brainly.com/question/26152499
#SPJ1
Downloading what appears to be a legitimate app, a user installs malware which contains keylogging software. What type of breach is the downloading of malware?
CIA Traid -
explain
Downloading what appears to be a legitimate app, a user installs malware which contains keylogging software. The type of breach that this downloading of malware is called option B: integrity.
What is CIA Traid about?The CIA triad, also known as confidentiality, integrity, and availability, is a concept created to direct information security policies inside a company. To avoid confusion with the Central Intelligence Agency, the approach is sometimes frequently referred to as the AIC triad (availability, integrity, and confidentiality).
Note that In the event of a cyber breach, the CIA triad offers organizations a clear and thorough checklist to assess their incident response strategy. The CIA trio is particularly crucial for identifying vulnerability sources and aiding in the investigation of what went wrong once a network has been infiltrated.
Learn more about malware from
https://brainly.com/question/399317
#SPJ1
See full question below
Downloading what appears to be a legitimate app, a user installs malware which contains keylogging software. What type of breach is the downloading of malware?
answer choices
Confidentiality
Integrity
How many subnets and host per subnet are available from network 192.168.43.0 255.255.255.224?
It is to be noted that from network 192.168.43.0 255.255.255.224 the number of subnets and hosts available are 8 and 32 respectively. Out of the 32 hosts only 30 are usually usable.
What is a host in networking?A computer or other device linked to a computer network is referred to as a network host. A host can function as a server, providing information resources, services, and programs to network users or other hosts. At least one network address is assigned to each host.
A computer network is a collection of computers that share resources that are located on or provided by network nodes. To interact with one another, the computers employ standard communication protocols across digital linkages.
So with regard to the above answer, note that by entering the data into an online IPv4 subnet calculator, we are able to arrive at the total number of:
8 subnets; and 30 hosts available for 192.168.43.0 (IP Address) and 255.255.255.224 (Subnet)Learn more about Subnets:
https://brainly.com/question/15055849
#SPJ1
How is trust built?
Select all the correct options and click Submit.
Trust is built incrementally.
Trust is earned behaviorally.
Trust is built by spending a lot of time with people.
Trust is built by being pleasant and polite.
The trust is built by the following options:
Trust is built incrementally.Trust is earned behaviorally.Trust is built by spending a lot of time with people.How trust is built?
Trust is built by spending much time with the people you are in contact with you have to observe the behavioral characteristics and notice the behavior accordingly. Most important characteristics to build trust: Honesty, Integrity, Transparency etc. Hence to conclude along with certain observance and characteristics trust is built. Consistency often leads to trust. We have the most faith in people who are always there for us, in good and bad times. Showing someone you're there to assist them on a regular basis is a great way to build trust.
To know more about trust please follow the link below:
https://brainly.com/question/11875869
#SPJ1
Write a simple computer program that asks a user to input their name and email address, and then displays a message that tells the person that you will be contacting them using the email address they entered.
name = input("Enter your name: ")
email = input("Enter you e-mail: ")
print("Hi",name,"we can contact you via your e-mail address which is",email)
Account A can retrieve or modify any relation except DEPENDENT and can grant any of these privileges to other users. (b) Account B can retrieve all the attributes of EMPLOYEE and DEPARTMENT except for SALARY, MGRSSN, and MGRSTARTDATE. (c) Account C can retrieve or modify WORKS_ON but can only retrieve the FNAME, MINIT, LNAME, SSN attributes of EMPLOYEE and the PNAME, PNUMBER attributes of PROJECT. (d) Account D can retrieve any attribute of EMPLOYEE or DEPENDENT and can modify DEPENDENT. (e) Account E can retrieve any attribute of EMPLOYEE but only for EMPLOYEE tuples that have DNO = 3. (f) Write SQL statements to grant these privileges. Use views were appropriate
The SQL statements to grant these privileges are as follows:
GRANT SELECT, UPDATEON EMPLOYEE, DEPARTMENT, DEPT_LOCATIONS, PROJECT,
WORKS_ON
TO ACCOUNTA
WITH GRANT OPTION;
CREATE VIEW EMPS ASSELECT FNAME, MINIT, LNAME, SSN, BDATE, ADDRESS, SEX
SUPERSSN, DNO
FROM EMPLOYEE;
GRANT SELECT ON EMPS
TO ACCOUNTB;
CREATE VIEW DEPTS AS
SELECT DNAME, DNUMBER
FROM DEPARTMENT;
GRANT SELECT ON DEPTS
TO ACCOUNTB;
GRANT SELECT, UPDATEON WORKS_ON
TO ACCOUNTC;
CREATE VIEW EMP1 AS
SELECT FNAME, MINIT, LNAME, SSN
FROM EMPLOYEE;
GRANT SELECT ON EMP1
TO ACCOUNTC;
CREATE VIEW PROJ1 AS
SELECT PNAME, PNUMBER
FROM PROJECT;
GRANT SELECT ON PROJ1
TO ACCOUNTC;
GRANT SELECT ON EMPLOYEE, DEPENDENTTO ACCOUNTD;
GRANT UPDATE ON DEPENDENT
TO ACCOUNTD;
CREATE VIEW DNO3_EMPLOYEES ASSELECT * FROM EMPLOYEE
WHERE DNO = 3;
GRANT SELECT ON DNO3_EMPLOYEES
TO ACCOUNTE;
What do you mean by SQL statement?SQL statement may be defined as a domain-specific language that is significantly utilized in programming and designed for controlling data held in a relational database management system. SQL stands for Structured Query Language.
Therefore, the SQL statements to grant these privileges are well described above.
To learn more about SQL statements, refer to the link:
https://brainly.com/question/14312429
#SPJ1
6.6 code practice question 2? 4 adjacent circles one
We have to create a program that draws an image of concentric circles with the help of canvas and frame using python.
Codding strucute of the given problem:
import simplegui
def draw_handler(canvas):
canvas.draw_circle((200, 130), 90, 5, "Green")
canvas.draw_circle((200, 130), 70, 5, "Green")
canvas.draw_circle((200, 130), 50, 5, "Green")
canvas.draw_circle((200, 130), 30, 5, "Green")
canvas.draw_circle((200, 130), 10, 5, "Green")
frame = simplegui.create_frame('Circle', 600, 600)
frame.set_canvas_background("White")
frame.set_draw_handler(draw_handler)
frame.start()
To know more about Python, visit: https://brainly.com/question/26497128
#SPJ1
Every workplace should have an emergency plan of action.
Please select the best answer from the choices provided
T
F
It is true that every workplace should have an emergency action plan.
What is an emergency action plan (EAP)?
A written document required by specific OSHA standards is an emergency action plan (EAP). [29 CFR 1910.38(a)] An EAP's purpose is to facilitate and organize employer and employee actions in the event of a workplace emergency.
During an emergency, well-developed emergency plans and proper employee training (so that employees understand their roles and responsibilities within the plan) will result in fewer and less severe employee injuries and less structural damage to the facility.
A poorly prepared plan will almost certainly result in a disorganized evacuation or emergency response, causing confusion, injury, and property damage.
So, the correct answer to the question is True (T).
To know more about the emergency action plan, visit: https://brainly.com/question/3238467
#SPJ1
Sammy’s Seashore Supplies rents beach equipment such as kayaks, canoes, beach chairs, and umbrella to tourists. Modify your Application as follows: Using Python
Modify the getinput() function that accepts the user information so that it prompts for a customer name, first name and last name. Store in two separate variables.
Add data validation to the account number so that only a 4 character string is allowed. The first character must be an A. You will need to use a while loop here because you do not know how many times the user will enter an invalid Account Number. You will have two conditions for the while loop: while the length of the account number variable does not equal 4 or while the account number variables does not start with the letter "A".
Add a phone number input to the getinput(). Make sure that the phone number is 7 digits. Use a while loop that keeps asking the user to enter the phone number until it is seven digits.
Return all values from the getinput() function -- there will be 5 of them.
Modify the main() function so that the line that calls the getinput() function stores all 5 returned values in separate variables.
Modify the main() function so that the values returned from the getinput() function are passed to the calculatefotal() function.
Modify the header of the calculatetotal() function so that is accepts 5 parameters ( the account number, the number of minutes, the first name, the last name , and the telephone number.
Modify the function that calculates the total and displays all the information, so that it displays the Contract Number, first and last names, and the Phone Number. The Phone Number should be displayed in the ###-#### format. You can the slice function to do this.
Includes comments at the top to identify file name, project and a brief description.
For further documentation, include comment for each section of code.
Sample Run:
ACCOUNT NUMBER:, A234 (program keeps prompting until a 4 character, starting with an A
Name Sally Douglass
123 – 4567 (formatted in the module that displays the result)
Minutes rented: 115
Whole hours rented: 1
Minutes remaining: 55
Rental cost: $ 80
Coupon good for 10% Off!
This is my original code base on the instruction how do I add the new code to the case
# Main function calls other functions
def main():
display()
a,x=getinput()
calculatetotal(x,a)
# function to display logo
def display():
#Display the Sammy’s logo
print("-------------------------------------------------------------")
print("+ +")
print("+ “SAMMY’S MAKES IT FUN IN THE SUN +")
print("+ +")
print("+ +")
print("-------------------------------------------------------------")
# function to receive input from user
def getinput():
# Request the minutes rented and store in variable
contract_number = (input("Enter the account number"))
rented_minutes = int(input("Enter the number of minutes it took to rent: "))
while (rented_minutes<60 or rented_minutes>7200):
rented_minutes = int(input("Try again"))
return rented_minutes,contract_number
# function to calculate hours, minutes remaining and cost
def calculatetotal(acc,mins):
# Calculate number of whole hours
whole_hours = mins//60
# Calculate the number of minutes remaining
remaining_min = mins % 60
# Calculate the cost as hours * 40 + minutes remaining times 1
#Calculation from smallest to greater by getting the smallest number
cost = whole_hours*40+ min(remaining_min*1, 40)
# >Display minutes, whole hours, minutes remaining, and cost with labels
# Print all values
print(("ACCOUNT NUMBER:"),acc)
print("Minutes Rented:",mins)
print("Whole Hours:",whole_hours)
print("Minutes Remaining:",remaining_min)
Answer:
figure it out
Explanation:
What hardware component is the main brain of the computer system that is responsible for all the activities of the processor stage of the IPOS cycle
Answer:
It is the Central Processing Unit (CPU)
what's formatting in computer
Answer:
completrly erasing
Explanation:
Reformatting a computer means completely erasing (formatting) the hard drive and reinstalling the operating system and all other applications and files. All of your data on the hard disk will be lost, so you will need to back it up to an External HD, DVD, flashdrive or another computer.
Formatting of computer means erasing something like hard drive disks etc.
Explanation:
Format or document format is the overall layout of a document or spreadsheet. For example, the formatting of text on many English documents.
Name two ways to store data
Answer:
Hard drives and solid-state drives
Explanation:
Match each benefit of participating in a professional network to the appropriate scenario.
1. building the professional network
2. preparing for interviews
3. upgrading knowledge
A. Miriam joins a group for employees of the company where she is interning.
B. Imelda reads about new technologies in the computer programming industry.
C. Rolf researches a company on a professional networking website.
Professional network Scenario
1 A
2 C
3 B
How to categorize professional networks with the scenario?
Scenario: A. Miriam joins a group of employees of the company where she is interning.
Professional network: 1. building the professional network
Scenario: C. Rolf researches a company on a professional networking website.
Professional network: 3. upgrading knowledge
Scenario: B. Imelda reads about new technologies in the computer programming industry.
Professional network: 2. preparing for interviews
Hence based on the appropriate scenario I have matched accordingly
To know more information on professional networks and related things, please follow the link below:
https://brainly.com/question/2083119
#SPJ1
SMCS School has hired you to set up an Internet connection within the school premises. The Internet connection will be utilized by both the junior and senior sections of the school situated in two different buildings on the same campus. Which of the following types of networks will you install in this scenario?
The network that will be install in the school premises and will be utilized by both the junior and senior sections of the school situated in two different buildings on the same campus is CAN (Campus Area Network).
Different Type of Networks:
Option 1 : MAN
Metropolitan Area Network is used to set up an Internet connection within the city.
So, this is the wrong option.
Option 2: WAN
Wide Area Network is used to setup an internet connection over a state, province or country.
So, this is the wrong option.
Option 3: CAN
Campus area network is used to setup internet connection within a limited geographical area like school campus, university campus etc. Given scenario is, the Internet connection will be utilized by both the junior and senior sections of the school situated in two different buildings on the same campus. When internet connection is to be used within the campus i.e., between two or three buildings then campus Area Network must be used there.
So, this is the Correct answer.
Option 4: LAN
Local Area Network is used to setup internet connection over the smallest area such as one school building, college buliding but not within the overall campus.
So, this is the wrong option.
To know more about network, visit: https://brainly.com/question/1167985
#SPJ1
Write and test the “digit” function: Function Prototype: int digit(int n,int k) This function returns the kth digit of the positive integer n. For example, if n is the integer 85,419, then the call digit(n,0) would return the digit 8, and the call digit(n,2) would return the digit 4. Examples: 1. Input: n = 25419 , k = 1 output: 5 2. Input: n = 2 , k = 0 output: 2 3. Input: n = 2 , k = 1 output: index out of bound (return -1) Note: • The digits are numbered from left to right beginning with the “zeroth” digit. • Take input and display output in main function. • Do not use array or string etc.
Explanation:
You have to just take a number n and after that you just reverse the number after that when the number is reversed you simply apply mod of 10 at that reversed number and then divide it by 10.
Note:
you have to use while loops when finding reversed number and the place of number to be found
Answer:
fastian broh its call plagrism
Explanation:
this is for a SQL server class:
Database level permissions apply to a specific database. Assigning permissions at this level is inefficient when dealing with ____
a. users with no permissions
b. large user groups
c. all of the above
Assigning permissions at this level is inefficient when dealing with large user groups. The correct option is b.
What is database-level permission?Permissions are the many sorts of access that are granted to specific securable. At the server level, permissions are assigned to SQL Server logins and server roles. At the database level, they are assigned to database users and database roles.
Read, write, and execute are the three types of permissions that files and directories can have. Anyone with reading permission can view the contents of a file or directory.
Therefore, the correct option is b. large user groups.
To learn more about database-level permission, refer to the link:
https://brainly.com/question/13108159
#SPJ1
An array is called vanilla if all its elements are made up of the same digit. For example {1, 1,
11, 1111, 1111111} is a vanilla array because all its elements use only the digit 1.
However, the array {11, 101, 1111, 11111} is not a vanilla array because its elements
use the digits 0 and 1.
Write a program that reads a string from a user that represent array and check if its a vanilla
array. Otherwise it will print message as in the sample run shown below and should continue to
allow the user to enter values. The program will terminate only if the user press the "Enter" key
without entering any value. For example the '{1}' is a vanilla array since all elements use the
same digit. Where '{11, 22, 13, 34, 125}' array is not vanilla array becuase elements used 5
different digits.
Using the knowledge in computational language in JAVA it is possible to write the code that An array is called vanilla if all its elements are made up of the same digit.
Writting the code:import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
int n;
Scanner sc=new Scanner(System.in);
System.out.print("Enter the number of elements you want to store: ");
//reading the number of elements from the that we want to enter
n=sc.nextInt();
//creates an array in the memory of length 10
int[] array = new int[10];
System.out.println("Enter the elements of the array: ");
for(int i=0; i<n; i++)
{
//reading array elements from the user
array[i]=sc.nextInt();
}
System.out.println("Array elements is: ");
for(int i=0; i<n; i++)
{
System.out.print(array[i]+" ");
} System.out.println("\n");
int res=0;
int t;
int k;
for(int i=0; i<n; i++)
{
t=array[i];
while(t>0)
{
k=t%10;
t=t/10;
if(k==0)
{
res=1;
break;
}
}if(res==1)
{System.out.println("False it is not vanilla array");
break;
}
}if(res==0)
{
System.out.println("True it is vanilla array");
}
See more about JAVA at brainly.com/question/12975450
#SPJ1
Knowledge Review 3
Which of the following are characteristics of the core capabilities? (Select all that apply.)
The above three are the characteristics of core capabilities.
What is National Response Framework?
The National Response Framework (NRF) is a guide to how the nation responds to all types of disasters and emergencies.
What are the main components of the National Response Framework?
Response doctrine is comprised of five key principles:
engaged partnershiptiered responsescalable, flexible, and adaptable operational capabilitiesunity of effort through the unified commandreadiness to act.To know more about NRF:
https://brainly.com/question/13107467
#SPJ13
Which is true about a gas? Choose the correct answer. Responses It changes to a liquid when it heats up. It changes to a liquid when it heats up. It takes up a definite amount of space. It takes up a definite amount of space. It takes up a definite amount of space but does not have a definite shape. It takes up a definite amount of space but does not have a definite shape. It does not take up a definite amount of space and does not have a definite shape. It does not take up a definite amount of space and does not have a definite shape.
A gas does not take up a definite amount of space and does not have a definite shape.
What are the properties of a gas?
There are four basic states of matter, with gas being one of them. A pure gas can be composed of single atoms, elemental molecules derived from a single type of atom, or complex molecules derived from a combination of atoms. There are many different pure gases in a gas mixture like air.
Three characteristics distinguish gas from liquids or solids they come from:
(1) they are easily compressed,
(2) they expand to fill their containers, and
(3) they take up a lot more area than solids or liquids.
To learn more about gas, use the link given
https://brainly.com/question/25649765
#SPJ9
First,
- select a classification methodology to learn in your project. Select either Classification Trees or Support Vector Machines.
- To actually get the data used in the ISLR examples, you will likely need to download an R package called ISLR; it contains the data sets used in the text.
- Begin by introducing your reader to the corporation from which your stock data (Leggett & Platt Incorporated) comes. Tell the reader something you learned about that corporation that you found interesting, something which would demonstrate to a recruiter that you possess curiosity and the ability to employ it.
- Then, using trimmed screenshots where needed from Excel, sketch out for the reader how you converted your Yahoo-sourced stock data into lagged stock risk data set since 2006.
Second,
-draw a random sample of size n=300 without replacement from your stock return data set. Recall that your stock return data contains a HiLo return column and standardized log lag1 and log lag2 return columns. I will call this your n=300 stock return data set. Show and explain how this is done.
- draw another random sample of size 300 without replacement from your stock return data set. Recall that your stock risk data contains a HiLo risk column and standardized log lag1 and log lag2 columns. I will call this your n=300 stock risk data set.
Next, using your n=300 stock return data set, walk through the steps covered by the ISLR text for your chosen method, SVM or CART, explaining in your own words what you are doing. Put your name into the title of any graphs you show.
Finally, run the program on your n=300 stock risk data set and compare the performance to that of your n=300 stock return data set. Include use of the chi-square test. Discuss the differences, the reasons that these would happen, and the lessons learned about the nature of the stock market.
third,
Select one of the tuning parameters or decision criteria that lie beneath the surface of your chosen methodology, CART or CART. Engage with it by researching beyond the ISLR text. Then experiment with it. Experiment with your data and with other data sets. Try decreasing or increasing n. Look at other sources for help, documenting the sources.
Forth,
Create classification space plots for both of your n=300 data sets, using your chosen methodology, SVM or CART. Be sure to explain how you went about this. Create the plot using the same techniques that we did in our plots for other methods.
] Prepare a comparative study of knn, naive Bayes, logistic regression, and your selected method. Make this comparison on your two n=300 data sets, splitting the data randomly in half to get the training and testing sets.
Explain what you are doing as you go along, explain what you understand about what distinguishes the methods, discuss reasons why the results vary, and why there might be systematic differences in performance between return data and risk data. Show classification space plots for knn, naïve Bayes, and logistic regression. At the end, show a single table in which you summarize the overall correct forecast rate for the stock returns for the four methods; then another table summarizing the performance on the stock risk data
Using the knowledge of the computational language in python it is possible to write a code that Create classification space plots for both of your n=300 data sets, using your chosen methodology, SVM or CART.
Writting the code:def randomize(X, Y):
permutation = np.random.permutation(Y.shape[0])
X2 = X[permutation,:]
Y2 = Y[permutation]
return X2, Y2
X2, y2 = randomize(X, y)
def draw_learning_curves(X, y, estimator, num_trainings):
train_sizes, train_scores, test_scores = learning_curve(estimator, X2, y2, cv=None, n_jobs=1, train_sizes=np.linspace(0.1, 1.0, num_trainings))
train_scores_mean = np.mean(train_scores, axis=1)
train_scores_std = np.std(train_scores, axis=1)
test_scores_mean = np.mean(test_scores, axis=1)
test_scores_std = np.std(test_scores, axis=1)
plt.grid()
plt.title("Learning Curves")
plt.xlabel("Training examples")
plt.ylabel("Score")
plt.plot(train_scores_mean, 'o-', color="g",
label="Training score")
plt.plot(test_scores_mean, 'o-', color="y",
label="Cross-validation score")
plt.legend(loc="best")
plt.show()
See more about python at brainly.com/question/18502436
#SPJ1
Can someone help me out with a code. Code's in python write a function that returns the longest common prefix of two strings. For example, the longest
common prefix of distance and disinfection is dis. The header of the method is:
def prefix(s1, s2)
If the two strings have no common prefix, the method returns an empty string.
Write a main function that prompts the user to enter two strings and displays their common
prefix.
here's what I have currently but its not working.
def longestCommonPrefix(self, arr):
arr.sort(reverse = False)
print(arr)
n= len(arr)
str1 = arr[0]
str2 = arr[n-1]
n1 = len(str1)
n2 = len(str2)
result = ""
j = 0
i = 0
while(i <= n1 - 1 and j <= n2 - 1):
if (str1[i] != str2[j]):
break
result += (str1[i])
i += 1
j += 1
return (result)
Just 10 lines of code.
from functools import reduce
list = []
def compare():
calc = [reduce(lambda a, b: a if a == b else None, x) for x in zip(*list)] + [None]
return list[0][:calc.index(None)]
list.append(input("Enter the first string: "))
list.append(input("Enter the second string: "))
print(compare())
Many documents use a specific format for a person's name. Write a program that reads a person's name in the following format:
firstName middleName lastName (in one line)
and outputs the person's name in the following format:
lastName, firstInitial.middleInitial.
Ex: If the input is:
Using the knowledge in computational language in JAVA it is possible to write the code that write a program whose input is: firstName middleName lastName, and whose output is: lastName, firstName middleInitial.
Writting the code:import java.util.Scanner;
import java.lang.*;
public class LabProgram{
public static void main(String[] args) {
String name;
String lastName="";
String firstName="";
char firstInitial=' ',middleInitial=' ';
int counter = 0;
Scanner input = new Scanner(System.in);
name = input.nextLine(); //read full name with spaces
int i;
for(i = name.length()-1;i>=0;i--){
if(name.charAt(i)==' '){
lastName = name.substring(i+1,name.length()); // find last name
break;
}
}
for(i = 0;i<name.length()-1;i++){
if(name.charAt(i)==' '){
firstName = name.substring(0, i); // find firstName
break;
}
}
for(i = 0 ;i<name.length();i++){
if(name.charAt(i)==' '){
counter++; //count entered names(first,middle,last or first last only)
}
}
if(counter == 2){
for(i = 0 ;i<name.length();i++){
if(Character.toUpperCase(name.charAt(i)) == ' '){
middleInitial = Character.toUpperCase(name.charAt(i+1));//find the middle name initial character
break;
}
}
}
firstInitial = Character.toUpperCase(name.charAt(0)); //the first name initial character
if(counter == 2){
System.out.print(lastName+", "+firstName+" "+middleInitial+".");
}else{
System.out.print(lastName+", "+firstName);
}
}
}
See more about JAVA at brainly.com/question/12975450
#SPJ1
Write a program that asks the user for the name of a file. The program should display only the first five lines of the file's contenents if the file contains less than five lines, it should display the files's entire contenents
To write a program that asks the user for the name of a file, we will use the readline() method of our file object, and using a for loop, we'll repeat the readline() five times.
The structure of the program and it's programming:
We will use readline() method of our file object( here it has been taken as file_obj).
Using a for loop we'll repeat the readline() five times.
If the file has less than five lines and we try to keep reading after the read position has gotten to the last character in the file, the readline() function will just return the empty string " ".
So nothing will be displayed. We need set end=' ' in our print() function to ensure that we don't get a bunch of extra new lines.
Don't forget to close the file after you're done with it.
# Getting file name from the user filename = input('Enter the filename :')
# Opening the file in read mode file_obj = open(filename, 'r');
# Reading and displaying the file's first five lines for i in range(5): print(file_obj.readline(), end = '')
# Reads a single line at a time and displays it # Closing the file file_obj.close()
To know more about programming, visit: https://brainly.com/question/16936315
#SPJ1
highlight the function of the system sofyware in the computer system
System software manages the computer itself. It runs in the background, maintaining the basic functions of the computer so that users can run higher-level application software to perform specific tasks. Essentially, system software serves as a foundation for application software to run on.
What is a System software?
System software is the most important type of software required to manage the computer system's resources.
Internally, system software runs and interacts with application software and hardware. Furthermore, it serves as a link between a hardware device and the end user.
System software runs in the background and manages all aspects of the computer's operation. Low-Level Software is so named because it runs at the most basic level of a computer and is usually written in a low-level language. When we install the operating system on one device, it is automatically installed on another.
System software contributes to the creation of the user interface and allows the operating system to communicate with the computer hardware in a computer system.
To learn more about System software, visit: https://brainly.com/question/13738259
#SPJ9
this is my data cancer['level_description'].head(10).plot.pie()
and the error says TypeError: '<' not supported between instances of 'str' and 'int'
Only items with the same numerical data type can be compared using mathematical operators. If you try to compare a string and an integer, you will get an error saying "not supported between instances of'str' and 'int'."
What is typeerror: '>' not supported between'str' and 'int' instances?Comparison operators cannot be used to compare strings and integers. This is due to the fact that strings and integers are different data types.Python is a programming language that is statically typed. If you need to compare a value of one type to another, you must manually change the type of the data.Let's say you want to convert a string to an integer. Before the comparison can take place, you must manually convert the string to an integer.When you try to perform a "greater than" comparison on a string and an integer, you get the "typeerror: '>' not supported between instances of'str' and 'int'" error.This error can occur with any comparison operation, including less than (), equal to (=), and greater than or equal to (>=).The string returned by the input() method. This means that our code attempts to compare a string to an integer (the value in "numerical grade").We solve this issue by converting "numerical grade" to an integer before performing any code comparisons:To learn more about 'str' and 'int' refer to:https://brainly.com/question/26352522
#SPJ1