Current streak:
0 days
Longest streak:
3 days
Less
More
from os import *
from sys import *
from collections import *
from math import *
class Person:
def __init__(self,name,age):
self.name=name
self.age=age
def __str__(self):
return "The name of the person is {} and the age is {}.".format(self.name,self.age)
#create your class here
name=input()
age=int(input())
n=Person(name,age)
print(n)
from os import *
from sys import *
from collections import *
import math
class Fraction:
#Create your fraction class here.
def __init__(self, num,den):
self.num = num
self.den = den
def lcm(self, a, b):
return abs(a*b) // math.gcd(a, b)
def __str__(self):
return "{}/{}".format(self.num,self.den)
def __add__(self,obj):
temp = Fraction(self.num,self.den)
a = self.lcm(self.den,obj.den)
b = (self.num * (a//self.den)) + (obj.num * (a//obj.den))
self.num = temp.num = b
self.den = temp.den = a
return temp
def __mul__(self,obj):
temp = Fraction(self.num,self.den)
a = self.num * obj.num
b = self.den * obj.den
self.num = temp.num = a
self.den = temp.den = b
return temp
def plus(self,obj):
return self + obj
def multiply(self,obj):
return self * obj
def simplify(self):
a = math.gcd(self.num,self.den)
self.num //= a
self.den //= a
return self
def Print(self):
print(self)
#Driver code goes here.
num1,den1 = list(map(int,input().split()))
fr1 = Fraction(num1,den1)
reps = int(input())
for _ in range(reps):
op,num2,den2 = list(map(int,input().split()))
fr2 = Fraction(num2,den2)
if op == 1:
fr1.plus(fr2)
fr1.simplify()
fr1.Print()
elif op == 2:
fr1.multiply(fr2)
fr1.simplify()
fr1.Print()
from sys import stdin
def removeAllOccurrencesOfChar(string, ch) :
n = len(string)
new_str = ""
for i in range(n):
if ch!=string[i]:
new_str+=string[i]
string = new_str
return string
#main
string = stdin.readline().strip()
ch = stdin.readline().strip()[0]
ans = removeAllOccurrencesOfChar(string, ch)
print(ans)
from sys import stdin
def reverseEachWord(string):
new_str=string.split()
ans=""
for i in range(len(new_str)):
temp=new_str[i]
temp = temp[::-1]
ans+=temp+" "
string=ans
return string
#main
string = stdin.readline().strip()
ans = reverseEachWord(string)
print(ans)
def isPermutation(string1, string2) :
#Your code goes here
if sorted(string1)==sorted(string2):
return True
else:
return False
#main
string1 = input()
string2 = input()
ans = isPermutation(string1, string2)
if ans :
print('true')
else :
print('false')
def kthSmallestLargest(arr,k):
#Your code goees here.
arr = list(set(arr))
if len(arr)<k:
return -1,-1
else:
return arr[k-1],arr[len(arr)-k]
#Driver's code
t = int(input())
while t > 0:
n,k = map(int,input().split())
arr = [int(i) for i in input().split()]
small,large = kthSmallestLargest(arr,k)
print(large,small)
t -= 1