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
037516f4744eee2121721a5806a1ebfa4c930b91
qianli2424/test11
/python_Practice/test.py
209
3.59375
4
# -*- coding-utf8 -*- # author :xiaosheng #文件说明 #创建时间:2019/12/16 print ('hello word') print(1+2*10) print('you age is \\test',str(20)) print(r'you age is \test',str(20)) print('hello','***')
6cd674cba2d8ca4e1e18695aa2ad1a2ae1cd36a7
nkorobkov/competitive-programming
/codeforces/1165/dtest.py
100
3.53125
4
print(25) for i in range(25): print(300) print(' '.join(list(map(str, range(i+3, i+303)))))
2299870e7d62ce84ed49d188bafcc519c744c09f
MACHEIKH/Datacamp_Machine_Learning_For_Everyone
/21_Introduction_to_Deep_Learning_with_Keras/2_Going_Deeper/exploringDollarBills.py
1,170
4.125
4
# Exploring dollar bills # You will practice building classification models in Keras with the Banknote Authentication dataset. # Your goal is to distinguish between real and fake dollar bills. In order to do this, the dataset comes with 4 features: variance,skewness,kurtosis and entropy. These features are calculated ...
0416e3b28cd13cd7eea9ef20e0dcaaba04f0aa11
SpykeX3/NSUPython2021
/problems-2/v-nikiforov/problem1.py
198
3.546875
4
n = int(input()) print( [ (x, y, z) for x in range(1, n) for y in range(1, n) for z in range(1, n) if x ** 2 + y ** 2 == z ** 2 if x <= y ] )
674d299bcd7d2103c99954e3d4730513a39d27e4
cwjshen/dailycodingproblems
/python/3-serialize-binary-tree.py
2,259
3.984375
4
# This problem was asked by Google. # Given the root to a binary tree, implement serialize(root), # which serializes the tree into a string, and deserialize(s), which deserializes the string back into the tree. # For example, given the following Node class # class Node: # def __init__(self, val, left=None, right...
fe6cfad1f1855e147acb40294a1dee598120db2a
nickthorpe71/python-playground
/cs50/pset6/lecture/scores.py
130
3.703125
4
scores = [72,73,33,33,55,66,77,88] print("Average: " + str(sum(scores) / len(scores))) s = raw_input("type: ") print(s.upper())
1af60fd5d0831c800e6f58d476187baa35f22b1f
tingxuelouwq/python
/src/com.kevin.python/advance/generator.py
834
4.09375
4
# 生成器 # 斐波那契数列模块 def fib(n): print(__name__) count, a, b = 0, 0, 1 while count < n: print(a, end=' ') a, b = b, a + b count = count + 1 print() def fib2(n): print(__name__) count, a, b = 0, 0, 1 while count < n: yield a a, b = b, a + b count ...
f94522e9cf49ceae0a05c6e3dc52d31be1f3ce4b
ryanolv/Learning-Python
/DesafioPOO/clientes.py
426
3.6875
4
from abc import ABC, abstractmethod class Pessoa(ABC): def __init__(self,nome,idade): self.__nome = nome self.__idade = idade @property def nome(self): return self.__nome @property def idade(self): return self.__nome class Cliente(Pessoa): de...
e9b4f17bf11e18f4c64a0928561c713c3a4415b8
gabrielramospereira/codes
/python/ex038 - maior.py
319
4.09375
4
n1 = int(input('Digite o primeiro número:')) n2 = int(input('Digite o segundo número: ')) if n1 > n2: print('O número {} é maior que o número {}'.format(n1,n2)) elif n1 < n2: print('O número {} é menor que o número {}'.format(n1,n2)) else: print('O número {} é igual ao número {}'.format(n1,n2))
f66fc1caf0f7ffcbaa91e0f97448dedb52d277ad
debolina-ca/my-projects
/Python Codes 2/List with count().py
250
4.09375
4
cities = ["New York", "Shanghai", "Munich", "Tokyo", "Dubai", "Mexico City", "São Paulo", "Hyderabad"] search_letter = "a" total = 0 for city_name in cities: total += city_name.lower().count("a") print("No. of 'a's in the list is", total)
26217d1ae8669e89d8257b3d1aa14987a7ee98f3
IshfaqKhawaja/Saving-Lists-in-Python-without-use-of-numpy-or-pickle
/Saving_lists_into_text_file.py
627
3.859375
4
# If you wanna save list into txt file and load it as list in python # IF you wanna save list into file as retrieve it back as list # with out using pickle or numpy in python # here is a trick import json data = [1, 2, 3, 4, 5] print(data[4]+data[2]) with open('bin.data', "wb") as file: file.write(json.dumps(dat...
ecace532f38b915b5722b61849f20fc9c82d23bb
KBataev/lab_python
/1/lab3.1.py
124
3.515625
4
string = 'FastEthernet0/1' print(string.replace('Fast', 'Gigabit')) MAC = 'AAAA:BBBB:CCCC' print(MAC.replace(':', '.'))
1d338b65838d5b0dc83b664f1233fd639e141dba
karolinanikolova/SoftUni-Software-Engineering
/1-Python-Programming-Basics (Sep 2020)/Course-Exercises-and-Exams/03_Conditional-Statements-Advanced/00.Book-Exercise-4.1-13-Point-in-the-Figure.py
1,864
4.09375
4
# точка във фигурата # Фигура се състои от 6 блокчета с размер h * h, разположени като на фигурата. Долният ляв ъгъл на сградата е на позиция {0, 0}. # Горният десен ъгъл на фигурата е на позиция {2*h, 4*h}. На фигурата координатите са дадени при h = 2: # # Да се напише програма, която въвежда цяло число h и координати...
c95cea11aa99a9f21bf821bbca44407cea3d60f9
QuisEgoSum/different
/algorithms/sort/insertion/insertion.py
478
3.84375
4
def main(): lenght = int(input('Lenght: ')) array = [None] * lenght for i in range(lenght): array[i] = int(input('Item {}: '.format(i))) print('Source array: ', array) for i in range(lenght): key = array[i] j = i - 1 while j >= 0 and array[j] > key: ...
0d6867a6f7cd976bbc731645aac7244357e6af12
WayneLambert/portfolio
/apps/blog/search.py
201
3.53125
4
import re def cleanup_string(q: str) -> str: """ Performs initial cleanup removing superfluous characters """ pattern = '[^a-zA-Z0-9" ]+' return re.sub(pattern, '', q).strip().casefold()
641dca7ade0794d21a667aa6b2380417f2e92ff3
popovale/python-stepic
/zad3_slovar_s_funcshion_v2_rab.py
208
3.578125
4
# Задача на словари урок3.2 def f(x): rez=x+1 return rez n=int(input()) d={} for i in range(n): x = int(input()) if x not in d: d[x]=f(x) print(d[x]) # print(d)
9212aab6bd078818314fb123c6d466952c50cf29
msilvprog7/get-with-the-program
/world/characters.py
5,521
3.890625
4
import pygame class Face: """ Represent the direction a character is facing """ LEFT = -1 RIGHT = 1 @staticmethod def is_facing_left(face): """ See if character is facing left """ return face == Face.LEFT @staticmethod def is_facing_right(face): """ See if character is facing right """ return face == ...
5fce0c197cabb709c75775f5acc3cddd1d2411c1
BerilBBJ/scraperwiki-scraper-vault
/Users/N/NicolaHughes/dod-contracts.py
3,724
3.609375
4
import scraperwiki from bs4 import BeautifulSoup # documentation at http://www.crummy.com/software/BeautifulSoup/bs4/doc/ # Searching for "Minsitry of Defence" on contracts finder excluding tenders fewing 200 results per page search_page = "http://www.contractsfinder.businesslink.gov.uk/Search%20Contracts/Search%20Co...
60ffff6e36f65c3e85fed41153792313f2ede3c9
rojit1/python_assignment
/q15.py
354
4.25
4
# 15. Write a Python function to insert a string in the middle of a string. # Sample function and result : # insert_sting_middle('[[]]<<>>', 'Python') -> [[Python]] # insert_sting_middle('{{}}', 'PHP') -> {{PHP}} def insert_sting_middle(s1, s2): middle = len(s1)//2 return s1[:middle]+s2+s1[middle:] print(in...
4aab3e8608e1c8710b1f62c9dbfcb39cb03c060d
SudhuM/Cart-Manager
/CartManager.py
4,324
3.5
4
from tkinter import * from tkinter import messagebox from tkinter import Event from tkinter import Listbox # app initilaization app = Tk() app.title("Parts Manager") app.geometry('550x330') # keeps entries = [] # text_variable = StringVar() # entry addition to the list box with proper checking , whether the users # ...
a29ecb8b2d9f1f3971b4877bfd1eefa739bc47a8
Momotaro10000/Arithmetic-arranger
/arithmetic_arranger.py
1,819
3.765625
4
def arithmetic_arranger(problems, *args): if len(problems) > 5: return "Error: Too many problems." result = [] for problem in problems: operation = problem.split() if operation[0].isnumeric() is False or operation[2].isnumeric() is False: return "Error: Numbers...
23b678da96b21df5751eb1ff23c55f34aeac589c
maribelcuales/Intro-Python
/src/dicts.py
534
4.34375
4
# Make an array of dictionaries. Each dictionary should have keys: # # lat: the latitude # lon: the longitude # name: the waypoint name # # Make up three entries of various values. waypoints = [ { "lat": "33.888 S", "lon": "151.2093 E", "name": "Sydney" }, { 'lat': 106.7288, 'lon': 0.696...
b93bbd2068c67bc94239d28f81e6a2678915bb0b
valleyceo/code_journal
/1. Problems/i. Recursion & Backtrack/Template/d. Random - Random Subset.py
857
3.984375
4
# Compute a Random Subset ''' - Given a positive integer n and a size k <= n - Return a size-k subset from {0, 1, 2, ..., n-1} ''' # time: O(k) | space: O(k) def random_subset(n: int, k: int) -> List[int]: changed_elements: Dict[int, int] = {} for i in range(k): # Generate a random index between i and...
befc8b7ef2057879e52240ac09cb74bd51bb173e
ioannis-papadimitriou/snagger
/Classic_ML/DL/ANN/.ipynb_checkpoints/full_ann-checkpoint.py
3,577
3.515625
4
# Artificial Neural Network # Installing Theano # pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git # Installing Tensorflow # Install Tensorflow from the website: https://www.tensorflow.org/versions/r0.12/get_started/os_setup.html # Installing Keras # pip install --upgrade keras # Part 1 - Data...
64022fc90de1ee460faef1ce06a76e7c41e21e19
wimbuhTri/Kelas-Python_TRE-2021
/P4/tugas3.py
115
3.9375
4
X=int(input("1: ")) Y=int(input("2: ")) P=X+Y if P >= 0: print("+") Q = X*Y else: print("-") Q = X/Y print(Q)
8437844878811a6676423a6c86dda682c14171a3
remixknighx/quantitative
/exercise/leetcode/validate_stack_sequences.py
1,062
3.75
4
# -*- coding: utf-8 -*- """ 946. Validate Stack Sequences @link https://leetcode.com/problems/validate-stack-sequences/ """ from typing import List class Solution: def validateStackSequences(self, pushed: List[int], popped: List[int]) -> bool: empty_stack = [] for push_word in pushed: ...
9eb2642f9f08989c3ddc5399f7a41c7946e9b0bf
FirelCrafter/Code_wars_solutions
/6_kyu/Your_order_please.py
153
3.5
4
def order(sentence): return ' '.join(sorted(sentence.split(), key=lambda a: next(b for b in a if b.isdigit()))) print(order('is2 Thi1s T4est 3a'))
763afd2ec62a37b7de57e7eb84c259c92d82060b
MurradA/pythontraining
/Challenges/P106.py
139
3.5
4
file = open("P106_Names.txt", "w") for i in range(0,5): name = input("Enter a name: ").strip() file.write(name+"\n") file.close()
533393575c6060207a283ff9f5ac46712180d1eb
DavidMarquezF/InfoQuadri2
/Exercicis Puntuables/Exercici Entregable 3 - Kursaal/Entrada.py
1,385
3.765625
4
class EntradaGeneral(object): def __init__(self, nom, preu = 10): self.galliner=True self.nom = nom self.__preu = preu def __eq__(self, other): return False def __str__(self): print "Entrada KURSAAL" if(self.galliner): return "Galliner. " + str(...
75a4784e4a2aab4095c2df618b19fc1fbf776369
grogsy/python_exercises
/other/memoization/tower_of_hanoi.py
336
3.734375
4
# This example(and other recursive examples in general) seem to benefit from memoization def hanoi(n): '''calculate the number of moves it costs to move disks among three needles in such a way that larger disks cannot be placed on top of smaller disks''' if n == 0: return 0 else: return 2 *...
e3c593a994bd3f9677bac179f668bbeb2cadbdb2
yaswanth12365/coding-problems
/find largest number in a list.py
173
4.3125
4
# Python program to find largest # number in a list # list of numbers list1 = [10, 20, 4, 45, 99] # printing the maximum element print("Largest element is:", max(list1))
80d35e56201b616e3b6c7bd91849d84da5840cd8
anila-a/CEN-206-Data-Structures
/lab07/ex4.py
548
4.03125
4
''' Program: ex4.py Author: Anila Hoxha Last date modified: 05/08/2020 Given a Binary Search Tree. The task is to find the maximum element in this given BST. If the tree is empty, there is no minimum element, so print -1 in that case. ''' from bst import * n = input() n = list(map(int, n.split(" "))) # S...
1e520c233587ac1a817a29a8a04df0bcba727612
Shrimad-Bhagwat/DODGE-CAR-RACE
/main.py
11,189
3.78125
4
#Importing the library import pygame from car import Car,Bush import random from pygame import mixer pygame.init() #define some colors BLACK = (0,0,0,) WHITE = (255,255,255) GREEN = (0,255,0) DARK_GREEN = (0,100,0) RED = (255,0,0) GREY = (169,169,169) DARK_GREY = (71,71,71) # light shade of the button...
ab74bd34811246804bd98f493714c643a5bd1d49
tdesfont/TensorFlow-DQN-CatMouseGame
/biocells/biocells_model.py
7,215
4.28125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ BIOCELLS MODEL: Set up the context for the agent, environment on learning and also the main methods as step, reward and possible actions. The environment is a square of 30 by 30. (Its left-down corner being the origin.) The prey is the agent controlled by our algori...
202bb65650e391ef309c456f3462b4637f4fb9fe
Igglyboo/Project-Euler
/Helper Functions/sieve.py
315
3.75
4
def sieve(upper_bound): prime = [False, False, True] + [True, False] * (upper_bound // 2) for p in range(3, int(upper_bound ** .5) + 1, 2): if prime[p]: for i in range(p * p, upper_bound, 2 * p): prime[i] = False return [p for p in range(2, upper_bound) if prime[p]]
116ce9cd9372af524a64ac79942219b88ecb98c0
martinmeagher/UCD_Exercises
/Module5_Data_Manipulation_Pandas/Inspecting_DataFrame.py
594
3.6875
4
# Import pandas using the alias pd import pandas as pd # import homelessness.csv homelessness = pd.read_csv("homelessness.csv") # Print the head of the homelessness data print(homelessness.head()) # Print information about homelessness print(homelessness.info()) # Print the shape of homelessness print(homelessness....
c5c7c7538dd9597a261f7686eb0bcc3bce532c83
furgot100/spd-hw
/Variable table/problem1.py
938
3.875
4
# Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length '''Given nums = [1,1,2], Your function should return length = 2, with the first two elements of nums being 1 and 2 respectively. It doesn't matter what you leave beyond the returned length.'''...
96c5568a51e0f05a05736d04f2b5e1ebabf9a5df
abhishekk3/Practice_python
/encrypt_decrypt.py
559
3.828125
4
#Below function is to encrypt/decrypt the strings which are in the repititive sequence of characters from collections import OrderedDict def encrypt(): s='abbhhiiii' A=[] sub=list(s) for letter in OrderedDict.fromkeys(s): count=0 while letter in sub: count+=1 sub.remove(letter) A.app...
ac9579b938c61e7262ad07d298d7ea903ba925e4
tatsuya-nagashima/atcoder
/abc219/a.py
155
3.59375
4
X = int(input()) if 0 <= X < 40: print(40 -X) elif 40<= X < 70: print(70 -X) elif 70<= X < 90: print(90 -X) elif X >=90: print('expert')
1e064dfb90d593d831ff07cbdc9df09ec3c3747b
cheykoff/thinkpython2e
/9-1-long-words.py
1,113
3.5625
4
def print_long_words(): fin = open('words.txt') count16 = 0 count17 = 0 count18 = 0 count19 = 0 count20 = 0 count21 = 0 count22andmore = 0 for line in fin: if len(line) > 15: if len(line) > 21: count22andmore = count22andmore + 1 elif l...
00e6c94de6c0740e85ef17a56fdc583aca0aeae4
knotknull/python_beyond_basics
/list1.py
2,856
4.40625
4
#!/usr/bin/python3.5 # list : heterogeneous mutable sequences of bytes # get a list from split s = "eenie meenie minie moe piggie . .. ...".split() print(s) # use a negative index to get piggie # -8 -7 -6 -5 -4 -3 -2 -1 # "eenie meenie minie moe piggie . .. ..." print("s[-4] = {}".format(s[-4])) # N...
2574175046e0a625d8714c44b48b92a2b043314e
FIRESTROM/Leetcode
/Python/251__Flatten_2D_Vector.py
674
3.625
4
class Vector2D(object): def __init__(self, vec2d): """ Initialize your data structure here. :type vec2d: List[List[int]] """ self.list = [] for lst in vec2d: self.list += lst self.length = len(self.list) self.index = -1 def next(self)...
997e508d2cfc920519cdf571728fceecbaedf9c4
UWPCE-PythonCert-ClassRepos/SP_Online_Course2_2018
/students/smitco/lesson06/calculator/calculator/subtracter.py
207
3.859375
4
"""Subtracts two numbers""" class Subtracter(): """Class for subtracter""" @staticmethod def calc(operand_1, operand_2): """Perform subtraction""" return operand_1 - operand_2
b9839e6a28b1c4b2250f5ed6097ebfb0d4e2038a
iamkissg/leetcode
/interview/华为/最大子数组和.py
389
3.5
4
from typing import List class Solution: def maxSubArray(self, nums: List[int]) -> int: ans = nums[0] sub_max = nums[0] for n in nums[1:]: sub_max = max(sub_max+n, n) if sub_max > ans: ans = sub_max return ans if __name__ == "__main__": s...
4f14e68fac0be5a0f5515f968c58c1ffdde9062e
xiebinhome/python--
/作业/010列表增加成员.py
253
3.75
4
print("列表增加数字") member = ['小甲鱼', 88, '黑夜', 90, '迷途', 85, '怡静', 90, '秋舞斜阳', 88] count = 0 length = len(member) for each in range(len(member)): if each%2 == 0: print(member[each], member[each+1])
7329a151bc179c0a79ad54770d400e90082955ad
Kori3a/M-PT1-38-21
/Tasks/Eugen Laikovski/tasks/home_work_0/hw_1_2.py
531
4.15625
4
from math import pow def calculation(): """ calculate the interest on the deposit """ try: start_sum = int(input('Enter your sum: ')) period = int(input('Enter your period (Years): ')) interest_rate = float(input('Interest rate %: ')) except ValueError: print('You values must...
b5246111c25c997ab3562d547c3e051ffd022d79
BONK1/Python
/complexConditionalStatements.py
803
4.1875
4
#Gender Liking Machine name = input("What's your name?") print(f'Hello {name},') print("NOTE: Type M (for male)") print(" Type F (for female)") print(" Type MF (for both)") gender = input("Your gender: ").upper() like = input("Your like: ").upper() if gender == 'M' and like == 'F': print(f'Congrats {na...
bebab37fd04e3828651ca886b2fcd0dae32b603b
henhuaidehaorena/magedu_python
/average_value.py
304
4.09375
4
#要求:輸入n個數,計算每次輸入后的平均值 # -*- coding: UTF-8 -*- #coding=utf-8 #等同於上面的聲明方式 #避免中文編碼異常 n=0 sum=0 while 1: digit=int(input('please input a digit:')) n=n+1 sum=sum+digit average=sum/n print('average value=',average)
83156a4fc5043ed962146b148befc038b38216ea
ThirdPartyNinjas/AdventOfCode2016
/day2a.py
435
3.78125
4
def clamp(n, smallest, largest): return max(smallest, min(n, largest)) def main(): x = 1 y = 1 movement = {'L' : {'x': -1, 'y': 0}, 'R' : {'x': 1, 'y': 0}, 'U' : {'x': 0, 'y': -1}, 'D' : {'x': 0, 'y': 1}} with open('day2a_input.txt') as f: for line in f: for c in line.strip(): x = clamp(x + movement[c]...
7b2942db76cd6d35eb8683b2cec7323a8c34a19f
Shiv2157k/leet_code
/goldman_sachs/find_pivot_index.py
777
3.890625
4
from typing import List class Array: def find_pivot_index(self, nums: List[int]) -> int: """ Approach: Prefix Sum Time Complexity: O(N) Space Complexity: O(1) :param nums: :return: """ # total_sum = sum(nums) total_sum = left_sum = 0 ...
522dced09ef4108e65b43358b1f8f6d3f3e3e230
MakeSchool-17/twitter-bot-python-DennisAleynikov
/dictionary_words.py
580
4
4
import random import sys # Function for making a capitalized sentence of len words out of wordlist dict def random_sentence(dict, len): words = random.sample(dict, len - 1) sentence = " " + " ".join(words) + "." sentence = random.choice(dict).title() + sentence return sentence if __name__ == '__main_...
ee8a94bffefd1683ffb1ba7a45b3d59fe279c329
nickbuker/python_practice
/src/lowercase_count.py
121
4.09375
4
from string import lowercase def lowercase_count(strng): return len([char for char in strng if char in lowercase])
ade51906917d4bb1deaf414f6847224e4ab3f135
renukamallade10/Python-problems
/Two dimensional list/lectures/spiralPrinting.py
1,025
3.859375
4
# -*- coding: utf-8 -*- """ Created on Wed Mar 11 12:50:33 2020 @author: cheerag.verma """ def spiralPrinting(arr): rowStart = 0 rowEnd = n colStart = 0 colEnd = m while rowStart<rowEnd and colStart<colEnd: for j in range(colStart,colEnd): print(ar...
682b7c9db6a6319c6e2f8313d6f4437d0886c671
esagiev/Multi-Agent_RL_with_PHC
/games.py
2,207
3.859375
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: # Developed by Erkin Sagiev, esagiev.github.io # Version on 15 September 2019. import numpy as np # To avoid "np is not defined" error. class matrix_game(): agent_num = 2 def agent_set(self): """ Returns the set of agents. """ return np.ar...
abcc8722c224c7099e733180f4a6bcc6cab69d13
jiangliu888/DemoForSpeed
/CI/python-coroutine/yield_8/test.py
215
3.53125
4
# -*- encoding=utf-8 -*- from yieldloop import coroutine,YieldLoop @coroutine def test1(): sum = 0 for i in range(1,10001): if i % 2 == 1: sum += yield i print('sum =', sum)
58391c43919d1f41ba60aee29fba2114c0336904
kimujinu/Introduction-to-Programming
/Turtle6.py
312
3.71875
4
import turtle t=turtle.Turtle() t.shape("turtle") while True : cmd = input("명령을 입력하시오: ") if cmd =="I": t.left(90) t.fd(100) elif cmd == "R": #else if t.right(90) t.fd(100) else : print("명령어는 I 또는 R 두가지입니다.")
a20790a6d13489fce95e3111fa21776f8ffe7c90
Antoshka-m/filter_sig
/flattening.py
1,290
3.5625
4
from scipy.stats import linregress import numpy as np def flattening(data, dt, chunk_l): """ Make flattening of raw data using windows (time chunks) of given size Parameters ------- data: list or np.array timeseries data (deflection magnitude) dt: float ...
dbb600d47f61ce8d7d83a00872c885047bc5e90d
angelasl/everything
/cyoa.py
1,826
4.125
4
start= "In a far away kingdom, there lived three orphan royals. Two twin sisters and an older brother named Timothy. You are the combined minds of the two sisters. You are plotting to kill Timothy to fight for the throne." print (start) #one print ("Do you want to choose the villager or poison. Type 'villager' or ...
4d4a735e6116a426eb0515fdfcc60c3b5d9a3f7d
JPeterson462/SettlersOfCatan
/gameserver/tile.py
986
3.5
4
from enum import Enum class TileType(Enum): MOUNTAINS = 1 PASTURE = 2 FOREST = 3 FIELDS = 4 HILLS = 5 UNKNOWN = 6 DESERT = 7 def get_tile_name(t): if t == TileType.MOUNTAINS: return ["Mountains", "Ore"] if t == TileType.PASTURE: return ["Pasture", "Wool"] if t == TileType.FOREST: return ["Forest", "Lum...
62a3d9600f4e83e0cba558a3e1b53c235c2a6f9a
gapigo/CEV_Aulas_Python
/Exercícios - Mundo 2/Ex050.py
174
4.0625
4
print('Digite 6 números: ') soma = 0 for c in range(0, 6): num = int(input('-> ')) if num % 2 == 0: soma += num print('A soma dos números pares foi', soma)
fa561ac96c7645933af1eaed678d3ae379135655
Dev2050/Python
/data_analysis_re_urlilib.py
1,514
3.515625
4
Python 3.7.0a1 (v3.7.0a1:8f51bb4, Sep 19 2017, 18:50:29) [MSC v.1900 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> import re >>> import urllib.request >>> def getStock(): url="https://finance.google.com/finance?q=" stock=input("Please enter the stock market name? ...
50c0034251204e8cafe13a80454012558f13fc8b
daniel-reich/turbo-robot
/od6i73gJxc6xGFzsz_5.py
653
4.34375
4
""" A number is considered _slidey_ if for every digit in the number, the next digit from that has an absolute difference of one. Check the examples below. ### Examples is_slidey(123454321) ➞ True is_slidey(54345) ➞ True is_slidey(987654321) ➞ True is_slidey(1123) ➞ False is...
86458ac4d721ae084863b401570f5b143a5adaaa
yyl2016000/algorithms_design
/BubbleSort.py
810
4.0625
4
def BubbleSort_raw(in_list : list): for i in range(len(in_list), 1, -1): for j in range(1, i): if in_list[j] < in_list[j-1]: in_list[j-1], in_list[j] = in_list[j], in_list[j-1] def BubbleSort_better(in_list : list): for i in range(len(in_list), 1, -1): flag = 1 ...
24cc943bd56170a09df1993ca21fad8390185110
vierth/hcs
/booleannonnum.py
201
3.796875
4
# Are two strings the same? "a" == "b" # False print ("a" is "a") # True a = ["hello"] b = ["hello"] print(a == b) # True print(a is b) # False print(id(a), id(b)) c = a print(a is c) # true
453477d13e090f22020a602cd4509a8ff30d020c
masadmalik71/Guess_Game
/main.py
1,693
3.90625
4
from replit import clear import random def game(number, attempts): game_countine = False while not game_countine: guessed_number = int(input(f"You have {attempts} remaining to guess the number.\nMake a guess: ")) if guessed_number == number: print(f"You got it! The answer was :{number}") gam...
ddc3327049e9a8eee828d70fe054849ed09c835b
hongcho7/Machine-Learning-Algo
/cross_validation.py
2,550
3.765625
4
''' df = data + target ''' import pandas as pd df = pd.read_csv("winequality-red.csv") ''' random shuffle - when you want to shuffle randomly - add the code inside/outside the loop ''' df = df.sample(frac=1).reset_index(drop=True) ''' holdout validation - also known as common splitting ''' df = df.sample(frac=1)....
9181406d3c62da8aecdf98e73ef3736b1c6a7a53
Jacksonleste/exercicios-python-curso-em-video
/ex063.py
314
4.09375
4
print('''{} SEQUÊNCIA DE FIBONACCI {}'''.format(12 * '=-', 12 * '=-')) num = int(input('insira um número:')) cont = 2 n1 = 0 n2 = 1 print('{} → {} → '.format(n1, n2), end='') while cont != num: n3 = n1 + n2 n1 = n2 n2 = n3 print('{} → '.format(n3), end='') cont = cont + 1 print('FIM')
0c59a8cab98f2b0ea7fdddb55cea77267f8bc82e
SaloniSwagata/Practice-Python
/palindrome.py
205
3.890625
4
def palin(text): if len(text)<=1: print("Palindrome") else: if text[0]==text[-1]: palin(text[1:-1]) else: print("Not a Palindrome") palin("Mysore")
91d68bc97a4e942d40f23c95adcc4768ac10ec0d
yangxicafuc/HardwayPython
/ex16.py
761
3.875
4
from sys import argv script, filename = argv print(f"We're going to erase {filename}.") print("If you don't want that, hit CTRL-C (^C).") print("If you do want that, hit RETURN.") input("?") print("Open the file...") target = open(filename, 'w') print("Trucating the file. Goodbye!") #target.trunc...
31c7e99a30b0f4d76ae802e5c9fd6fd3a81abac9
aacharyakaushik/i_code_in_python
/leetcode/48_rotate_image.py
743
3.921875
4
""" @author: Kaushik Acharya """ from typing import List def rotate(self, matrix: List[List[int]]) -> None: """ Do not return anything, modify matrix in-place instead. """ for i in range(len(matrix)): for j in range(i, len(matrix)): # temp = matrix[i][j] # matrix[i][j]...
e5ca8c9906fcae06b2ffb6bcd3540aa22beb3e11
jbteves/git_practice
/sub.py
163
3.53125
4
def sub(a,b): ans = float(a - b) return ans def main(): a = float(input()) b = float(input()) sub(a,b) if __name__ == '__main__': main()
b3f0a32cccc84098f33b714ae047285ff473e2b1
sai-gopi/gitpractice
/vs practice/swaping.py
83
3.75
4
a = int(input("enter a:")) b = int(input("enter b: ")) a,b = b,a print(a) print(b)
36f71d297dfdd0fdb0c2ba70d3c8780aab5f9dd4
arrimurri/simu
/chase.py
18,330
3.609375
4
import random import math import simu # Consult python documentation in http://www.python.org ######################################################################## # Put all your code for the chaser agent into this class. You have # to implement the execute method, but you can also add other methods # as well....
45caca991f0a4eba7d807e7205d75634f62ca126
vlad0-0/lab8
/task1.py
104
3.671875
4
a = int(input()) b = int(input()) if a != b: a = max(a, b) else: a = 0 b = a print(str(a)+" "+str(b))
3773d3e877488ab71902ec8b465c7825439b6edc
UjjwalDhakal7/basicpython
/inputstatement.py
1,089
4.1875
4
#Wap to read data from employee from the keyboard and print the data. ''' eno = int(input('Enter employee number :')) ename = input('Enter Employee name :') esal = float(input('Enter Employee salary : ')) eadd = input('Enter Employee address :') estatus = eval(input('Enter marriage status? [True|False] :')) pr...
0faa84125695775e3c487120e92116539034185b
laxmanlax/Programming-Practice
/MiscGlassdoor/fb.py
1,994
3.609375
4
#!/usr/bin/env python import sys # Without just doing: return max(arr) def get_max(arr): if len(arr) < 2: return arr return sorted(arr)[-1] # Without sorting. def get_max2(arr): if len(arr) < 2: return arr max_yet = arr[0] for e in arr: if e > max_yet: max_yet = e return max_yet ...
cf5cde753dd29eb41c1bb2a795654b99fa3bd364
andrewc91/Python_Fundamentals
/Python/sum_list.py
141
3.640625
4
a = [1, 2, 5, 10, 255, 3] print sum(a) #or a = [1, 2, 5, 10, 255, 3] total = 0 for numbers in a: total = total + numbers print total
eae62a24872283c0071f4103a48bdf5d4f5db202
Kevinpsk/LT614N
/load/packages/exercises/package_init_solution/main.py
267
3.8125
4
from conversion import * def main(): print(f"3 km is {distance.km_to_miles(3):.2f} miles") print(f"3 kg is {weight.kg_to_lbs(3):.2f} lbs") print(f"100 deg C is {temperature.celsius_to_fahrenheit(100):.0f} deg F") if __name__ == "__main__": main()
ba02a02c3b195fcb04e1639347e84d331c87de30
vyxxr/python3-curso-em-video
/Mundo1/007.py
262
3.890625
4
''' Desenvolva um programa que leia as duas notas de um aluno, calcule e mostre a sua média ''' n1 = float(input('Entre com a primeira nota: ')) n2 = float(input('Entre com a segunda nota: ')) print('A média ente {} e {} é: {:.1f}'.format(n1, n2, (n1+n2)/2))
029920342a56756633c84c2b95a9cd9cbe1bffd7
asheed/tryhelloworld
/excercise/ex099.py
494
3.671875
4
#!/usr/bin/env python # -*- coding: utf8 -* # 099 구구단 출력하기 (홀수만 출력하기) # # 사용자로부터 2~9 사이의 숫자를 입력 받은 후 해당 숫자에 대한 구구단을 출력하는 프로그램을 작성하라. 단, 구구단의 결과값이 홀수인 경우만 출력하라. # # 구구단: 3 # 3x1 = 3 # 3x3 = 9 # 3x5 = 15 # 3x7 = 21 # 3x9 = 27 dan = int(input('구구단: ')) for i in range(1, 10, 2): print(str(dan) + 'x' + str(i) + ' = '...
4fe7b46f83a0bcfaa8413db48c9012cf1146270d
xUlqx/Programacion-1
/Parcial-1/parrafos.py
468
3.578125
4
class Parrafo(): def __init__(self): self.lineas = [] def agregar_lineas(self, nombre): entry = input("\nIngrese parrafo. Para terminar ingresesolamente '.': \n") while entry != ".": self.lineas.append(entry) entry = input("") self.lineas = '...
59dcbbd08b53d168688366c702058cab6421b14d
jairajsahgal/DailyByte
/Uncommon_words.py
217
3.890625
4
def fun(s1,s2): s1=set(s1.split()) s2=set(s2.split()) print("S1: ",s1,"\nS2",s2) # print(s1-s2) return (s1.union(s2))-(s1&s2) def main(): s1=input("Enter s1") s2=input("Enter s2") print(fun(s1,s2)) main()
fcc7722e09fdd051c89a86bbc0eba53719aa7e71
huiqi2100/python2013lab4
/compress.py
984
3.53125
4
# Filename: compress.py # Author: Koh Hui Qi # Date created: 14 Feb 2013 # Description: Compress large textual documents # http://rosettacode.org/wiki/LZW_compression#Python def compress(uncompressed): """Compress a string to a list of output symbols.""" # Build the dictionary. dict_size = 256 dictio...
40607519a1b88c7249f468075870f5b1f2430c57
alinalimov/pythonProject
/pythonApp/alina.py
1,004
4.0625
4
#birth_year = input("enter birth year:") #import datetime #now = datetime.datetime.now() #age = now.year - int(birth_year) #print (age) #zodiac_sign = input("what month were you born?") month = input("what month were you born?") day = input("on what day were you born?") if int(month) == 1 and int(day) < 20: print (...
ce8e9adefc5ce80b8c31add4fd33a76b6014084f
ArhamChouradiya/Python-Course
/12function.py
217
3.875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Aug 3 23:06:37 2019 @author: arham """ def calc(a,b): x=a+b y=a-b z=a*b u=a/b return x,y,z,u for i in calc(10,5): print(i)
8f1ef8ab928bf8160cf2fe3e8e4b9c9c0feea21c
Thefloor075/ProjectEuler
/ProblemeEuler32.py
1,337
3.71875
4
""" We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once; for example, the 5-digit number, 15234, is 1 through 5 pandigital. The product 7254 is unusual, as the identity, 39 × 186 = 7254, containing multiplicand, multiplier, and product is 1 through 9 pandigital. Fin...
d04e2dcc8f0ca2c236d98bc8cf7bfdca648eef24
Infinidrix/competitive-programming
/Take 2 Contests/Contest 4/q2.py
1,045
4
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def isEvenOddTree(self, root: TreeNode) -> bool: path = collections.deque() path.append((roo...
948ac629318f91e18673ef8f98f5ca62639f2822
guolei0601/leetcode
/206.py
646
3.8125
4
#!/usr/bin/python # -*- coding: utf-8 -*- # @File : 206.py # @Author: guolei # @Time : 20/07/2019 2:59 PM # @Desc :反转链表 # @Ans :迭代法,创建一个节点存储下一个位置 # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): ...
5ec5c4ebc922d97073797b9b838e12421f1202db
MargitStar/python_course
/HW_1/Bobkova_Margarita.py
855
4.15625
4
input_string = "Не знаю как там в Лондоне, я не была."\ "Может, там собака - друг человека."\ "А у нас управдом - друг человека!" print("Original string: ", input_string) print("The amount of symbles: ", len(input_string)) print("Reversed string: ", input_string[::-1]) print("Capitilized string: ", input_strin...
cd6be002b265fed6014dbf985feddfda1c2856c4
BobbySweaters/Python-for-Everybody-Class-Labs
/1. Programming for Everybody/Chapter_3.2_Try_Accept_L.py
380
4.21875
4
# in this exercise we are going to include try/except protecton for traceback errors # when inputs are strings hrs = input("Enter Hours: ") rate = input("Enter Rate: ") try: h = float(hrs) r = float(rate) except: print("Error, please enter numeric input!") quit() pay = h * r if h <= 40: prin...
9bed7c7813a309ac8a19d5afce79958f4ff37b4c
ReejoJoseph1244/Hacktober2021-cpp-py
/BubbleSort.py
882
4.46875
4
#Bubble Sort Program implementation in Python, where the List is input by the user during the runtime. #This code is Contributed by Reejo. def Bubblesort(l,n): #BubbleSort function for i in range(0,n): for j in range(0,n-i-1): if l[j]>l[j+1]: l[j],l[j+1]=...
6fd131e3367378db3c9e0dd3e4673e80a8b0f0ab
Rayman96/LeetCode
/35_Search Insert Position.py
293
3.796875
4
class Solution: def searchInsert(self, nums: List[int], target: int) -> int: if target > nums[-1]: return len(nums) else: for index, number in enumerate(nums): if number == target or number > target: return index
29a921b99690829a69a1d1d86563e62911dfc463
Mohit-007/MACHINE-LEARNING
/Part 2 - Regression/Section 7 - Support Vector Regression (SVR)/svr.py
2,847
3.59375
4
# SVR # Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd class SVR: def __init__(self, learning_rate=0.001, lambda_param=0.01, n_iters=1000): self.lr = learning_rate self.lambda_param = lambda_param self.n_iters = n_iters self.w = None...
17fa1615c486d37e855be31b802ba07e7af4fd39
Pantufas42/Curso_Guanabara
/ex019.py
327
3.796875
4
from random import choice a1 = str(input('Nome do primeiro candidato: ')) a2 = str(input('Nome do segundo candidato: ')) a3 = str(input('Nome do terceiro candidato :')) a4 = str(input('Nome do quarto candidato :')) lista = (a1, a2, a3, a4) escolhido = choice(lista) print('O aluno escolhido foi: {}'.format(escolh...
f2faa18407a8b641aa603507f561a8b2f5200dd2
shsh9888/leet
/stack_implementation/sol.py
937
3.90625
4
class MinStack: def __init__(self): """ initialize your data structure here. """ self.stack=[] self.topmost =-1 def push(self, x): """ :type x: int :rtype: void """ if self.topmost is -1: self.stack.append((x,x)) ...
4f5a57e46e334b40a37a33f6489761d85de2f7fb
codesyariah122/MyPython
/classes/lat7.py
758
3.78125
4
class Kendaraan(object): def __init__(self, nama): self.nama = nama self.penumpang = [] def tambah_penumpang(self, nama_penumpang): self.penumpang.append(nama_penumpang) # membuat class mobil yang merupakan turunan dari class kendaraan class Mobil(Kendaraan): pintu_terbuka = False pintu_tertutup = False ...
eeb50c7fe51e4fef82d981dda947fc0ca991daba
shankar7791/MI-10-DevOps
/Personel/pooja/Assesment/16march/substring.py
204
4
4
def check(string, sub_string): if string.find(sub_string) == -1: print("no") else: print("yes") string = 'my name is pooja' sub_string = 'pooja' print(check(string, sub_string))
8bbdc722c6f02db6b7bfcc3e3da9487d47db77b9
adilhussain540/scheduling_algorithms
/FCFS.py
3,680
3.765625
4
class process: def __init__(self): self.id = 0 self.arrival_time = 0 self.burst_time = 0 self.start_time = 0 self.finish_time = 0 self.waiting_time = 0 self.turnaround_time = 0 def display(self): print(self.id, end=" "*20) print(self.arriv...
55105a82a7dc3b9adf0a398535ccdc5a23bf42fb
prakriti-singh/University-Projects
/Ex1_PrakritiSingh.py
2,333
3.84375
4
import math pi = math.pi def MyArcTan(x,N): #Function to calculate arctan n= 0 sum = 0 while n <= N: sum += ((((-1)**n) * (x**((2*n)+1))) / ((2*n) + 1)) n+=1 return sum def FinalAnswer(x,N): #Funtion to calculate arctan for different values of x ...
be31f760227073e57e300fd34729d67e19edfcd2
pauleclifton/GP_Python210B_Winter_2019
/examples/office_hours_code/class_property.py
597
3.5
4
class DrivingRules: def __init__(self, minimum_age, drivers_age): #self.minimum_age = minimum_age self._minimum_age = minimum_age #self.drivers_age = drivers_age self._drivers_age = drivers_age @property def minimum_age(self): return self._minimum_age @minimum_a...