blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
8c138a34e5ca629a06804b658886c4f646b3b7b8
Goessi/CS_Grad_Courses
/6-0001/ps2/2.py
1,661
3.515625
4
# -*- coding: utf-8 -*- """ Created on Mon Nov 19 20:05:22 2018 @author: JingQIN """ # lecture 3 s = 'abc' print(len(s)) s = 'abcdefgh' print(s[3:6]) print(s[3:6:2]) print(s[::]) print(s[::-1]) print(s[4:1:-2]) s = 'hello' #s[0] = 'i' ,string is immutable s = 'y' + s[1:] s = 'abcdefgh' for index in range(len(s)): ...
542ac37fa6f3b77bdda887c940a06c90c7427f63
yurika-jim0401/PythonWorkSpace
/Python_OOP/ex05.py
976
3.796875
4
# Mixin案例 class Person(): name = "jim" age = 23 def eat(self): print("eat...") def drink(self): print("drink...") def sleep(self): print("sleep...") class Teacher(Person): def work(self): print("work...") class Student(Person): def study(self): pr...
d78905f063ce971455540c99ee9a644b27507565
SgtSteiner/CursoPython
/src/ex5.py
574
3.859375
4
# -*- coding: utf-8 -*- """ Exercise 5: More Variables and Printing """ nombre = "Sgt. Steiner" edad = 49 altura = 179 # cm peso = 74 # kg ojos = "marrones" dientes = "blancos" pelo = "blanco" print(f"Vamos a hablar sobre {nombre}") print(f"Mide {altura} cm. de altura") print(f"Pesa {peso} kg.") pri...
4c87fa9604c9fdb9faecaba49c2351369512d46c
harshi1466/Ds-Mysql-Practice-Problems
/Find a pair with given sum in array.py
363
3.671875
4
def findPair(arr,sum): arr.sort() low,high=0,len(arr)-1 while low<high: if arr[low]+arr[high]==sum : print(arr[low],arr[high]) return elif arr[low]+arr[high]<sum: low=low+1 else: high =high-1 print("Not found") ...
6f40bb55cc1d6ccb8637e9cd5e489a153c32ab7b
joaonetto/python_HardWay
/otherSamples/Exemplos_Consulta/exemplo_list1.py
884
3.796875
4
teste = [ ("a", "b", "c"), ("Z", "W", "Y") ] teste2 = ["a", "b", "c"] teste3 = [ ["EX2200"], ["EX4500"] ] #b = 0 #while b < len(teste): # for b in range(0, len(teste)): # for d in range(0, len(teste[b])): # print(f"O valor de first[{b}][{d}] é: {teste[b][d]}") # b += 1 #print(...
ee3a760416cc5c7ecf71b2b2f26f62b1f9cd7ee9
msrshahrukh100/DSandAlgo
/tree/checkmirror.py
930
3.953125
4
# check if mirror of itself # https://www.geeksforgeeks.org/symmetric-tree-tree-which-is-mirror-image-of-itself/ class Node: def __init__(self, v): self.val = v self.left = None self.right = None def check_is_mirror(r1, r2): if r1 == None and r2 == None: return True ...
6696a626b9e906c18364b8643f26ec2cb2c543d5
kunal21/LeetCode-Problems
/AverageOfLevels.py
876
3.84375
4
class Node(object): def __init__(self,val): self.val = val self.left = None self.right = None def Average(root): if root is None: return queue = [] avg = [] temp = [] summation = 0 counter = 0 queue.append(root) while(len(queue) > 0): while(len(queue)>0): node = queue.pop(0) ...
52736171593a12edc585b80860741b7bfc496184
michalslowikowski00/LearnThePythonHardWay
/ex21_drill.py
751
3.796875
4
# function drill # return number 998 g_value = 998 def add(a, b): print "adding %d + %d" % (a, b) return a + b def substract(a, b): print "substract %d - %d" % (a, b) return a - b def multiply(a, b): print "mulitply %d * %d" % (a, b) return a * b def divide(a, b): print "Divide...
8cbc89bd9354b669d6b7e22f4cd8f8af2caedd6d
kaustubh2708/INFYTQ-fundamnetals-assignment
/experiment47.py
555
3.65625
4
#PF-Assgn-47 vow=['a','e','i','o','u','A','E','I','O','U'] def encrypt_sentence(sentence): l=[] list1=sentence.split(" ") for i in range (0,len(list1)): word=list1[i] if((i+1)%2!=0): l.append(word[::-1]) else: vowel=[] consonant=[] for i in word: if i in vow: vowel.append(i) ...
7378ea5821ff425c4a9a143b20daf3649ffa6a4d
shishiranataraj/machine-learning
/linear-regression/simple_linear_regression.py
855
3.96875
4
import numpy as np import matplotlib.pyplot as plt import pandas as pd #generate dataset dataset = pd.read_csv('simple_linear_regression.csv') x = dataset.iloc[:, :-1].values y = dataset.iloc[:, 1].values #split it into train and test from sklearn.model_selection import train_test_split X_Train, X_Test, Y_Train, Y_Te...
e35697d3206ddbdaeef48d11c8e8180dc360862d
Cleomir/learning-python
/inheritance.py
973
4.28125
4
# inheritance without overriding class Parent: def __init__(self, firstName, lastName): self.firstName = firstName self.lastName = lastName def printName(self): print(self.firstName, self.lastName) class Child(Parent): pass child = Child("John", "Jr.") child.printName() # inheritance with overridi...
920da88f287212636fec3755c1a9bc43b974172f
kkwietniewski/cdv
/programowanie_strukturalne/5_listy.py
1,045
3.875
4
#programowanie = [listy] (tuple) {słownik} programowanie = ['Python', 'C#', 'JS', 'PHP', 'Java'] print(programowanie) print(type(programowanie)) first = programowanie[0] print(f'Pierwszy język programowanie w liście: {first}') last = programowanie[-1] print(f'Ostatni język programowanie w liście: {last}') threeElem...
380584434e8b81b6b3ba6e8a2527040821526fb7
zacharyluck/three-x-plus-one
/part-2.py
1,162
3.953125
4
lowestFail = 1 def threeXPlusOne(num): startNum = num numlist = [] looped = False global lowestFail # iterate on number while num > 1: # check condition: have I failed? if num <= lowestFail: break # do work: iterate on the number if n...
086bb560248e1e35ba2fabf389dadb0ddf71f995
raytso0831/unit3
/warmup9.py
265
3.921875
4
#Ray Tso #3/1/18 #warmup9.py word = input('Enter a word: ') for ch in word: if ch == 'a' or ch == 'A' or ch == 'e' or ch == 'E' or ch == 'i' or ch == 'I' or ch == 'o' or ch == 'O' or ch == 'u' or ch == 'U': print(ch.upper()) else: print(ch)
c8c3300e8265d014883e497baa6a3b2497b448fc
MarTecs/python-introducing
/尹成Python/day01plus/第二章习题/3.py
202
3.90625
4
# -*-coding:utf-8-*- # Author: sivan # computer: notebook # description: 将英尺数转换为米数 feet = eval(input("Enter a value for feet:")) print("%f feet is %f meters" % (feet, feet * 0.305))
d6c6b850835d603030477fd5f3a3c3b4b026da89
venky18/foobar
/solution.py
526
3.78125
4
# def answer(numbers): # # states[i]: current count. # states = [0] * len(numbers) # index = 0 # count = 0 # while states[index] == 0: # states[index] = count # count += 1 # index = numbers[index] # return count - states[index] def answer(numbers): count = 0 e...
d98f554e831a9dffb04711ae19bc3be51c100311
naytozero/recuperacion-
/recuperacion/ejercicio 3.py
606
3.78125
4
def vacuna_comtra_el_covid19(): str años=float(input("digite sub edad " )) genero=input("digite sub genero " ) if años<=0: print("edad incorrecta ¿error al digitar la edad") else: if años>=70: print("se le aplicara la vacuna de tipo c sin inportar el genero") else: if años>=16: ...
cf8df052e57d04deab9b9051e004efb81a445a6f
knitinjaideep/Python
/Peak.py
764
4.03125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Apr 9 08:26:26 2020 @author: nitinkotcherlakota """ def longestPeak(array): # Write your code here. i = 0 j = i + 1 k = i count = 0 final = 0 while j < len(array): if array[j] > array[k]: k += 1 ...
49d0c3ce80e55f183a5c8816a041d82ce7439127
madhumallidi/my-python-app
/16.Iterators.py
181
4.15625
4
myTuple = ('red', 'blue', 'orange', 'yellow') """for x in myTuple: print(x)""" myIte = iter(myTuple) print(next(myIte)) print(next(myIte)) print(next(myIte)) print(next(myIte))
d81bfff19ec16a6823574b514be8cb0fb07341b3
mariagarciau/EntregaPractica3
/ejercicio5.py
583
3.984375
4
#Construya un diagrama de flujo (DF) un pseudocódigo y un desarrollo # en Python que resuelva un problema que tiene una gasolinera. Los # dispensadores de esta registran lo que “surten” en galones, pero # el precio de la gasolina está fijado en litros. El desarrollo debe # calcular e imprimir lo que hay que cobrarle al...
ccf14f4816c3cf34555f9fc8cd6e7680b4b547a3
fabianoft/FATEC-MECATRONICA-1600792021016-FABIANO
/LTP1-2020-2/Pratica03/programa04.py
172
3.890625
4
# pede um valor em cm e converte ele para metros valor_cm = float (input('informe um calor em cm:')) valor_m = valor_cm / 100 print('valor convertido em metros:', valor_m)
d44517925e56c7efad4b40ba157ccb8553131901
Gulshan06/List-Assessment-
/day6/carclass.py
440
3.890625
4
class cars: color = "black" brand = "BMW" def findMileage(self,li,km): return km/li myCar=cars() a = input("enter color: ") b = input("enter brand: ") li = int(input('enter the litres ')) km = int(input("enter the km ")) mileage = myCar.findMileage(li,km) myCar.color=a myCar.brand=b print(myCar.col...
af574cd24381bccc3875cfd359e499570fea408e
brunnossanttos/exercicios-intro-python3
/CeVExercicios/ex029 - Radar Eletronico.py
285
3.8125
4
velocidade = float(input('Qual a velocidade do automóvel:km/h ')) if velocidade <= 80: print('Parabéns, continue dirigindo com cuidado!!!') else: multa = (velocidade - 80) * 7 print('Você foi multado em R${:.2f}, por andar acima da velocidade permitida.'.format(multa))
69ac396348e16dffdcf22e32d4254e47f1537504
Liam-Brew/SSW-215
/Scrooge McDuck/Bank.py
2,429
3.65625
4
class Bank(object): def __init__(self, account_list): self.account_list = account_list self.txt_file = open("Result.txt", "w") self.txt_file.write("Initial State:\n" + self.account_list_to_str() + "\n") def withdrawal(self, slave_acc_number, master_acc_number, value): ...
097f10d8c4a12022be24b607bb9c721089117145
StefanCsPurge/Artificial-Intelligence
/Faculty Labs/5 Fuzzy control of inverted pendulum 3D - RBS/solver.py
3,826
3.609375
4
# -*- coding: utf-8 -*- """ In this file your task is to write the solver function! """ def solver(t,w): """ Parameters ---------- t : TYPE: float DESCRIPTION: the angle theta w : TYPE: float DESCRIPTION: the angular speed omega Returns ------- F : TYPE: float ...
d384cd81277f812af7d83a305c50a06f1f924677
bunnybooboo/learning-path
/mit/6.00SC_Introduction_to_Computer_Science_and_Programming_2011/problem_set_1.py
2,275
4.625
5
# Problem 1 # Write a program to calculate the credit card balance after one year if a person only pays the # minimum monthly payment required by the credit card company each month. # # Use raw_input() to ask for the following three floating point numbers: # # 1. the outstanding balance on the credit card my_balance = ...
6af2620a4bc9f7c6ef8f3e41dfa44b4d35aacca2
ketanmittal25/Rasa-Chatbot
/actions/weather.py
719
3.6875
4
import requests import pandas as pd def weather_func(day): url1 = "https://goweather.herokuapp.com/weather/india" json_data = requests.get(url1).json() today_temp = json_data['temperature'] print(json_data) forecast = json_data['forecast'] print(forecast) if(day == "Today" or day == "tod...
a49037475d462ebf46bc04e2d6ffc6d5fc3ddc48
KimDongGon/Algorithm
/2000/2900/2941.py
128
3.625
4
arr = ['c=', 'c-', 'dz=', 'd-', 'lj', 'nj', 's=', 'z='] a = input() cnt = len(a) for i in arr: cnt -= a.count(i) print(cnt)
7f9185686ba7af7888824eae3b043c828ebbf017
sohwi/clay9_hw.py
/clay9_hw.py
1,650
3.640625
4
import turtle as t t.shape("turtle") #거북이의모양을거북이로한다 t.bgcolor("black") #바탕색을 검정으로한다 t.color("red") #거북이색을 빨강으로한다 t.speed(0) #거북이를 제일 빠르게 한다 x=input("50+20= ") #문제를 보여주고 입력받은 답을 x에 저장한다 a=int(x) #x에 저장된 문자열을 정수로 바꾼다 if a==50+20: #만약 a가 70이면 for x in rang...
8d7e4335b6a60d51b36100d0f63fb78764b77b33
nsi6000/practice
/programming_challenges/python/206_reverse_linked_list.py
1,689
4
4
#Leetcode 206 # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next # Iterative solution class Solution: def reverseList(self, head: ListNode) -> ListNode: #check if head is empty or is the only value i...
60bec8a1c5f33c060d787d2632ad445e873bec77
ahmedhammad97/30-Day-LeetCoding-Challenge
/Week 1/maximum_subarray.py
705
3.65625
4
class Solution: def maxSubArray(self, nums: List[int]) -> int: max_so_far = nums[0] curr_max = nums[0] for num in nums[1:]: curr_max = max(curr_max + num, num) max_so_far = max(max_so_far, curr_max) return max_so_far # Kadane’s algorithm is by far the opti...
b94527c318d0588b6f1ffb67b8d2e1df3fec0cda
kiran260790/python_basic_scripting
/Addition.py
59
3.59375
4
a = 10 b = 20 print("The Addition of Two Number is :",a+b)
06fb7d8b36c0a52af9cbb4b8a3bef20f86769419
amsully/alienshooter-
/Alienshooter.py
11,755
3.859375
4
import pygame, sys, math from pygame.locals import* class Main: #Explanation of "magic" numbers ROT_SPEED=2 #rotate speed for the cannon R=18 #set radius for the bubbles D=R*math.sqrt(3) #distance between center of the bubbles DEG_TO_RAD=0.0174532925 #conversion rate BUBBLE_SPEED=15 #speed the bubble travels ...
9deafb2b01d4829b3731204a4b26d4404bcd41e7
Sathyasree-Sundaravel/sathya
/Count_the_number_of_spaces_in_a_string.py
125
3.953125
4
#Count the number of spaces in a string a=input() count=0 for i in a: if i.isspace()==True: count=count+1 print(count)
602ee29c8ae0aa4dc1b15a4308c533af708376c2
xerifeazeitona/autbor
/chapter07/projects/date_detection.py
1,825
4.75
5
""" Date Detection Write a regular expression that detects dates in the DD/MM/YYYY format. Assume that the days range from 01 to 31, the months range from 01 to 12, and the years range from 1000 to 2999. Note that if the day or month is a single digit, it’ll have a leading zero. The regular expression doesn’t have to d...
d8d235929aeebf4f0c873650910f28fdbe4932b3
ketasaka/Python_study
/09.関数(メソッド)/9_8.py
209
3.515625
4
color = { "赤":"red", "白":"white", "黒":"black", "青":"blue", "緑":"green", } def rensou(color): for key,value in color.items(): print(key,":",value,sep="") rensou(color)
bb7aab8cb2180ee497ff4339afbefecca76935a4
nihal-wadhwa/Computer-Science-1
/Homeworks/HW6/test_debug2.py
3,435
4.1875
4
""" This program includes a function to find and return the length of a longest common consecutive substring shared by two strings. If the strings have nothing in common, the longest common consecutive substring has length 0. For example, if string1 = "established", and string2 = "ballistic", the function returns the...
0da18e0ce214cea7fa480ad33d50ca3efb1b0f34
abdalimran/46_Simple_Python_Exercises
/14.py
299
3.75
4
def length(str): count=0 count=int(count) for c in str: count+=1 return count def mapping(li): for i in range(0,len(li)): print("{}={}".format(li[i],length(li[i]))) def Main(): l=input() li=l.split() mapping(li) if __name__=="__main__": Main()
b5a9ae42e6c43b619ac8ee77f9f89b292ca08387
ashrafulemon/python
/uri1279.2.py
563
3.640625
4
p = 0 while True: try: a = int(input()) b = 0 ord = 1 if p: print('') p = 1 if (a % 4 == 0) and (not (a % 100 == 0) or (a % 400 == 0)): print('This is leap year.') b = 1 ord = 0 if (a % 15 == 0): pri...
bf952cec0485c29fe07e1bb5c85b03db463f87ff
williamabreu/damas
/board/board.py
6,731
3.875
4
from .square import Square from .piece import Piece from constants import Color from constants import Direction class Board: def __init__(self): self.matrix = self.new_board() def new_board(self): """ Create a new board matrix. """ # initialize squares and place them in matrix matrix = [[None] * 8 for...
9897e5a2231741630dcc2fb26bca17cdafc4494a
OneJane/nlp_tutorial
/ner.py
4,535
3.671875
4
""" 命名实体识别的任务就是识别出待处理文本中三大类(实体类、时间类和数字类)、七小类(人名、机构名、地名、时间、日期、货币和百分比)命名实体 """ """ 基于nltk实现ner """ import re import pandas as pd import nltk def parse_document(document): document = re.sub('\n', ' ', document) if isinstance(document, str): document = document else: raise ValueError('Document...
b42626f6eaf7c4e0a3a7c8ddbaf4ba90cc948120
vagarwala/CodeWars-Solutions
/is_merge2.py
366
3.84375
4
def is_merge2(s, part1, part2): s = list(s) part1 = list(part1) part2 = list(part2) if not sorted(s) == sorted(part1 + part2): return False for i in range(len(part1) - 1): if s.index(part1[i]) < s.index(part1[i+1]): s.remove(part1[i]) else: return False s.remo...
6014efc12d69802372d550fa6781484bc70621c2
vincent-kwon/rsa-example
/rsa-sample-slides.py
516
3.765625
4
def inverse_mod(e, x): """ python for: d * e mod x = 1 """ t = 0 newt = 1 r = x newr = e while newr != 0: q = r // newr t, newt = newt, t - q * newt r, newr = newr, r - q * newr if r > 1: return None if t < 0: t += x return t p, ...
3e83fd7f1e7b9e42635cde0d993aa9fcbc989f25
F1AMG/Py4EAssignment1
/Py4EAssignment1/Py4EAssignment1.py
227
3.59375
4
# Project Py4E # Assignment 1 # Objective: Print out Hello World # Author: Brian Sherrell # email: jsocdev@gmx.com / brsherr@microsoft.com # Display something other than Hello World print('Hey Lewis, nice win at Silverstone Sunday!') # End Program quit()
4a941a245834ac184d7d4f5bc46fa6845bab6239
alu0100842418/prct05
/src/calculopi.py
479
3.578125
4
#!/usr/bin/python PI = 3.1415926535897931159979634685441852 n = int(raw_input('Numero de intervalos: ')) suma = 0 while n <= 0: print 'El numero debe ser mayor que 0' n = int(raw_input('Numero de intervalos: ')) for i in range (1,n+1): a = float(i-1)/n b = float(i)/n xi = (i-0.5)/n fxi = 4.0/(1.0 + xi*xi) ...
b9e3dfa0014c96fe15116ddfc8dd3815dbbb9efa
Maanasa25/Becomecoder-
/eg-3.py
84
3.6875
4
num=int(input()) count=0 while num: num=num//10 count+=1 print(count)
915bc2dbf0a8131ce94816eb5cea80ee605c9e10
lukasz-kamil-bednarski/Machine-Learning-From-Scratch
/SimpleLinearRegression/model_tester.py
1,307
3.609375
4
from linear_regression import SimpleLinearRegression import pandas as pd import matplotlib.pyplot as plt import numpy as np data_path = "./data/Salary_Data.csv" dataframe =pd.read_csv(data_path) X = dataframe['YearsExperience'].values Y = dataframe['Salary'].values model = SimpleLinearRegression() """Uncomment if yo...
5f5f4187902b6d9168dd5daae6da45c5c49897e1
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/223/users/4183/codes/1667_2968.py
219
3.59375
4
w = input("Digite (L/S): ") quant1 = int(input("Quantidade: ")) quant2 = int(input("Quantidade: ")) vl = 5.00 * quant1 s = 3.50 * quant1 r = 4.00 * quant2 if (w == "L"): print(round(vl+r,2)) else: print(round(s+r,2))
b280dc8beb23b1e85216bb6b82f542046ccd424a
manimanis/LeetCode
/May2021/sol_07.py
3,187
3.796875
4
"""Delete Operation for Two Strings. https://leetcode.com/explore/challenge/card/may-leetcoding-challenge-2021/598/week-1-may-1st-may-7th/3734/ ## Problem Given two strings word1 and word2, return the minimum number of steps required to make word1 and word2 the same. In one step, you can delete exactly one characte...
0a73892ca18b8a809653afa551073330117d2d0f
QianM2020/Create-pythonpackage-NewtonMethod
/package/NewtonMethod_QM/NewtonMethod.py
1,282
3.546875
4
import numpy as np from .GeneralDiff import Diff from .FstDiff import Jacobian from .SecDiff import Hessian class NewMeth(Diff): def __init__(self,f,x,iters): """ Computing approximate optimal values with Newton methods. Attributes f (characters) representing the function to differetiate ...
ba571a3d106aabf8ac9a582cc52c4e31445381da
Asabeneh/data-analysis-with-python-summer-2021
/week1/set_example.py
147
4.09375
4
nums = {1, 2, 3, 4, 5, 5} nums.add(6) for i in [9, 10, 11]: nums.add(i) print(nums) for num in nums: print(num) empty_dict = {} dict()
4bea749c7c8227863ac894656ff5967bd1a7cc87
den01-python-programming-exercises/exercise-5-8-card-payments-vivyansoul
/src/payment_card.py
443
3.875
4
class PaymentCard: def __init__(self, balance): self.balance = balance def balance(self): return self.balance def add_money(self, increase): self.balance = self.balance + increase def take_money(self, amount): # implement the method so that it only takes money from th...
c41ccd81d088271c8e03eefef5824f83c2dc8562
niksfred/SoftUni_Advanced
/functions/rounding.py
192
3.5
4
sequence = list(map(float, input().split())) round_value = lambda x: round(x) rounded_values = [] for value in sequence: rounded_values.append(round_value(value)) print(rounded_values)
0d32068cf51f07e56a479ffc65782d8ee0652897
padamcs36/Introduction_to_Python_By_Daniel
/Chapter 6 Functions/Example_29 Credit card Validation.py
1,345
3.921875
4
def main(): cardValid = eval(input("Enter Your ID card for Validation 13 - 16 : ")) print("Sum of even Places: ",sumOfDoubleEvenNumber(cardValid), "\nSum of Odd Places: ", sumOfOddNumber(cardValid)) isValid(cardValid) def isValid(number): if (sumOfDoubleEvenNumber(number) + sumOfOddNum...
6804a103fcdb6adeb3d85478ddb4b3494b34b2ab
ghufransyed/udacity_cs101
/02_age_days_udacity_version.py
3,139
3.609375
4
# By Websten from forums # # Given your birthday and the current date, calculate your age in days. # Account for leap days. # # Assume that the birthday and current date are correct dates (and no # time travel). # monthArray = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] monthArrayLeap = [31, 29, 31, 30, 31, 30, 3...
94ac58c4c70152229e90653de15aeedfe2a61159
MichaelCHarrison/Programmer_Dictionary
/Python Chap12.py
1,248
4.15625
4
# Establishing programmer dictionary epic_programmer_dict = { 'tim berners-lee': ['tbl@gmail.com',111], 'guido van rossum': ['gvr@gmail.com',222], 'linus torvalds': ['lt@gmail.com',333], 'larry page': ['lp@gmail.com',444], 'sergey brin': ['sb@gmail.com',555], 'mikael stadden':['mksteezy...
67e032758dcf0d15c4554700adf29ff47a647c1a
kurczynski/connect-four
/bin/connect_four
1,702
3.90625
4
#!/usr/bin/env python from enum import Enum, unique class GameBoard(object): ROWS = 6 COLUMNS = 7 player_color = None agent_color = None board = None def __init__(self): self.board = \ [[Checker.empty for i in range(self.ROWS)] for j in range(self.COLUMNS)] def print(self): """ Prints the gam...
a6d6eb41446553b8e98ba347d33599885aa83f65
miro-lp/SoftUni
/Fundamentals/Functions/FactorialDivision.py
383
3.875
4
def factorial_division(num, div): factotial_result = 1 for i in range(1, num + 1): factotial_result *= i factotial_div = 1 for i in range(1,div+1): factotial_div *= i finall_num = factotial_result / factotial_div return finall_num first_num = int(input()) second_num = int(input...
1082c343d2cb57ff1a5ad1df8c8450f7ec7be6c9
AxelRaze/JuegoAdivinaNumero
/JuegoAdivinaNumero.py
1,166
3.65625
4
from random import randrange from Juego import * class JuegoAdivinaNumero(Juego): def __init__(self, num, vidas): self._num = num self._vidas = vidas if (num < 0 or vidas < 0): self._num = 0 self._vidas = 0 def Juega(self): while self._vidas !=...
5eb3ff567dd63b544f2a65acdcfcd6270c438bba
salemalem/opencv-python-projects
/scripts/resizing image.py
563
3.515625
4
import cv2 import numpy as np img = cv2.imread("../resources/black-friday.jpg") # Resizing image (Making it smaller) because original image is too big scale_percent = 5 width = int(img.shape[1] * scale_percent / 100) height = int(img.shape[0] * scale_percent / 100) dimensions = (width, height) resizedSmallerImage = ...
8df18b6a42ef5c85ac37c9fc9d6f8c9ceef77c08
marcinpgit/Python_exercises
/Exercises_1/najlepsze wyniki2 zagniezdzenia.py
892
3.96875
4
# Najlepszy wynik - metody zagnieżdżania list i krotek scores =[] choice = None while choice != "0": print ( """ --Najlepsze wyniki-- 0 - zakończ 1 - pokaż wynik 2 - dodaj wynik """ ) choice = input ("Wybierasz: ") print () if choice == "0": ...
0069be14044eb9dbe17593bb2b8541edee03c8b9
hugechuanqi/Algorithms-and-Data-Structures
/Big大话数据结构/Search查找/01、二分查找.py
1,481
3.734375
4
# coding: utf-8 ## 扩展:二分法只能查找排序好的数组,那如何利用非遍历的方法查找未排序的数组呢?假设数组中存储的是字符串,又该如何? class Solution: # 递归版(如果找到,则直接返回list_[mid]) def binary_lookup(self, list_, key): n = len(list_) if n<1: return False mid = n//2 if list_[mid] < key: return self.binary_lookup(list...
6c6c2ad6e470ed8142340af5355150125d625884
bryceklund/codewars-projects
/Rovarspraket.py
675
4.1875
4
#!/usr/bin/env python # coding: utf-8 # In[1]: ## take any word and append all consonants with an "o" and themselves ## eg. "b" becomes "bob", "r" becomes "ror", and "bread" becomes "bobroreadod" # In[2]: def rovarmaker(target): consonants = "bcdfghjklmnpqrstvxzwy" after_word = [""] count = 0 ...
12ee7165273e4784e95b0d2020effcb36d663520
WisdomLLong/LeetCode-Projection
/Sword-Points-Offer/Stack-Queue/31-栈的压入弹出序列.py
792
3.734375
4
''' P168 问题:压栈顺序[1,2,3,4,5],[4,5,3,2,1]是该压栈序列对应的一个弹出序列,但[4,3,5,1,2]就不是 注意: 1、判为FALSE的条件就是:所有数字都压入栈,但仍然没有找到下一个弹出的数字 ''' class solution(object): def ispoplist(self, pushlist, poplist): ans = [] if len(pushlist) != len(poplist): return ans.append(pushlist.pop(0)) while len(...
96c04674cc11aa490971a03e6f95fcbe4b5a5a61
Katuri31/PSP
/python/Take in the Marks of 5 Subjects and Display the Grade.py
786
4.0625
4
print("Enter Marks Obtained in 5 Subjects: ") markOne = int(input()) markTwo = int(input()) markThree = int(input()) markFour = int(input()) markFive = int(input()) tot = markOne+markTwo+markThree+markFour+markFive avg = tot/5 if avg>=91 and avg<=100: print("Your Grade is A1") elif avg>=81 and avg<91:...
be91070223284b3bc49b08352e8de6bed1924526
aagudobruno/python
/P6/P6E10.py
1,348
4.25
4
"""AUTOR:Adrián Agudo Bruno ENUNCIADO:Escribe un programa que te pida los nombres y notas de alumnos. Si escribes una nota fuera del intervalo de 0 a 10, el programa entenderá que no quieres introducir más notas de este alumno. Si no escribes el nombre, el programa entenderá que no quieres introducir más alumnos. No...
8c0013b57ac9ace0a2a3a3f78e402aa991ba7fe7
clicianaldoni/aprimeronpython
/chapter2/2.21-listcomp2for.py
228
4.0625
4
""" Convert nested list comprehensions to nested standard loops """ # q = [r**2 for r in [10**i for i in range(5)]] r = [] s = [] for i in range(5): r.append(10**i) for j in range(len(r)): s.append(r[j] ** 2) print s
fcd4a94108c0ac26583ef8f2fc6b18358e9324c5
brandoneng000/LeetCode
/medium/148.py
1,386
3.921875
4
from typing import Optional # Definition for singly-linked list. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: def sortList(self, head: Optional[ListNode]) -> Optional[ListNode]: if not head or not head.next: return hea...
10692d1053a42d728ce2279479fbeeb802f3e745
SajalGupta0306/House-Price-Prediction
/ML1.py
1,795
3.984375
4
import matplotlib.pyplot as plt import numpy as np from sklearn import datasets, linear_model from sklearn.metrics import mean_squared_error diabetesData = datasets.load_diabetes() # gets second feature and makes a new column for that # diabetesData_X_Axis = diabetesData.data[:, np.newaxis, 2] diabetesData_X_A...
9e803a23adcfde46e7e6705f9b71875fa3bc51f9
danieladriano/padroes_projeto
/AV1/NikitaLogisticsSA_Python/transports/truck.py
374
3.75
4
from transports.transport import Transport class Truck(Transport): _cost: float = 0 def __init__(self): self._cost = 10 def deliver(self, distance: float) -> float: self.to_drive(distance) return distance * self._cost def to_drive(self, distance: float): print(f"...
9e60c80dadbf3c68cd0a1cf10cfd42b27b1c1227
saulhappy/algoPractice
/python/miscPracticeProblems/Algorithms/Misc/longestCommonPrfx.py
568
3.734375
4
""" source: https://leetcode.com/problems/longest-common-prefix/ """ strs = ["flower","flight","flower", "saul"] def longestCommonPrefix(strs): if strs is None or len(strs) == 0: return "" lngstCommonPrefix = strs[0] for i in range(1, len(strs)): while lngstCommonPrefix != st...
11eb81e791e6d96eb821b76865ba025c0f926653
Owain94/BINP-Python
/BINP/Week3/Opdrachten/Opdracht.py
1,684
3.703125
4
# from typing import Iterator __author__ = 'Owain' class Switch(object): def __init__(self, value: int) -> None: self.value = value self.fall = False # def __iter__(self) -> Iterator: def __iter__(self): yield self.match raise StopIteration def match(self, *args: int...
57b201097099c31cff2e85970ada4a0be0982a99
tiroring09/Study
/Python_DataStructure_and_Algorithm/1장_숫자/11_generate_prime.py
1,345
4.3125
4
""" random모듈을 사용하여 n비트 내의 임의의 소수를 생성하는 함수 """ import math import random import sys def finding_prime_sqrt(number): num = abs(number) if num == 1: return False for divider in range(2, int(math.sqrt(num)) + 1): if number % divider == 0: return False return True def generate_p...
8a41ad2803241d4f5ae0f9e8f0f405ad934c3f79
Cemal-y/Python_Fundamentals
/fundamentals/Opdracht_6.py
753
4.25
4
def list_manipulation(list, command, location, value=""): if command == "remove" and location == "end": return list.pop(-1) elif command == "remove" and location == "beginning": return list.pop(0) elif command == "add" and location == "beginning": list.insert(0, value) return...
7f5fb5d358aaf558a47df8e0d8e66d372c16f219
max829/2019python
/7.1 생년월일 입력.py
637
3.859375
4
while 1: bir = input("생년월일 입력") list_bir = [] for i in bir: list_bir.append(i) t_bir = (list_bir) print(t_bir) if len(t_bir) != 8 or t_bir[0] == 0: print("잘못된 생년월일 입니다.") continue elif int(t_bir[4]) > 1 or int(t_bir[6]) > 3: print("잘못된 생년월일 입니...
7c49a71271d376272d463efae10b848867a9a965
smetanadvorak/programming_problems
/general/grokking/2_selection_sort/selection_sort.py
510
3.9375
4
def selection_sort(arr): for i in range(len(arr)): smallest_ind = i + find_smallest(arr[i:]) dummy = arr[i] arr[i] = arr[smallest_ind] arr[smallest_ind] = dummy return arr def find_smallest(arr): smallest_ind = 0 smallest_val = arr[smallest_ind] for i in range(1, len(arr)): if arr[i] < smallest_val: ...
3241c8fe10c6f88262f771a6161ecd74cf1f84ab
itanaskovic/Data-Science-Algorithms-in-a-Week
/Appendix_C_Python/example05_tuple.py
468
3.65625
4
import math point_a = (1.2, 2.5) point_b = (5.7, 4.8) # math.sqrt computes the square root of a float number. # math.pow computes the power of a float number. segment_length = math.sqrt( math.pow(point_a[0] - point_b[0], 2) + math.pow(point_a[1] - point_b[1], 2)) print "Let the point A have the coordinates", p...
815078cc426ac5f2b0d017d7f75174ccc3f3cba3
tanmaysgs/OpenCVPractice
/05.imageRotation.py
795
3.546875
4
#Rotating an Image import cv2 import numpy as np FILE_NAME = './inputImages/dog.jpg' try: # Read image from the disk. img = cv2.imread(FILE_NAME) # Shape of image in terms of pixels. (rows, cols) = img.shape[:2] # getRotationMatrix2D creates a matrix needed for transformation. # We want matrix for rotat...
41d3af978a68657fad39fc9c923e5e07b72b7483
Bushraafsar/assignment-5may-2019
/25_sum_digits.py
186
4.09375
4
# TASK 25 # PYTHON PRORAM TO CALCULATE SUM OF DIGITS OF N INTEGERS: n = input("ENTER AN INTEGER:") sum1=0 for i in n: sum1 += int(i) print("SUM OF DIGITS IS:",sum1)
2fcdc8266386d3602b597d6eb9fcd8d9b7e999da
AdamZhouSE/pythonHomework
/Code/CodeRecords/2451/61406/307545.py
258
3.71875
4
source = input().split(',') target = int(input()) for a in range(0,len(source)): source[a] = int(source[a]) if source.count(target)!=0: print(source.index(target)) else: source.append(target) source.sort() print(source.index(target))
32fa5ed263319f5faade2a8f3b6fc6b2e941a11c
m-triple-m/Machine-Learning-The-future
/Part 2 -Regression/Random Forest Regression/Decision tree regression.py
1,122
3.59375
4
# -*- coding: utf-8 -*- """ Decision tree Regression """ #Importing the libraries import numpy as np import pandas as pd import matplotlib.pyplot as plt #Importing the dataset dataset = pd.read_csv('Salary_Position.csv') X = dataset.iloc[:, 1:2].values y = dataset.iloc[:,2].values #Fitting decisio...
95f6426db6745fd9196069fd507dd155259bf220
unisociesc/Projeto-Programar
/Operadores/Logicos.py
222
3.90625
4
#Operadores Lógicos num1 = int(10) num2 = int(20) num3 = int(30) print(num1<num2 and num2<num3) #Operador and (e) print(num1>num3 or num3>num2) #Operador or (ou) print(not(num1<num2 and num2<num3)) #Operador not (não)
09862d54d4f199a1f24881d3266fc436fc68bbcf
SteveSYTsai/wordcloud_training
/wordclou_test1.py
1,038
3.875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Sep 21 21:41:50 2020 @author: stevesytsai """ import wikipedia as wiki import matplotlib.pyplot as plt # To display our wordcloud from wordcloud import WordCloud, STOPWORDS, ImageColorGenerator from PIL import Image # To load our image import numpy as ...
32c743e7a424ec266b741e5d87d129bc269dc347
Prakashchater/Daily-Practice-questions
/AlgoExpert/productsum.py
231
3.65625
4
def productSum(arr,mul=1): sum=0 for element in arr: if type(element) is list: sum+=productSum(element,mul+1) else: sum+=element return sum * mul arr=[5,2,[7-1],3,[6,[-13,8],4]]
bfbc6dd377397ba9905019fe535ac11a5554e60f
rangaeeeee/codes-geeksforgeeks
/basic/find-the-highest-number.py
745
4.09375
4
''' Find the Highest number Given an array in such a way that the elements stored in array are in increasing order initially and then after reaching to a peak element , elements stored are in decreasing order. Find the highest element. Input: The first line of input contains an integer T denoting the numb...
f4a2fb7e6692bfff3227dbdacde5e338d2b6b72f
chuck2kill/CoursPython
/chapitre_8/exemple_2.py
811
3.546875
4
from tkinter import * fen1 = Tk() # création des widgets 'Label' et 'Entry' Label(fen1, text='Premier champ :').grid(row=1, sticky=E) Label(fen1, text='Second :').grid(row=2, sticky=E) Label(fen1, text='Troisième :').grid(row=3, sticky=E) entr1 = Entry(fen1) entr2 = Entry(fen1) entr3 = Entry(fen1) chek1 = Checkbutton...
96453ba84c1e26c1e80e9fb1ff6146e7007f92b2
AngelaPSerrano/ejerciciosPython
/hoja3/ex01.py
4,457
3.5
4
def arabeARomano (stringArabes): suma = "" stringArabes = list(stringArabes) stringFinal = [] if len(stringArabes) > 4: print("El número no puede ser mayor a 4000") else: if len(stringArabes)== 4: stringFinal = transformarMillares(stringArabes[0]),transformarCentenas(stri...
378af4bc78b44d4c6bd03a04dc258823db16b50f
shivansh10/adhoc-projects
/program5.py
563
4.25
4
#!/Library/Frameworks/Python.framework/Versions/3.7/bin/python3 import datetime x = datetime.datetime.now() name = input("Enter your name :") if (x.hour >= 0 and x.hour <= 5): print("Hello " + name +" Good Night ") if (x.hour >= 6 and x.hour <= 12): print("Hello " + name +" Good Morning ") if (x.hour >= ...
2d93bc57ff91d9b7e0cfce86552bc4449373cdd7
Yunyi111/git_test
/week 8/Exception_raise.py
151
3.703125
4
student_number=input("Enter your student number >") if (len(student_number)<8): raise Exception("Sorry the student number must be 8 digits long.")
cb2c72c7834bad9ab7ccaac2efc648a66dba5b37
Girum-Haile/PythonStudy
/while loop.py
599
4.40625
4
# while loop are used to execute an instruction until a given condition is satisfied count = 0 while count < 3: count = count + 1 print("Hello") # using else statement with while loop # count = 0 # while count < 3: # count = count + 1 # print("Hello world") # else: # print("world") # # # break stat...
ba545b0ac8e46b371db04fb034f69b329c967c78
jdavini23/python
/Problems/Spellchecker/task.py
227
4.03125
4
dictionary = ["aa", "abab", "aac", "ba", "bac", "baba", "cac", "caac"] def spell_checker(): word = input() if word in dictionary: return 'Correct' else: return 'Incorrect' print(spell_checker())
00a1a5943fb211d4dd19c98a029b4219f41385c3
incredibleNinjaHacker/number-detective-game
/password.py
664
4.03125
4
from random import randint lowest = 1 highest = 97 awnser = randint(lowest, highest) while True: guess = input ('The number is:' + str (lowest) + '-' + str(highest) + ':\n>>') try: guess = int(guess) except ValueError: print('sorry, the password must be/n') con...
16ae0855315eb00ae0d375d2d68b276be8081b16
bakunobu/exercise
/1400_basic_tasks/chap_2/2.9.py
390
3.703125
4
# a def calc_expr_one(x:float, y:float) -> float: expr_1 = 2 * x ** 3 - 3.44 * x * y expr_2 = 2.3 * x ** 2 - 7.1 * y + 2 z = expr_1 + expr_2 return(z) print(calc_expr_one(1, 3)) # b def calc_expr_two(a:float, b:float) -> float: expr_1 = 3.14 * (a + b) ** 3 + 2.75 * b ** 2 expr_2 = 12.7 * a - ...
5f7c8dacea050e88ad83c23dedfacb1c4bde06d8
cat1984x/Learning_Python
/exercises/7/7_3_10.py
184
3.65625
4
num=int(input("请输入一个整数,我将判断这是不是10的整数倍: ")) if (num%10==0): print(str(num)+"是10的整数倍") else: print(str(num)+"不是10的整数倍")
6c2cf9e697c4b351ef9f6027cef65549b4cd7200
JerinPaulS/Python-Programs
/LargestPerimeterTriangle.py
856
3.96875
4
''' 976. Largest Perimeter Triangle Given an integer array nums, return the largest perimeter of a triangle with a non-zero area, formed from three of these lengths. If it is impossible to form any triangle of a non-zero area, return 0. Example 1: Input: nums = [2,1,2] Output: 5 Example 2: Input: nums = [1,2,1] O...
2df86989d22142441f7d04d80f9f3c741bab2b82
michelleshan/coding_dojo_python_course
/python/fundamentals/Day2/assignments/bankaccount.py
842
3.609375
4
class BankAccount: def __init__(self,balance,int_rate): self.balance = balance self.int_rate = int_rate def deposit(self,amount): self.balance += amount return self def withdraw(self,amount): self.balance -= amount return self def display_account_info(s...
c54a6e2a4ddea9a26d84e0edb618e605b4eac2a0
likgjava/apiTestGit
/req/test06_response_json.py
573
3.640625
4
# 1). 访问查询天气信息的接口,并获取JSON响应数据 # 2). 接口地址:http://www.weather.com.cn/data/sk/101010100.html # 1.导包 import requests # 2.发送请求 response = requests.get("http://www.weather.com.cn/data/sk/101010100.html") # response = requests.get("http://www.baidu.com") print("encoding=", response.encoding) response.encoding = "UTF-8" prin...
66d426b24fd15581f179007e5ae2897e74a43b05
nithinveer/leetcode-solutions
/Fizz Buzz.py
368
3.640625
4
def fizzBuzz( n): rtn_lst = [] for i in range(1, n+1): if i%15 == 0: rtn_lst.append("FizzBuzz") elif i%3 ==0: rtn_lst.append("Fizz") elif i%5 ==0: rtn_lst.append("Buzz") else: rtn_lst.append(str(i)) return rtn_lst if __name__ ...
4c03863dbde07e7ba7adecef7554084c7f43b1ac
Ajith-Kumar-V/Online_coding_round_questions
/Find_The_Divisors.py
212
3.8125
4
def divisors(integer): pass delt=[] for i in range(2,integer): if ((integer%i)==0): delt.append(i) if len(delt)==0: return (str(integer)+(" is prime")) return delt
7bea2943593b8ab725fc09daedfdf1458c926758
luanribeiros/Exercicios
/exercicio-01/Marlysson/exercicio.py
162
3.75
4
# -*- coding:utf-8 -*- vetor = [int(num) for num in raw_input('Números separados por espaço: ').split()] print 'Números digitados:' for i in vetor: print i