Skip to content
Leetcode
# Start coding here...
def capitalizeTitle(n):
"""
:type title: str
:rtype: str
"""
digits = (int(d) for d in reversed(str(n)))
total = 0
for position, digit in enumerate(digits):
if position % 2 == 1:
digit *= 2
if digit > 9:
digit -= 9
total += digit
return total capitalizeTitle('79927398713')def checkLuhn(cardNo):
nDigits = len(cardNo)
nSum = 0
isSecond = False
for i in range(nDigits - 1, -1, -1):
d = ord(cardNo[i]) - ord('0')
if (isSecond == True):
d = d * 2
# We add two digits to handle
# cases that make two digits after
# doubling
nSum += d // 10
nSum += d % 10
isSecond = not isSecond
return nSum
checkLuhn('79927398713')print("Enter the Total Number of Terms: ")
n = 20
if n > 0 and n & (n-1) == 0:
print('True')
else:
print('False')import sys
for line in sys.stdin:
print(line, end = " ")
nums = sys.stdin.readline().split()
if nums[0] < nums[1]:
print("<")
elif nums[0] > nums[1]:
print(">")
else:
print("=")import sys
import pandas as pd
df = pd.read_csv('cereal.csv')
m1=df['price'].max()
m2=df['price'].min()
m3=df['price'].mean()
s=df['price'].std()
print(round(m1, 2),"\n",round(m2, 2),"\n",round(m3, 3),"\n",round(s, 4))