Code :
def blackjack(a, b):
s = a + b
if s > 21:
if a == 11:
a = 1
elif b == 11:
b = 1
else:
a, b = 0, 0
s = a + b
return s
i = int(input("Enter First Card Number : "))
j = int(input("Enter Second Card Number : "))
print("Sum =", blackjack(i, j))
Functions is set of instructions which perform specific task.
Functions are of two types:
1. Built-in functions
2. User-defined functions
def is used to define User-defined function in python. Functions provide ease to the programmer and avoid repetition of code. In above code blackjack is a user-defined function.
Pre-defined functions are known as built-in functions. In above code input is a built-in function which is used to take input from the user.
Functions are of two types:
1. Built-in functions
2. User-defined functions
def is used to define User-defined function in python. Functions provide ease to the programmer and avoid repetition of code. In above code blackjack is a user-defined function.
Pre-defined functions are known as built-in functions. In above code input is a built-in function which is used to take input from the user.
Output :
when i = 11 and j = 8
Enter First Card Number : 11
Enter Second Card Number : 13
Sum = 14
when i = 12 and j = 14
Enter First Card Number : 12
Enter Second Card Number : 14
Sum = 0
0 Comments
Ask Your Queries in the comments