blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
8dc33b0291f00e04734c54e2b5d66b45260144b9
Jeevanantham13/Python
/palindrome.py
232
4.09375
4
num=int(input("enter the number")) c=num rev=0 while(num>0): rem=num%10 rev=(rev*10)+(rem) num=num//10 print("the reversed num:",rev) if(c==rev): print("its a palindrome") else: print("its not a palindrome")
aeacf191277ccc20bb75496acb42253a1456e434
Hao-HOU/LearnPython3theHardWay
/code/ex19.py
1,055
3.9375
4
def cheese_and_crackers(cheese_count, boxes_of_crackers): print(f"You have {cheese_count} cheeses!") print(f"You have {boxes_of_crackers} boxes of crackers!") print("Man that's enough for a party!") print("Get a blanket.\n") print("We can just give the function numbers directly:") cheese_and_crackers(...
95e099e035ade30eac662e546b901e08ce1e0962
RobertoRosa7/python
/py_intro_to_python/fila.py
585
4
4
# -*- coding: utf-8 -*- from collections import deque def fila(): ''' Trabalhando com filas - deque se for inserido mais do que o limite o primeiro elemento será removido append() - adiciona no final appendleft() - adiciona no inicio pop() - remover elemento no fina...
d3d111088b67b12e04e0b2620c2836d545e70057
TapanManu/Py-Ton
/strings/duplicate_letters.py
168
3.75
4
str=input('get the string') ls=[x for x in str] dup=list(set(ls)) if len(dup)==len(ls): print("string has unique letters only") else: print("string has repetitions")
374faafae9b7e6da34f4ed24eba1706a5b0878eb
johnklee/algprac
/hackerrank/graph/medium/journey-to-the-moon.py
3,383
3.609375
4
#!/usr/bin/env python r''' https://www.hackerrank.com/challenges/journey-to-the-moon/problem ''' import math import os import random import re import sys class Node: def __init__(self, v): self.v = v self.neighbors = set() self.visit = False def addN(self, n): if n not in sel...
c2bc9309ea47292a8a79355d41c82a6de822b905
shuchita-rahman/HakkerRank
/sWAP cASE Solution.py
272
4
4
def swap_case(s): newstring ='' for a in s: if (a.isupper()) == True: newstring+=(a.lower()) elif (a.islower()) == True: newstring+=(a.upper()) else: newstring+= a return newstring
0fa541dc157ce16ad55e5211e88459eaaccc67b9
SatishMurthy/Python-Practice
/Hackerrank scripts.py
3,468
4.125
4
# #Polar Coordinates # # import cmath # # cnum = input('Enter complex number a+ij: ') # # #complex(input()) # # polarcoord = cmath.polar(complex(cnum)) # # for n in polarcoord: # print(round(n,3)) # #Average of distinct numbers from a given set of numbers # def average(array): # # your code goes h...
90e88f861fddc5ce39e21028f2ae7f72fd2dae94
vikkiorrikki/Google-calendar-Mongo
/work.py
6,272
3.546875
4
# -*- coding: utf-8 -*- from __future__ import print_function import httplib2 import os import time import datetime import itertools from operator import itemgetter from pymongo import MongoClient def main(): client = MongoClient('localhost', 27017) db = client['calendar-data'] mongo_calendars = db.calendars em...
a4d0cbc66717476eb3382200b4ea71e60e732c01
wpgalmeida/tic-tac-toe-python-playground
/tests/apps/test_judge.py
3,695
3.5625
4
from unittest import TestCase from tic_tac_toe_python_playground.apps.core.judge import check_end_game class Test(TestCase): def test_should_win_in_row_1(self): fake_actual_board_to_be_tested = [["X", "X", "X"], [3, 4, 5], [6, 7, 8]] self.assert_(check_end_game(fake_actual_board_to_be_tested)) ...
47bfc900304f2e4435908d08e278d16723820358
etfrer-yi/Python-Reddit-Webscraper-
/Python Reddit Webscraper/reddit_word_cloud.py
631
3.765625
4
# Code to generate the word cloud taken from # https://towardsdatascience.com/simple-wordcloud-in-python-2ae54a9f58e5 import matplotlib.pyplot as plt from wordcloud import WordCloud, STOPWORDS def plot_cloud(wordcloud): plt.figure(figsize=(40, 30)) plt.imshow(wordcloud) plt.axis("off") p...
9b561c8b8eba0f3af33b7319ddc19b5509f3a990
everaldobass/curso-python3
/8-curso-cod3r-python/pacote/tipos/01-for.py
257
3.796875
4
# for i in range(10): # print(i) # for a in range(1, 100, 2): # print(a) #num = [1, 2, 3, 4, 5] # for n in num: # print(n) produto = { "nome": "Caneta", "preco": 2.50, "desc": 0.5 } for can in produto: print(can, "==>", produto[can])
f4f99a5f55db9f43a2d507f2ada6a2f85c98af87
ctc316/algorithm-python
/Lintcode/G_Practice/OAs/1646. CheckWords.py
702
3.640625
4
class Solution: """ @param s: @param str: @return: Output whether this combination meets the condition """ def checkWord(self, s, str): dict = set(str) stack = [] visited = set() if s not in dict: return False stack.append(s) visited....
75190a2a508e622e875e0ac23a7976a686e8df01
giabao2807/python-study-challenge
/basic-python/module-package/my_math.py
862
4.1875
4
print('--- start of my_math ---') PI = 3.14159 E = 2.71828 message = 'My math module' def sum(start, *numbers): '''Calculate the sum of unlimited number Params: start:int/float, the start sum *numbers:int/float, the numbers to sum up Return: int/float ''' for x in numbers: ...
96bc7a96b0ff902c79737d1f7186432383e8f12c
MS-87/Daily-Coding
/20180528 - Talking Clock/talkclock.py
2,760
4.0625
4
""" Description No more hiding from your alarm clock! You've decided you want your computer to keep you updated on the time so you're never late again. A talking clock takes a 24-hour time and translates it into words. Input Description An hour (0-23) followed by a colon followed by the minute (0-59). Output Descript...
883458c8a596b0d4c6f5bbd80185072b6710280a
lkogant1/Python
/while_armstr.py
259
4
4
#armstrong number or not #sum of each digit cubes is equal to the given number #eg: 153 x n = int(input("number: ")) t = n s = 0 while(n>0): d = n%10 s = s+(d*d*d) n = int(n/10) if(s == t): print("Armstrong number") else: print("Not an Armstrong number")
b170ad3edf29ed96b06dc64fc4eb746aa992e7c6
cabbageGG/study_
/python/test_python_grammar/test_mysql.py
1,340
3.578125
4
#-*- coding: utf-8 -*- # author: li yangjin import MySQLdb """ MYSQL:用法 host string, host to connect user string, user to connect as passwd string, password to use db string, database to use port integer, TCP/IP port to ...
acf9947ef51f668bc986b97444f2f3f927d78aa7
kenji-tolede/Travaux-python
/EXO 16.py
255
3.9375
4
m1 = input('entrez 1er mot') m2 = input('entrez le 2eme mot') def hamming_distance(m1, m2): distance = 0 for i in range(len(m1)): if m1[i] != m2[i]: distance += 1 return distance print(hamming_distance(m1,m2))
cd5fff209d684ffffb01a035bd0632b08ef529ff
sunsunza2009/Image-Classifier-Web-GUI
/Flask Train Server/CNN/model.py
1,037
3.546875
4
from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense, Dropout, Activation, Flatten, Conv2D, MaxPooling2D def getModel(numClass,shape): # Building the model model = Sequential() # 3 convolutional layers model.add(Conv2D(32, (3, 3), input_shape = shape)) model.add(Activation("rel...
f60343b59b05c8cd1461b6f65775135ac0986a42
qiwsir/LearningWithLaoqi
/PythonBase/08program.py
384
3.515625
4
#coding:utf-8 class Person: def __init__(self, name): self.name = name def height(self, m): h = dict((["height", m],)) return h class Student(Person): def score(self, mark): result = {self.name: mark} return result if __name__ == "__main__": tom = Stud...
6091e9a8988cd0ba5dcad05369ad459524740286
daniel-reich/turbo-robot
/Pf2kDoCRvEL8qzKTs_22.py
1,625
4.25
4
""" Create a function that takes in the size of the line and the number of people waiting and places people in an _S-shape_ ordering. The demonstration below will make it clear: # Ordering numbers 1-15 in a [5,3] space. order_people([5, 3], 15) ➞ [ [1, 2, 3], [6, 5, 4], [7, 8, 9], ...
55097e6dcb4da8743b4ac5dc86dcd573bea033b0
ghoshrohit72/Algorithm-Hub
/UsingPython/EvenFibonacciNumbers.py
580
3.890625
4
''' Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. ''' d...
e8f209a256dd7776de56ea8f5c7c46619e96fc7a
AbhinavRobinson/RSA-over-SHA
/generate_keys.py
1,507
3.875
4
""" ! Set of Functions to Generate Keys Generates private and public key pair p_num1 = first prime p_num2 = second prime key_size = define key size (128 bits : default) """ # Imports random for randomint generation import random def generate(p_num1, p_num2, key_size=128): n = p_num1 * p_nu...
614911c74484505d486575f79a4ca954d5ccc81d
rodri0315/pythonCSC121
/chapter9/dictionary_example.py
638
4.03125
4
players = dict( Messi='forward', Pique='Defender', Xavi='Midfielder', Valdez='Goalie') for key in players: print(f"FCBarcelona player: {key}") print("____") for key in players: print("{} plays as a {}".format(key, players[key])) # will return everything in dictionary print(players.items()) ...
16ab8dab4f6eec4c8ab668fa6aeb434c6f95f5e4
hmaryam/Thinkful_codes
/Lesson2_1.py
1,371
4.03125
4
Write a function to ask what style of drink a customer likes import random questions = { "strong": "Do ye like your drinks strong?", "salty": "Do ye like it with a salty tang?", "bitter": "Are ye a lubber who likes it bitter?", "sweet": "Would ye like a bit of sweetness with yer poison?", "fruity": ...
ee4833ed599e2c9ddbd1711a946e3e4e1f6ead40
allegheny-college-expressioneers/while-while-west-practical-solution
/1_temperature_converter.py
537
4.28125
4
def to_celsius(fahrenheit): return (fahrenheit - 32) * 5 / 9 def to_fahrenheit(celsius): return 9/5 * celsius + 32 temperature = input('Enter a temperature value: ') unit = input('Enter the temperature\'s unit: ') if unit == 'C' or unit == 'c': print(f'The temperature is {round(to_fahrenheit(int(temperat...
c0b69a21cebcf47e0d2b26ed26960283d3c51442
lgrant146/JetbrainsPython
/Problems/Desks/main.py
257
3.796875
4
# put your python code here group1 = int(input()) group2 = int(input()) group3 = int(input()) desk1 = group1 // 2 + group1 % 2 desk2 = group2 // 2 + group2 % 2 desk3 = group3 // 2 + group3 % 2 total_desks = desk1 + desk2 + desk3 print(total_desks)
26b2f4b00a8b6ea2a2f7a55225545c6dd458532b
CarolineWinter/gothic
/data_processing/test_spacy.py
1,723
3.65625
4
""" Testing basic concepts & tools before doing our main analysis. """ import re from collections import defaultdict from oed_color import color_words import spacy nlp = spacy.load('en') def tokenize_text(): """ This function generates a list of tokens with punctuation and spaces removed. """ text_to...
40ef1fa0538d453a6f95ddc9bc422d0e6c19136f
MrHamdulay/csc3-capstone
/examples/data/Assignment_7/bxtnaa002/question1.py
758
3.984375
4
# question1.py # author: bxtnaa002 # assignment 7 words = [] word = input("Enter strings (end with DONE):\n") # create a list containing words and DONE is inputed to terminate the growth of the list while word != "DONE": words.append(word) word = input("") unique = [] #create a new list f...
6650fa86f62f3cc472c3c79b71ba1c736eeec2e6
ntupenn/exercises
/hard/272.py
1,451
3.828125
4
""" Given a non-empty binary search tree and a target value, find k values in the BST that are closest to the target. Note: Given target value is a floating point. You may assume k is always valid, that is: k <= total nodes. You are guaranteed to have only one unique set of k values in the BST that are closest to the...
bbdef09bfee0b8623d6a84271f23174ad14a1589
M0use7/python
/LeetCode/最长公共前缀.py
281
3.59375
4
"""__author__ = 唐宏进 """ class Solution(object): def longestCommonPrefix(self, strs): """ :type strs: List[str] :rtype: str """ n = len(strs) for item in strs: for _ in range(n): item[n] ==
d0faec85f786686f341e6affc51e5406772880b4
enu93/ElephantGame
/drawing_shapes.py
993
3.546875
4
import pygame, sys from pygame.locals import * pygame.init() screen = pygame.display.set_mode((640, 350), 0, 32) color = (255, 255, 0) # polygon ponts points = [(20, 120), (140, 140), (10,30)] # circle points position = (300, 176) radius = (60) # ellipse points rectangle = (140, 180, 50, 190) # ...
d0ea6e7381beed60aa921331c5b9cb9f51ba7f9d
Liganggooo/Work_File
/python/Python1/File.py
530
3.796875
4
f = open('text.txt','r') # f.write('abc') # content = f.read() #将文件存入一个列表中然后对列表进行遍历 lines = f.readlines() for line in lines: print(line.strip()) # print(content) f.close #免关闭文件式阅读文件方法 # filename = 'text.txt' # with open(filename) as f: # content = f.read() # print(content) # #写入文件、追加文件位置 # with o...
9c177c7016c9edf051297633de926ed2e9b13039
JamieRRobillardSr/stpd
/challenges/ch06/6-5.py
203
3.578125
4
l1 = [ "The", "fox", "jumped", "over", "the", "fence", "." ] s1 = "" for word in l1: if (word == "."): s1 = s1.strip() s1 += word else: s1 += word + " " print(s1)
9dd0100eef6551a5d7973a20fa38c0810341edf8
At0m07/python
/dz1.py
844
4.5
4
#1.Поработайте с переменными, создайте несколько, выведите на экран, #запросите у пользователя несколько чисел и строк и сохраните в переменные, #выведите на экран. print("Добро пожаловать!") a = 5 b = 10 print ("Вывод переменных a и b:",a,b) number = int(input("Введите первое число:")) string = input("Введ...
a1bb6be4882167b0692406b13d3c8ba562e39262
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_74/522.py
1,668
3.625
4
#!/opt/local/bin/python import sys from itertools import count def get_next_position(position_it, robot): while True: try: next = position_it.next() except StopIteration: return None if next[1] == robot: return next[0] input_it = iter(sys.stdin.readline...
6463cd932456a519035862ff3e76a35e3943a2f9
zhaoyang6943/Python_JiChu
/day05/03 运算符.py
1,655
4.28125
4
# 学习的思路:什么是?为什么要有这个? # 1. 算术运算符 # print(111 + 3) # print(type(100 - 3.1)) # # print(10 / 3) # 带小数 # print(10 // 3) # 只保留整数部分 # # print(10 % 3) # 取余 # # print(10 ** 3) # 代表10的3次方 # 2. 比较运算符 # print(1 > 3) # # print(1 == 1) # # print(10 >= 10) # print(10 <= 3) # name=input('your name') # print('agen' == name) # 3...
1a62e2eb3cac117b0f23fb0acb9b35e29b3a8006
AmyrSam/lab-test
/lab-test
1,196
4.15625
4
#!/usr/bin/env python # coding: utf-8 Soalan 1: def countSetBits(n): count = 0 while (n): count += n & 1 n >>= 1 return count i = input("Enter the number: ") print(countSetBits(int(i))) Soalan 2: import collections s = input("Enter your word: ") print(collections.Counter(s...
95d5211974ca6ac985f55b05f22ca1ff225ea0a6
Edw10/holbertonschool-higher_level_programming
/0x0C-python-almost_a_circle/models/square.py
1,548
3.84375
4
#!/usr/bin/python3 """ this module define the square """ from models.rectangle import Rectangle class Square(Rectangle): """ this is the square class """ def __init__(self, size, x=0, y=0, id=None): """this initialice a square""" super().__init__(size, size, x, y, id) def __str_...
5c99a76b5445fbdc3f6c3c350eee95b27ec93fdc
Ellen172/UFU-Python
/For range.py
494
4
4
#imprimindo os numeros primos, dentro de uma tupla primos = (1, 3, 5, 7, 11, 13) for k in primos : print(k) #cria uma tupla de 0 a 5, sem incluir o 5, atraves de uma p.a r = tuple (range (0, 5)) print("r = ", r) #a tupla é gerada a cada 2 numeros l = tuple (range (0, 10, 2)) print("l =", l) #cria um...
7307c88244801bfe9cdc0fd12ac9a9e75b176842
jgartsu12/my_python_learning
/python_data_structures/tuples/remove_elements.py
1,468
4.59375
5
# Three Ways to Remove Elements from a Python Tuple # tuples are immutable so original is not having anything removed but the new ones will be new tuples with elements removed # real world situation u didnt create the tuple but working with outsdie library with collection and cant ctrl tuple is what u have to work w/ ...
12ebff9127351880383916e47e85aac753b9051a
muhil77/Project-One
/prime_check.py
314
4.1875
4
# this function checks if a number is prime def prime_checker(num): flag = True for divisor in range(2, num / 2): if num % divisor ==0: flag = False return flag return flag number_to_check = int(raw_input("Enter number to check ")) print prime_checker(number_to_check)
6af7045d8f10d43395571fbeeed07d25a4908b27
YannTorres/Python-mundo1e2
/Desafios/10ConversorMoeda.py
183
3.65625
4
a = float(input('Há quantos reais em sua carteira? R$')) print(f'Com R${a:.2f} você pode comprar US${a/5.47:.2f}') print(f'Com R${a:.2f} você pode comprar EU€{a/6.62:.2f}')
3d76a9121810c1270ff2e3e4cf5c7339714d14be
Nafsan/hackerrank-python
/Detect Floating Point Number.py
1,087
3.9375
4
# for _ in range(int(input())): # string = input() # plus = string.count('+') # minus = string.count('-') # plus_minus = plus + minus # dot = string.count('.') # dot_index = string.find('.') # flag = 0 # if plus_minus > 1: # flag = 1 # elif string.isalpha() is True: # ...
0b34fbae6a35a1c851e5bf83a10ae9dcecc79329
FHJXS/PythonStudy
/Eclipse/Test/Day6.py
735
3.546875
4
# -*- coding: UTF-8 -*- ''' Created on 2018��2��10�� @author: www60 ''' import re def func1(): """ A|B可以匹配A或B,所以(P|p)ython可以匹配'Python'或者'python'。 ^表示行的开头,^\d表示必须以数字开头。 $表示行的结束,\d$表示必须以数字结束。 """ m = re.match(r'^(\d{3})-(\d{3,8})$', '010-12345') print(m) print(m.group(0)) # 匹配整个字符串 print(m.gro...
fb01898a36c5abc5124aee0464d33b9cdc90f592
marandmath/programming_challenges
/Advent of Code Programs/2015/Day 2/Day 2.py
1,194
3.765625
4
import numpy as np file_name = "input.txt" # Due to efficiency we will use a list consisting of lists / rows instead of # numpy arrays! For more read this SO article: # https://stackoverflow.com/questions/568962/how-do-i-create-an-empty-array-matrix-in-numpy matrix = [] with open(file_name) as f_obj: d...
5ec0125828d0ddcea457b758ccaef36f73ea0bbc
christian-townsend/capstone-project
/Machine Learning/generateData.py
5,353
3.65625
4
import random skills = [] projects = [] groups = [] units = [9785, 9786, 10004, 10005, 10098, 11522] #update below variables maxGroupsPerProject=2 unitsPerProject = 2 minStudentsPerGroup=3 maxStudentsPerGroup = 5 skillsPerProject = 6 skillsPerGroup = 8 totalGroups = 50 totalProjects = 100 pointsFactorPerSkillMatch = 8...
28f6f7f02adac77df95dc3d83e133a469a66bd70
mfkiwl/midi_studio_hw
/scripts/output_imp.py
684
3.671875
4
# Find the output resistance (impedance at DC) and Thevanin voltage of a circuit # Supply the script with V1 measured with R1 across the ouput and V2 with R2 # across the output # The script gives output resistance and Thevanin voltage. import sys import numpy as np if len(sys.argv) != 5: sys.stderr.write("argume...
eef5e94d1625baa4187da6a79d2b47be10391449
Mierln/Computer-Science
/William/Blackjack.py
5,220
3.578125
4
import random suits = ('Hearts', 'Diamonds', 'Spades', 'Clubs') ranks = ('Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Jack', 'Queen', 'King', 'Ace') values = {'Two':2, 'Three':3, 'Four':4, 'Five':5, 'Six':6, 'Seven':7, 'Eight':8, 'Nine':9, 'Ten':10, 'Jack':10, 'Queen':10, 'King...
05f01f142978c681ea3b20f70f578d5b15ad01a1
devyani143/if-else
/chocolate.py
196
4.125
4
# num=int(input("enter a number")) # if num%3==0 and num%5==0: # print("chocolate") # elif num%3==0: # print("choco") # elif num%5==0: # print("late") # else: # print("dairy milk")
44f8ca34f3e3959f767f91390c8f49b716bcde1f
356108814/algorithm
/twitter.py
2,919
4
4
# coding: utf-8 # letcode 355 from typing import List class ID: index = 0 class Tweet: def __init__(self, tweetId): ID.index += 1 self.tweetId = tweetId self.time = ID.index class Twitter: def __init__(self): """ Initialize your data structure here. """ ...
c9945262a44a8c9c9779cef5a5307d1e8c46455c
nekapoor7/Python-and-Django
/GREEKSFORGREEKS/String/remove_duplicate.py
191
4.0625
4
#Remove all duplicates from a given string in Python from collections import OrderedDict def removechar(s): return "".join(OrderedDict.fromkeys(s)) s = input() print(removechar(s))
7b82acf9062f85b1eab73194be3b7f90f4bce660
Dark5Matter/GradeCalculator
/gradecalculator.py
5,112
4.46875
4
#!/usr/bin/env python3.5 print ("now using Python 3.5\n") #on 17th October 2017 #by Benjamin ******** #This program first takes in the values from the CSV file from memory, then places the values in RAM to await the next time the values will be used. #The computer will then either deem the data replacable or read...
aac9d91104bcd6ba36b7fd195031fda637411d7f
TSmithJr/Python-Projects
/HW1/Volume.py
2,098
4.375
4
# Volume.py """ MIS 15-01 This program computes the volume of a bottle with two cylinders, and a cone in between them. It uses the volume of a cylinder formula and the volume of a cone section formula. Our output for volume is going to be different because of math functions for pi. The example volume w...
6b38a9410196c7c3c1fffe7912f56f6cdd4de454
santoshgawande/PythonPractices
/for.py
1,295
4.59375
5
#For loop : If we know how much loop will run then used for i in range(5): print(i) #print('\n') #extra just see proper output #For using String for letter in 'Names': print(letter, end =" ") print('\n') #For using List sequence : # This is the better way about performance than using index list1 = [1,2,3...
af092923bfa57369e8f041b3dcbbab2a9d64e2bc
Aasthaengg/IBMdataset
/Python_codes/p02257/s497783881.py
270
3.671875
4
import math def is_prime(n): for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return n != 1 n = int(input()) answer = 0 for _ in range(0, n): m = int(input()) if is_prime(m): answer = answer + 1 print(answer)
3c8e572ff2e500b9498a94449a1197ee728a6c30
abzalmyrzash/webdev2019
/week 10/hackerrank/nested lists.py
609
3.8125
4
def alphabetic_order(a, b): if a[0] > b[0]: return 1 elif a[0] < b[0]: return -1 else: return 0 if __name__ == '__main__': arr = [] for _ in range(int(raw_input())): name = raw_input() score = float(raw_input()) arr.append([name, score]) arr.sor...
85f4167f393e5cebd92480eb53fc55525aa328fc
ducsuus/RoK-Calc
/logic.py
833
3.984375
4
# Reign Of Kings Calculator Logic # A list of all the block types, linking to a list of all the materials needed to craft that block. blocks = {"block" : [["stone", 2], ["wood", 100]], "cobble" : [["stone", 30]] } # The parameters needed user_block = str(input("Block: ")) user_perimeter = int(in...
651690ba4aec0e434be792a3dcf7c118c0321763
kktkyungtae/TIL
/Algorithm/2019.01/2019.01.24/Practice/10_if흐름제어4(X).py
1,171
4.09375
4
# 다음의 결과와 같이 가상의 두 사람이 가위 바위 보 중 하나를 내서 승패를 가르는 가위 바위 보 게임을 작성하십시오. # 이 때 ["가위", "바위", "보"] 리스트를 활용합니다. import random Man = {'가위':1, '바위':2, '보':3} Man1 = [random.choice(Man)] Man2 = [random.choice(Man)] print(f'{Man1[0]} {Man2[0]}') # if Man1[0] == '가위' and Man2[0] =='보': # print("Result : Man1 Win!") ...
8c48fa4f8d7579eb738614acc3218a015eab1ce8
liidenee/Python-test-example
/tests/test_class_inheritance.py
190
3.640625
4
from code.class_inheritance import Teacher x = Teacher('Amy', 'Harrot', 1979) assert x.get_name() == 'Amy Harrot', 'Name should be "Amy Harrot"' assert x.get_year() == 1989, 'Year should be 1989'
7546695afa4e62b727d293399866bdc6d74a0e90
Guilherme-Artigas/Python-intermediario
/Aula 12.5 - Exercício 40 - Aquele clássico da Média/ex040_.py
355
3.703125
4
n1 = float(input('Digite a 1º nota: ')) n2 = float(input('Digite a 2º nota: ')) media = (n1 + n2) / 2 if media < 4.9: print('Média: {}'.format(media)) print('REPROVADO!') elif (media > 5.0) and (media < 6.9): print('Média: {}'.format(media)) print('RECUPERAÇÃO!') else: print('Média: {}'.format(med...
a1a7e5faad35847f22301b117952e223857d951a
nestorsgarzonc/leetcode_problems
/6.zigzag_convertion.py
1,459
4.375
4
""" The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And then read line by line: "PAHNAPLSIIGYIR" Write the code that will take a string and make this conve...
ae58132685b2d3fcb924b3d7a0a4b3f66d4b1238
klm127/rpio-cli-state-machine
/src/Game/GameStart.py
3,403
3.84375
4
""" The starting state for the game. Shows some text and spinners to introduce the player to the game. When space-bar is pressed or when the text is finished scrolling, loads up the MapState to begin game. Extends src.Game.Map.GameStates.Game """ from src.Game.GameStates import Game from src.Game import TitleScree...
86dd565b040bc3969a49ccc07b3b7d0d69e72289
vladosfedulov/DES
/main.py
844
3.53125
4
# name Владислав ROUNDS = 16 KEY = 'Bладислав' text = 'Куй железо не отходя от кассы' block = [] key_position = 0 while ROUNDS > len(KEY): KEY += KEY if (len(text) % 2) == 1: text = text + ' ' for i in range(0, len(text), 2): block.append(text[i:i + 2]) def cript(b, k): return [i[1] + chr(ord(i[0...
a9d8e157a246d03d7252c752de3f1a8367d0c26e
plammens/python-introduction
/Fundamentals I/String basics/Concatenation/task.py
224
4.28125
4
# ----- concatenation ----- name = "Bob" # modify this age = "42" # modify this # substitute <name> with the contents of name and age (using the variables!) print("My name is " + name + " and I'm " + age + " years old")
66a84c837c393eb0fd3bf118980831845561ae1d
ctrl-nivedha/backtracking-sudoku
/sudoku_backtracker/sudoku-backtracker.py
2,413
3.828125
4
# -*- coding: utf-8 -*- """ Created on Sun Apr 19 19:48:46 2020 @author: Mro """ row= False col= False board = [ [0,3,0,0,0,5,0,8,0], [0,5,0,0,0,9,0,0,0], [0,0,0,0,2,0,0,3,0], [3,0,0,0,0,0,0,9,0], [0,0,5,0,0,0,6,0,0], [0,9,0,0,0,0,0,0,8], [0,1,0,0,3,0,0,0,0], [7,0,...
3c8d173582166f5a5f6a7e15f6c9b59687c6ed00
s1monLee/CodingChallenge
/LeetCode/Python3/1512_Number_of_Good_Pairs.py
678
3.515625
4
""" Given an array of integers nums. A pair (i,j) is called good if nums[i] == nums[j] and i < j. Return the number of good pairs. """ """ class Solution: def numIdenticalPairs(self, nums: List[int]) -> int: pair = 0 for i, n in enumerate(nums): for j in range(i+1,len(nums)): ...
9db50e34cc5777797536a0ececee2760be9be747
yize11/1808
/14day/07-默认参数.py
135
3.765625
4
def a(b,c=100): for i in range(b,c): if i%3 == 0 and i%5 == 0: print(i) b = int(input('请输入数字')) a(b)
17523829e6e1e93c53320b897ca889b9d846058f
isbirukov/diff_courses
/Deep_Learning_2019_2020_base_flow/3.3_homework_sum_diag_even_elements.py
663
3.875
4
""" Напишите функцию, которая находит сумму четных элементов на главной диагонали квадратной матрицы (именно чётных элементов, а не элементов на чётных позициях!). Если чётных элементов нет, то вывести 0. Используйте библиотеку numpy. Входные данные -- квадратный np.ndarray. """ import numpy as np def diag_2k(a): ...
b465071b74da54e33626f6a8777ceb8801146b2c
L316645200/_Python
/fluent_python_eg/9 、符合Python风格的对象/9.5 格式化显示.py
813
3.59375
4
brl = 1/2.43 print(brl) print(format(brl, '0.4f')) print('1 BRL = {rate:0.2f} USD'.format(rate=brl)) # 格式规范微语言为一些内置类型提供了专用的表示代码。 # 比如,b 和 x 分别表示二进制和十六进制的 int 类型,f 表示小数形式的 float 类 型,而 % 表示百分数形式 print(format(42, 'b')) print(format(2/3, '.1%')) # 格式规范微语言是可扩展的,因为各个类可以自行决定如何解释 format_spec 参数。 # 例如, datetime 模块中的类,它们的 __...
f5fa95227eaa5c0bf63de562fdb2d8306407e1d4
manishakoirala/python
/sums_loop.py
240
3.609375
4
print("input data :") N=input() listnum1 =[] listnum2 =[] for i in range(N) : listnum1.append(input()) for x in range(N): listnum2.append(input()) print("output data:") for j in range(N): sumn=listnum1[j]+listnum2[j] print(sumn)
3d73044416539da2865987a64c43325c589e15a5
RJD02/Joy-Of-Computing-Using-Python
/Assignments/Week-12/Assignment12_2.py
1,182
3.734375
4
''' Ramesh and Suresh have written GATE this year. They were not prepared for the exam. There were only multiple choice questions. There were 5 options for each question listed 1,2,3,4,5. There was only one valid answer. Each question carries 1 mark and no negative mark. Ramesh and Suresh are so sure that there is n...
721ff59cc46883b8ea41fa9563d7031a382c550f
tchdesde/cloud-developer
/bikeshare.py
11,038
4.4375
4
import time import pandas as pd import numpy as np CITY_DATA = { 'chicago': 'chicago.csv', 'new york city': 'new_york_city.csv', 'washington': 'washington.csv' } MONTHS_DATA = ['january', 'february', 'march', 'april', 'may', 'june', 'all'] DAYS_DATA = ['monday', 'tuesday', 'wednesday',...
2a08949e93681d7e2d36812e1f617172696396b2
IvanRado/AI
/LinearRegression/systolic.py
1,148
3.78125
4
if __name__ == "__main__": # Example computing systolic blood pressure from age and weight # The data (x1, x2, x3) are for each patient # x1 is the systolic blood pressure # x2 is the age in years # x3 is the weight in pounds import numpy as np import pandas as pd import matplotlib.pyp...
88f69835ee782f7489758cd4a2e07887eab2e2b9
SACHSTech/livehack-1-python-basics-BrianLi15
/problem1.py
598
4.625
5
---------------------------------------------------------------------- Name: problem1.py Purpose: Given the user input of celsius, it can convert the celsius temperature to fahrenheit Author: Li.B Created: 07/12/2020 ---------------------------------------------------------------------- #This gets the user input...
4d009a61f55252eb2414efdf12f721eba62ee8e4
kateleecheng/Python-for-Everybody-Specialization
/2_Python Data Structures/Week_4_Class2.py
517
3.578125
4
#Week_4_Class2.py a=[1,2,3] b=[4,5,6] c=a+b print(c) print(a) t=[9,41,12,3,74,15] print(t[1:3]) # up to but not including!! print(t[:4]) print(t[3:]) print(t[:]) stuff=list() #list with nothing stuff.append('book') stuff.append(99) print(stuff) stuff.append('cookie') print(stuff) friends=['Joseph...
29dfe80b2342dce80aae715e71acce4c2d66769f
benedictuttley/CM1101-Project
/game.py
1,944
4.21875
4
#This is the main game engine # prints current room (example : print_room(rooms["Room1"]) def print_room(room): print() print(room["name"].upper()) print() print(room["description"]) print() # takes a dictionary of exits and a direction returns the name of the exit it leads to # example ( exit_...
93fa43b7deb4ad79e0e1ff8ba3b84fb3609f3e32
benbendaisy/CommunicationCodes
/python_module/examples/881_Boats_to_Save_People.py
1,131
3.96875
4
from typing import List class Solution: """ You are given an array people where people[i] is the weight of the ith person, and an infinite number of boats where each boat can carry a maximum weight of limit. Each boat carries at most two people at the same time, provided the sum of the weight of those peo...
6400fad3abb28af292e4898d793f32449ea3a5da
WirKekc/prject1
/stepik.org/stringIn.py
221
3.546875
4
a = input() b = input() s = set() if a.find(b) == -1: print(a.find(b)) else: for i in range(len(a)): if a.find(b,i) != -1: s.add(a.find(b, i)) s = sorted(list(s)) print(*s, sep=" ")
f7639f508f734bc21e58fa27b134618cdf88e724
Naimulnobel/uri-online-judge
/problem8.py
216
3.78125
4
# -*- coding: utf-8 -*- """ Created on Thu Jan 31 15:23:55 2019 @author: Student Mct """ a=input('Employee Number ') b=input() c=input() amount=int(b)*float(c) print('NUMBER =',a) print('SALARY = U$',amount)
83207c6c395fb6864dbe9b48add827620166ace9
Unit26/EpicPython
/23_get_parity.py
171
3.859375
4
def fun(x): if x % 2 == 0: return ' чётное ' else: return ' нечётное ' x = int(input('Введите число: ')) print(fun(x))
79b5b843ea30a444569f75af0b5fd848be9d294e
vinija/LeetCode
/81-search-in-rotated-sorted-array-ii/81-search-in-rotated-sorted-array-ii.py
696
3.5625
4
class Solution: def search(self, nums: List[int], target: int) -> bool: start = 0 end = len(nums) -1 while start <= end: mid = (start + end)//2 if target in [nums[mid], nums[start], nums[end]]: return True eli...
936324de85562d3841be2253c56c52088602f22a
Quarantinex/Hackerrank_Python_Algorithm
/Repeated_Sting.py
164
3.671875
4
def repeatedString(s, n): x,y = divmod(n,len(s)) return s[:y].count("a")*(x+1) + s[y:].count("a")*x s = input() n = int(input()) print(repeatedString(s, n))
bc3061ba4c5af24e3923d20fec9fb1ec15539d9c
meltemtokgoz/Sentence-Or-Not-Context-free-grammar
/code/assignment3.py
5,380
3.640625
4
import random # find necessary comment line number def find_line_num(path): start_vocab = 0 start_rule = 0 with open(path) as f: for line in f: start_vocab += 1 if '# Vocabulary. There is no rule for rewriting the terminals.' in line: break with open(pat...
ced3c790c3d8d19a451c078e57db8da76d3b2a50
paigetruelove/AirOvalCode
/graph_maker.py
5,558
4.03125
4
import pandas as pd import matplotlib matplotlib.use('Agg') from matplotlib import pyplot as plt import datetime import matplotlib.dates as mdates def getdata(daysToGet): """ This function imports the CSV file which contains the sensor data, and selects a specified data timeframe to create a graph. daysT...
1e8137947f4de94f5fde222e3f09154cea837880
Computational-Physics-Research/Computational-Physics-1
/PythonProgramming/Homework 08/wood_10.2.py
1,038
3.828125
4
""" Problem 2 Hypersphere Volume """ import numpy as np import numpy.random as ran import matplotlib.pyplot as plt # main function definition def multisphere_volume(n_dims, n_samples, radius = 1): # initialize some working params n_iter = 0 points = 0 while n_iter < n_samples: # gen...
83127d3519a1e00413bcb56a3034c348337ad522
JohnKearney2020/python
/class.py
928
4.25
4
#print("I\'m a string") #concatinating #print("Hello" + " world") #escape symbols # print('I\'m a string') # print('I\'m a \t\t\t\t string') # print('I\'m a \v\v\v\v string') #print("hello \nworld") # name = "John" # lname = "Kearney" # output = "Good morning {student1} {student2}".format(student1=name,student2=ln...
0800ff57bb7170cb49ac6546fbbc64bba5ce2fe3
DanielMartinez79/Algorithms
/AlgLab1F.py
3,871
3.796875
4
# -*- coding: utf-8 -*- """ Created on Wed Sep 27 19:02:37 2017 @author: Danny This lab compares the average and worst case performance of linear and binary search """ import random import time import math #linear search def linear(arr, key): for x in range(0, len(arr)): if (arr[x] == key): #...
9096b7a3e5687e4fe126743e84b588d0449fd1f4
julienemo/exo_headfirst
/2-phraseomatic.py
1,121
3.71875
4
# this program generates random phrases structured as # verb+adj+noun # where each part is chosen randomly from their given list import random # import the fonction that otherwise in not # automatically include # then the three lists # NB Atom encourages putting both brackets alone # instead of on the same row as co...
851d71b875500739081a505d0f404e3364013c5c
sreedhar9999/python-first
/lagnum.py
118
3.890625
4
x=int(raw_input()) y=int(raw_input()) z=int(raw_input()) if(x>y>z): print(x ) elif(y>x>z): print(y) else: print(z)
169e82d04d9086d2f3f1195bb04d16830fe28d02
gclegg4201/python
/input3_while.py
153
4.09375
4
print("INPUT THREE NUMBERS") a=float(input('A:')) b=float(input('B:')) c=float(input('C:')) x=0 while True: y=a*x*x+b*x+c print("x =",x,"y =",y) x+=1
40775417e7ba92bfa3c083c2e3d495390c5724e7
Aasthaengg/IBMdataset
/Python_codes/p03080/s133965546.py
266
3.6875
4
def main(): _ = int(input()) s = input().rstrip() r, b = 0, 0 for c in s: if c == "R": r += 1 else: b += 1 if r > b: print("Yes") else: print("No") if __name__ == "__main__": main()
f8a8da2c8b2162cb5b629083e023211c4c504773
FaizIkhwan/Competitive-Programming
/Al-Khawarizmi/2014/h.py
199
3.640625
4
t = int(input()) for i in range(t): inp = str(input()) if list(inp) == list(reversed(inp)): print('Case #{}: Yes'.format(i+1)) else: print('Case #{}: No'.format(i+1))
24a8d2229edae8f55ec33137112200bb334815bc
Ydeh22/CRPM
/crpm/quantilenorm.py
588
3.796875
4
""" quantile normalize matricies by rows """ def quantilenorm(matrixlist): """ normalizes matricies to have corresponding rows with similar distributions Args: matrixlist: a list of 2D array-like objects all with same number of rows. Returns: A matrix list of the transformed original matri...
e3566deed8917f4354670b3e2ef5d999d5ab12fa
chinmairam/Python
/regex14.py
756
3.8125
4
import re print(re.search(r"[a-zA-Z]{5}", "a ghost")) print(re.search(r"[a-zA-Z]{5}", "a scary ghost appeared")) print(re.findall(r"[a-zA-Z]{5}", "a scary ghost appeared")) print(re.findall(r"\b[a-zA-Z]{5}\b", "A scary ghost appeared")) print(re.findall(r"\w{5,10}", "I really like strawberries")) print(re.findall(r"\w...
46cf731f6d28256f3e52114b23946d529a116400
jems-lee/adventofcode
/2019/day03.py
2,923
3.734375
4
from dataclasses import dataclass @dataclass class Point: x: int y: int def __add__(self, other): return Point( self.x + other.x, self.y + other.y ) def __sub__(self, other): return Point( self.x - other.x, self.y - other.y ...
237d12a50601b6a5438d63ea9ccb0cbd3de8ff3b
sohom-das/Python-Practice
/LPTHW - Ex17.py
1,122
3.6875
4
from sys import * #importing function from the sys module from os.path import * #importing function from os.path module script, from_file, to_file = argv #get argv command line arguments (w...
fa2856baf58fe22a47c900bba3bd85b5867d0deb
polku/python_stuff
/timeout.py
935
3.625
4
#!/usr/bin/python3 """ Mechanism to timeout if a function takes too much time """ import random import signal import time from functools import wraps class TimeoutException(Exception): pass def sig_handler(signum, frame): raise TimeoutException() def timeout(delay): def timeout_sec(func): @w...
07e157319c6c33c155fb096996d0514c365128d8
kahlb/btce_calcs
/btce_portfolio.py
1,475
4.03125
4
#!/usr/bin/env python2.7 # this software calculates the current value of your portfolio # author kahlb, ltc donations welcome :) LSRLVCerfwbAxBEyZJ4JtcZPdVwxc4zWs2 fee=0.2 feecalc=1-(fee/100) #makes the fee easier to calc. Just multiply with this value. currnumber = input("Enter the number of different currencies i...
d7483fee3f38bcff15ab34d1f5768479f22605c6
iGoWithYou/Laboratories
/lab1.1.py
269
3.828125
4
# -*- coding: utf-8 -*- """ Created on Wed Mar 20 16:01:09 2019 @author: Mati """ from math import* x = 56 z = 0 while x <= 100: y = 2*(x**2) + 2*x + 2 print('for x = ',x,'function value y = ',y) x = x+1; z = z + y; print('function y total value = ',z)
0f934c3c6a3429ae1b044ebc04c3e64dcba83c64
fikrirazor/bigramindo
/tesbigram/testbigram2.py
611
3.640625
4
# -*- coding: utf-8 -*- """ Created on Sun Feb 10 23:44:06 2019 @author: Rozan """ #countofwords #menghitung jumlah kata W = ("saya","makan","nasi","goreng","di","rumah") jumlahdata = {} pw=len(W) for i in range (pw): if W[i] in jumlahdata: jumlahdata[W[i]] += 1 else: jumlahdata[W[i]] = 1 #men...