Write a function timestable(n), which prints a multiplication table of size n. For example, timestable(5) would print: 1 2 3 4 5 2 3 4 5 4 6 8 10 6 9 12 15 8 12 16 20 10 15 20 25 Use the function in a program where you ask the user for n and you print the corresponding table.
Q: Write a program whose input is two integers and whose output is the two integers swapped. Ex: If the…
A: def swap_values(user_val1, user_val2): temp = user_val1 user_val1 = user_val2 user_val2…
Q: For this program, I would like you to create a function which returns a character value based on a…
A: For this program, I would like you to create a function which returns a character value based on a…
Q: Write a function hello(name), which prints "Hello" followed by the value of name. For example,…
A: Given: Write a function hello(name), which prints "Hello" followed by the value of name. For…
Q: program c Write a function that will calculate the sum of all the numbers multiple of 3 from 1 to…
A: Algorithm: Start Implement computeTotal() method which takes a number num as argument Inside the…
Q: Write a function “func(n)” that returns the number of values generated until all values are obtained…
A: To write a function that returns the number of values generated using Harmonic.
Q: Write a function that makes the first number as large as possible by swapping out its digits for…
A: function maxPossible(n1, n2) { arr1 = n1.toString().split('') arr2 =…
Q: Given the following function: def nPrint (message, n): while n > 0: print (message, end='') n -= 1…
A: Here in this question nprint (a, 4 ) is called..so until while condition is true..it will go inside…
Q: Write a Python program that inputs five positive integer numbers, finds their maximum and sort them…
A: Required:
Q: Write a function in python squared_diff that takes two number inputs and returns the squared…
A: The program in python is: def squared_diff(a,b): #function definition return…
Q: The code is already given above. Problem: Using PYTHON, create a code that asks you to enter three…
A: Get a, b, and x from the user. Declare an empty list 'res'. Call the function: mult(a, b, x) Inside…
Q: For a given number in binary, having combinations of 1s and 0s only, write a program that outputs…
A: NOTE: Since the programming language is not mentioned. Therefore answering questions in Python…
Q: Write a program whose input is a character and a string, and whose output indicates the number of…
A: The C++ program to count the appearance of a character present in a string by using a user-defined…
Q: Write a function print_shampoo_instructions() with parameter num_cycles. If num_cycles is less than…
A: Solution :
Q: Write a python function that gets a string, as presented below, as a parameter and returns the user…
A: In this question we have to write a python program in which we have to find the email id from the…
Q: This code is for Python
A: Note: The below program has been complied and executed in "repl.it" online complierThe screenshot…
Q: In Pyhton IDLE Write a function that takes the first 10 even numbers and adds them to the first 10…
A: => Find first 10 even numbers. => Find the first 10 odd numbers. => Write a function to add…
Q: Write a function double power(double x, int n) that will compute xn
A: This question comes from Programming Language which is a paper of Computer Science. Let's discuss it…
Q: The code is already given above. Problem: Using PYTHON, create a code that asks you to enter three…
A: Given: Given a python coding problem.
Q: Write a program that does temperature converter :\n", "- The user will enter if he wants the result…
A: As per the requirement program developed. Note: In the question programming language is not…
Q: Write a program whose inputs are three integers, and whose outputs are the largest of the three…
A: Hey there, I am writing the required solution based on the above given question. Please do find the…
Q: fun_x(13,2), the return value of the * function would be 1 float fun_x (int t, int x=10) 2 3 return…
A: 1. f(13,2) return 13/2 = 6.5 But both t and x are integers. So, the result will be 6. Correct…
Q: Write a function print_triangular_numbers(n) that prints out the first n triangular numbers. A call…
A: here in this question we have asked to write a function print_triangular_numbers(n) which print out…
Q: Write a program whose input is two integers and whose output is the two integers swapped. Ex: If…
A: Code : To swap two values using a temporary variable def swap_values(user_val1, user_val2):…
Q: Write a c program that uses six calls to the function rand () to generate six random integer…
A: #include <stdio.h>#include <stdlib.h>#include <time.h>int main(){ int num1,…
Q: In Python Write a function shampoo_instructions() with parameter num_cycles. If num_cycles is less…
A: def shampoo_instructions(user_cycles): if user_cycles<1: print('Too few.') elif…
Q: Write a program in Python with a function decimalToBinary(n) that converts a positive decimal…
A: To convert a number to its binary we store the reminder part after dividing the number by 2 and…
Q: A user enters a list of positive integers until it enters -1 which marks the end of input and wants…
A: The program is written in C Programming. Check the program screenshot for the correct indentation.…
Q: Write a function input_names that takes as an argument a number player (supposedly valid)…
A: CODE - name=[] #take input list that will be used to print…
Q: Write a Python program that inputs five positive integer numbers, finds their maximum and sort them…
A: def getValue(): # getValue function print("Please input 5…
Q: Write a program that reads a list of names and total points for students until -1 is entered. After…
A: Given data is shown below: Write a program that reads a list of names and total points for students…
Q: Consider the following code def f(a, b): if a > 3: return a, b-a return a+b, b you can call the…
A: Provided the solution for above given code where Correct answer of the question is Option d.…
Q: Write a function that finds digital root of given number. Digital root is the number which is equal…
A: def digitalRoot(num): # function to calculate digital root if num < 10:…
Q: write a function sequence in Python that accepts an number ( int ) and that prints a sequence of…
A: Code def sequence(n): while(n>1): print(n) if(n%2==0):#Check Even Number…
Q: Write a function to calculate the sum of all numbers from 1 to a given number x y = 1 +2 + 3 + ... +…
A: Python Code for above : def sumOfDigitsFrom1ToN(n): return n * (n+1) / 2 # call…
Q: Write a program whose input is two integers and whose output is the two integers swapped.
A: The header stdio.h represents Standard Input Output. The data identified with input/yield…
Q: receives an integer number and prints out a random number between one (1) and that number.
A: As programming language is not mentioned, so we are providing answer in python language.
Q: Write a C++ program using while or do while loop that will ask the user for number of terms N and…
A: Given: Write a C++ program using while or do while loop that will ask the user for number of terms N…
Q: Write a program that finds the grade corresponding to the average mark. The program uses a function…
A: Write a program that finds the grade corresponding to the average marks. Answer: #include…
Q: write a program that asks the users to input three numbers (x,y,z) and calculate the sum,…
A: Dear Student, as no language was mentioned I have done the program in c++
Q: Write a program in Python with a function biggestOdd(), which reads in numbers from the user until…
A: Below is the code in python and sample output:
Q: Write a computer program using C++ to compute the expression (n*(2^m!)), Where n, m are positive…
A: Functions in C++ are a block of statements which perform a specific task. Function has three parts:…
Q: Write a Python program that asks the user for an integer n and then prints out all its prime…
A: Solution: isPrime:- isprime() function is a SymPy module built-in function which can be used to…
Q: Write a program to help kids learn math! Your program should: Generate two numbers using…
A: Java Code as no coding language is mentioned: import java.util.Scanner; public class Main {…
Q: Write a function that receives a positive integer n as a parameter, then it must calculate the sum…
A: There is no specific language mentioned used c++ algorithm step 1: start step 2: create a function…
Q: Consider this very simple function: def cube(x): answer = x*X*X return answer a) Here is a fragment…
A: Lets analyse the given code: def cube(x): #takes variable x as input argument answer =…
Q: Write a C program that does the Asks the user to input an integer number (n). Prints the value of n…
A: Input number. Function for the call by reference. The input value incremented by 5. Print…
Q: Write a Python function that gets the abbreviation of a currency and the queried day of the year as…
A: We can use dictionaries with country names to salve this problem.We need to store all currencies in…
Q: Write a function hello(firstname, lastname), which, for example, if called with hello('James,…
A: Hi. Since you have not mentioned any programming language, I will attempt this question using…
Q: Write a program in python with a function hello(firstname, lastname), which, for example, if called…
A: According to the provided information: We need to write a program in python with a function…
Q: نقطتان )2( If the function is called, such as fun_x(13,2), the return value of the * function would…
A: Introduction: A default argument refers to the value that is assigned while declaring the function.…
Write a function timestable(n), which prints a multiplication table of size n. For example,
timestable(5) would print:
1 2 3 4 5
2 3 4 5
4 6 8 10
6 9 12 15
8 12 16 20
10 15 20 25
Use the function in a program where you ask the user for n and you print the corresponding table.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 4 images
- (Program) Write a program that tests the effectiveness of the rand() library function. Start by initializing 10 counters, such as zerocount, onecount, twocount, and so forth, to 0. Then generate a large number of pseudorandom integers between 0 and 9. Each time 0 occurs, increment zerocount; when 1 occurs, increment onecount; and so on. Finally, display the number of 0s, 1s, 2s, and so on that occurred and the percentage of time they occurred.(Numerical) Write a program that tests the effectiveness of the rand() library function. Start by initializing 10 counters to 0, and then generate a large number of pseudorandom integers between 0 and 9. Each time a 0 occurs, increment the variable you have designated as the zero counter; when a 1 occurs, increment the counter variable that’s keeping count of the 1s that occur; and so on. Finally, display the number of 0s, 1s, 2s, and so on that occurred and the percentage of the time they occurred.Write a program in python with a function repeatPhrase(phrase, n), which prints the given phrase n times, alternating between lowercase and uppercase. For example, repeat('The sky is yellow', 5) would print: the sky is yellow THE SKY IS YELLOW the sky is yellow THE SKY IS YELLOW the sky is yellow Use the function in a program where you ask the user for the phrase and the value of n
- Write a function sum_of_digits(a,b), that takes two arguments a and b, computes a to the power of b, then recursively finds the sum of digits until there is only one digit left. You must PRINT all steps of the process as shown in the below example. sum_of_digits(5,3) will PRINT on the screen the following: 5ˆ3 = 125 = 1 + 2 + 5 = 8 sum_of_digits(2,8) will PRINT on the screen the following: 2ˆ8 = 256 = 2 + 5 + 6 = 13 = 1 + 3 = 4Write a function that keeps computing the sum of the digits of x^n, until there is only one digit left. For example, sumOfDigits(2,5) returns 5, because 2 ^ 5 = 32 = 3 + 2 = 5 Another example, sumOfDigits(2,8) returns 4, because 2 ^ 8 = 128 = 1 + 2 + 8 = 13 = 1 + 3 = 4C++ Write a program that uses a recursive function to convert a number in decimal to base 8 or base 16. Your program should prompt the user for an integer and then for either 8 for base 8 conversion or 16 for base 16 conversion and output the conversion to the console.
- In python, write a function named series that takes an input N and returns the sum of series 1+3+5+7+9+.....+N. Include N if N is an odd number.Write a function to check if a given input number is a jumping number. A number is called jumpingnumberif all adjacent digits in it differ by 1. All single digits are considered as jumping numbers. Some examplesof jumping numbers are 0, 5, 10, 12, 78, 567, 101.Write a function in C programming language that gets two ints x and y, and returns the sum of all ints between x and y, including them. int sum_interval(int x, int y); For example: - sum_interval(1, 4)returns 1+2+3+4=10. - sum_interval(10, 3)returns 3+4+5+6+7+8+9+10=52. - sum_interval(2, -1)returns (-1)+0+1+2=2. - sum_interval(-1, -1)returns -1. Note that we may have x>=y or x<=y. You may assume that the sum will be within the range of int.
- Write your own definition for the function absfun( ) which receives real number x as an argument and returns its absolute value (i.e. abs(x)=|x|). Use this function in a program that reads numbers from the keyboard and prints their absolute values. [Don’t use math library] Sample Run Enter x :-3 Output: abs(-3) = 3.00 in c languageWrite a recursive function to convert a given string into the number it represents. That is input will be a numeric string that contains only numbers, you need to convert the string into corresponding integer and return the answer. Input format : Numeric string S (string, Eg. "1234") Output format : Corresponding integer N (int, Eg. 1234) Constraints : 0 <= |S| <= 9 where |S| represents length of string S. Sample Input 1 : 00001231 Sample Output 1 : 1231 Sample Input 2 : 12567 Sample Output 2 : 12567 Solution:////////////////.497 Bytes Write a recursive function that returns the sum of the digits of a given integer.Input format :Integer NOutput format :Sum of digits of NConstraints :0 <= N <= 10^9Sample Input 1 :12345Sample Output 1 :15Sample Input 2 :9Sample Output 2 :9 Solution:///////////// public class solution { public static int sumOfDigits(int input){ int sum; if(input<10){ return input; } sum = (input % 10) + sumOfDigits(input / 10); return sum; }}. .