Question

In: Computer Science

Q4. Please write a function Calculate_integer_division(). Your function should accept two parameters num1 and num2 and...

Q4. Please write a function Calculate_integer_division(). Your function should accept two parameters num1 and num2 and return the result of integer division of num1 by num2. So if num1 is 9 and num2 is 2, the function should return 4. Call your function and print out the result.

Q5. Please print out the following with the help of a range() function: 200, 400, 600, 800

Q6. Please print 'Go.' if the traffic light is green, 'Wait.' if it's yellow and 'Stop!' if it's red. If it's none of the above, print 'Unknown color.'

Q7. Please print 'This is correct' if a real number is between 10.0 and 20.0 (including both 10 and 20).

Q8. Please print 'This is not correct' if a real number falls outside of the range described in the previous question.

Q9. Let's say that you decide to stop by the local cafe and purchase a cup of coffee. Please write a program that asks a user (you) for the price of this beverage. This program should then compute NY sales tax - 8.875% and display the amount of purchase, tax and total. Please use the format function to display cents.

Q10.Please write a program to produce the following output, please use as few print statements as possible:
A1
A2
A3
A4
B1
B2
B3
B4
C1
C2
C3
C4

Q11. Please print the following string:

Cat said 'meou'.

Q12. Assume that c is a string variable. Write an expression that checks if c is a space, a tab or a newline character.

Solutions

Expert Solution

4 ans:

5 ans:

6 ans:

7 ans:

8 ans:

9 ans:

10 ans:

11 ans:

12 ans:

#if you have any doubt or more information needed comment below.i will respond as possible as soon..thanks.


Related Solutions

Write an interactive program that inputs a decimal num1 and an integer num2. If num1 is...
Write an interactive program that inputs a decimal num1 and an integer num2. If num1 is less than num2, then it displays "num 1 is less than num 2"; if they are identical, it starts over again; if . If num2 is less than num1, then it displays "num 2 is less than num 1
Write an assembly language program to calculate score = (num1 + num2) /2 i.e input two...
Write an assembly language program to calculate score = (num1 + num2) /2 i.e input two numbers num 1 and num 2 and divide it by 2 to display score.Test your program for the Pep/9 computer.
Write a function that will accept two integer matrices C and D by reference parameters. The...
Write a function that will accept two integer matrices C and D by reference parameters. The function will compute the transpose of C and store it in D. For your information, the transpose of matrix C is D, where D[j][i] = C[i][j]. [7 marks] Explain the time complexity of this function inside of the function code as a comment. [3 marks] in C++
Assembly using x86 irvine (masm) Write a complete program that will input values for num1 ,num2,...
Assembly using x86 irvine (masm) Write a complete program that will input values for num1 ,num2, and num3 and display the value of the expression ( (num1 ^ 3) * num2 + 5 * ( num2 ^ 2) ) / num3. assume that the user enters only numbers that are greater than zero and the calculation never exceed 4 bytes size. Sample run: num1 = 1 num2 = 2 num3 = 3 ((num1 ^ 3) * num2 + 5 *...
please explain how does the following C code work. a) int function1(int num1, int num2) {...
please explain how does the following C code work. a) int function1(int num1, int num2) { int num = num1 ^ num2; int result = 0; while(num > 0) { result += (num & 1); num >>= 1; } return result; } b) int function2(unsigned int num) { return num & ~(num - 1); } c) int f1(unsigned int x) { int count = 0; while(x) { count++; x = x&(x-1); } return count; } d) double ldexp(double x, int...
Write an overloaded function of function area with 3 (float) parameters. This function should calculate and...
Write an overloaded function of function area with 3 (float) parameters. This function should calculate and print out the product of the 3 parameters.
using python 1. #Write a function called multiply_file_by_index. This function #should take two parameters, both strings....
using python 1. #Write a function called multiply_file_by_index. This function #should take two parameters, both strings. The first string is #the filename of a file to which to write (output_file), and #the second string is the filename of a file from which to read #(input_file). # #In the input file, there will be an integer on every line. #To the output file, you should write the integer from the #original file multiplied by the line number on which it #appeared....
Write a function in R named counts. This function should take as parameters a numeric vector...
Write a function in R named counts. This function should take as parameters a numeric vector x and also a number indicating a number of bins n. The function will consider the range [min(x),max(x)], and then consider a parti- tion of this interval into n non-overlapping equally sized half open intervals: I1 = [min(x),b1),I2 = [b1,b − 2),...,In = (bn−1,max(x)]. Note that since the intervals are equally sized, the value of bi is constrained. The function will then return a...
Write a function using MATLAB that will accept a structure as an argument and return two...
Write a function using MATLAB that will accept a structure as an argument and return two cell arrays containing the names of the fields of that structure and the data types of each field. Be sure to check that the input argument is a structure, and generate an error message if it is not.
Sovle with python 3.8 please. 1, Write a function called same_without_ends that has two string parameters....
Sovle with python 3.8 please. 1, Write a function called same_without_ends that has two string parameters. It should return True if those strings are equal WITHOUT considering the characters on the ends (the beginning character and the last character). It should return False otherwise. For example, "last" and "bask" would be considered equal without considering the characters on the ends. Don't worry about the case where the strings have fewer than three characters. Your function MUST be called same_without_ends. You...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT