def cop():
    u = Util()

    coupon_number = int(
        input("enter coupon number: "))  # take input for coupon number

    u.coupon(coupon_number)
Esempio n. 2
0
def wind():
    u = Util()

    t = int(input("enter value for t: "))
    v = int(input("enter value for v: "))

    u.win(t, v)
Esempio n. 3
0
def binary():
    u = Util()

    n = int(input("enter the number to see its binary representation: "))

    u.convert_binary(n)

    print(u.convert_binary(n))
Esempio n. 4
0
def power():
    u = Util()
    n = int(input("enter number of questions: "))

    k = (2**n) - 1
    print("think of a integer between 0 to ", k)

    u.guess(0, k)
Esempio n. 5
0
def arr():
    u = Util()

    n = int(input(
        "enter number of rows: "))  # take number of rows and columns fom user
    m = int(input("enter number of columns: "))

    u.arrays(n, m)
def sorting():
    u = Util()
    try:
        stringlist = list(
            input("enter elements for list(only string): ").split(" "))
        u.userstring(stringlist)
    except ValueError:
        print("only strings")
Esempio n. 7
0
def triples():
    try:
        u = Util()
        a = [int(x) for x in input("enter list elements: ").split()]
        print(a)
        n = len(a)
        u.dist_triples(a, n)
    except ValueError:
        print("input should be separated by space")
Esempio n. 8
0
def search():
    u = Util()
    filename = "../sample.txt"

    with open(filename) as f:
        list_file = f.read().split(",")
        list_file[-1] = list_file[-1].strip()

    u.filesearching(list_file)
Esempio n. 9
0
def quad():
    u = Util()

    print("quadratic equation in form of a*x*x + b*x + c")
    a = int(input("value of a: "))
    b = int(input("value of b: "))
    c = int(input("value of c: "))

    u.qua(a, b, c)
Esempio n. 10
0
def sorting():
    u = Util()
    try:
        intlist = list(input("Enter elements separated by spaces").split(" "))
        intlist = [int(x) for x in intlist]

    except ValueError:
        print("only int")

    u.userint(intlist)
Esempio n. 11
0
def harmonic():
    u = Util()
    try:  # handle error if user input is 0
        n = int(input("enter harmonic value N: "))
        if n != 0:  # checking if N is not equal to 0
            u.harmonic_value(n)
        else:
            raise ZeroDivisionError  # number can not be divided by 0 hence raise exception to handle it

    except ZeroDivisionError:
        print('Handling run-time error: N should not be zero'
              )  # if user input is 0 then print this error
Esempio n. 12
0
def week():
    u = Util()
    day = int(input("enter day: "))
    if 0 < day < 32:  # day must be between 1 to 31
        months = int(input("enter month: "))
        if 0 < months < 13:  # month between 1 - 12
            year = input("enter year: ")
            if len(year) == 4:  # length should be 4 for year
                u.day_week(day, months, year)
            else:
                print("invalid year")
        else:
            print("invalid month")
    else:
        print("invalid day")
Esempio n. 13
0
def converting():
    u = Util()
    n = int(
        input(
            "select 1 for fahrenheit to Celsius..... and select 2 for Celsius to fahrenheit "
        ))
    if n == 1:  # choose between 1/2

        f = int(input(
            "temperature in fahrenheit: "))  # 1 for fahrenheit to Celsius
        u.f_to_c(f)  # 2 for Celsius to fahrenheit

    elif n == 2:
        c = int(input("temperature in Celsius: "))
        u.c_to_f(c)

    else:  # if user choose other than 1/2 it will show wrong choice
        print("wrong choice")
Esempio n. 14
0
* @since 5-1-2019
*
***********************************************************************************/
'''
from utilities.utility import Util
from utilities import datastructqueue
'''
store week days and total number of days in list.
this calender is implemented using stack operations
We are creating 2 stacks hence there are two objects of same class stack 
Operation works as : Push elements in one stack then pop that element and push to another stack
At the end justify the dates and pop the starting dates if the starting days are blank
The reason we have to maintain 2 stacks is stack works on LIFO so the last day will displayed at 1st
date if 2nd stack is not used.
'''
u = Util()

if __name__ == "__main__":
    month = int(input("enter month : "))
    year = int(input("enter year : "))
    day = ['S', ' M', ' T', ' W', ' Th', 'F', ' S']

    days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

    values = 1
    d = 1

    m = month
    y = year
    y0 = y - (14 - m) // 12
    x = y0 + y0 // 4 - y0 // 100 + y0 // 400
Esempio n. 15
0
def dist():
    u = Util()
    x = int(input("enter x co ordinate: "))  # take (x,y) input
    y = int(input("enter y co ordinate: "))

    u.distance(x, y)
Esempio n. 16
0
def timers():
    u = Util()
    start_value = int(input("enter 1 to start: "))  # to start stopwatch
    u.stopwatch(start_value)
Esempio n. 17
0
def primen():
    u = Util()

    num = int(input("enter number for factorization: "))

    u.prime(num)
Esempio n. 18
0
/**********************************************************************************
* Purpose: Write a program Calendar.java that takes the month and year as command­line
* arguments and prints the Calendar of the month. Store the Calendar in an 2D Array,
* the first dimension the week of the month and the second dimension stores the day
* of the week.

* @author : Janhavi Mhatre
* @python version 3.7
* @platform : PyCharm
* @since 3-1-2019
*
***********************************************************************************/
'''
from utilities.utility import Util

u = Util()

if __name__ == "__main__":
    month = int(input("enter month : "))
    year = int(input("enter year : "))
    day = ['S', ' M', ' T', ' W', ' Th', 'F', ' S']

    days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

    values = 1
    d = 1
    m = month
    y = year
    y0 = y - (14 - m) // 12
    x = y0 + y0 // 4 - y0 // 100 + y0 // 400
    m0 = m + 12 * ((14 - m) // 12) - 2
Esempio n. 19
0
def decm():
    u = Util()
    m = int(input("enter the number to see its binary representation: "))

    u.decimal_convert(m)
Esempio n. 20
0
'''
/**********************************************************************************
* Purpose: Anagram and Palindrome
*
* @author : Janhavi Mhatre
* @python version 3.7
* @platform : PyCharm
* @since 21-12-2018
*
***********************************************************************************/
'''

from utilities.utility import Util
if __name__ == "__main__":
    u = Util()
    u.check_condition()






Esempio n. 21
0
def power():
    u = Util()
    n = int(input("enter power value N: ")
            )  # take power value from user i.e if 2^N then ask for N
    u.power_two(n)
Esempio n. 22
0
def gameb():
    u = Util()
    stake = int(input("enter stake: "))  # take starting amount as stake
    goal = int(input("enter goal: "))  # take final amount to win
    turns = int(input("enter number of trials: "))  # number of trials
    u.gambler_game(stake, goal, turns)
Esempio n. 23
0
def method():
    u = Util()
    key = int(input("enter number to be search: "))
    u.binarysearchint(list_int, key)

    key2 = input("enter string to be search: ")
    u.binarysearchstring(list_string, key2)

    u.bubblesortint(list_int)
    u.bubblesortstring(list_string)
    u.insertionsortint(list_int)
    u.insertionsortstring(list_string)
Esempio n. 24
0
'''
/**********************************************************************************
* Purpose: Take a range of 0 ­ 1000 Numbers and find the Prime numbers in that range
*
* @author : Janhavi Mhatre
* @python version 3.7
* @platform : PyCharm
* @since 24-12-2018
*
***********************************************************************************/
'''

from utilities.utility import Util
if __name__ == "__main__":
    u = Util()

    u.prime_numbers()
Esempio n. 25
0
/**********************************************************************************
* Purpose: Create the Week Object having a list of WeekDay objects each storing the day (i.e
* S,M,T,W,Th,..) and the Date (1,2,3..) . The WeekDay objects are stored in a Queue
* implemented using Linked List. Further maintain also a Week Object in a Queue to
* finally display the Calendar

* @author : Janhavi Mhatre
* @python version 3.7
* @platform : PyCharm
* @since 3-1-2019
*
***********************************************************************************/
'''
from utilities.utility import Util
from utilities import datastructqueue
u = Util()

if __name__ == "__main__":
    month = int(input("enter month : "))
    year = int(input("enter year : "))

    day = ['S', ' M', ' T', ' W', ' Th', 'F', ' S']  # store day names

    days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30,
            31]  # store total number of days in every month

    values = 1
    d = 1

    m = month
    y = year
Esempio n. 26
0
def ana():
    u = Util()

    str1 = input("enter string 1: ")
    str2 = input("enter string 2: ")
    u.anagram_check(str1, str2)
Esempio n. 27
0
def vending():
    u = Util()
    amount = int(input("enter amount: "))  # ask user to enter amount
    u.vending(amount)
Esempio n. 28
0
def permutation():
    u = Util()
    data = input("enter string: ")  # enter string for permutation
    print(u.permutation_py(data))
Esempio n. 29
0
def sorting():
    u = Util()
    print("unsorted: ", array)

    result = u.merge_sort(array)
    print("sorted: ", result)
Esempio n. 30
0
def sqr():
    u = Util()

    c = int(input("take a number of which sqrt is to be calculate: "))

    u.sqr_num(c)