Hacker Rank Python:
if __name__ == '__main__':
a = int(input())
b = int(input())
sumn = lambda a,b : a+b
print(sumn(a,b))
diff = lambda a,b : a-b
print(diff(a,b))
prod = lambda a,b : a*b
print(prod(a,b))
'''The first line contains the sum of the two numbers.
The second line contains the difference of the two numbers (first -
second).
The third line contains the product of the two numbers.'''
'''Task
Read an integer . For all non-negative integers , print . See the
sample for details.'''
if __name__ == '__main__':
n = int(input())
for i in range(n):
print(i**2)
'''Task
Read two integers and print two lines. The first line should
contain integer division, // . The second line should contain
float division, / .
You don't need to perform any rounding or formatting operations.'''
'''floor division // always give floor answer
division / always give floating point ans'''
if __name__ == '__main__':
a = int(input())
b = int(input())
intdiv = lambda a,b : a//b
print(intdiv(a,b))
decdiv = lambda a,b : a/b
print(decdiv(a,b))
'''Read an integer N.
Without using any string methods, try to print the following:
123...N
Note that "" represents the values in between'''
if __name__ == '__main__':
n = int(input())
for i in range(1,n+1):
print(i,end='')
# Enter your code here. Read input from STDIN. Print output to
STDOUT
'''A valid email address meets the following criteria:
It's composed of a username, domain name, and extension assembled
in this format: username@domain.extension
The username starts with an English alphabetical character, and any
subsequent characters consist of one or more of the following:
alphanumeric characters, -,., and _.
The domain and extension contain only English alphabetical
characters.
The extension is 1,2, or 3 characters in length.
Given n pairs of names and email addresses as input, print each
name and email address pair having a valid email address on a new
line.
Hint: Try using Email.utils() to complete this challenge. For
example, this code:
import email.utils
print email.utils.parseaddr('DOSHI <DOSHI@hackerrank.com>')
print email.utils.formataddr(('DOSHI', 'DOSHI@hackerrank.com'))
produces this output:
('DOSHI', 'DOSHI@hackerrank.com')
DOSHI <DOSHI@hackerrank.com>'''
from email.utils import parseaddr,formataddr
import re
n = int(input())
pattern = r'^[A-Za-z][\w\.\-\_]+@[a-z]+\.([a-z]{1,3})$'
for i in range(n):
nameemail = input()
a = parseaddr(nameemail)
if re.match(pattern,a[1]):
print(nameemail)
'''CSS colors are defined using a hexadecimal (HEX) notation for
the combination of Red, Green, and Blue color values (RGB).
Specifications of HEX Color Code
■ It must start with a '#' symbol.
■ It can have 3 or 6 digits.
Each digit is in the range of 0 to F.
(0,1,2,3,4,5,6,7,8,9,A,B,C,D,E and F ).'''
import re
pattern = r'[\s:](#[0-9a-f]{3,6})'
for i in range(int(input())):
css = input()
matches = re.findall(pattern,css,re.IGNORECASE)
for m in matches:
print(m)