Write a program to check the divisibility of two numbers. Use the concept of default argument here. If the number is not divisible, check whether the first number is a prime or not, using the previously defined divisibility check function.
Q: What is the output of the code below? def mystery_func(input, num, t = 0, x = 10, y = 10) [this…
A: The output of the code is 1.
Q: Evaluate the following postfix expressions by hand (a) 5 5 * 2 2 * 4 / + (b) 10 10 * 1 - 9 / (c) 3 3…
A: a) 5 5 * 2 2 * 4 / + First calculate 5*5 = 25 Then 2*2= 4 Now 4/4= 1
Q: 1.Write all permutation for ABC. (Consider as a letter A, B,C). (PYTHON)
A: Note: Answering the first question as per the guidelines. Input : String: ABC Output : All…
Q: What does the following function do? int fun(int x, int y) if (y == 0) return 0; return (x + fun(x,…
A: Lets dry run for x=2 and y=4 1.fun(2,4) y==4 So 2+fun(2,3)---------------------->2+6(returned by…
Q: d. Write a program to convert English unit to metric as unit by using switch - case statement. The…
A: The question asks to make a program in such a way that it would display a menu where many metric…
Q: Write. program to find maximum number between three numbers?
A: Task :- Write a program to find maximum number between three numbers. Program :- #include…
Q: Write a program that checks prime numbers using a function.
A: Python code: def isPrime(n): if n == 1: return False elif n == 2: return True else:…
Q: The below program will run without any errors
A: Since value of y is entered as string and value of x will entered as integer because of int…
Q: Fill-In Blanks of the following question: Postfix 2 3 4 * 5+ - is equal to...................
A: Please refer below for your reference: The given postfix expression is : 2 ,3,4,*,5,+,-
Q: According to the assignment rule, what should be the precondition in the following program…
A: Given: x = x - 2 x = y
Q: Write a program to compare two fractional numbers by overloading relational operators (,=,==, !=)…
A: //Executable code #include<iostream>#include<cstdlib>using namespace std; class…
Q: Write a program , that finds solution (roots) of quadratic equation, allow user to input as much as…
A: Specific programming language is missing in the question. The below answer is provided in “C++” and…
Q: In the following segment of c++ when we enter a value for f we get a value for P, one of the choices…
A: EXPLANATION :- According to the given question, there is a one variable "f" which is taken as user…
Q: Write a program to compare two fractional numbers by overloading relational operators (,=,==, !=)
A: //Please follow the coding in pictures #inсlude<iоstreаm>#inсlude<сstdlib>using…
Q: d) What will be the value of func(2,5,4). int func(int x, int y, int z){ return pow(x,y)/z; }
A: Given Function: int func(int x, int y, int z){return pow(x,y)/z;} Requirement: Find the value of…
Q: n an integer n as input, print smallest number x such that x >= n and x is a palindrome. You have…
A: Lets see the solution.
Q: c# Write program that asks to enter an x numbers and sum the even numbers and odd numbers…
A: Write program that asks to enter an x numbers and sum the even numbers and odd numbers separately…
Q: Modify the code to print the last occurrences of x and print how many times it exists?
A: A linked list is a linear data structure. It is a collection of nodes. Each node is divided into two…
Q: Consider the following statement: int* p, q; This statement could lead to what type of…
A: The problem is based on the basics of pointers in programming languages.
Q: Using functions, create a program that reads three integer values, and then determines whether they…
A: Ans : Code: #include <iostream> using namespace std;void isTriangle(int a, int b, int c){…
Q: The following function is written incorrectly: int factorial (int n) { if (n == 0) return 1; return…
A: To find the result of calling a given function with large integer.
Q: what is the output of the following code and correct the mistakes if any ( this code to find the…
A:
Q: Modify the below program that the input values representing fractions are stored with denominators…
A: [Java Code ] //Import the essential package import java.util.ArrayList; import…
Q: In the following segment of c++ when we enter a value for f we get a value for P, one of the choices…
A: Objective: Here, a code segment is given with an incorrect syntax. The wrong statement should be…
Q: What will be the value of variable "c", when the following code is int c=0; for (int d = 1; d 3) {…
A: 1) Code and output with explanation: #include <iostream>using namespace std;int main(){ int…
Q: Based on the code segment below, fill in correct code line using call by reference. void func (__---…
A: code segment given is- void func(____________________){ total=x*y; }
Q: b- Write a program that allows the user to enter coordinates of circle center and radius then asks…
A: Given: Write a program that allows the user to enter coordinates of circle center and radius then…
Q: In the following segment of c++ when we enter a value for f we get a value for P, * one of the…
A: #include <iostream>#include <cmath> using namespace std; int main(){ int f,p;…
Q: Write a function int Factorial(int n) to calculate factorial of n. If n is non negative then it…
A: Here I have first of all created a function Factorial() to find the factorial of the given number.…
Q: Find out the final values of a,b and c where following expressions are executed sequentially:[4] int…
A: Here in this question we have given a code fragment.and we have asked to find the final value of a…
Q: What is the value of "a" such that the following expression "b = 35 % 6 + a * a/ 7;" assigns "b"…
A: Task : Choose the correct option for given question.
Q: Given the following program fill in the blanks resulting from the cout statements: int c1 = 3; int…
A: I have given C code to find the value of c1,c2,c3 and *p1,*p2,*p3.
Q: Write program to print all ODD numbers beturen 7 te 77 that divided by 7 without remainder?
A: Computer programming or the code is the communication between computers and users. Creating a code…
Q: Write a program that finds a number positive or negative. Using the function
A: Since no programming language is mentioned, I am using python Algorithm: Start Read a number n…
Q: Write a function that returns the average of the digits in the even places in an integer using the…
A: Here is the program in C++: #include <iostream> #include<cmath> #include<ctime>…
Q: Q2) Write a program to read a group of numbers between 1 to 100, then find the sum of the even…
A: "Since you have not mention any programming language, so we will write our program in C++ language."…
Q: Part (a) Write a python function that computes the binomial coefficient (:). The function should…
A: The value of C(n.k) can be calculated by recursively using the following formula for Binomial…
Q: Which of the following is the base case in the recursive function below?
A: Best case scenario is also called as base condition or the condition where the function doesn't…
Q: Write a program that will take user's three numbers and display them in ascending order.
A: class Demo{ public static void main(String args[]){ System.out.println("Please enter any three…
Q: Prompt the user to enter a random integer I, write a program that generates a random string…
A: Here I have taken input from the user and stored it into the variable named i. Next, I have used for…
Q: 5. Write a function harmonic that will take an integer n as a parameter and return the result of the…
A: In this question, we are asked to write a program which return a sum of harmonic function Note:…
Q: ro-pressure specific heat of dry air cp in kJ/(kg K) is given by: cp = 0.99403 + 1.671 × 10−4T +…
A: ##%Use linspace to generate 50 points between temperatures 0K and 1200KT = linspace(0,1200,50);%Cp =…
Q: 1) Run the multiple-target assignment statement below by using C++, Java and Python. Display the…
A: Using C++ :- #include <iostream> using namespace std; int main() { int a,b,c;…
Q: what is the output of the following ; ([]) code? isvector logical error O 1 O 0 O syntactical error
A: Answer is given below:
Write a
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images
- 6. Write a program which reads string and rewrite it in alphabetical order. For example, the word STRING should be written as GINRST. 7. Write a program to replace a particular word by another word in a given string. For example the “PYTHON” should be replaced by “C” in the text “It is good to program in PYTHON language”. 8. Write a program that will find the maximum number from 3 float type numbers. You have to usethe function getMax which will take 3 pointer variables and return the maximum number.Write another version of the checkeven function. This version receives 3 integer variables and returns true if all three numbers are even. Otherwise, the function returns false. Write the statements to read in three numbers and call the checkeven function. Then print YES if all three numbers were even, or print NO if they were not all even.Modify the below program that the input values representingfractions are stored with denominators that are positive integers. You cannot require the user to only enter a positive denominator value; the user should not be inconvenienced by such a restriction. For example, whilst values of 1 / -2 are acceptable inputs for a fraction, the output representation should be -1 / 2. Your solution should check the denominator input; if it is negative, swap the sign of both numerator and denominator instance variables. //Import the essential package import java.util.ArrayList; import java.util.Scanner; //Define the class Fraction class Fraction { private int n, d; public Fraction() { //Initialize the values this.n = this.d = 0; } public Fraction(int n, int d) { //Initialize the variables this.n = n; this.d = d; } //Define the getter function getNum() that returns the numerator public int getNum() {…
- A pentagonal number is defined as for and so on. So, the first few numbers are 1, 5, 12, 22, .... Write a function with the following header that returns a pentagonal number:def getPentagonalNumber(n):Write a test program that uses this function to display the first 100 pentagonal numbers with 10 numbers on each line.Write a program that calculates the Euclidean distance and the Manhattan or taxicabdistance between two two-dimensional points. Make sure you 1) use a point structureto store the points (see above), 2) use functions to calculate the two distances and3) ask the user for the point data. The Euclidean distance is calculated using thePythagorean Theorem for (points (x1,y1),and (x2, y2):euclidean = ( x1-x2)^2 + ( y1-y2)^2And the Manhattan distance is calculated as:manhattan = | x1-x2 | + | y1-y2 |The function doit(a,b,c,d) is a function that multiplies the smallest of its integers arguments by 2. If more than one arguments are equal and are the smallest, they are multiplied by 2. For example given a=5,b=3,c=7,d=9, doit (a,b,c,d) changes b to 6. Write the code of the function doit and test it.
- Write the following function to draw a regular polygon:def drawPolygon(x = 0, y = 0, radius = 50, numberOfSides = 3):The polygon is centered at (x, y) with a specified radius for the bounding circle for the polygon and the number of sides. Write a test program that displays a triangle, square, pentagon, hexagon, heptagon, and octagon, as shown in Figure 6.12a.Can not use "and" or "or" in java Language Write the function parrotTrouble.** We have a loud talking parrot. The "hour" parameter* is the current hour time in the range 0..23. We are* in trouble if the parrot is talking and the hour* is before 7 or after 20. Return true if we are* in trouble.** Some Examples:* parrotTrouble(true, 6) returns true* parrotTrouble(true, 7) returns false* parrotTrouble(false, 6) returns false** @param isTalking true if the parrot is talking.* @param hour the time of day from 0..23.* @return true if you're in trouble with your neighbors.Fix an error and show it please? And here are the information about the homework and for the error too. def kwargs_to_args_decorator(*args, **kwargs): This question is meant to test your knowledge of creating a decorator that accepts an arbitrary number of positional and keyword arguments, to decorate a function that accepts an arbitrary number of positional and keyword arguments, and alters the arguments before passing them to the decorated function. When the decorated function is invoked, this decorator should modify the arguments the decorated function receives. This decorator should filter out all positional arguments passed to the decorated function, which are found in the positional arguments passed to the decorator when the decorator was initialized. It should also filter out all keyword arguments with keys that are found in the keyword arguments given to the decorator when the decorator was initialized. After performing the modifications to the arguments, the decorator should…
- NEED HELP WITH THIS import random print(random.randint(1,6)) #prints a number between 1 and 6. #or: x = random.randint(1,6) print(x) #prints a number between 1 and 6. write a python program that simulates a game with two dice roll based on their sum and value. Your program should: Define a function try_your_luck(dice1, dice2) that takes two arguments i.e., the numbers generated by randint() function (use randint twice). The random numbers should be passed to the function as argument The player wins some money, when: a. Sum of both dice is divisible by three, player wins $5 b. Same number on both die, player wins $10 c. For all other cases, print "try again" Player loses the game, when: a. Sum is greater than 10 and odd b. Sum is 7. Display an appropriate message for each case (player wins or loses)."" Hosoya triangle (originally Fibonacci triangle) is a triangular arrangement of numbers, where if you take any number it is the sum of 2 numbers above. First line is always 1, and second line is always {1 1}. This printHosoya function takes argument n which is the height of the triangle (number of lines). For example: printHosoya( 6 ) would return: 1 1 1 2 1 2 3 2 2 3 5 3 4 3 5 8 5 6 6 5 8 The complexity is O(n^3). """ def hosoya(height, width):.Hi, I need help with the following assignment. Implement a program that reads in a year and outputs the approximate value of a Ferrari 250 GTO in that year. Use the following table that describes the estimated value of a GTO at different times since 1962. Year Value 1962-1964 $18,500 1965-1968 $6,000 1969-1971 $12,000 1972-1975 $48,000 1976-1980 $200,000 1981-1985 $650,000 1986-2012 $35,000,000 2013-2014 $52,000,000