Count of total Heads and Tails after N flips in a coin | Function to find count of head and tail ; Check if initially all the coins are facing towards head ; Check if initially all the coins are facing towards tail ; Driver Code
import math NEW_LINE def count_ht ( s , N ) : NEW_LINE INDENT if s == " H " : NEW_LINE INDENT h = math . floor ( N / 2 ) NEW_LINE t = math . ceil ( N / 2 ) NEW_LINE DEDENT elif s == " T " : NEW_LINE INDENT h = math . ceil ( N / 2 ) NEW_LINE t = math . floor ( N / 2 ) NEW_LINE DEDENT return [ h , t ] NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT C = " H " NEW_LINE N = 5 NEW_LINE l = count_ht ( C , n ) NEW_LINE print ( " Head ▁ = ▁ " , l [ 0 ] ) NEW_LINE print ( " Tail ▁ = ▁ " , l [ 1 ] ) NEW_LINE DEDENT