def stopwatch(sec):
    logger.setLevel(logging.INFO)
    """
    import time package
    define function for stopwatch format
        time b/w start and end clicks
        
    """
    min = (sec // 3600)//60
    sec = ((sec % 3600)%60)
    hours = min//3600
    logger.info('%02d:%02d:%02d' %(hours, min, sec))
def coupon_number(number_of_coupons):
    logger.setLevel(logging.INFO)
    """ get input from user to genearte n random coupon numbe
        check the random numbers in loop check the number is not in random nums 
    and append the number is random_nums list
             """
    coupons = 0
    random_numbers = 0
    random_nums = []
    while coupons != number_of_coupon:
        number = random.randint(1, 10**4)
        if number not in random_nums:
            random_nums.append(number)
            coupons += 1

    logger.info(random_nums)
def print_board():
    """board logic
    assign blocks using for loop


"""
    logger.setLevel(logging.INFO)
    x = 1
    for i in board:
        end = ' | '
        if x % 3 == 0:
            end = ' \n'
            if i != 1:
                end += '---------\n'
        char = ' '
        if i in ('X', 'O'):
            char = i
        x += 1
        print(char, end=end)
def gambler(stake,goal,number_of_times):
    logger.setLevel(logging.INFO)
    """
          :param stake: initial amaount
          :param goal: goal to reach particular amount
          :return: win or loss
          while loop till gambler stake=0 or stake =goal(200)
          random var for win or loose
          if gambler looses stake-1 and number of loose-1
          increment wins stake++ and win++
          printing number of bets
          printing win percentage
          """
    # initially win=0 and loose=0
    bets=0
    win=0
    # while loop till gambler stake=0 or stake =goal(200)
    while win!=goal and stake!=0:
        # random var for win or loose
        num=random.random()
        if num<0.5:
            # if gambler looses stake-1 and number of loose-1
            bets+=1
            win+=1
        else:
            # if wins stake++ and win++
            bets+=1
            stake-=1
    loss_percentage=((bets-win)/bets)*100
    win_percentage=(win/bets)*100
    # printing number of bets
    logger.info(f"Total number of bets = {bets}")
    # printing number of wins
    logger.info(f"Total win = {win}")
    # printing win percentage
    logger.info(f"win percentage  ={win_percentage}")
    logger.info(f"loss percentage ={loss_percentage}")
"""
date = '27/04/2021'
modified_date = '28/04/2021'
author = 'Mahesh Naik'
description =crete text file and perform read write operation"""
import logging
from logicallog import logger
logger.setLevel(logging.INFO)

"""read and write text file
using read,write function
using append function add data in text file"""


with open('simple.txt', 'w') as f:
    a = f.write('hello mahesh how are you')
    print(a)
with open('simple.txt','r') as f:
    a = f.read()

f= open('simple.txt','r')
data = f.read()
logger.info(data)
f.close()