Question

In: Computer Science

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.

Solutions

Expert Solution

def mul_table(number):
    for i in range(1,13):
        print(number,'x',i,'=',number*i)  


def sum_of_num(number):
    s=0
    for i in range(1,number+1):
        s=s+i
    print("The sum of all the numbers from 1 to ",number," is : ",s)
    
def odd_even(number):
    if number%2==0:
        print("The number ",number," is : even")
    else:
         print("The number ",number," is :odd")

        
    
    
#input
number=int(input("enter number : "))

#Print multiplication table of the number from 1 to 12.
print("-----------------------multiplication table from 1 to 12 :-----------------------")
mul_table(number)


#ii) Print the sum of all the numbers from 1 to up the number given.
print("----------------------- Print the sum of all the numbers from 1 to up the number given:-----------------------")
sum_of_num(number)

#iii) Print if the number supplied is odd or even.
print("-----------------------checking whether the the number is odd or even-----------------------")
odd_even(number)

---------------------------------------------------------------------------------------------

Question 2:

import sys
#condition is always true
while(1):
    input_user=input("Enter something,to exit enter end : ")
    if(input_user=="end"):
        #exit when user type end
        sys.exit()


------------------------------------------------------------------------------------------------------------------------


Related Solutions

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.
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.
Solve by using python function. use loop Input; Crossing Times = { 10,15,20,25} 1.Firstly person '1'...
Solve by using python function. use loop Input; Crossing Times = { 10,15,20,25} 1.Firstly person '1' and '2' cross the path with total time about 15 min(maximum of 10, 15) 2.Now the person '1' will come back with total time of '10' minutes. 3. Now, person 1 and person 3 cross the path with total of about 20 minutes .(maximum of 10,20) 4. Now the person 1 will come back in 10 mintues 5. Lastly person 1 and person 4...
Use python write a function that translates the input string into Pig Latin. The translation should...
Use python write a function that translates the input string into Pig Latin. The translation should be done word by word, where all words will be separated by only one space. You may assume that each word must have at least one vowel (a,e,i,o,u and uppercased counterparts), and there will be no punctuation or other special characters in the input string. The Pig Latin rules are as follows: For words that begin with consonants, all letters before the initial vowel...
In Python Write a function to read a Sudoku board from an input string. The input...
In Python Write a function to read a Sudoku board from an input string. The input string must be exactly 81 characters long (plus the terminating null that marks the end of the string) and contains digits and dots (the `.` character represents an unmarked position). The input contains all 9 rows packed together. For example, a Sudoku board that looks like this: ``` ..7 ... ... 6.4 ... ..3 ... .54 ..2 ... .4. ... 9.. ... ..5 385...
Use Python for this quetions: Write a python functions that use Dictionary to: 1) function name...
Use Python for this quetions: Write a python functions that use Dictionary to: 1) function name it addToDictionary(s,r) that take a string and add it to a dictionary if the string exist increment its frequenc 2) function named freq(s,r) that take a string and a record if the string not exist in the dictinary it return 0 if it exist it should return its frequancy.
In python write a function whose input is a string. This function determines the data type...
In python write a function whose input is a string. This function determines the data type of the input string. The data types can be a float, int, or string. Most pass the following assertions: assert determine_data_type('1.2') == float assert determine_data_type('4') == int assert determine_data_type('EAS503') == str
This is python: #Write a function called count_positive_evens. This function #should take as input a list...
This is python: #Write a function called count_positive_evens. This function #should take as input a list of integers, and return as #output a single integer. The number the function returns #should be the count of numbers from the list that were both #positive and even. # #For example: # # count_positive_evens([5, 7, 9, 8, -1, -2, -3]) -> 1 # count_positive_evens([2, 4, 6, 8, 10, 12, 15]) -> 6 # count_positive_evens([-2, -4, -6, -8, -10, 1]) -> 0 # #0...
Write a Python function that takes as input parameters base_cost (a float) and customer_type and prints...
Write a Python function that takes as input parameters base_cost (a float) and customer_type and prints a message with information about the total amount owed and how much the tip was. As a reminder, the tip amounts are 10%, 15% and 20% for stingy, regular, and generous customers. And the tax amount should be 7%. The total amount is calculated as the sum of two amounts: check_amount = base_cost*1.07 tip_amount = tip_percentage*check_amount To receive full credit, you must use string...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT