blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
a73906c3f5ad1048534c63ce3d2c6dcac5d3946b
Gaurav-dawadi/Python-Assignment-II
/question2.py
311
4.375
4
''' Write an if statement to determine whether a variable holding a year is a leap year. ''' inputYear = int(input("Enter a Year: ")) if ((inputYear%400 == 0) or ((inputYear% 400 == 0) and (inputYear%100 == 0))): print("The Given Year is Leap Year") else: print("The Given Year is not Leap Year")
3f922d74ed30d0df128783e444a27cc2dc5e807f
KeerthanaPriya-B/Ds-Oop
/3. Data Abstraction.py
1,260
4.53125
5
# Python program to define abstract class from abc import ABC class Polygon(ABC): # abstract method def sides(self): pass class Triangle(Polygon): def sides(self): print("Triangle has 3 sides") class Pentagon(Polygon): def sides(self): ...
f1f2b1923c4c8b58e3607e2e193351ba1a3addaf
MOHAMMADHOSSEIN-JAFARI/Mini-Project-Calculating-GPA-and-sorting-GPA-from-csv
/source.py
4,207
3.765625
4
from collections import OrderedDict import csv from statistics import mean def calculate_averages(input_file_name, output_file_name): average= [] lname= [] with open(input_file_name, newline= '') as f: reader= csv.reader(f) for row in reader: name = row[0] ...
c889d5c9248759cbab59c245b21203e0f90313c1
kisan79/Django-RESTful-Web-Service
/json/demo1.py
489
3.921875
4
#Serialization :Dumping Python Object into File Byte-Stream import json #Python dict obj student={ 'id':101, 'name':'kisan', 'course':'python', 'isJoined':False, 'isMarried':None } print(student) #Function For Dumping dict into a File def dumpIntoFile(fileName,d1,/): with open(file=fileName...
596ed8badc2390df9022cfc50cce315574e02f7d
codingyen/CodeAlone
/Python/0232_implement_queue_using_stacks.py
532
3.8125
4
class MyQueue: def __init__(self): self.A = [] self.B = [] def push(self, x): self.A.append(x) def pop(self): self.peek() return self.B.pop() def peek(self): if not self.B: while self.A: self.B.append(self.A.pop()) re...
1a60b2b3d80f6b1e5b7169ca4a86fd868bbecf61
rani-solanki/DSA_hyperverge
/Array/step5.py/ques3.py
449
3.921875
4
def DuplicateNumber(arr,arrSize): if (arrSize > 2): print("size should be less than two") list = [] list2 = [] for index in range(arrSize): if arr[index] not in list: list.append(arr[index]) elif arr[index] not in list2: list2.a...
4dcb25ccd5dd4480e0ea86df43864b7dfe329afa
sohelsorowar/python
/methods1.py
537
3.640625
4
#two types of methods 1.class method 2.static method class Student: school = 'RDA' def __init__(self,m1,m2,m3): self.m1 = m1 self.m2 = m2 self.m3 = m3 def avg(self): return (self.m1 + self.m2 + self.m2)/3 @classmethod # class method def info(cls): r...
2adb88def97b10ddfc75bc76083acc4226bc9343
privateHmmmm/leetcode
/279-perfect-squares/perfect-squares.py
1,690
3.5
4
# -*- coding:utf-8 -*- # # Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n. # # # # For example, given n = 12, return 3 because 12 = 4 + 4 + 4; given n = 13, return 2 because 13 = 4 + 9. # # # Credits:Special thanks to @jianchao.li.fighter f...
4519644f09c21205db3ff458ffda3a039521bf09
akshirapov/think-python
/08-strings/ex_8_13_5.py
871
4.0625
4
# -*- coding: utf-8 -*- """ This module contains a code for ex.5 related to ch.8.13 of Think Python, 2nd Edition by Allen Downey http://thinkpython2.com """ def rotate_word(word, n): """Rotates each letter by a fixed number of places. It is the implementation of the Caesar cypher. https://en.wikipedia.o...
61b6a82f77acf6eb7d2a7f0331160dd01b6c2e9a
AbhishekH1936/1BM17CS006
/divisors.py
196
3.9375
4
li=[] def divi(num): for i in range(1,num+1): if(num%i==0): print(i,end=" ") num=int(input('enter the no')) print('divisors of ',num,'are') divi(num)
960cfff0567dccc5c13f9b24f196b0402d583137
noumannahmad/Amazing-Python
/Image_Resizing_convertion.py
375
3.5
4
# -*- coding: utf-8 -*- """ Created on Wed Mar 17 00:43:33 2021 @author: Nouman Ahmad """ from PIL import Image image =Image.open("image.png") #rgb_img=image.convert("RGB") #rgb_img.save("convertedimg.jpg") width,height =image.size print(width,'x',height) #224 x 224 img=image.resize((224,224)) ...
d9aea8fe1e2f2f95f295f861651f87c6751c4c45
Minsik113/AI_course-using-python
/과제/test2.py
2,661
3.9375
4
from abc import abstractmethod from abc import ABCMeta import random class Duck(metaclass=ABCMeta): SIZE = 30 color_list = ['blue','red','orange','green'] def __init__(self): self._x = random.randint(-300, 300) self._y = random.randint(-300, 300) def swim(self): print...
5ce75245240027a653e903acba6d6ae850fa5482
xico2001pt/feup-fpro
/Play/Py03/diagram.py
483
3.6875
4
# -*- coding: utf-8 -*- """ Rewrite the following flow diagram as a Python script. <diagram.png> Note that := is assignment. """ L = int(input()) S = int(input()) R = L def fun_if(S, R): if S > R: pass else: while not(S > R): R = R - S return R if R > S: pass else: L...
c3b48fe7c39714d9182b04d9d2b3b5e4c36d5081
noahabe/interpolation_in_odes_and_pdes
/interpolation_using_lagrange_polynomial.py
594
3.875
4
def lagrange_interpolation_evaluation(x_values:list,y_values:list,x:float): ''' Returns the result of the interpolated polynomial evaluated at x. Source of Algorithm: Applied Numerical Analysis page 163 of 620 ''' assert(len(x_values) == len(y_values)) result = 0 for i in range(0,len(x_values)): P = 1 ...
47e1b1d101e01dbdcdf32a128129515aff793e9b
x95102003/leetcode
/implement_strStr.py
644
3.84375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- def strStr(self, haystack, needle): """ Implement the indexOf function, each length must include substr size. :type haystack: str :type needle: str :rtype: int """ j, pos = 0, -1 check = False nlen = len(needle) hlen = len(haystack) ...
8a72737a1c98d0358d1086299aef578b2d38d2f5
cauegonzalez/cursoPython
/listaDeExercicios/ex088.py
885
3.890625
4
# coding=UTF-8 # Faça um programa que ajude um jogador da MEGA SENA a criar palpites. O programa vai perguntar quantos jogos serão gerados e vai sortear 6 números # entre 1 e 60 para cada jogo, cadastrando tudo em uma lista composta. from random import randint from time import sleep todosOsJogos = list() jogo = list...
7331301ec29da9ae5b824d23fa98bb4444d89a10
whosdman2005/python_train
/Books.py
407
4
4
# check if a book is existing in your collection collectionOfBooks = ["The Alchemist", "How to win friends and influence people", "The seven habits of highly effective people"] print("Enter the name of the book: ") bookToBeChecked = input() for book in collectionOfBooks: if book == bookToBeChecked: print("...
eca8a528e81e8458651113726e746a4a2353dc8d
kimihito/hajipy
/hajipy/part4/addDict.py
304
3.5
4
#!/usr/bin/env python # coding: utf-8 def addDict(d1, d2): new = {} for key in d1.keys(): new[key] = d1[key] for key in d2.keys(): new[key] = d2[key] print new addDict({'a':1,'b': 2}, {'a':1,'b':2}) addDict({'a':1,'b': 2}, {'d':1,'e':2}) addDict({'a':1,'b': 2}, {'a':5,'f':88888888})
6db7beb06e551837e836ee300001f3a539ecbbda
yanpan9/Some-Code
/ArrayList/80.py
963
3.546875
4
from typing import List class Solution_Double_Point: def removeDuplicates(self, nums: List[int]) -> int: length = len(nums) front, back, count = 0, 1, 1 while back < length: if nums[back]==nums[front]: if count == 1: front += 1 ...
c3ed414ce64fb787de934ab2cf2a5a5dbc47ce99
Anirudh-Chauhan/30-Days-of-code
/Day 6/find missing element.py
914
3.625
4
''' iven an array C of size N-1 and given that there are numbers from 1 to N with one element missing, the missing number is to be found. Input: The first line of input contains an integer T denoting the number of test cases. For each test case first line contains N(size of array). The subsequent line contains N...
f2cf0fc614d800613953f17c5476a97a880f2719
gayu-thri/Coding
/Longest Common Prefix.py
806
3.515625
4
# -*- coding: utf-8 -*- """ Created on Thu Apr 9 14:44:22 2020 @author: egayu """ class Solution: def longestCommonPrefix(self, strs) -> str: """ :type strs: List[str] :rtype: str """ #minimum = min(strs, key=len) #finds shortest minimum = len(strs[0]) for ...
5713cf113954f72bc10fd8d0c4f9a15cfc62c3c0
munix24/python
/math ops/combinatorics.py
885
3.71875
4
#https://docs.python.org/3/library/itertools.html import math import cProfile factorial=math.factorial mem_choose = {} def nCr(n, k): """ N choose K """ key = (n, k) if key not in mem_choose: if k > n: c = 0 elif k==0 or n==k: c = 1 ...
153ea02be0dcffe77778625c4bd52f250d1724e5
bramirez96/CS2.1-Practice
/linkedlist.py
720
4
4
class Node: def __init__(self): self.value = None self.next = None class LinkedList: def __init__(self): self.head = None def find(self, value): cur = self.head while cur is not None: if cur.value == value: return cur cur = c...
bbb16184dc4131b713679f58b815e7f2ce1a51ca
jayashelan/python-workbook
/src/chapter09/test_name_function.py
548
3.609375
4
import unittest from name_function import get_formatted_name class NamesTestCase(unittest.TestCase): """Test for 'name_function.py'""" def test_first_name(self) : """Do names like Janis Joplin work ? """ formatted_name = get_formatted_name('janis','joplin') self.assertEqual(formatted_name,'Janis Joplin') de...
0ce6c55a99d80473ffab0acbd8e101859c82ea25
tianweiy/CenterPoint
/det3d/torchie/fileio/handlers/base.py
684
3.625
4
from abc import ABCMeta, abstractmethod class BaseFileHandler(object): __metaclass__ = ABCMeta # python 2 compatibility @abstractmethod def load_from_fileobj(self, file, **kwargs): pass @abstractmethod def dump_to_fileobj(self, obj, file, **kwargs): pass @abstractmethod ...
a4611ef6f79065450db5c7ed023fe5a8c7806400
wayne214/python-study
/src/hoc.py
221
3.609375
4
from math import factorial # 高阶函数 def high_func(f, arr): return [f(x) for x in arr] def square(n): return n ** 2 print(high_func(factorial, list(range(10)))) print(high_func(square, list(range(10))))
73ccc046bfab5cbb4b5921c00b1eea1a11ce8dfb
chengnuo123/ichw
/planets.py
1,785
3.828125
4
import turtle import math ####one wn=turtle.Screen() turtle.delay(1) ####two sun=turtle.Turtle() sun.color("yellow") sun.shape("circle") mercury=turtle.Turtle() mercury.shape("circle") mercury.color("blue") venus=turtle.Turtle() venus.shape("circle") venus.color("green") mars=turtle.Tur...
b0a552154a9a68b3880069988e9aeb3bc2440e25
Horneringer/UdemyProjects
/Section13 Application5/BookShop_front.py
4,085
3.765625
4
""" Программа, хранящая информация о книгах: Заголовок, Автор Год, Номер идентификации Пользователь может: Просматривать записи Искать записи Добавлять записи Вносить изменения в записи Удалять записи Закрывать программу """ from tkinter import * import BookShop_back as backend # баг с пустым listbox'ом можно ис...
b9e00d02971975134eb5199973edee74e05217cf
GHMusicalCoder/My100Days
/Day3/cwk_fix_mistakes.py
320
3.703125
4
def correct(string): fixes = {'0': 'O', '5': 'S', '1': 'I'} issue = '015' result = '' for s in string: if s in issue: result += fixes[s] else: result += s return result # best fix def correct(string): return string.translate(str.maketrans("501", "SOI"))
a1c860865ec2611b532dcf6783432e253a002c00
piyushaga27/Criminal-record
/criminal_record.py
3,690
3.890625
4
#criminal data import pandas as pd import matplotlib.pyplot as plt df=pd.read_csv('criminal_data.csv',sep=',') rew=list(df['reward']) nme=list(df['name']) city=list(df['city']) city_dict={} for i in city: city_dict[i]=city.count(i) def allData(): print('All Data is:') print('='*50) ...
55a0fc36c34bbfdac558880997b052c0f7ca9a58
rocioregina/ejercicios-python
/Simple/simple.py
1,536
3.515625
4
import random def generate_list(amount): """ Testea la funcion que genera una lista >>> random.seed(10) >>> generate_list(10) [{'id': 1, 'edad': 74}, {'id': 2, 'edad': 5}, {'id': 3, 'edad': 55}, {'id': 4, 'edad': 62}, {'id': 5, 'edad': 74}, {'id': 6, 'edad': 2}, {'id': 7, 'edad': 27}, {'id': 8, 'ed...
3b0d7e9e0ab963bafe3138046e0498df620e88b5
itsvinayak/labs
/python_algo_lab/binary_search.py
449
4.125
4
def binary_search(array, left, right, item): if left > right: return -1 mid = (left + right) // 2 if item < array[mid]: return binary_search(array, left, mid - 1, item) elif item > array[mid]: return binary_search(array, mid + 1, right, item) else: return mid if __...
e0b1b0681c6995a80919a691c5e07a99190e0f8e
DavidNjoroge/instagram_clone
/kata.py
617
3.65625
4
def increment_string(strng): numstr='' strstr='' str2=strstr[:len(numstr)] print(str2) for cha in strng: if cha.isdigit(): numstr+=cha else: strstr+=cha if numstr=='': print(strstr+'1') return 1 num=int(numstr) str2=strstr[:len(nums...
e5b31a15db48610ab538e4d1635f164c7c789122
Jamilnineteen91/Sorting-Algorithms
/Shell_sort.py
645
3.875
4
nums = [34,-5,7,42,6,82,311,4,-45,7,33,12,74,3] def Shell_sort(alist): sublistCount=len(alist)//2 while sublistCount>0: for startPosition in range(sublistCount): gap_insertion_sort(alist,startPosition,sublistCount) print("Increment size:", sublistCount, "List:", alist) s...
a398f12c6076275d0577686dce1be887cccc45a7
Yasmin-Core/Python
/Mundo_2(Python)/funcao_break/aula15_desafio71.py
1,184
4.03125
4
# Simulação de um banco eletrônico # cedulas : R$ 50, 20, 10, 1 print('----------------------------------') print('-=-=-=-= BANCO DA YASMIN -=-=-=-=-') print('----------------------------------') print(' ') sacar= int(input('Qual o valor que você quer sacar ?: R$ ')) # O valor maior das cedulas ced= 50 # contar a quan...
11a472bd22d30f6a733bfc1a84f7ca4f3b92d9f8
IZOBRETATEL777/Python-labs
/Lesson-10/del_max_py_style.py
729
3.75
4
from random import randint def remExtr(a, n): max1 = a.index(max(a)) min1 = a.index(min(a)) b = [] for i in range(n): if i != max1 and i != min1: b.append(a[i]) max2 = b.index(max(b)) min2 = b.index(min(b)) print(f'Первый максимальный {a[max1]}, второй максимальный {b[m...
ab917d86ea593a1f7c765bf652a5f03d7534f490
Roma017/most_frequent-function
/function.py
323
3.625
4
import operator def most_frequent(s): d=dict() for key in s: if key in d: d[key]+=1 else: d[key]=1 sort_d=dict(sorted(d.items(),key=operator.itemgetter(1),reverse=True)) for key, value in sort_d.items(): print(key,' =',value) s="Mississippi" most_frequent(...
d4216911838a922c0bc6e027bc74ee8d9c4803cb
sweetpand/LeetCode-1
/solutions/python3/0127.py
933
3.5
4
class Solution: def ladderLength(self, beginWord: str, endWord: str, wordList: List[str]) -> int: wordList = set(wordList) if endWord not in wordList: return 0 ans = 0 set1 = set([beginWord]) set2 = set([endWord]) while set1 and set2: ans +...
dc51df3db27e0345ed5b4b61be33896ae720973e
matthdll/DesafiosPythonicos
/02_both_ends.py
1,125
4.28125
4
""" 02. both_ends Dada uma string s, retorne uma string feita com os dois primeiros e os dois ultimos caracteres da string original. Exemplo: 'spring' retorna 'spng'. Entretanto, se o tamanho da string for menor que 2, retorne uma string vazia. """ def both_ends(s): # +++ SUA SOLUÇÃO +++ if len(s) < 2: ...
13c0f52137fa8289523611b553bcd1424390c382
goareum93/Algorithm
/01, 특강_210705_0706/02, source/CookData(2021.01.15)/Code11-07.py
539
3.5
4
## 함수 선언 부분 ## def selectionSort(ary) : n = len(ary) for i in range(0, n-1) : minIdx = i for k in range(i+1, n) : if (ary[minIdx] > ary[k] ) : minIdx = k tmp = ary[i] ary[i] = ary[minIdx] ary[minIdx] = tmp return ary ## 전역 변수 선언 부분 ## moneyAry = [7, 5, 11, 6, 9, 80000, 10, 6, 15, 12] ## 메인 코드 부분 ...
d5236cb80410b0594d642e6c68439f337c6e4117
Deaddy0430/python_learning
/01_basic_python_1/10_set_1.py
438
3.75
4
managers={"Ethan", "David", "Phoebe"} techs={"Ethan", "Zac", "Phoebe", "Kyle"} print("Both manager and tech: ", managers & techs) print("manager but not tech: ", managers - techs) print("tech but not manager: ", techs - managers) if "Phoebe" in managers: print("Phoebe is a manager") else: print("Phoebe ...
a0936abf335fe1b9892ccf00f2816868f5493f48
rmount96/Digital-Crafts-Classes
/programming-101/Exercises/Medium/3.py
375
4.0625
4
coins = 0 #print(f"You have {coins} coins.") #more = input("Do you want another?") #yes also works more = "yes" while more == "yes": more = "no" #coins += 1 print (f"You have {coins} coins ") more = input("Do you want another? ") if more == "yes": coins += 1 if more == "no": coins == coi...
51c4221a2a940715cc1f96fa6e7b31afd5e34663
RamonAgramon/PrimerParcialTopicos
/lista.py
387
4.21875
4
#!/usr/bin/env/ python lista = [1,2,'3', ('uno','dos',3)] print(type(lista)) print (lista) print(lista[0]) print(lista[3][-2]) lista.append('nuevo') print(lista) #verifica los valores for item in lista: print(item) #Separa los item if type(item)==tuple: #separa las tuple for itemnew i...
bdf8b80928603cbb779465be636ec91319f02271
anmolrajaroraa/core-python-july
/07-functions.py
1,063
3.84375
4
# def square(num): # return num * num # # print() # unreachable code # # number = 849493 # # print(f"Square of {number} is {square(number)}") numbers = list(range(1, 100)) # square_of_numbers = [] # for number in numbers: # # sq = square(number) # # print(f"Square of {number} is {sq}") # square_o...
fea0cae9651e024cddca765193ef497aa2b4d7fa
allenwhc/Hackerranks
/Algorithm/CoinChange/main.py
485
3.53125
4
def coinChange(amount, coins): cols=amount+1 dp=[[1 if col==0 else 0 for col in range(cols)] for _ in range(len(coins))] for i in range(len(dp)): for j in range(len(dp[0])): dp[i][j]=dp[i-1][j] + (dp[i][j-coins[i]] if j>=coins[i] else 0) return dp[-1][-1] if __name__ == '__main__': file=open('data.txt','r')...
f2905b0d7bcd7d5cfd4438c940cd28b386f525a1
Rub444/-practicas-programacion-orientada-a-objetos-
/program20.py
361
3.828125
4
cantidad = int(input("¿Cuántas veces quieres que te salude? ")) for i in range(0, cantidad): print("Hola") numero = int(input("Dime el número que quieras ver si es primo: ")) divisores = 0 for i in range(1, numero+1): if numero % i == 0: divisores += 1 if divisores == 2: print("Es pr...
f5fe4f21bb751af8d41cee7c7d43b69e10c721d4
shamithshetty/HankerRank
/Minimum Start Value/minimumstartvalue.py
381
3.703125
4
# -*- coding: utf-8 -*- """ Created on Tue Aug 4 16:40:09 2020 @author: Shamith h shetty """ def cal(): a=[-5,4,-2,3,1-1,-6,-1,0,5] x=0 sum=0 while(1): x=x+1 c=1 for i in a: c=c+1 sum=x+i if sum <=1: break if c==...
8e13e343635715b3bdaa7ed76380d0ccd46b7399
GhimpuLucianEduard/CodingChallenges
/challenges/leetcode/excel_sheet_column.py
956
3.84375
4
""" 171. Excel Sheet Column Number Given a column title as appear in an Excel sheet, return its corresponding column number. For example: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28 ... Example 1: Input: "A" Output: 1 Example 2: Input: "AB" Output: 28 Example 3: Input: "ZY" ...
ca8f13a239bd92869b64c7dfaffdf63bec266ad0
ixtWuko/Python-100days
/day-01to15/12-re.py
1,506
3.546875
4
""" Day 12 正则表达式 """ import re def case_one(): m1 = False m2 = False while not m1 or not m2: username = input('请输入用户名:') qq_number = input('请输入QQ号码:') m1 = re.match(r'^[0-9a-zA-Z_]{6,20}$', username) if not m1: print('请输入有效的用户名。') m2 = re.match(r'[1-9]\d...
e2b6169525fe943e7bbcf86649dbabe402f77c5a
paulobjrr/Scripting
/Scripting/Class5/GroupExercise2.py
342
3.765625
4
''' Created on Oct 20, 2017 @author: paulo ''' dict = {'a':1,'e':1,'i':1,'l':1,'n':1,'o':1,'r':1,'s':1,'t':1,'u':1,'d':2,'g':2,'b':3,'c':3,'m':3,'p':3,'f':4,'h':4,'v':4,'w':4,'y':4,'k':5,'j':8,'x':8,'q':10,'z':10} total = 0 word = input('Type the word: ') for c in word: total = total + dict[c] print('Total ma...
6f4842213fd4adcc87c47b6dfceef899dc79a02b
nishanthgampa/PythonPractice
/Unsorted/myPets.py
223
4.1875
4
myPets = ['Harley', 'Zorro', 'Whisky','Hercules'] print("Enter the name of your pet") petName = input() if petName not in myPets: print("I do not have a pet named ", petName) else: print("I do have a pet named ", petName)
cd4f9ff0056d9e5b36978e475e8d0dd43379f28c
ThreePointFive/aid1907_0814
/mounth02/day06/is_and_in.py
534
4.15625
4
'''字符串为不可变类型,字 符串的切片地址不变相当于整形存储方式 列表为可容器,切片后相当于浅拷贝''' a='ssssaaa' b=a[:] c='ss' d='sa' print(a is b) print(c in a,d in a) '''in 可以判断单个字符和字符串''' list01=['a','b','c'] list02=list01[:] print(list02) print(list01 is list02) list03=['a','b'] list04='b' f='a' print(list03 in list01,list04 in list01,f in list01) '''只能判断一个元...
a575e6fad4bdc26ff556de08d5e1e7e806ca4ba7
kallelzied/PythonTutoriel
/best_practice_examples/list_comprehensions_bp.py
1,419
3.6875
4
"""list_comprehensions_bp.py: Giving an example of best practicing with list.""" __author__ = "Zied Kallel" __copyright__ = """ Copyright 2018 list_comprehensions_bp.py Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You...
0ef4f66c1debd34c62f20f4fd144e53456b6a343
iam3mer/mTICP172022
/Ciclo I/Unidad 3/fibonacci.py
609
3.953125
4
# 0, 1, 1, 2, 3, 5, 8, 13, ... def fibenacci(num:int = 100)->str: a, b = 0, 1 while b < num: print(b), a, b = b, a + b #fibonacci(100) # Obtener la serie de Fibonacci dado un valor inicial y un limite. (Ojo, en la serie de Fibonacci # no se puede iniciar con numeros diferentes de 0 y 1) # La ...
f3dee964e749a0d2a75184d06731f94224717c80
macabdul9/python-learning
/basics/recursion.py
576
4.09375
4
# is given string pallindrom means on reversing string remains same # iterative # def ispallindrome(s): # a = s.__len__() # if a < 2: # return True # # for i in range(int(a/2)): # if s[i] != s[a - 1 - i]: # return False # return True def ispallindrome(s, itr, len): if ...
54605fab9741420e4fd7e469a610d3aaeeb50d67
ShantanuBal/Code
/careerCup/3.py
678
3.59375
4
real_pos = 1 array = [8,9,1,2,3,4,5,6,7] x = 9 def piv_search(l,r): print array[l:r+1] mid = (l+r)/2 if array[l] > array[mid]: #pivot on left if array[mid+1] <= x <= array[r]: bin_search(mid+1,r) elif x == array[mid]: print "pos:", mid else: piv_search(l, mid-1) else: #pivot on right if arra...
4da10554320b9cf90722a06ad487df22297588fd
Humility-K/Rosalind
/Algorithmic_001_FIBO/Algorithmic_001_FIBO.py
404
3.78125
4
''' My solution to Rosalind Algorithmic Heights Problem 001 Title: Fibonacci Numbers Rosalind ID: FIBO Rosalind #: 001 URL: http://rosalind.info/problems/fibo The problem was to return the n-th value of the fibonacci sequence. ''' # for loop function for only the total def fib(n): a,b = 1,1 for i in range(n-...
f1ad6a9d089c9d0828490efba35cd8cc6dcf4de9
Ten2016/Leetcode
/2020.02-2020.04/探索模块/链表/061-旋转链表/061-1.py
1,274
3.875
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def rotateRight(self, head, k): """ :type head: ListNode :type k: int :rtype: ListNode """ # 考察链表反转 # 向右移动则反...
e09b141994e69d5cb707f98417d477941725edad
matthewoatess/Reddit-Miner
/Miner/Miner.py
2,861
3.515625
4
import requests import re import csv import time import math #checking if the API sends any data back when the user inputs the subreddit def validate_input(subreddit): varification_API = 'https://api.pushshift.io/reddit/submission/search/?subreddit=' + subreddit json_data = requests.get(varification_API).json(...
55af079dedf5496432f654714f51d58f1a7085b0
d0ntblink/100-Days-of-Code
/Day 3/pizzacostcalculator.py
1,040
4.25
4
# 🚨 Don't change the code below 👇 print("Welcome to Python Pizza Deliveries!") size = input("What size pizza do you want? S, M, or L ") add_pepperoni = input("Do you want pepperoni? Y or N ") extra_cheese = input("Do you want extra cheese? Y or N ") # 🚨 Don't change the code above 👆 #Write your code below this lin...
1d5c556323e324cf2308e0cf0fbd465b171a3b13
brunabispo/shopping_cart
/db.py
1,756
3.53125
4
# -*- coding: utf-8 -*- """ Created on Mon Apr 6 13:49:48 2020 @author: Bruna """ import sys import os import sqlite3 from contextlib import closing from classes import Item from classes import Customer conn = sqlite3.connect("project.sqlite") conn.row_factory = sqlite3.Row def connect(): global conn if no...
e88f6508ed0a044a67133775b9a38620774450ff
vineetbhardwaz/tasks
/monkey_trouble.py
858
3.8125
4
########################################################################################################## #ID : Task 2 # #Author : Vineet Bhardwaz 05/12/2016 #...
c66ae0c3fbec88edf60398509a1b783a3e8097b1
ElliottThomasStaude/PythonLibrary
/PythonWalker.py
2,401
3.609375
4
# Used for command line parameters import sys import getopt # Used for parsing information from each page's content from bs4 import BeautifulSoup # Used for getting "curl" content import urllib2 # Used for file operations import os # Function gets a page's content, prints a page's content to a file, loops through ea...
a8e82f93720eecc8f8849c5ab54bda1ed0b47dff
TrickFF/helloworld
/func_like_obj.py
350
3.8125
4
def some_f(): return 10 result = some_f() print(result) # В переменную a записывается сама функция, а не ее результат # т.е. какой-то адрес в памяти a = some_f print(a) print(type(a)) # т.о. функция в python также является объектом print(a())
df116751a4ef748f13b84277c08ba9c8a57809c7
enrique-ayala/untitled
/divisor.py
210
3.859375
4
__author__ = 'enrique' #http://www.practicepython.org/solution/2014/07/25/13-fibonacci-solutions.html def getDivisor(num): for x in range(1,num+1): if num%x==0: print(x) getDivisor(10)
fb7ca6725ed2665ac51b16df1a29b711dabed341
FS-coding/Python_Essentials_2_INTERMEDIATE
/my_calendar_module_lab.py
1,543
4.25
4
# 4.6.1.13 LAB: the calendar module # extend its functionality with a new method called count_weekday_in_year, # which takes a year and a weekday as parameters, # and then returns the number of occurrences of a specific weekday in the year. # Create a class called MyCalendar that extends the Calendar class; # ...
fc8cb92c55ff689cea73e52814f64b4605778f73
Mahler7/zelle-python-exercises
/ch8/ch8-ex5.py
858
4.09375
4
import math def print_number(isPrime): if isPrime == True: return "Number is prime" elif isPrime == False: return "Number is not prime" def is_prime(n): i = 2 while i < n: if n % i == 0: return False i = i + 1 print(i) return True def inputs(): ...
2adcdd25e8f223dfa72a492306cc7c730c613532
IonutPopovici1992/CyberSecurity
/Python/variables.py
401
3.75
4
# print() print("Python Rocks!!!") print('Hello, World!!!') print('Hello, my name is "Alexis" and I love Python.') print(10 * "-") # Mathematical Operators print(1 + 2) print(1 - 2) print(1 * 2) print(1 / 2) print(1 % 2) print(10 * "-") # Variables age = 20 name = "Alexis" name = "John Wick" print(age + 45) prin...
16c41df4387213162fe1376bc3ca197f8fc1a412
zz198808/core-algorithm
/ch01_basic/at011_maxsubarr3.py
1,272
3.515625
4
#!/usr/bin/env python # -*- encoding: utf-8 -*- # at010_maxsubarr3: 寻找最大子数组(非递归的线性时间算法) """ Topic: sample Desc : 寻找最大子数组(非递归的线性时间算法) 从数组A的左边界开始,从左至右记录目前已经找到了的最大子数组 若已知A[0..j]的最大子数组为A[m..n],基于如下性质扩展到A[0..j+1]: A[0..j+1]的最大子数组要么就是A[0..j]的最大子数组,要么是某个子数组 A[i..j+1](0<=i<=j+1)。这样可以在线性时...
10e5ec6cff2842765bd104543e1846cdbb178cdb
aleghyk/phyton
/applied python/hello.py
205
3.734375
4
if a <b: res = a print (res) elif a == b: print ("equal") else: res = b print (b) try: 5/b except ZeroDivisionError: print ('error') i = 0 while i<5: print (i) i+=1
3b92f5bf8a1920d7f30487ee0510e41f4e3a527f
pastelmind/ast-codez
/ast_codez_tools/literal_statement_remover.py
2,885
3.578125
4
import ast import sys import typing from collections import deque # We rely on Python 3.8+ behavior of treating all constants as ast.Constant if sys.version_info < (3, 8): raise Exception( f"Python version 3.8 required; your Python version is {sys.version}" ) def is_literal_statement(node: ast.AST) -...
9125f5259876edf56694e26137925d708baf69c8
Hugens25/School-Projects
/Python/game.py
386
3.5625
4
num_cases = int(input()) for i in range(num_cases): lowest_floor = 0 floors = [] floors.append(0) directions = input() for letter in directions: if letter == "^": lowest_floor += 1 floors.append(lowest_floor) if letter == "v": lowest_floor -= 1 ...
37e83d77278c7a7c72a82bc7a681bcdff7a36592
rishabh-1004/projectEuler
/Python/euler021.py
458
3.578125
4
import time def sum_of_divisors(n): sum_=0 for i in range(1,n//2+1): if(n%i==0): sum_+=i return sum_ def main(): list1=[] sum_=0 for i in range(1,10_000): s=sum_of_divisors(i) r=sum_of_divisors(s) #print(s,r,i) if(r==i and i!=s): sum_+=i print(sum_) if __name__=='__main_...
8b60b1bc057a483f8bb4626f76b2aa8ef7d86e22
lidongze6/leetcode-
/两两交换链表中的节点.py
1,010
3.734375
4
class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def swapPairs(self, head: ListNode) -> ListNode: if head==None or head.next==None: return head p = ListNode(None) p.next = head cur = p self.swap(cur, cur.ne...
96dd602bd63a2fef7664864299cfd2987ff0072f
sean-mcgauley/OO-Design-Casino
/Roulette.py
19,907
3.640625
4
#! python import random from abc import ABC, abstractmethod from functools import partial # import csv # import os class Outcome: def __init__(self, name, odds): self.name = name self.odds = odds def __eq__(self, other): return self.name == other.name def __ne__...
27564ee57c035862f7006363809bf0cef9c5774e
deepagitmca/Basic-programming-using-python
/continue_examplesqaure.py
102
3.859375
4
for n in range(1,10,2): #for(start,stop,incrementby) if n%3==0: continue print(n*n)
43e9b2ef452a627ddcf74cfb08162a17b5033eab
longfight123/19-TurtleEtchSketchAndTurtleRace
/EtchSketch.py
744
4.34375
4
""" This script creates a Turtle object that walks in the direction you choose. This script requires that 'turtle' be installed within the Python environment you are running this script in. """ from turtle import Turtle, Screen tim = Turtle() def move_forward(): tim.forward(distance=10) def move_backward()...
e5e3e6605d3568c23f3af2bfd588ec2a75aacff3
adrianatrianac/Adventure-game
/game1122.py
3,025
3.765625
4
import time import random enemy = ["Ogre", "Pirate", "Troll"] items = [] current_enemy = random.choice(enemy) def printpause(string): print(string) time.sleep(2) def valid_input(question, option1, option2): while True: answer = input(question) if option1 == answer: ...
156330597e011994fb08fc14a7d18786052b62f0
JacquesFernandes/SEM-7-Practical-Codes
/AI/exp1/tic_tac_toe.py
5,424
4
4
''' Main module for Tic Tac Toe game ''' import os; import bot as game_bot; import random; class Grid: def __init__(self): self.grid = list(list(" " for i in range(3)) for i in range(3)); #grid self.finished = False; def get_grid(self): return(self.grid); def get_occupied_list(self): ret = list(); f...
441a7d3f8f3b2c1b7c44e1b72d5b64d0763753b5
BenLiuMath/A3-water-polo-shots
/data_gathering/convert_to_json.py
627
4.3125
4
# This script just converts a csv file to a JSON file # Here is an example of how it is used to convert filename.csv to a JSON file outputname.json # python convert_to_json filename.csv outputname.json import sys import pandas as pd # Check that the correct number of arguments are passed assert len(sys.argv) == 2 o...
b5334fbb038a1836b460afe28c8742933ab76075
Honoriot/Python_code
/OOP/Class Code1.py
773
3.96875
4
class person: def __init__(self): self.name = "Aniket" self.age = 21 def get_info(self): print("Name: " + self.name + ". " + "Age " + str(self.age)) def update(self): self.age = 23 def update(self, new_age): self.age = new_age def compare(self, other): ...
398b9d52cdfec36c2f2c4b748107483cb31dfcf6
JoaoMoreira2002/Linguagens-de-programacao
/Python/pythonProject/exercise/ex 009.py
125
3.546875
4
reais = float(input('quanto din din cê tem no bolso?')) us = reais/3.27 print('isso equivale a {:.2f} dólares' .format(us))
13993ff8d5f90e3eea3f465201e319418110c676
id3at/czas_zycia
/czaszyciafunc.py
2,397
3.84375
4
""" Autor: Tomasz Głuc Program pobiera dane czasu narodzin i zwraca informacje o długości zycia w sekundach minutach i dniach itd """ import datetime def czaszycia(IMIE="Tomasz", ROK=1983, MIESIAC=5, DZIEN=28): """ Autor: Tomasz Głuc Funkcja zwraca informacje o czasie zycia w sekundach minutach i dniach ...
287c89ff1213ff7f71dc6adb98a6099f1a1f33f2
MrKioZ/Project-Euler-Solutions
/Problems/p9.py
532
4.0625
4
""" An Efficient Solution can print all triplets in O(k) time where k is number of triplets printed. The idea is to use square sum relation of Pythagorean triplet, i.e., addition of squares of a and b is equal to square of c, we can write these number in terms of m and n such that, Written in one Line Intentionally fo...
669f67e5dca0a4805429a07f4d1fb32f7af2b18b
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/225/users/4004/codes/1573_2897.py
179
3.8125
4
# Use este codigo como ponto de partida 2 # Leitura de valores de entrada e conversao para inteiro num = int(input("digite o numero")) # Impressao do dobro do numero print(2*num)
37d7b18c9d3dc6f3f4aa0412acef38829dc06d5b
NaNdalal-dev/mycodes
/solflag.py
686
3.65625
4
import turtle clr=turtle.Turtle() clr.color("white","orange") wn=turtle.Screen() wn.bgcolor('black') wn.title("Jai Hind") wn.bgpic('army.png') clr.up() clr.goto(-100,0) clr.goto(-120,-30) clr.down() clr.goto(-120,-30) clr.goto(-120,280) clr.setheading(90) clr.speed(1) def rec(color): clr.begin_fill() clr.fil...
e7179058db79631701e5da220dd1c419eee6177c
MARGARITADO/Mision_05
/mision05 (2).py
7,823
3.703125
4
#Martha Margarita Dorantes Cordero #Dibujar círculos y cuadrados import pygame import random # Para generar el color aleatorio import math # Para el cálculo de PI y los centros de los círculos # Dimensiones de la ventana ANCHO = 800 ALTO = 800 # Colores NEGRO = (0,0,0) BLANCO = (255,255,255) def dibujarCua...
d8916bad45ca34a90b5a5053c9d8b27f656af7e4
brrbaral/pythonbasic
/PythonBasic/FormattingOutput.py
282
4
4
name="Bishow" age=26 salary=1000.23 print(name,age,salary) #USING % print("Name:%s Age:%d Salary:%f"%(name,age,salary)) #USING {} print("Name:{} Age:{} Salary:{}".format(name,age,salary)) #USING {0}{1}{2} print("Name:{0} Age:{1} Salary:{2}".format(name,age,salary))
c3d67389d08b39ff1174ddc2ff29c4b2817b0a03
xuyongqi/program-study
/Python_study/重量转换.py
243
3.546875
4
def g_kg(g): #创建新函数组 kg = g / 1000 #克向千克转换关系式 return str(kg) + 'kg' #循环输出 #k = g_kg(1200)#调用函数参数为1200 print("请输入你要转换的数字") g = float(input()) print(g_kg(g))#输出
45ea7de03831dc122aa5a83e5f3deb67ceb495bd
anujnirval/automate_boring_stuff_exercise
/ch_2_flow_excercise_9.py
152
3.890625
4
print('Enter a digit: '); spam = input() if spam == str(1): print('Hello'); elif spam == str(2): print('Howdy'); else: print('Greetings!');
d84bf0f64c0ae17a34ea924bb7ca008d3ef30973
a1424186319/tutorial
/sheng/tutorial/L4数据结构/列表练习1.py
157
3.75
4
list1 = ['小明','小红','小青','小王','小红'] def f(list1): if len(list1)>=5: print(list1[0:2]) else: print('None') f(list1)
37100559f36c7cf2ede356446d8a994f111fa510
ShilpaMurali/DynamicProgrammingPractice
/maximumSumIncreasingSubsequence.py
1,106
3.546875
4
def maxSumIncSubSeq(oriArr): maxArr=[None]*len(oriArr) indArr=[None]*len(oriArr) for i in range(len(oriArr)): maxArr[i]=oriArr[i] indArr[i]=i print(maxArr) print(indArr) j=0 for i in range(1,len(oriArr)): for j in range(i): if(oriArr[j]<oriArr[i...
b882c7a46050d1dbdc9ca2ebfa948543824b1bdc
eng-lenin/Python
/ex58.py
738
3.859375
4
from random import randint from time import sleep computador = randint(0,10) #aqui puxei a biblioteca random e usei o módulo randint print('-=-'*20) print('Vou pensar em um número entre 0 e 10. Tente adivinhar.') print('-=-'*20) computador = randint(0,10) #aqui puxei a biblioteca random e usei o módulo randint acertou ...
65b6d5971d20a6160fb24d67e2d6b03de1ceb3fb
Mrgon96/BridgeLabz_Programs
/Week1_python/Fuctional_Programs/string_permutation.py
565
3.84375
4
#fuction to conver list to string def toString(L): return ' '.join(L) # define fuction taking three Inputs def Permute(a,l,r): #checking for equality of start and end if l == r: print toString(a) else: for i in range(l,r+1): #swap values a[l],a[i]=a[i],a[l] ...
f14f48f77142b353d782e96fcfb153e3b33acc20
BlablaOlya/Python18plus
/8less/HW/email_login_BD_8.py
882
3.71875
4
import re l = input("Введите свой login: ") l = l.rstrip().title() e = input("Введите свой email: ") e = e.rstrip() def validate(email_v): pattern = re.compile(r"[a-z0-9\._]+@\w+\.\w+") valid = pattern.match(email_v) if valid: return True else: return False def save_data(email, login...
cc7412ffc34532cd285134e588252580f66e842e
iamsmore/thirteenf
/q_end.py
786
3.65625
4
import datetime import calendar #get prior quarter def get_prior_quarter(q): prior = q - 1 if prior == 0: prior = 4 return prior #get current quarter def get_quarter(date): return (date.month - 1) / 3 + 1 #get prior weekday for given date def prev_weekday(date): date -= datetime.timedel...
c785fd142c26316a1dbdbc45be8be862c3460b10
MAgungArdiansyah/Python
/Kondisi.py
156
3.71875
4
nilai = 9 if nilai == 9: print('Nilai Lebih besar dari 8') elif nilai == 8: print('Nilai sama dengan 8') else: print('Nilai Lebih Kecil dari 8')
79bfd1fda16526f42af7e5fe3741168659c8170e
gjghendriks/TetrisRL
/src/representation.py
1,479
3.5
4
# representation.py import tetris import constants import tensorflow as tf if __name__ == "__main__": print("This file is not ment to be run") class Representation(object): """ Simple representation of the state of a Tetris board Has an array arr with the length equal to the width of the board. Each element...
f8f3d423546beba9cb647b0c163359d84b683f5e
connor-roche/CS50-Projects
/pset6/sentiments/analyzer.py
1,169
3.65625
4
import nltk class Analyzer(): #Implements sentiment analysis def __init__(self, positives, negatives): self.positives = set() self.negatives = set() #load positive words file_positive = open("positive-words.txt", "r") for line in file_positive: if l...
bda1fb03b6a6c3e5e88a2507a0727b8a3dbc10c8
DeVriesMatt/HybridImages
/MyConvolution.py
2,261
3.796875
4
import numpy as np def convolve(image: np.ndarray, kernel: np.ndarray) -> np.ndarray: """ Convolve an image with a kernel assuming zero-padding of the image to handle the borders :param image: the image (either greyscale shape=(rows,cols) or colour shape=(rows,cols,channels)) :type numpy.ndarray ...