1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
djverab [1.8K]
2 years ago
12

Write a function definition for a function which takes one parameter and returns twice that parameter

Computers and Technology
1 answer:
dezoksy [38]2 years ago
8 0

Answer:

The function in python is as follows:

def twice(num):

   return 2 * num

Explanation:

This defines the function; The function receives num as its parameter

def twice(num):

This returns twice of num

   return 2 * num

You might be interested in
The tax calculator program of the case study outputs a floating-point number that might show more than two digits of precision.
Aneli [31]

Answer:

TAX_RATE = 0.20

STANDART_DEDUCTION = 10000.0

DEPENDENT_DEDUCTION = 3000.0

gross_income = float(input("Enter the gross income: "))

number_of_dependents = int(input("Enter the number of dependents: "))

income = gross_income - STANDART_DEDUCTION - (DEPENDENT_DEDUCTION * number_of_dependents)

tax = income * TAX_RATE

print ("The income tax is $" + str(round(tax, 2)))

Explanation:

Define the <em>constants</em>

Ask user to enter the <em>gross income</em> and <em>number of dependents</em>

Calculate the <em>income</em> using formula (income = gross_income - STANDART_DEDUCTION - (DEPENDENT_DEDUCTION * number_of_dependents))

Calculate the <em>tax</em>

Print the <em>tax</em>

<em />

round(number, number of digits) -> This is the general usage of the <em>round</em> function in Python.

Since we need <u>two digits of precision</u>, we need to modify the program as str(<u>round(incomeTax, 2</u>)).

4 0
3 years ago
What permissions are needed in order to use a work online that is in the public domain?
Maurinko [17]
<h2 /><h2>⇒Written  \: permission  \: from \\  the  \: creator</h2>

The term “public domain” refers to creative materials that are not protected by intellectual property laws such as copyright, trademark, or patent laws. ... Anyone can use a public domain work without obtaining permission, but no one can ever own it.

5 0
2 years ago
Write a program that prompts the user for the lengths of the two legs of a right triangle, and which reports the length of the h
timurjin [86]

Answer: The following code is in c++

#include <iostream>

#include<math.h>

using namespace std;

int main()

{

   float a,b,c;

   cout<<"Enter height and base of triangle\n";

   cin>>a>>b;  //reading two sides from user

   c=sqrt(pow(a,2)+pow(b,2));  //calculating hypotenuse

   cout<<"Length of hypotenuse is "<<c;  //printing third side of triangle

   return 0;

}

OUTPUT :

Enter height and base of triangle                                                                                            

3                                                                                                                              

4                                                                                                                              

Length of hypotenuse is 5  

Explanation:

In the above code, three variables a, b and c of int type are declared. After that, it is asked from user to enter the value of a and b. The user puts the value and then c is calculated with the help of Pythagoras theorem formulae which squares the values of two sides and then adds them to calculate hypotenuse of a right angled triangle and finally c is printed to console.

3 0
3 years ago
What symbol do we use to denote a character?
pychu [463]

Answer:

'Single Character'

Explanation:

A Character, commonly abbreviated as "char", is a computer symbol, letter, or number. A keyboard is an input device that inputs a character when a key is pressed.

5 0
2 years ago
Design a class named Employee. The class should keep the following information in member variables:
Paha777 [63]

Answer:

Here is the code.

Explanation:

#include <iostream>

#include <cstdlib>

#include <string>

#include <iomanip>

using namespace std;

class Employee

{

private:

string employeeName;

int employeeNumber;

int hireDate;

public:

void setemployeeName(string employeeName);

void setemployeeNumber(int);

void sethireDate(int);

string getemployeeName() const;

int getemployeeNumber() const;

int gethireDate() const;

Employee();

};

void Employee::setemployeeName(string employeeName)

{

employeeName = employeeName;

}

void Employee::setemployeeNumber(int b)

{

employeeNumber = b;

}

void Employee::sethireDate(int d)

{

hireDate = d;

}

string Employee::getemployeeName() const

{

return employeeName;

}

int Employee::getemployeeNumber() const

{

return employeeNumber;

}

int Employee::gethireDate() const

{

return hireDate;

}

Employee::Employee()

{

cout << "Please answer some questions about your employees, ";

}

class ProductionWorker :public Employee

{

private:

int Shift;

double hourlyPay;

public:

void setShift(int);

void sethourlyPay(double);

int getShift() const;

double gethourlyPay() const;

ProductionWorker();

};

void ProductionWorker::setShift(int s)

{

Shift = s;

}

void ProductionWorker::sethourlyPay(double p)

{

hourlyPay = p;

}

int ProductionWorker::getShift() const

{

return Shift;

}

double ProductionWorker::gethourlyPay() const

{

return hourlyPay;

}

ProductionWorker::ProductionWorker()

{

cout << "Your responses will be displayed after all data has been received. "<<endl;

}

int main()

{

ProductionWorker info;

string name;

int num;

int date;

int shift;

double pay;

cout << "Please enter employee name: ";

cin >> name;

cout << "Please enter employee number: ";

cin >> num;

cout << "Please enter employee hire date using the format \n";

cout << "2 digit month, 2 digit day, 4 digit year as one number: \n";

cout << "(Example August 12 1981 = 08121981)";

cin >> date;

cout << "Which shift does the employee work: \n";

cout << "Enter 1, 2, or 3";

cin >> shift;

cout << "Please enter the employee's rate of pay: ";

cin >> pay;

info.setemployeeName(name);

info.setemployeeNumber(num);

info.sethireDate(date);

info.setShift(shift);

info.sethourlyPay(pay);

cout << "The data you entered for this employee is as follows: \n";

cout << "Name: " << info.getemployeeName() << endl;

cout << "Number: " << info.getemployeeNumber() << endl;

cout << "Hire Date: " << info.gethireDate() << endl;

cout << "Shift: " << info.getShift() << endl;

cout << setprecision(2) << fixed;

cout << "Pay Rate: " << info.gethourlyPay() << endl;

system("pause");

return 0;

}

7 0
2 years ago
Other questions:
  • Sam wanted to open a file that he saved yesterday. Which component inside the computer stores this file? the hard drive the fax
    13·2 answers
  • It is used to replace numeric number of a website​
    7·1 answer
  • A tablet computer transmits a file over a wi-fi link to an access point.
    13·1 answer
  • The architecture that the large paper company Mohawk adopted enables the company to scale technology services up and down instan
    14·1 answer
  • Released in 1976, the Apple I was Apple Computer's first product.<br><br> O True<br> O False
    6·1 answer
  • How is the architecture converted into software code? Elaborate the steps its passes through with help of examples / Diagram.
    15·1 answer
  • Define the terms network, LAN, WAN, and Internet.
    11·1 answer
  • which two functions are performed at the llc sublayer of the osi data link layer to facilitate ethernet communication? (choose t
    13·1 answer
  • Explain any two types of board band connection​
    11·1 answer
  • Writing queries in sql to compile data from a database is related to the physical level of databases true or false?.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!