Loading...
More Python Posts
import pandas as pdx = pd.read_excel(FILE_NAME)print(x)
print("hellur")
from colorama import init, Fore# Initialize coloramainit()print(Fore.RED + "This text is in red color.")print(Fore.GREEN + "This text is in green color.")print(Fore.BLUE + "This text is in blue color.")# Reset coloramaprint(Fore.RESET + "This text is back to the default color.")
def to_roman_numeral(num):lookup = [(1000, 'M'),(900, 'CM'),(500, 'D'),(400, 'CD'),(100, 'C'),(90, 'XC'),(50, 'L'),(40, 'XL'),(10, 'X'),(9, 'IX'),(5, 'V'),(4, 'IV'),(1, 'I'),]res = ''for (n, roman) in lookup:(d, num) = divmod(num, n)res += roman * dreturn resto_roman_numeral(3) # 'III'to_roman_numeral(11) # 'XI'to_roman_numeral(1998) # 'MCMXCVIII'
""" Rock Paper Scissors----------------------------------------"""import randomimport osimport reos.system('cls' if os.name=='nt' else 'clear')while (1 < 2):print "\n"print "Rock, Paper, Scissors - Shoot!"userChoice = raw_input("Choose your weapon [R]ock], [P]aper, or [S]cissors: ")if not re.match("[SsRrPp]", userChoice):print "Please choose a letter:"print "[R]ock, [S]cissors or [P]aper."continue// Echo the user's choiceprint "You chose: " + userChoicechoices = ['R', 'P', 'S']opponenetChoice = random.choice(choices)print "I chose: " + opponenetChoiceif opponenetChoice == str.upper(userChoice):print "Tie! "#if opponenetChoice == str("R") and str.upper(userChoice) == "P"elif opponenetChoice == 'R' and userChoice.upper() == 'S':print "Scissors beats rock, I win! "continueelif opponenetChoice == 'S' and userChoice.upper() == 'P':print "Scissors beats paper! I win! "continueelif opponenetChoice == 'P' and userChoice.upper() == 'R':print "Paper beat rock, I win! "continueelse:print "You win!"
def max_n(lst, n = 1):return sorted(lst, reverse = True)[:n]max_n([1, 2, 3]) # [3]max_n([1, 2, 3], 2) # [3, 2]