4.1 Using a loop structure, write function myPow(double x, int y) which calculates x. Write a python program that uses myPow() to calculate the following: z - x* + 2x3 + 6x – 2 ++ where x is entered by the user Sample output: Enter x: 2 2- 42.875 4.2 Modify your program such that the myPow(double x, int y) function can handle the case when y is negative. Test your program using the following equation: Tip: x" 1/x k - x-3 + 2x-2
Q: consider the code: import numpy speed = [100,86,88,88,111,86,103,87,94,78,77,85,99] x =…
A: Given python code And array of elements declared as speed import numpy…
Q: In Python IDLE, how would I write a function loop that will take each item in (set a) [1,2,3] and…
A:
Q: 5. Consider the following code segment. 23 х MOD y Which of the following initial values of the…
A: The MOD in the above-given code segment is basically a 'modulus' or 'modulo' which is the remainder…
Q: Write a program integrate.c that calculates the definite integral of the function f(x)=x2 from x=a…
A: Required: Write a program integrate.c that calculates the definite integral of the function…
Q: dd a function called reversed_ascii_caps() to this program that takes a list of characters as its…
A: We need to define the function reversed_ascii_caps() that receive the list and receive the ASCII…
Q: You are given the following information. A function with prototype int mystery(int a, int b, int c,…
A: Here, I have to write a C code for the mystery function.
Q: 22 44 peat the table for the following values of x: 526 b. 847 a. c. 914 d. 752 e. 439 a. Write a…
A: Note : Answering the first question i.e. (a) as per the guidelines. Input : Two odd integer…
Q: that of Figure 7.4 (Page 354). After entry into block A in function f. After entry into block B in…
A:
Q: 3. (25%) Convert the following function in Python code into MIPS code. Note that 2 integers a and b…
A: We have to convert the following python function in MIPS.
Q: 8 Write a python program that will produce Bowditch or Lissajous figures (x(t) vs y(t)) o (x(t) =…
A: Code: from numpy import sin,cos,pi,linspacefrom pylab import plot,show,subplotimport…
Q: int i, j, k; int suma 0; %3D for (j = 1; j = j; -i) suma += i + j;
A: Given code, int i,j,k int sum=0; for(j=1;j<=k;++j) for(i=k;i>=j;--i) sum+=i+j; We…
Q: (python) 10. Create a function based on the following information: Your mission is to encrypt a…
A: We have to create a function based on the following using python programming.
Q: this c++ coding. calculate the total cost and show us step by step the calculation of the total cost…
A: The above C++ program is converted to assembly program using MIPS. coding:- $LC0: .ascii…
Q: Question 1 What is the outcome of the following code segment: x = [[1, 2]. [5, 6]. [8, 9]] x = [[a,…
A: Given:
Q: 2.1. Background In C++, fundamental type int is used to store signed integers. If no length…
A: It is defined as a direct descendant of C programming language with additional features such as type…
Q: uppose you are given a function in module foo named loop_string_reverse to reverse a string using…
A: Ans:) In this program we simply need to iterate over each element of list and reverse the element…
Q: 2. The Lucas series is series based on adding two previous terms defined as follows L₁ = ifn=0 ifn=1…
A: Program: #function definition def L(n): #if n is 0 return 2 if n==0: return 2 #if n is 1 return 1…
Q: Consider the following code fragment. After execution of the program fragment is finished, what is…
A: Explanation: The question is asked the value of x after the execution of code fragment. The last…
Q: You are given the following information. A function with prototype int mystery(int a, int b, int c,…
A: C Source Code: int mystery(int a, int b, int c, int d)
Q: Consider the following Python code: def multiply_numbers(x, y): z = x * y return z w =…
A: Function returns the value z
Q: Which of the following code fragment is equivalent (that is, behaves exactly in the same way) as the…
A: The answer is option b. b.if x > 10 and y < 5:print("A")else:print("B")
Q: Write a program integrate.c that calculates the definite integral of the function f(x)=x2 from x=a…
A: 1. create a main function.2. ask user to enter value for n a, and b;3. call the function…
Q: Given the following: #includ int a[] ={4, 6}, i = 0, y =3, z =1; void f(int x){ int z = 2; g (); X =…
A: Static Scoping: It is also known as lexical scoping. In this, the variable refers to its top level…
Q: 3. Write a program that prints the uppercase alphabet in reverse order, (ie, prints ZYXW...CBA) by a…
A: The answer is given below:-
Q: Exercise 4 What is the output of the following Python script? Draw the Call-Return path of the steps…
A: Answer : output of the given python script will be : [2] As its a recursive function, it will…
Q: Write a program integrate.c that calculates the definite integral of the function f(x)=x^2 from…
A: Required: Write a program integrate.c that calculates the definite integral of the function…
Q: a program integrate.c that calculates the definite integral of the function f(x)=x^2 from x=a to…
A: It is defined as the declaration of a function that specifies function's name, parameters and return…
Q: Consider the following code chunk: import random x=0 while(x < 4): x = random.choice([1, 2, 3])…
A: Python is an interpreted and object oriented programming language. "random" is a module in python…
Q: Check all correct representations of the following function. F(x.y,z) = x'y'z + xy'z' + xy'z + xyz'…
A:
Q: Question 5 Not yet answered P Flag question In the initialization code below, both function foo()…
A: i give this answer in next step,
Q: 1. Write a C/C++ program that will print the following table, shown below. For each function f(n)…
A:
Q: What would the output if dynamic scoping is used. Consider that execution of the code starts from…
A: There are two types of scoping used while coding: Dynamic and Static Difference between Dynamic…
Q: Write a program integrate.c that calculates the definite integral of the function f(x)=x^2 from…
A: 1.) firstly we will create the main function and after that, we need to ask the user to enter values…
Q: consider this data sequence: "3 11 5 5 5 2 4 6 6 7 3 -8". Any value that is the same as the…
A: code : - li = [3, 11, 5 ,5, 5 ,2, 4, 6, 6, 7, 3, -8] pre = None count = 0 # loop over each element…
Q: Write a program to compute Z value from following series by using subroutine. (X-4)6 Z = 7! (X-6)8…
A: Sample Response: //C++ program to compute sum of series (X-4)^6/7! + (X-6)^8/9! + (X-8)^10/11! +…
Q: Write a program integrate.c that calculates the definite integral of the function f(x)=x2 from x=a…
A: //c code given in step2
Q: Suppose that the following code is run on a machine that has a maximum integer value of 32,767. int…
A: - We hello machine with the maximum integer value of 32767. We have performing addition operation on…
Q: Q.5/ Show the output of the following statements of FORTRAN 90 program (Draw and put numbers inside…
A: As per our guidelines we are supposed to answer only 1st three parts. Kindly repost the remaining…
Q: Write a python program whose input is two integers and whose output is the two integers swapped.…
A: Here is the program to swap the 2 interger:
Q: Instruction: A mathematician named Ulam proposed generating a sequence of numbers from any positive…
A: Even number is found for when it is divided by 2 , and we get remainder 0 2) 8 (4…
Q: 6.a) Write a program to load the R5 with 16-bit hex number 79AC. Assume the 16- bit number comes…
A: Note: As per guidelines we are supposed to answer only one question at a time please repost the…
Q: t the program intends to do ! Program 4 .begin .org 2048 main: ld [a], %r1 ld [b], %r2 ld [c], %r3…
A: To speed up the processor operations, the processor includes some internal memory storage locations,…
Q: The ceil(x) function is applicable to both int and double/floating point data type. (True or False)…
A: ceil() method rounds the particular double/floating value and returns the smallest integer which is…
Q: Implement the following in C++: 1) Differentiate a given function with respect to x. The input will…
A: #include <iostream>#include <cmath>using namespace std;int main() { ifstream…
Q: Instruction: A mathematician named Ulam proposed generating a sequence of numbers from any positive…
A: - We have to code and make flowchart for the Ulam pattern.
Q: Figure 1(a): SOURCE CODE 1. int T (int x, int y) 2. { 3. int dif = 0; 4. if (odd(x)) 5. x = x/2; 6.…
A: A block of code in programming called function. It will only run when it is called. It can be called…
Q: Instruction: A mathematician named Ulam proposed generating a sequence of numbers from any positive…
A: PROGRAM EXPLANATION Import the java.util package. Create the main class. Define the main method.…
Q: 11. What are the values of the following Python expressions? 2** (3**2) (2**3) **2 2**3**2 а. 512,…
A: 11. a. 512,64,512 12. 56.23 13. 4
Q: You are given the following information. A function with prototype int mystery(int a, int b, int…
A: Computer machines are the devices which understand machine language which consist of only 0's and…
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
- C++ 13.9.2 Pass by reference Define a function ScaleGrade() that takes two parameters: points: an integer, passed by value, for the student's score. grade: a char, passed by reference, for the student's letter grade. ScaleGrade() changes grade to A if the points are greater than or equal to 88 and less than or equal to 100, and grade is not A. Otherwise, grade is not changed. The function returns true if grade has changed, and returns false otherwise. Ex: If the input is 88 B, then the output is: Grade is A after curving. Using the following code #include <iostream>using namespace std; // insert code here int main() { int studentPoints; char studentGrade; bool isChanged; cin >> studentPoints; cin >> studentGrade; isChanged = ScaleGrade(studentPoints, studentGrade); if (isChanged) { cout << "Grade is " << studentGrade << " after curving." << endl; } else { cout << "Grade " << studentGrade…5.22 In Python: Write a program whose input is two integers and whose output is the two integers swapped. Ex: If the input is: 3 8 the output is: 8 3 Your program must define and call the following function. swap_values() returns the two values in swapped order.def swap_values(user_val1, user_val2)5.21 In Python: A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate around the sun. To account for the difference in time, every 4 years, a leap year takes place. A leap year is when a year has 366 days: An extra day, February 29th. The requirements for a given year to be a leap year are: 1) The year must be divisible by 4 2) If the year is a century year (1700, 1800, etc.), the year must be evenly divisible by 400 Some example leap years are 1600, 1712, and 2016. Write a program that takes in a year and determines whether that year is a leap year. Ex: If the input is: 1712 the output is: 1712 is a leap year. Ex: If the input is: 1913 the output is: 1913 is not a leap year. Your program must define and call the following function. The function should return true if the input year is a leap year and false otherwise.def is_leap_year(user_year)
- 1(a): Implement the following C function : concatenate the lowest byte of each of two integers. The output should have 0's in the two most significant bytes , followed by the least significant byte of the first then second argument . For example , concatLowBytes (0x12345678 , 0xaabbccdd) 0x000078dd . You may use hexidecimal constants of any size. You should not use binary notation , function calls , loops or conditional statements. Examples : concatLowBytes ( 0x00000011 , 0x00000022)=0x00001122 concatLowBytes (0x12345678 , 0xaabbccdd )= 0x000078dd int concatLowBytes (int x, int y){ }4.6.1: Recursive function: Writing the base case. Add an if branch to complete double_pennies()'s base case.Sample output with inputs: 1 10Number of pennies after 10 days: 1024 Note: If the submitted code has an infinite loop, the system will stop running the code after a few seconds, and report "Program end never reached." The system doesn't print the test case that caused the reported message # Returns number of pennies if pennies are doubled num_days timesdef double_pennies(num_pennies, num_days):total_pennies = 0 ''' Your solution goes here ''' else:total_pennies = double_pennies((num_pennies * 2), (num_days - 1)) return total_pennies # Program computes pennies if you have 1 penny today,# 2 pennies after one day, 4 after two days, and so onstarting_pennies = int(input())user_days = int(input()) print('Number of pennies after', user_days, 'days: ', end="")print(double_pennies(starting_pennies, user_days))21.2 Project 1 (Checkpoint B): DNA Write the full C++ code for this Implement the following functions: /** * Reads from standard input a list of Short Tandem Repeat (STRs) * and their known counts for several individuals * * @param nameSTRs the STRs (eg. AGAT, AATG, TATC) * @param nameIndividuals the names of individuals (eg. Alice, Bob, Charlie) * @param STRcounts the count of the longest consecutive occurrences of each STR in the DNA sequence for each individual * @pre nameSTRs, nameIndividuals, and nameSTRs are empty * @post nameSTRs, nameIndividuals and STRcounts are populated with data read from stdin **/ void readData(vector<string>& nameSTRs, vector<string>& nameIndividuals, vector<vector<int>>& STRcounts) For example, consider the input: 3 AGAT AATG TATC Alice 5 2 8 Bob 3 7 4 Charlie 6 1 5 In the first line, the number of STRs followed by the names of those STRs, which will be populated into the vector nameSTRs. The remaining lines contain…
- Question 40. Consider the following code chunk: import random x=0while(x < 4): x = random.choice([1, 2, 3]) print(x) It is not a good idea to run these lines because...a) x is an invalid argument to print().b) the condition x < 4 is never violated.c) the function random.choice() does not exist. d) x is initialised with the wrong type.4) Answer the question in C++ A) What is wrong with the following code segment? enum CarType {GM, FORD, BMW}; int main() { CartType = BMW; return 0; } B) Assume that the addresses of x and y is 0x61feb8 and 0x61feb0, respectively. What will be the values of x, y, p, and q, respectively, when the following code runs successfully? int main() { int x; double y; int* p = &x; double* q = &y; *p = 3; *q = 3.14; increaseByOne(p, q); cout << x << " " << y << endl; cout << p << " " << q << endl; return 0; }void increaseByOne(int*& p1, double* q1){ (*p1)++; (*q1)++; p1++; q1++;} The four value:10.25 LAB: Quadratic formula Implement the quadratic_formula() function. The function takes 3 arguments, a, b, and c, and computes the two results of the quadratic formula: x1=−b+b2−4ac2a x2=−b−b2−4ac2a The quadratic_formula() function returns the tuple (x1, x2). Ex: When a = 1, b = -5, and c = 6, quadratic_formula() returns (3, 2). Code provided in main.py reads a single input line containing values for a, b, and c, separated by spaces. Each input is converted to a float and passed to the quadratic_formula() function. Ex: If the input is: 2 -3 -77 the output is: Solutions to 2x^2 + -3x + -77 = 0 x1 = 7 x2 = -5.50
- 35.3 Lecture 19-Apr-Q3 Suppose you are given a function in module foo named loop_string_reverse to reverse a string using loops that accepts the original string and returns the reversed string. But the numbers in the string are ignored. for eg, If the user input is he2ll8o will resolve to hello after removing the numbers 2 and 8 which will produce olleh as the reverse string output Now define a function loop_string_reverse_all that accepts a list of user entries and applies the method loop_string_reverse`` in modulefoo``` to each of them, and returns a new list of reverse strings. If function accepts the list input ['ab2ji89','6hel', 'ol5f'] then the function call returns the list ['ijba', 'leh ', 'flo'] Please answer in Python thank you13.16.1: Overload salutation printing. Complete the second PrintSalutation function to print the following given personName "Holly" and customSalutation "Welcome":Welcome, Holly End with a newline. #include <iostream>#include <string>using namespace std; void PrintSalutation(string personName) { cout << "Hello, " << personName << endl;} // Define void PrintSalutation(string personName, string customSalutation)... /* Your solution goes here */ int main() { PrintSalutation("Holly", "Welcome"); PrintSalutation("Sanjiv"); return 0;}(python) 10. Create a function based on the following information: Your mission is to encrypt a secret message (text only, without special chars like "!", "&", "?" etc.) using Caesar cipher where each letter of input text is replaced by another that stands at a fixed distance. For example ("a b c", 3) == "d e f" Input: A secret message as a string (lowercase letters only and white spaces) and number to move text Output: The same string, but encrypted Return: The same string, but encrypted