blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
151b11ea988165be6b215526021cfe054fc6f94c
waddahAldrobi/RatebTut-
/Python Algs copy/insertion_sort.py
280
3.9375
4
a = [3,4,1] alist = [54,26,93,17,77,31,44,55,20] def insertion_sort(a): for i in range(1,len(a)): this = a[i] pos = i while pos>0 and a[pos-1]>this: a[pos] = a[pos-1] pos=pos-1 a[pos]=this insertion_sort(a) print(a)
b681ac437b3132d3ddb27047fa57462f45ec0abb
sufiaan/homework
/Homework_2/ZyLab_7.25.py
1,448
3.828125
4
""" Sufiaan Shaikh - 1859029 CIS-2348-18349 ZyLab - 7.25 """ def exact_change(user_total): dollars = user_total // 100 user_total %= 100 quarters = user_total // 25 user_total %= 25 dimes = user_total // 10 user_total %= 10 nickels = user_total // ...
d609fda91d88b1025ef4d32aeb23b96b2bc805e5
Mechanical-Arm-Design-Practice/108-2-teaching-material
/python_sample_code/3/Python_list.py
944
3.84375
4
#create data list_a = [] list_b = list() list_c = [1.0, 2.0, 3.0] tuple_a = (1, 'a', 3.14) ''' #string to list list_a = list('cat') print("list_a:", list_a) #tuple to list list_b = list(tuple_a) print("list_b:", list_b) ''' #================================ ''' #assign list_d to list_c list_d = list_c print("list_d:...
3ce398a1598c2be1f6f289640956a5197ac67d58
Mechanical-Arm-Design-Practice/108-2-teaching-material
/python_sample_code/numpy/5_numpy_reshape.py
503
3.5625
4
import numpy as np grid = np.arange(1, 10).reshape((3, 3)) print("grid:{}\n".format(grid)) x1 = np.array([1, 2, 3]) x1_reshape1 = x1.reshape(1, 3) x1_reshape2 = x1.reshape(3, 1) x1_reshape3 = x1[np.newaxis, :] x1_reshape4 = x1[:, np.newaxis] #======================================== print("x1:{}\n".format(x1)) pr...
8ebe85468c1ce00e17d1bb93f99373f654dcc905
nathanestill/POEProject1
/PythonReceiveData.py
3,267
4.0625
4
# ****************************************************************** # * * # * * # * Example Python program that receives data from an Arduino * # * ...
8fc3791795ba4f7be4da91cf325c64d2a3810572
alexnicolescu/Python-Practice
/lambda/ex1.py
289
4.1875
4
# Write a Python program to create a lambda function that adds 15 to a given number passed in as an argument, also create a lambda function that multiplies argument x with argument y and print the result. def l1(x): return x + 15 def l2(x, y): return print(x*y) print(l1(15)) l2(12, 10)
b8fba80dd4732b64c65f8f10cba10d4d949ef8eb
alexnicolescu/Python-Practice
/lambda/ex12.py
194
4.25
4
# Write a Python program to add two given lists using map and lambda. list_1 = [1, 2, 3 ,4 ,5 ,6] list_2 = [1, 2, 3 ,4 ,5 ,6] list_3 = list(map(lambda x, y: x + y, list_1, list_2)) print(list_3)
fcd2326cf7de7f940addc5d6a147bfdf95c80a28
alexnicolescu/Python-Practice
/ex7.py
145
3.546875
4
class Car: def __init__(self, year): self.year = year def age(self): return self.year c = Car(2018) print(c.age())
a6099bc9283e52aacf41fb0d83a1b357adb9b67d
ValDagon/different
/Quadratic Equations/Quadratic Equations.py
1,584
4.1875
4
# Valentin 1 September 2017 # Решение квадратных уравнений import math while True: a = float(input('Введите a: ')) b = float(input('Введите b: ')) c = float(input('Введите c: ')) #total = str(a) + "x^2" + str(b) + "x" + str(c) #print("Итоговый вид уравнения: ", total) d = b ** 2...
c82870abca988247ab2a07c841550bf1e57d36b8
Adamrathjen/MOD1
/Module1.py
1,073
4.125
4
import os print("Character Creator!") selected = 1 while "4" != selected: print("Make new Character: 1") print("Delete character: 2") print("See current characters: 3") print("Quit: 4") selected = input("Make your selection: ") if selected == "1": print("you selected 1") char...
03b4bd666fcf33ba6e1b44778e69f46287ab69d7
tlmaloney/thomas-maloney-hw3-agent
/Agent.py
3,912
3.75
4
''' Created on Nov 25, 2011 @author: tlmaloney ''' class Agent(object): ''' An Agent has a name and Unique ID. An Agent participates in the Market to trade Assets. An Agent keeps track of what Assets s/he owns and in what amounts. ''' def __init__(self, unique_id, name, owned_assets={}, ...
b5c89cc66fde2059ade6319a7b1485da0b48bdb7
lzmaths/leetcode
/leetcode_1058_minimize_rounding_error_meet_target.py
751
3.53125
4
import math, sys class Solution(object): def minimizeError(self, prices, target): """ :type prices: List[str] :type target: int :rtype: str """ prices = [float(num) for num in prices] ceil_sum = sum([math.ceil(num) for num in prices]) floor_sum = sum(...
011641587b6aeb8b62b354e4cc5de3ff786f22f7
lzmaths/leetcode
/leetcode_755_pour_water.py
798
3.5625
4
import sys class Solution(object): def pourWater(self, heights, V, K): """ :type heights: List[int] :type V: int :type K: int :rtype: List[int] """ if K == 0: return heights for _ in range(V): r = K while r < len(h...
9498f4ac1c223f0dea77dfd7564ba82ff4ded16f
lzmaths/leetcode
/leetcode_733_flood_fill.py
844
3.53125
4
import sys class Solution(object): def floodFill(self, image, sr, sc, newColor): """ :type image: List[List[int]] :type sr: int :type sc: int :type newColor: int :rtype: List[List[int]] """ # DFS if not image or image[sr][sc] == newColor: ...
b82a8846a857615a9fd565e84c0a11c42044f9c3
JunTeng1113/First-Midterm
/Q67_最大公因數.py
508
3.53125
4
# -*- coding: utf-8 -*- """ Created on Sat Dec 26 15:18:50 2020 @author: 林駿騰 @description: 最大公因數 """ import math def main(): val = list(map(int, input("輸入值為: ").split(","))) print(gcd_list(val)) def gcd_list(array): max_val = 0 for i in range(len(array)): for j in ra...
15ae66322ad89f10a2d04addfbe13e6a634ffec7
JunTeng1113/First-Midterm
/Q20_學生資料搜尋.py
503
3.703125
4
# -*- coding: utf-8 -*- """ Created on @author: 林駿騰 @description: 學生資料搜尋 """ def main(): data = [["123", "Tom", "DTGD"], ["456", "Cat", "CSIE"], ["789", "Nana", "ASIE"], ["321", "Lim", "DBA"], ["654", "Won", "FDD"]] findindex = lambda array, i, ...
3983e3af3e69217f27e6c2dd0bae2c9c94737b0a
kokoro511/Practice
/prac 5/emails.py
637
4.09375
4
def main(): email_name = {} email = input("Please enter your email address: ") while email != "": name = get_email_name(email) verify = input("Is your name {}? (Y/n) ".format(name)) if verify.upper() != "Y" and verify != "": name = input("Name: ") ...
a6783e11bb11679e22bc301396f386cc22309237
asteffey/portfolio-finder
/portfoliofinder/contributions/contributions.py
449
3.5625
4
from abc import ABC, abstractmethod class Contributions(ABC): # pylint: disable=too-few-public-methods """The contributions made to a portfolio for each year.""" @abstractmethod def get_contribution_for_year(self, year: int): """Gets the contribution for the specified year. :param year: ...
7b67bdcd6f6dfef936e27507d5b5390562475359
sohinipattanayak/Fundamentals_Of_Python
/p2_palindrome_num.py
638
4.21875
4
#Check if num is plaindrome num=int(input("Enter the number: ")) num_str=str(num) #Type-casting the number to String flag=0 #No need to iterate throught the whole of string #Just iterate till the half of the string #If the last two match it is automatically a reverse for i in range(len(num_str)//2): #halfing the list...
c152ad6323be281eff9726c95a3f372842d0286a
veechand/AlgorithmsPractise
/Practise-2021/word_available_in_grid.py
2,728
3.96875
4
""" words are available in m * n ? Adjacent Cells : Horizontally and Vertically neighboring How big is the word array - 30000 For each element in the words: start_from grid[0][0] and do a BFS BFS will be added only if grid char matches with current char Need to see with each cell as the starting char https://leet...
62c9631340202aaa2d86a03ad6086c3bbd89511f
veechand/AlgorithmsPractise
/Practise-2021/max_subarray_sum_kadene_algo.py
625
3.625
4
class Solution(object): def maxSubArray(self, nums): """ :type nums: List[int] :rtype: int """ """ Implementation of Kadane's Algorithm Refer https://www.geeksforgeeks.org/largest-sum-contiguous-subarray/ """ max_so_far = -(sys.maxint) - 1 ...
f9c613d67f11489650ec5992e44a8753ac2e5955
veechand/AlgorithmsPractise
/Practise-2021/trials1_working.py
6,063
3.734375
4
from collections import namedtuple import random import pprint import sys MAX_ROW = 6 MAX_COLUMN = 7 DEBUG = False EMPTY = "-" Piece = namedtuple('Piece', ['x','y']) QueueElement = namedtuple('QueueElement', ['row','column','player','count', 'direction']) PLAYER1 = "Y" PLAYER2 = "R" TOP = "T" BOTTOM = "B" LEFT = "L...
cfadd580abc31e4f9a844f5e87f438950121e6f4
veechand/AlgorithmsPractise
/Practise-2021/longest_palidromic_substring.py
2,656
3.953125
4
""" Given a string s, return the longest palindromic substring in s. Palindrome: Reverse should be same S = [] : Return : [] S = [ab] : Return 0 What to do is to assume everypoint is middle of the palidrome. Try to expand each side, make sure to check the edges, Once the string is not same then (j-i) + 1 is the lon...
25d51db906a26570671cb2460907cc1ff81f7b07
veechand/AlgorithmsPractise
/Practise-2021/odd_set.py
3,216
4.09375
4
""" Given an array of sets find the one that does not belong: example: [[a,b,c,d], [a,b,f,g], [a,b,h,i], [j,k,l,m]] output: [j,k,l,m] We can see above that the first three sets have a subset [a,b,c] and the last one does not. Note: There may be a case where the outlier set does have elements contained in the input gro...
f6618a5698329b063290f3eade10864897b0403d
little-pear/practicability
/Python/comparing_strings.py
170
4.28125
4
country = input('Enter the name of your home country: ') if country.lower() == 'canada': print('So you must like hockey!') else: print('You are not from Canada')
673a8997d23d032814d7fddf49cdce4ca8e1b159
nittursupriya/QA
/WorkingWithElementsList.py
792
3.5
4
from selenium import webdriver from selenium.webdriver.common.by import By import time class WorkingWithElementsList(): def test(self): baseURL = "https://learn.letskodeit.com/p/practice" driver = webdriver.Chrome() driver.maximize_window() driver.get(baseURL) driv...
a94426f5e57d3027080f43255a23b785fc829bae
alaamarashdeh92/CA06---More-about-Functions-Scope
/P3.py
2,132
4.375
4
# Shopping List # Your shopping list should keep asking for new items until nothing is entered (no input followed by enter/return key). # The program should then print a menu for the user to choose one of the following options: # (A)dd - To add a new item to the list. # (F)ind - To search for an item in the list....
de7b58676a443f9121f1fe8f8aa3a1d6cf77fcb5
wendelsantiago/Trabalho-Pacman-IA
/search/search.py
5,546
3.8125
4
import util class SearchProblem: """ This class outlines the structure of a search problem, but doesn't implement any of the methods (in object-oriented terminology: an abstract class). You do not need to change anything in this class, ever. """ def getStartState(self): """ Re...
7ae1adcceee6751b5f626e859149ae85390c68c7
aleksandar-buha/lastmile
/ants/engine/routemap.py
4,625
3.578125
4
''' Route Map Store a collection of nodes and information about their interrelations ''' import ants.engine.operations as op import ants.parameters as params import numpy as np class RouteMap(object): ''' Central point for informationg aboug graph edges Caches matrices of distance, time, cost, and inverse...
a083799a7db854440ed2ee11282b97a679fd5270
aleksandar-buha/lastmile
/ants/engine/utilities.py
1,031
3.828125
4
''' Utility functions used by the solver. Author: Evan K. Friis ''' from itertools import izip, islice, tee def consecutive_pairs(the_list): ''' Generator which returns consecutive pairs from an iterable/generator Example: >>> list(consecutive_pairs([1,2,3,4])) >>> [(1,2), (2,3), (3,4)] ''' ...
f48000827821bc5835b946b2418eb93760ff63cf
kpazoles/Hear_me_code
/list_dedupe.py
821
3.796875
4
def textfile_to_list(filename,delimiter="\n"): with open(filename,'r') as textfile: newlist=textfile.read().split(delimiter) return newlist def deduplicate(my_list): my_list=list(set(my_list)) return my_list def find_duplicates(list_1, list_2): duplicates=[] master_list=list(set(list_1+list_2)) for item in ...
3e6bc6403951b605fe1779a3c7d3dad2235678e7
wenfei-alibaba/Pyhton3_mianxiangduixiang
/01-面向对象基础/6-利用参数设置属性初始值.py
338
3.65625
4
class Cat: def __init__(self,new_name): print("这是一个初始化方法") self.name = new_name def eat(self): print("%s 爱吃鱼" % self.name) # 使用类名()创建对象的时候,会自动调用初始化方法 __init__ tom = Cat("Tom") print(tom.name) lazt_cat = Cat("大懒猫") lazt_cat.eat()
aba86daa0b8fcb7decb2fb429f8ea0e8fa2d98ab
Dumbtext/Practice
/passgen.py
756
3.59375
4
from random import choice,randint from passwordmeter import test lettas = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] specials = ['@','$',"!"] def create_pass(numlettas=8, numdigits=4, numspecial=3): pass_str = '' for _ in range(numlettas...
7f5b19b97d4c16d3031bec7fb4b06c921c2cafcb
annizhao/frc-hw-submissions
/lesson2/lesson2hw.py
252
4
4
name = raw_input("enter your name:") x = raw_input("number of pizzas you want to order?") y = raw_input("number of pepperonis?") z = raw_input("number of olives?") print name + " ordered " + x + " pizzas with " + y + " pepperonis and " + z + " olives."
755dba422df29f2062e412dd373e79fc6946755c
BabyDunk/Tile_Price_Calculator
/app.py
6,046
3.796875
4
from CoverCost import CoverCost def get_measurement(tile_object): """ Requests conversion method to use metric or imperial :param tile_object: object :return: none """ while True: try: measure = input("Which type of measurement? (metric or imperial) ").lower() ...
67aecd74983f0c37abe4024ec429e8983362ab70
TommyCpp/AhaMoment
/leetcode/206-ReverseLinkedList.py
725
3.90625
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def reverseList(self, head): """ :type head: ListNode :rtype: ListNode """ if head == None: return None i...
96a27b34571b41f36cc577ae63d5504e250b4f13
TommyCpp/AhaMoment
/leetcode/784-LetterCasePermutation.py
856
3.703125
4
class Solution: def letterCasePermutation(self, S): """ :type S: str :rtype: List[str] """ def backtracking(S): res = [] if len(S) == 0: return [""] if len(S) == 1: # End situation if S.isnumeric(): ...
b2894bcee3f5fb73f4fdb116e991a584b3a80a1f
TommyCpp/AhaMoment
/leetcode/797-AllPathsFromSourceToTarget.py
890
3.5
4
class Solution: """ Note that for a acyclic graph, it means that every member of grpah[i] are guarantee to be bigger than i. """ def findPath(self,graph,offset): target = offset + len(graph) - 1 # offset maintain the index of the original graph results = [] if target in graph[0]...
a4290855151f2d7b801c56d2d7bc8e60caf4363b
feerahardt/Aula-06
/codelab_11_05.py/3.py
265
3.765625
4
# Crie uma função que receba uma string como argumento e retorne a # mesma string em letras maiúsculas. Faça uma chamada à função, # passando como parâmetro uma string. def nome(texto): texto = texto.upper() return texto print(nome('fernanda'))
c5db25f2d341c00dbd093bcab1d2db34b1c898e0
codylieu/DukeTextbookMarketplace
/PythonReq/test.py
953
3.515625
4
from urllib2 import Request, urlopen, URLError import json KEY = '48a841041e19085bb7a6e9cc4638ec7f'; TERM = 'FA14'; DEPT = 'ECE'; COURSE = '280L'; SEC = '001'; req = 'https://streamer.oit.duke.edu/curriculum/courses/subject/COMPSCI?access_token=' + KEY; req1 = Request(req) try: response = urlopen(req1) te...
137bf8d5c8cbb2157883d08c33f7677a66a8ea78
duyipai/Intelligent-Glove
/sensor_fusion/Generate_data.py
709
3.640625
4
#! /usr/bin/env python3 import sys # To use this script, specify one file, like # 'python Generate_data.py sample_data.txt' # The output file is saved as 'data.txt' in current directory if len(sys.argv) != 2: print('Please specify input file') exit() in_file = open(sys.argv[1]) file_name = (((sys...
d918d82456e19b4106706688d463db936dc7c12b
SarahSawadogo/make-a-profile-python-oop
/profile_class.py
311
3.609375
4
# View the readme on Github to get more information on how to start this definition. class Profile: def __init__(self, name, age, savings, plays_tennis): self.name = name self.age = age self.savings = savings self.plays_Tennis = plays_tennis print("Profile created")
03aaeaef2d1321aa76a1a74403bb7fca5f22a610
Ancksunamun/Tamrin-2-Aydin-eradat
/2.fibo.py
159
3.734375
4
n=int(input("Enter n:"))-1 a=0 b=1 c=0 fibo=[1 ] for n in range(n): c=a+b a=b b=c fibo.append(c) print(fibo)
1c4e2748b376fbe867ce2a8c27b5a27563509e9c
rwtodd/small_programs_2018
/bishop_puzzle/python_version/bishop_puzzle.py
4,249
3.546875
4
sign = lambda v: (1,-1)[v < 0] import copy class Board(): ROWS = 4 COLS = 5 @staticmethod def empty_places(): result = [] for _ in range(Board.ROWS): result.append([0]*Board.COLS) return result def __init__(self, places, prev=None, move=None): self.places = pla...
2f1a8aa44734b20a9250950ff268f5feace71be0
createnewdemo/istudy_test
/基础加强/day1/字符串操作.py
970
3.984375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2020/3/27 12:48 # @Author : lihanhan # @Email : demo1li@163.com s1 = r'\'hello, world!\'' s2 = r'\n\\hello, world!\\\n' print(s1, s2, end='') str2 = 'abc123456' # 从字符串中取出指定位置的字符(下标运算) print(str2[2]) # c # 字符串切片(从指定的开始索引到指定的结束索引) print(str2[2:5]) # c12 print(...
8459d1d50132d843115247caa875c64dffbcd618
hickcp/CalculadoraPython
/pratica.py
1,897
3.890625
4
def seep(): sep = "-" * 40 def soma(x,y): a = x + y return(print(x,"+",y,"=",a)) def sub(x, y): a = x - y return(print(x,"-",y,"=",a)) def div (x, y): a = x/y return(print(x,"/",y,"=",a)) def mult (x, y): a = x * y return(print(x,"*",y,"=",a)) seep() def teste(): while True:...
6ef793589bd46d0a795a9f17df66bc6744c83957
layamathikshara/Basic-Recursion-Problems
/Reversing_a_Sentence.py
763
3.796875
4
""" Question: Reverse a given sentence using recursion. """ def convert(lst): # converting a sentence into a list return (lst[0].split()) def reverse(List, revList): # reversing the list if List == []: firstItem = revList.pop(0) revList.insert(5,firstItem) return revList ...
d1b6531045c6f8fe2808175b2ba68e0d9bc1ec5c
raschoff88/funstuff
/funstuff/polynomial_regression.py
2,554
3.59375
4
# Module with python numeric computations import numpy as numpy # Modules used to make graphs import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D import random # Creates variable t defined as np.array (0,...,10) in .1 intervals x_1=np.random.random(1000) # Creates variable u defined as np.array (...
cd593ead80f32ebda641099f0ce5fabaf57facb4
dataCalculus/stringAnalysisProject
/harfAnalizi_2.py
2,554
3.625
4
#length of English alphabet is equal to 26 from collections import OrderedDict #düzenlemeler yapıldı... class HarfAnalizMuhendisi(): harfSozluguKucuk_count = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0, 'f': 0, 'g': 0, 'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l'...
afa1435c20c906ba4a8503278555f8a8c46779b9
Yeasayer/Random-Exercises
/Python/ex9.py
318
3.65625
4
days = "Mon Tues Wed Thu Fri Sat Sun" months = "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug" print "Here are the days: %s"% days print "Here are the months: %s"% months print """ There's something amiss... With three double quotes... We'll be able to type as much as we like. Four, Five, maybe even... ... Six lines! """
d6482340a7a0125c28ac00e22c30974bb3edf79d
riteshsharma29/Python_data_extraction
/ex_2.py
501
4.28125
4
#!/usr/bin/python # coding: utf-8 -*- #This example shows reading a dataset using csv reader import csv #creating an empty list MonthlySales = [] with open('data/MonthlySales.csv', 'r') as f: reader = csv.DictReader(f) for row in reader: MonthlySales.append(row) for a in MonthlySales: print a ...
5ec88f298d20834564af117f25404904f24ad32f
RobertaLara/ExercisesPython2
/Exercise16.py
3,609
4.125
4
# Exercício 16 - Faça um Programa para uma loja de tintas. O programa deverá pedir o tamanho em metros quadrados da área # a ser pintada. Considere que a cobertura da tinta é de 1 litro para cada 6 metros quadrados e que a tinta é vendida em # latas de 18 litros, que custam R$ 80,00 ou em galões de 3,6 litros, que cu...
f7982ba2562801a772cd0db22df7f91e66d99e1b
RobertaLara/ExercisesPython2
/Exercise04.py
396
4
4
# Exercício 04 - Faça um Programa que converta metros para centímetros # Programadora Roberta Lara import os def clear(): # Função para limpar console os.system('clear') clear() valorMetro = input("\n\nDigite o valor em metros que deseja converter para centímetros: ") valorCentimetro = float...
643ee8a498dc11c807aca9e7ca83c9c07b2454a3
balani98/unjumbled-words-game
/shuffle.py
1,313
3.859375
4
import tkinter # tkinter is python interface to TK GUI toolkit from tkinter import * from tkinter import messagebox import random from random import shuffle root = tkinter.Tk() def ans_check(): global words,num,answers user_input=el.get() if user_input==answers[num]: messagebox.showinfo("success",...
9e419de2d65836407c14543f62f94dd6e3c8e447
yusufemrebudak/Python-Studies
/if_elif.py
744
3.890625
4
# isim=input('isim: ') # yas=int(input('yas: ')) # egitim=input('Eğitim durumu (universite veya lise): ') # if (yas>=18) and (egitim=='universite' or egitim=='lise') : # print('Sayın '+isim+' ehliyet alabilirsiniz.') # else: # print('Sayın '+isim+' ehliyet alamazsınız.') ######################################...
86ac991f1d038ce07e93678c9ddee2834c02c3c5
yusufemrebudak/Python-Studies
/advanced-modules/_json.py
1,125
3.75
4
import json # person_string='{"name":"Ali","languages":["Python","C#"]}' # --> string json bilgisi # #herhangi bir kaynaktan string json bilgisini alıp python içersinde dic yapısına çevirmem lazım # result = json.loads(person_string) # print(result) # {'name': 'Ali', 'languages': ['Python', 'C#']} dic ye çevirdik # p...
406002913411dfd9538c285b1969ddcee05bf9f9
yusufemrebudak/Python-Studies
/loop_operations.py
1,956
4.5625
5
# range method for item in range(2,10): # 2 den 10 a kadar olan sayıları yazdır print(item) print(list(range(5,100,20))) # [5, 25, 45, 65, 85] basar #################### enumarete #################### greeting = 'hello' for index,letter in enumerate(greeting): print(f'index: {index} , letter: {letter}') fo...
bf1e019dd282a67e1bc14546cf88437cb487b937
yusufemrebudak/Python-Studies
/while.py
892
3.765625
4
# x=0 # while x<100: # print(x) # x+=1 # numbers=[] # i=0 # while i<5 : # sayi=int(input('sayı : ')) # numbers.append(sayi) # i+=1 # numbers.sort() # print(numbers) ################# NICE APP ##################################33 # urunler=[] # adet = int(input('kaç adet ürün eklemek istiyorsunuz...
cb8a5e949c52d3fb180a021e9d063f23bef8efbb
yusufemrebudak/Python-Studies
/veri-analizi-pandas/groupby.py
3,107
3.890625
4
import pandas as pd import numpy as np personeller ={ 'Calisan':['Ahmet Yılmaz','Yusuf Budak','Abdulkadir Budak','Ahmet Faruk Budak','Salih efe Budak','İbrahim Budak'], 'Departman':['İnsan Kaynakları','Bilgi İşlem','Muhasebe','İnsan Kaynakları','Bilgi İşlem','Muhasebe'], 'Yas':[40,21,24,25,11,55], 'Sem...
76dfc5303a170bd729de391242e64239d3ceb409
yusufemrebudak/Python-Studies
/veri-analizi-pandas/pandas-frames.py
1,476
3.9375
4
import pandas as pd # serilerde bi kolon ismi yoktur sadece indeksleme vardır #dataframelerde kolon isimleride mevcuttur s1 = pd.Series([3,2,0,1]) s2 = pd.Series([0,3,7,2]) data = dict(apples = s1 , oranges = s2) # sözlük veri yapısına verdiğimiz parametreler kolon isimlerine dönüştü print(data) # {'apples': 0 3 # ...
d02c320e9f07ce46262ca8c5bc7bf1adff3612e6
yusufemrebudak/Python-Studies
/veri-analizi-pandas/pandas-filters.py
1,541
3.765625
4
import pandas as pd import numpy as np data = np.random.randint(10,100,75).reshape(15,5) print(data) # [[10 95 49 47 48] # [94 10 30 57 31] # [65 55 72 23 14] # [91 66 81 29 70] # [13 50 27 55 10] # [88 37 77 83 24] # [60 91 55 72 25] # [39 42 33 80 57] # [82 77 46 32 35] # [83 55 77 79 81] # [29 50 64 33 61...
92d4a6772791bc8f3561192f76a90a133c36a875
yusufemrebudak/Python-Studies
/dictionary.py
985
3.5
4
# key -> value # 41-> kocaeli 34->İstanbul sehirler=['kocaeli','istanbul','bursa'] plakalar = [41,34,16] print(plakalar[ sehirler.index('bursa') ] ) ### fakat ben şunu istiyorum 2 liste üzerinden değil de tek liste üzerinden #print(plakalar['istanbul']) => 34 #print(plakalar['bursa']) => 16 plakalar ={'kocaeli':41,...
333f2d5a2ebe688d92ef6e91f26478ceb8db0d9c
cloudaice/leetcode
/minPathSum.py
883
3.546875
4
#-*- coding: utf-8 -*- # 属于最简单的动态规划, 计算出从左上角到每一个格子的最短距离,知道计算到右下角的格子 class Solution(): def minPathSum(slef, grid): dic = {} m, n = 0, 0 n = len(grid) m = len(grid[0]) if n != 0 else 0 if m * n == 0: return 0 dic[(0, 0)] = grid[0][0] for i in rang...
bb28d37a9d2ee73aefcaa279e83365bc5fe47282
cloudaice/leetcode
/sumroot.py
1,017
3.90625
4
#-*- coding: utf-8 -*- # Definition for a binary tree node class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: # @param root, a tree node # @return an integer def sumNumbers(self, root): total = [] def middl...
87703dbe28ae23d4e96ba2d4f2b4f387964fe1ec
ThejeshwarAB/programming-basics
/BasicCoding/SumOfDigits.py
70
3.828125
4
num=int(input()) s=0 while(num): s+=num%10 num//=10 print(s)
c5bdb4c791f0e34fe0bfa12ed7760f0e130f77d3
ThejeshwarAB/programming-basics
/ComplexCoding/BinaryToDecimal.py
186
3.984375
4
binary=int(input()) decimal=0 i=0 dummy=binary while(dummy): r=dummy%10 decimal+=r*int(pow(2,i)) i+=1 dummy//=10 print(f"Decimal equivalent of {binary} is: {decimal}")
a3c064d553ebba97cbc1daebbeaec23bffb5a3f7
ThejeshwarAB/programming-basics
/BasicCoding/AlphabetOrNot.py
96
3.859375
4
char=input().strip() if char.isalpha(): print("Alphabet") else: print("Not an alphabet")
53992109c5c8ed45552266bd566a0a04ca819db5
tupuku556556/python_fun
/Untitled3.py
322
3.828125
4
#!/usr/bin/env python # coding: utf-8 # In[21]: text="paypalishiring" #from string import ascii_lowercase for i in range(0,len(text), 3): for i in range(0,len(text), 1): text += text[i:i+1] + ' ' from itertools import zip_longest for x in zip_longest(*text.split()): print (' '.join(x)) # In[ ]: ...
a55605a459e20041a45d6a60888a42baf7b6d343
AndriiSokulskyi/UniverStuding2year
/Python/EducPract3.py
3,463
3.890625
4
#Переписати завдання за допомогою Linked List. # Задано масив з N цілих чисел. # Сформувати масив таким чином, щоб спочатку були всі від’ємні елементи масиву, потім додатні і, після них нульові, зберігши порядок. # Якщо якоїсь групи чисел не існує, то після кожного числа, що дорівнює K вставити рандомне число х цієї гр...
7cf6dab6aeca7b241f2b9daa0cba2b22e4ed4468
buggybear0/safe_problem
/main.py
16,488
3.609375
4
"""Solution to safe problem.""" import argparse import operator from binary_search_tree import * from constants import * from utils import * parser = argparse.ArgumentParser(description='Safe problem') parser.add_argument('--input', default='input.txt', help='path to input text file') args = par...
d89b39b3306ec6ed460705cf1095cd32b78a4f61
wmontanaro/ProjectEuler
/Problem0058.py
1,876
3.75
4
''' Project Euler Problem 58: Starting with 1 and spiralling anticlockwise in the following way, a square spiral with side length 7 is formed. 37 36 35 34 33 32 31 38 17 16 15 14 13 30 39 18 5 4 3 12 29 40 19 6 1 2 11 28 41 20 7 8 9 10 27 42 21 22 23 24 25 26 43 44 45 46 47 48 49 It is interesting to note t...
a0d8df8849744d997232c07230c500ca06557eb3
wmontanaro/ProjectEuler
/Problem0048.py
339
3.578125
4
''' Project Euler Problem 48: The series, 1^1 + 2^2 + 3^3 + ... + 10^10 = 10405071317. Find the last ten digits of the series, 1^1 + 2^2 + 3^3 + ... + 1000^1000. ''' def main(n): total = 0 for i in range(1, n+1): total += i**i s = str(total) return int(s[-10:]) print("Problem 48 solution: " ...
7889022b02d5261c27885a1605cffbcf26e3b5fd
wmontanaro/ProjectEuler
/Problem0038.py
1,847
3.796875
4
''' Project Euler Problem 38: Take the number 192 and multiply it by each of 1, 2, and 3: 192 × 1 = 192 192 × 2 = 384 192 × 3 = 576 By concatenating each product we get the 1 to 9 pandigital, 192384576. We will call 192384576 the concatenated product of 192 and (1,2,3) The same can be achieved by starting with 9 and...
e935f79835442fad72c90f429b93b5b5b2872e0e
wmontanaro/ProjectEuler
/Problem0016.py
324
3.8125
4
''' Project Euler Problem 16: 2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of the number 21000? ''' def sum_digits(n): s = str(n) total = 0 for char in s: total += int(char) return total print("Problem 16 solution: " + str(sum_digits(2**1000...
44eaf6ab89cd11096195e6ec9895bfc746f57967
wmontanaro/ProjectEuler
/Problem0033.py
2,311
3.625
4
''' Project Euler Problem 33: The fraction 49/98 is a curious fraction, as an inexperienced mathematician in attempting to simplify it may incorrectly believe that 49/98 = 4/8, which is correct, is obtained by cancelling the 9s. We shall consider fractions like, 30/50 = 3/5, to be trivial examples. There are exactly...
1035996f4e5b2653a066e142dbf18dd340189d66
wmontanaro/ProjectEuler
/Problem0030.py
972
3.75
4
''' Project Euler Problem 30: Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits: 1634 = 1^4 + 6^4 + 3^4 + 4^4 8208 = 8^4 + 2^4 + 0^4 + 8^4 9474 = 9^4 + 4^4 + 7^4 + 4^4 As 1 = 1^4 is not a sum it is not included. The sum of these numbers is 1634 + 8208 + 9474 =...
c2d1f3a29fe34f4159a708b9ad099678a1eeea6f
wmontanaro/ProjectEuler
/Problem0057.py
1,490
3.859375
4
''' Project Euler Problem 57: It is possible to show that the square root of two can be expressed as an infinite continued fraction. sqrt(2) = 1 + 1/(2 + 1/(2 + 1/(2 + ... ))) = 1.414213... By expanding this for the first four iterations, we get: 1 + 1/2 = 3/2 = 1.5 1 + 1/(2 + 1/2) = 7/5 = 1.4 1 + 1/(2 + 1/(2 + 1/2...
c6d3212bab67ab74ac6aa88960e40afb54a90da6
pranjalpandey1511/Binary-Search-2
/first_and_last_occurence.py
1,459
3.515625
4
#find_minimum_rotated_sorted_array #time complexity: O(logN) #space complexity: O(1) #Did this code successfully run on Leetcode : Yes #Any problem you faced while coding this : No class Solution: def searchRange(self, nums: List[int], target: int) -> List[int]: res = [] if nums == None: ...
d414c79520bd2542f0cb64f158dd0958b3b5aeee
madhuri7112/MyGeeks
/find_two_repeating_elements.py
689
4.0625
4
''' Author: Madhuri Palagummi Date: 20-05-2017 Program: Find two elements whose sum is closest to zero Reference: http://www.geeksforgeeks.org/find-the-two-repeating-elements-in-a-given-array/ ''' def find_two_repeating_elements(num_list): for num in num_list: num_list[abs(num)] = -1*num_list[abs(num)] ...
a849e9d22c7301fcee6ec44fea0acb33d9b78d87
madhuri7112/MyGeeks
/check_consecutive.py
565
3.8125
4
def main(): nums = [1,3,4,3] is_consecutive = check_consecutive(nums) print is_consecutive def check_consecutive(nums): min = nums[0] max = nums[0] for num in nums: if num<min: min = num if num>max: max = num if ((max-min+1)!= len(nums)): ...
311b74c9eb6d34d907cb3eebbac92e01f7b01a99
madhuri7112/MyGeeks
/append_and_delete.py
839
3.71875
4
def main(): init_str = "aba" target = "aba" k = 9 if (append_and_delete(init_str, target, k)): print "Yes" else: print "No" def append_and_delete(init_str, target, k): init_l = len(init_str) target_l = len(target) if k > init_l + target_l: return True #find num of commo...
05170fbd3dfee9f3aaea9a7175265273f92d313e
madhuri7112/MyGeeks
/lost_duplicated.py
756
3.890625
4
#https://www.geeksforgeeks.org/find-lost-element-from-a-duplicated-array/ #This solution is assuming the two arrays are sorted def main(): orig = [1, 4 ,5, 7, 9, 16] missing = [1,5,7,9,16] num = find_lost_element(orig, missing) print num #first is the original array and second is the one with missing element ...
5509b9321a4c5776d62ca0c11d1cf200397cab4f
banana-sniffer/anderson_CS
/hello_github.py
220
3.546875
4
print("Hello Github!") print("Hello LobsterCheese!") if (1 == 1): print("scotch dog tape") if (1 == 1): print("Hello github again!") angela = "playing" if (angela == "playing"): print("LOl") else: print("bored")
e46f4efb2c303e4e5ca85de2eaef94b614ebd6c2
tengdann/SI_507
/Homework_4/hw4.py
4,452
3.765625
4
''' SI 507 F18 homework 4: Classes and Inheritance Your discussion section: 003 People you worked with: ######### DO NOT CHANGE PROVIDED CODE ############ ''' ####################################################################### #---------- Part 1: Class ###########################################################...
2f5fc8a24b97cc19987d1387525235936768d3b6
tengdann/SI_507
/Lecture_9/something.py
1,719
3.6875
4
import sqlite3 conn = sqlite3.connect('Northwind_small.sqlite') cur = conn.cursor() # input = ('Western Europe',) # cur.execute('SELECT CompanyName FROM Customer WHERE Region = ?', input) # print('Companies in Western Europe') # print('---------------------------') # for row in cur: # print(row[0]) # print()...
7faa984d489feb24213e27ef08587ec76b16233e
tengdann/SI_507
/Homework_2/cards2.py
4,963
4.09375
4
import unittest # Because what even is importing from another file class Card(object): suit_names = ["Diamonds","Clubs","Hearts","Spades"] rank_levels = [1,2,3,4,5,6,7,8,9,10,11,12,13] faces = {1:"Ace",11:"Jack",12:"Queen",13:"King"} def __init__(self, suit=0,rank=2): self.suit = self.suit_na...
1b68093bd759731471133a6449cdc74f15ad960f
stoneNo/UNO
/deck.py
871
3.734375
4
#!/usr/bin/python # -*- coding:utf-8 -*- from cards import * import copy import random class Deck(object): def __init__(self): self.deck = [] self.color = ["green", "yellow", "red", "blue"] self.letter = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "+2", "+4", "ban", "revers", "chan...
6a296745a5d413d0f2c23635425fba1e751d1af1
DanielOjo/Iteration
/Classroom exercises/Development/Iteration Class Exercise (Development Part 2).py
347
4.21875
4
#DanielOgunlana #31-10-2014 #Iteration Class Exercise (Development Part 2) number_stars = int(input("How many stars do you want on each row:")) number_display = int(input("How many times would you like this to display?:")) stars_printed = "*" for stars in range(1,number_display+1): print(stars_printed*n...
0c0d1092bc53e7b30648601701b996cb95bc1b23
madhavsharma/Data_Science
/Twitter_Analysis/term_sentiment.py
2,288
3.5
4
''' @Author : Madhav @Summary: Calculates the sentiment score of a new words in a tweet. ''' import sys import json import re def hw(sent_file,tweet_file): scores = {} with open(sent_file) as f: lines = f.readlines() for line in range(len(lines)): term, score = lines[line]...
bedf3b6a28190bca51edf2eea4328371078a3c14
LSSTDESC/DESCFormats
/descformats/base.py
4,591
3.515625
4
import pathlib class FileValidationError(Exception): pass class DataFile: """ A class representing a DataFile to be made by pipeline stages and passed on to subsequent ones. DataFile itself should not be instantiated - instead subclasses should be defined for different file types. These ...
e537db058c41d167b3f02a31883d608a5ee1786e
asterane/python-exercises
/other/ResistorTolerance.py
331
3.65625
4
while True: txtval=eval(input("Value: ")) if txtval=="stop": print("\n") break try: val=int(txtval) except: print("\n") continue tol=0.05*(val) upper=val+tol lower=val-tol print(("Tolerance: %s \nUpper: %s \nLower: %s \n" %(tol, upper,...
b5e899274afdc81c7f73fce542979378cb475a2b
asterane/python-exercises
/cs50/pset6/credit/credit.py
1,017
3.8125
4
from sys import exit # get a credit card number from the user number = input("Number: ") digits = [] code = "INVALID" # place all digits into a list in reverse order for c in number: try: digits.insert(0, int(c)) except ValueError: print(code) exit(1) # check for characteristic featur...
d223031deac627cd02f4c4cb223534b185b07579
asterane/python-exercises
/other/friend/Multiplication Tables.py
204
4.21875
4
print("What multiplication table would you like? ") i = input() print("Here's your table: ") for j in range(11): print(i, " x ", j, "=", i * j) # The code above creates the table... I hope. #
5e78fe72459f0ba069aab9dd547e2a2a57ac40bc
asterane/python-exercises
/hello-world/star.py
113
3.796875
4
numStars = int(input ("How many stars do you want? ")) + 1 for i in range (1, numStars): print('*', end=' ')
e58833115a377540e81bf986a7ae07ab6052f2f9
walterscarborough/verification-group-project
/python/pyexz3-modified/bubble_sort_wrapper.py
863
3.90625
4
__author__ = 'AWood' def bubble_sort_wrapper(x, y, z): array_in = [x, y, z] array_in = bubble_sort(array_in) return tuple(array_in) def expected_result(): return [ (0, 2, 9), (0, 0, 2), (0, 1, 2), (0, 2, 8), (0, 0, 0), (2, 8, 9), ...
07cfb29400d4263b8f486219587e8349459e1a67
walterscarborough/verification-group-project
/python/pyexz3-modified/instrumentation/bubble_sort_wrapper.py
2,181
3.625
4
__author__ = 'AWood' from instrumentation import Instrumentation def bubble_sort_wrapper(x, y, z): array_in = [x, y, z] array_in = bubble_sort(array_in) return tuple(array_in) def expected_result(): return [ (0, 2, 9), (0, 0, 2), (0, 1, 2), (0, 2, 8...
f077759634401f5e48619bfc41b8f1ed257e8874
caiuafranca/projetos
/Python/Introdução/fatorial.py
218
4.09375
4
#!/usr/bin/python #-*-coding:latin1-*- __author__="Caiua Franca" __date__="$DD/MM/AA hh:mm:ss$" num=input("Entre com o numero: ") fat=1 for i in range(1,num+1): fat=fat*i print "O Fatorial do Numero",num,"é: ",fat
9ec24a10f6e144bc02ec56e2b3a08c5d6ef99c3c
google-code/0xic-zex
/Python/atbash.py
1,344
3.953125
4
r1 = {'A':'0','B':'1','C':'2','D':'3','E':'4','F':'5','G':'6','H':'7','I':'8','J':'9','K':'!','L':'#','M':'$','N':'%','O':'^','P':'&','Q':'*','R':'(','S':')','T':'-','U':'=','V':',','W':'.','X':';','Y':':','Z':']','@':'26'} r2 = {'0':'Z','1':'Y','2':'X','3':'W','4':'V','5':'U','6':'T','7':'S','8':'R','9':'Q','!':'P'...
6b0016fb58db47ea3721d9ca0e489092564f70a5
google-code/0xic-zex
/Python/spanishtrenchcipher.py
960
3.828125
4
r1 = {'A':'53'or'91','B':'12'or'70','C':'40'or '86','D':'31','E':'27'or'43','F':'24','G':'16','H':'11','Y':'40'or '59','J':'22','L':'13','M':'15','N':'96' or'66','O':'84'or '39','P':'75','Q':'71','S':'28' or '54', 'R':'28' or '54', 'T':'19','U':'74' or '44'} def replace_all(text, *dic): for h in dic: for i, j in ...
aecaac8744a5e6aaa9903a7b81461b19dff9faae
teresahu/digitalcrafts
/python-exercises-2/square2.py
160
3.71875
4
def prompter(): return int(input("How big is the square? >")) def squarer(size): for i in range(size): print ("*" * size) squarer(prompter())