Question

In: Computer Science

Pythons code using idle Write an input function. Then use it to supply the input to...

Pythons code using idle

Write an input function. Then use it to supply the input to following additional functions:

i) Print multiplication table of the number from 1 to 12.

ii) Print the sum of all the numbers from 1 to up the number given.

iii) Print if the number supplied is odd or even.

Solutions

Expert Solution

PYTHON CODE:

#function definitions
#function for multiplication table
def multiplication_table(num):
    for i in range(1, 13):
        print(f"{num}\tx\t{i}\t=\t{num*i}")
        
#function for summation
def summation(num):
    summ=0
    for i in range(1,num+1):
        summ=summ+i
    print(f"Sum (1 to {num}): {summ}")
    
#function for even or odd
def evenOdd(num):
    if num%2==0:
        print(f"{num} is even")
    else:
        print(f"{num} is odd")
    
#function to call other three functions
def input_func():
    #taking input of number
    n=int(input("Enter the number: "))
    
    print()
    multiplication_table(n) #function call
    print()
    summation(n)  #function call
    print()
    evenOdd(n)  #function call
     
        
#main

#function call
input_func()

Related Solutions

Using Python Question 1 Write an input function. Then use it to supply the input to...
Using Python Question 1 Write an input function. Then use it to supply the input to following additional functions: i) Print multiplication table of the number from 1 to 12. ii) Print the sum of all the numbers from 1 to up the number given. iii) Print if the number supplied is odd or even. Question 2 Write function that asks for input from a user. If the user types 'end', the program exits, otherwise it just keeps going.
Please write the code in c++ Write a function with one input parameter that is a...
Please write the code in c++ Write a function with one input parameter that is a vector of strings. The function should count and return the number of strings in the vector that have either an 'x' or a 'z' character in them. For example, when the function is called, if the vector argument contains the 6 string values, "enter", "exit", "zebra", "tiger", "pizza", "zootaxy" the function should return a count of 4. ("exit", "zebra", "pizza", and "zootaxy" all have...
Write a python code to Design and implement a function with no input parameter which reads...
Write a python code to Design and implement a function with no input parameter which reads a number from input (like 123). Only non-decimal numbers are valid (floating points are not valid). The number entered by the user should not be divisible by 10 and if the user enters a number that is divisible by 10 (like 560), it is considered invalid and the application should keep asking until the user enters a valid input. Once the user enters a...
Write code in C please. #1 Write a function multiples() which will take an integer input...
Write code in C please. #1 Write a function multiples() which will take an integer input and it will print out all the multiples of this number starting from 2 but not including itself. For example, multiples(10) will print 2, 5 and multiples(100) will print 2, 4, 5, 10, 20, 25, 50 #2 Write and test a Fibonacci() function that uses a loop instead of recursion to calculate Fibonacci numbers.
create a program using IDLE where you will gather input from the user using a loop....
create a program using IDLE where you will gather input from the user using a loop. The user needs to provide you with a list of test scores for two categories (two different classrooms). Test scores must be integer values between 0 and 10. You need to process each score so that you can output the following: Number of test scores entered for classroom A. Number of test scores entered for classroom B. Average of test scores entered for classroom...
create a program using IDLE where you will gather input from the user using a loop....
create a program using IDLE where you will gather input from the user using a loop. The user needs to provide you with a list of test scores for two categories (two different classrooms). Test scores must be integer values between 0 and 10. You need to process each score so that you can output the following: Number of test scores entered for classroom A. Number of test scores entered for classroom B. Average of test scores entered for classroom...
write a matlab function for frequency analysis using DFT. the function should take as input a...
write a matlab function for frequency analysis using DFT. the function should take as input a signal, and as output the number of sinusoids and their frequencies.
Using SQL, write a table-valued function that: -- takes a space delimited string as input (Input...
Using SQL, write a table-valued function that: -- takes a space delimited string as input (Input string will be a sentance ex: "The cat is on the chair and the bear is on the chair") -- returns a table (word varchar(max), count int) (Output is a table that shows how many times each word appeared in the sentance) Where each space-delimited “word” in the string appears in the table along with the number of times it appeared in the input...
USING PYTHON, write a function that takes a list of integers as input and returns a...
USING PYTHON, write a function that takes a list of integers as input and returns a list with only the even numbers in descending order (Largest to smallest) Example: Input list: [1,6,3,8,2,5] List returned: [8, 6, 2]. DO NOT use any special or built in functions like append, reverse etc.
Question) The following simple shell program/code using gets() function to obtain input from user. Using the...
Question) The following simple shell program/code using gets() function to obtain input from user. Using the gets() function is potentially dangerous and it allows buffer to overflow. You need to do following modification in the code; (a) change the provided code so that you now use fgets() function instead of fget() to obtain input from the user, (b) make any other necessary changes in the code because of using fgets() function, and (c) fill in the code for the exectute()...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT