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
8eddb17d135cec0e30f093e6425ac43dec98dcef
suryak24/python-code
/50.py
114
3.84375
4
n=int(input("Enetr the n value:")) sum=1; i=1 for i in range(1,n): sum=sum*2; if(sum==n): print("Yes") i=i+1
5600bdadd711889a6beccb3c611de2015cc87f3b
suryak24/python-code
/94.py
149
3.984375
4
n=int(input("Enter the n value:")) m=int(input("Enter the m value:")) a=[] for i in range(0,n): num=int(input()) a.append(num) print(a[m-1])
4123910d0890c657c80215c58b39b124f978aec1
suryak24/python-code
/114.py
180
3.625
4
n=int(input("Enter the n value:")) m=int(input("Enter the m value:")) a=[] b=[] for i in range(n): k=int(input()) a.append(k) for i in a: if i%2!=0: b.append(i) print(b[m-1])
5fe4bb3a8d3946fa6c1fb59da53b8e763c81a804
suryak24/python-code
/108.py
139
3.8125
4
a=int(input("Enter the a value:")) b=int(input("Enter the b value:")) c=int(input("Enter the c value:")) s=((c//2)*(2*a+(c-1)*b)) print(s)
f15a6196a0d104906632511d99f5e96728c855f4
suryak24/python-code
/107.py
125
3.90625
4
n=int(input("Enter the n value:")) m=int(input("Enter the m value:")) p=int(input("Enter the p value:")) print(int((n*m)/p))
fca8a8264ea5abd08e43a3ae22f23ed465abd200
dpinezich/python_foundations
/Source/solutions/ex_04.py
478
4.0625
4
import maths def distance(x1, y1, x2, y2): return maths.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2) def volume_from_radius(radius): return 4.0/3 * maths.pi * radius ** 3 def volume_from_points(x1, y1, x2, y2): radius = distance(x1, y1, x2, y2) return volume_from_radius(radius) x1 = int(input('Point 1 x-co...
c00f29be5003e4b6bc8d610f02dcd1980b88d98b
KalpIC/pythonrecap
/venv/For_else in python.py
161
3.703125
4
nums =[12,16,18,21,20,24] tup = (25, 58,51) print(type(tup)) for num in nums: if num % 5 ==0: print(num) break else: print("not found")
0896981bf340e5b3f324802518bffe09c26f66df
gscho74/ImageProcessing
/chapter2/image_bright.py
588
3.5
4
# 나. 영상의 밝기조절 # g(x,y)=f(x,y)+n import numpy as np from scipy import misc import matplotlib.pyplot as plt im = misc.imread('image/lena_256.bmp') row, col = im.shape num = 50 im_bright = im + num im_dark = im - num im_bright2=np.where((im+num)>255,255,im+num) im_dark2=np.where((im-num)<0,0,im-num) plt.subplot(1,3,1); ...
a9abb01c7c9db8ae7ddccb1bb07a80d2d9c6d3c6
gscho74/ImageProcessing
/chapter3/add_image2.py
531
3.578125
4
# 3-2 영상의 덧셈 # h(x,y) = af(x,y)+(1-a)g(x,y) import numpy as np from scipy import misc import matplotlib.pyplot as plt im_new3 = np.zeros(shape=(256,256)) for i in range(1,9): filename = 'image/noise'+ str(i) +'.bmp' im = misc.imread(filename) plt.subplot(2,4,i),plt.imshow(im),plt.gray() plt.title('No...
eedc11f8317d722b60c57941cf51e3bd3ab40114
Crootcovitz/Kurs_iSAPython
/dzien3/war2.py
621
3.984375
4
nazwisko=input('Podaj nazwisko:\n') # print(type(nazwisko)) #jeśli w stringu są cyfry, napisać komunikat i przerwać proogram if not nazwisko.isalpha(): print('Muszą być tylko litery.') exit(99) #usunąć whitespace'y z początku i końca #naz_czyste=nazwisko.strip() # nazwisko=nazwisko.strip() #zamienić wszystkie ...
f94fc82916410a57d8abe418a65aff6fffe15ff9
Crootcovitz/Kurs_iSAPython
/dzien4/petla2.py
340
3.9375
4
prawidlowe = False while not prawidlowe: nazwisko = input('Podaj nazwisko drukowanymi literami lub Q aby zakończyć:\n') if nazwisko.upper() == 'Q': print('Do widzenia.') quit() elif nazwisko.isalpha(): if nazwisko.isupper(): prawidlowe = True print('Gratulacje, jesteś ...
add7a98a6ae7486379f79e55a394263cc03ed409
Crootcovitz/Kurs_iSAPython
/dzien6/slownik.py
500
3.6875
4
elementy = {1: 'ola', 0: 'ala', 2: 'ela'} print(elementy) print(elementy[1]) slownik = {"imie": 'Adam', 'nazwisko': 'Kowalski', 'wiek': 32} # # print(slownik.keys()) # print(slownik.values()) # # for klucz, wartosc in slownik.items(): # print(f'Klucz: {klucz} ma wartość {wartosc}') # # if 'adres' in slownik.keys(...
4da207a1a2319c55eb3a8553a867e2719ae78065
lrally1/Tower_Defense
/lib/projectile.py
2,687
3.75
4
from pygame import sprite, Rect from math import atan2, cos, sin, hypot # Base Projectile class class Projectile(sprite.Sprite): def __init__(self, pos, tower, target, image, speed, damage): sprite.Sprite.__init__(self) self.pos = pos self.tower = tower self.target = target ...
0e9d4d9c0892d2ab85cf04197a0e290e0b9b72c8
EAzriq/python2020-workshop-main2
/setup.py
1,992
3.9375
4
# SETUP FILE # This file creates the config.ini that will store our encrypted password # It will only be run once during initialization, but it is handy to keep it here in case you want to reset your password # or if something ever goes wrong! # Remember to import encryption(handles encryption/decryption) & json(to s...
d898138fb7d85be9975b061e66900d27c9f37d39
macleodmac/pypatterns
/creational/abstract_factory/vehicles.py
529
3.671875
4
class Vehicle(object): MAX_SPEED = 500 def __init__(self, speed=0): self.speed = speed def accelerate(self, speed): new_speed = self.speed + speed self.speed = min(new_speed, self.MAX_SPEED) def decelerate(self, speed): new_speed = self.speed - speed self.spe...
0ed87021544bd5c80d71778b90b3e2d7f2db17b2
Ashleyyychao/git
/exercise_5.py
110
3.859375
4
x = input('請輸入') b = '' for i in x: b = i + b if b == x: print('true') else: print('false')
8e6a98926bfdb9dd1d7af31e352985593396c7a6
Ruchir17-cmd/HacktoberFest2022-1
/longest_common_subsequence.py
3,569
4.03125
4
""" Dynamic Programming (DP) : Algorithm for finding Longest Common subsequence in python LONGEST COMMON SUBSEQUENCE PROBLEM: Given two strings, find the length of longest subsequence present in both of them. A subsequence is a sequence that appears in the same relative order and NOT necessarily continuous. Name: A...
1ed3bf3f1f9d6012e7873c6ee1be7ac850525b4f
actively-lazy/programming-language-3-
/Mtt/mtt3.py
915
3.96875
4
# import time # import Tkinter # # root = Tk() # root.title("MTT3") # # # listbox = Listbox(root) # # # lbl.pack() # listbox.pack() # # root.mainloop() from Tkinter import * top = Tk() top.title("MTT3 Karunesh") lbl = Label(top, text="Subjects in Semester 6") lb2 = Label(top, text="Select the Subjects you want") lb3 ...
14fcdf32541ff677acd5bf8f30676f03b6074f8c
janlee1020/Scientific-Calculator-Project
/Scientific Calculator.py
473
3.859375
4
#Create a Scientific Calculator from tkinter import * from math import * win = Tk() win.title("Scientific Calculator") input = Entry(win, width = 40, fg = "White", bg = "Black") input.grid(column = 0, row = 0, padx = 5, pady = 5, columnspan = 5) def clear(): input.delete(0, END) def stringtoAnswer(...
0cc4422dd476ab0e9ddc4b54c91f05d62c3d1684
nchong128/fit2004
/Week 1/stackQueue.py
317
3.96875
4
def computeList(list): # Will always have a number followed by operator followed by number def main(): # Examples: # 5*5^3 -> 5*(5^3) # 5/10 * 3 -> (5/10) * 3 # 5 + 2 * 10 -> 5 + (2*10) # 5 * 3 * 2 -> 5 * 3 * 2 # 5 * 3 + 2 -> (5*3) + 2 x = [5, "*", 5, "^", 3] computeList(x)
fbe92e35a0093d9aa392b043b5f707519d17ad65
ESSS/datatree
/datatree/symbols.py
464
3.65625
4
class Symbol(object): """A symbol is used to represent a string, usually one that is intended to be rendered as unquoted. """ def __init__(self, name): self.name = name def __getattr__(self, name): self.__dict__[name] = result = self.__dict__.get(name, self.__class__(name)) ...
f0823e0287a52afb7cc30808a247557df4d084bf
ESSS/datatree
/example.py
796
3.578125
4
from datatree import Tree if __name__ == '__main__': tree = Tree() #tree.instruct('xml', version='1.0') with tree.node("author") as author: author.node('name', 'Terry Pratchett') author.node('genre', 'Fantasy/Comedy') author.comment("Only 2 books listed") with author.node('n...
14045d6da76bce0d8a09990bac0f388448581cfc
shanerodricks/CPSC230_assignment6
/standard_dev.py
1,241
4.09375
4
import math pos_int = int(input("Enter a positive integer: ")) list = [] def print_sorted(int_list): #takes a list of integers and prints them sorted_grades print(list.sort()) def compute_mean(int_list): #takes list of integers and prints mean count = 0 var = 0 sum = 0 for num in list: ...
e0d40cf7db84bfbdd908470ceaf3b6714784be16
Erikm8/Get-Home
/hw7.py
5,577
3.59375
4
#!/usr/bin/env python3 ''' Erik Miller's Foundations of Programming: hw7 To run this script, from the pycharm Terminal: python hw7.py Requires: python3 ''' from sortedcontainers import SortedDict def print_menu(): print('1. Print Users') print('2. Add a User') print('3. Remove a User...
6c9c24951d4d849beea1a962cee78ccaec9f455d
jakegoodman01/kanu
/tests/test_equation.py
1,186
3.640625
4
import unittest from kanu.equation import * class EquationTests(unittest.TestCase): def test_solve_single_linear_equation(self): self.assertEqual(solve_single_linear_equation('x=x'), 'There are infinite solutions') self.assertEqual(solve_single_linear_equation(' x = x'), 'There are infinit...
9fb46b04af383f957bffb69b737252df3210bb6f
Rasesh2005/Tic-Tac-Toe-AI
/main.py
5,437
3.703125
4
from random import choice board = [' ']*9 def findEmpty(board): for index, item in enumerate(board): if item == ' ': return index def printBoard(board): print(' | | ') print(f' {board[0]} | {board[1]} | {board[2]} ') print(' | | ') print('_'*11) print(' | ...
b71a8bce48f06f65a21b0d933ba684c4b6e57190
abecm/abe
/how_many_days.py
104
3.609375
4
def how_many_days(m): d=[0,31,28,31,30,31,30,31,31,30,31,30,31] return(d[m]) print(how_many_days(1))
b05426de80f68892aa78bf6088187c43f3ee29d6
Naveen745/Python_LA_Crime_Analysis
/LA Crime Analysis/LAPD_Crime_Analysis.py
3,790
3.609375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ THIS IS THE CODE USED TO CLEAN THE DATASET. DROPPED RECORDS WITH NO VALUES AND REDUCED THE NUMBER OF ATTRIBUTES i mport pandas as pd df = pd.read_csv("Crime_Data_from_2010_to_Present.csv") columns = ['DR Number','Reporting District','Crime Code','MO Codes','Prem...
3004d7f371f5a3e8321d711a946499d89844bdba
francislz/8-puzzle
/bfs/bfs.py
3,319
3.78125
4
#!/usr/bin/python # -*- coding: utf-8 -*- import copy class BFS: def __init__(self, matrix, goal, max_plays=None, max_time = None, start_time=None): self.matrix = matrix self.start = copy.deepcopy(matrix) self.goal = goal self.max_plays = max_plays self.max_time = max_time...
ce2cd50babd97d616dc3c2d8f6474dfe2c9c77a9
chaitanyatech/python
/sample.py
668
3.703125
4
#!/usr/bin/python import os import sys import errno import shutil ''' #make a directory using try catch to get tthe error type path = sys.argv[1] try: os.makedirs(path,0755) except OSError as exception: if exception.errno != errno.EEXIST: raise #make a directory with if else path = sys.argv...
1651160aade5f22daa568c65caf14b7dfe065b1e
Riceyo/QA-Consulting-ONS-Academy
/PySpark/textfile_split.py
660
3.71875
4
from pyspark import SparkConf, SparkContext def GetMale(x): split = x.split("|") # split the rows data by pipe if split[2] == "M": return True else: return False def GetFemale(x): split = x.split("|") # split the rows data by pipe if split[2] == "F": return True else: return False conf = SparkConf() sc...
e9a58e74c280fecc529e5291d4bf7143c5d358fb
Riceyo/QA-Consulting-ONS-Academy
/Python/input_if_nested_tax.py
720
3.890625
4
salary = int(input("Salary? ")) grade = input("Grade? ") dept = input("Dept? ") if salary > 15000: if dept == 'IT': if int(grade) < 11: tax = 9 if int(grade) > 10: tax = 17 if grade == 'CTO': tax = 2 if dept == 'HR': if int(grade)...
3784bcdfa10daa389b0b4a9752f0fd6ea0666d96
Riceyo/QA-Consulting-ONS-Academy
/Python/input_sum_print.py
127
3.875
4
num1 = input("Enter number ") num2 = input("Enter number ") a = int(num1) b = int(num2) print("%d + %d = %d" % (a, b, a+b))
fdde4c3b327fc39f4c7c5b9d51d5481f6041178d
Riceyo/QA-Consulting-ONS-Academy
/Python/input_alphabet_count.py
282
3.859375
4
inputstring = input("input alphabet string ").lower() alphabet = "abcdefghijklmnopqrstuvwxyz" for loop in alphabet: if inputstring.count(loop) > 0: print(loop, end="") print("-", end="") print(inputstring.count(loop), end="") print("")
ccbcf463e3edea98bc1a99b3316ac1261924773a
Riceyo/QA-Consulting-ONS-Academy
/Python/inheritance_single.py
1,204
4.0625
4
class empty: pass class parent: def printparent(self): print("parent") class child(parent): def printchild(self): print("child") class grandchild(child): def printgrandchild(self): print("grandchild") print(issubclass(grandchild, child)) # check if sub class ...
d13d28d4f660f162e1616826d3ca3159b11f2d60
miht-sem/algorithms
/quick-sort.py
1,297
3.8125
4
from random import randint def quick_merge_middle_sort(list_): if len(list_) < 2: return list_ else: main_el = len(list_) // 2 pivot = list_[main_el] less = [i for i in list_[:main_el] if i <= pivot] + [i for i in list_[main_el + 1:] if i <= pivot] greater = [i for i in...
b172e59d006dadf853cc7edbdbbe5dbc1618255b
rawanvib/edx_course
/problem set 1/problem_1.py
146
3.84375
4
s count=0 vowels=['a','e','i','o','u'] for i in s: if i in vowels: count+=1 else: continue print("Number of vowels: ",count)
f8222ae9887585a3e998a35fe7eb1f3d6991dc47
AlessiaGagliano/esercitazione
/main.py
184
3.796875
4
print("Buongiorno io sono Alessia") a = str(input("Dimmi il tuo nome")) print("ciao", a) b = str(input("Quanti anni hai?")) print("Ora so che hai", b, "anni") print("benvenuto")
d2e07ea83aea3f9fdd0fe3bb2335dd0d214de661
chaz05/SSW-567
/SSW-567/Assignment0/tjfTriangle.py
1,739
3.734375
4
''' Created on Jan 23, 2017 @author: tjfloyd ''' def classifyTriangle(a, b, c, thresh = 0.0001): ''' Function returns type of triangle a, b, and c are the lengths of each of the sides. Expect real values. thresh represents the resolution for comparing two sides to be equal ''' ...
a376c4c5c40ea4c84da52386b8ad476e31e9069f
antoninabondarchuk/algorithms_and_data_structures
/dynamic/max_profit.py
346
3.984375
4
def maxProfit(prices) -> int: min_price = float('inf') max_delta = 0 for price in prices: min_price = min(min_price, price) current_delta = price - min_price max_delta = max(max_delta, current_delta) return max_delta if __name__ == '__main__': result1 = maxProfit([3, 1, 7, ...
aa6dd8d09043290ecea8bdf154196d6a1238ec6e
antoninabondarchuk/algorithms_and_data_structures
/strings/permutations_with_duplicates.py
782
3.984375
4
def create_hash_map(string): hash_map = {} for char in string: if char in hash_map: hash_map[char] += 1 else: hash_map[char] = 1 return hash_map def duplicated_permutation(hash_map, prefix, remaining, result_list): if remaining == 0: result_list.append(p...
1a48020c36bdb9d2d66c0ac748e9a6b8737377f6
antoninabondarchuk/algorithms_and_data_structures
/lists/is_valid_sudoku.py
1,106
3.671875
4
def isValidSudoku(board) -> bool: met_nums = {} for i in range(len(board)): for j in range(len(board[0])): if board[i][j] == '.': continue if not board[i][j] in met_nums: met_nums[board[i][j]] = [(i, j), ] continue for c...
6b8442b9cd22aa2eeb37966d42ca6511f3ba6c17
antoninabondarchuk/algorithms_and_data_structures
/sorting/merge_sort.py
797
4.125
4
def merge_sort(array): if len(array) < 2: return array sorted_array = [] middle = int(len(array) / 2) left = merge_sort(array[:middle]) right = merge_sort(array[middle:]) left_i = 0 right_i = 0 while left_i < len(left) and right_i < len(right): if left[left_i] > right[rig...
0f7739e73ad8d7d108644b20ae0661ac1bee10ae
nsmryan/aoc2020
/day23/day23.py
2,065
3.65625
4
from collections import deque import sys def result(cups): startindex = 0 for index in range(0, len(cups)): if cups[index] == '1': startindex = index + 1 break result_list = [] for index in range(0, len(cups) - 1): result_list.append(cups[(startindex...
ea98bba8ce53db4fed46639cc821f616a3516156
nsmryan/aoc2020
/day20/day20.py
9,160
3.578125
4
import itertools import sys import math import copy import functools class Tile(): def __init__(self, num, pixels, rotation, horiz, vert): self.num = num self.pixels = [[pixel for pixel in line] for line in pixels] self.rotation = rotation self.horiz = horiz ...
7668ab3a9fed23fd3f74e254fa5abb4d8d3ab81a
edsar/sliderule
/data-wrangling-json.py
4,721
3.625
4
import pandas as pd import json from pandas.io.json import json_normalize # Using data in file 'data/world_bank_projects.json' and the techniques demonstrated above, df = pd.read_json('data/world_bank_projects.json') # 1. Find the 10 countries with most projects df[["countryname"]].stack().value_counts()[:10] # Peo...
e3801b0173ddeb250a8328bad841d0a7d584da9b
wuchenkang/ArtificialIntelligenceExperiment
/Exp2/PreProcess.py
1,496
3.5625
4
import csv # 将数据集依据K-折交叉验证划分为训练集和验证集 def kFold(data_set, k): result = [[[], []] for _ in range(k)] for i in range(k): for j in range(len(data_set)): if j % k != i: result[i][0].append(data_set[j][:]) else: result[i][1].append(data_set[j][:]) ...
12ee12d7d101ed158bae6079f14e8a6360c424f6
elicecheng/Python-Practice-Code
/Exercise1.py
359
4.15625
4
#Exercise 1 #Asks the user to enter their name and age. #Print out a message addressed to them that #tells them the year that they will turn 100 years old. import datetime name = input("What is your name?") age = int(input("How old are you?")) now = datetime.datetime.now() year = (now.year - age) + 100 print(name, ...
b9fbb71b95b9fa8379871470e58d8709272784f9
mathans1695/Ireland-Covid-cases
/latest_cases.py
1,458
3.921875
4
import pandas as pd import shapefile class LatestCases: '''LatestCases deal with latest covid cases params -> path to csv params -> number of counties/district present in csv file''' def __init__(self, path, num_of_counties): '''create pandas dataframe and store it in df variable get latest data using tai...
cb04890ea51898c5c225686f982e77da4dc71535
playwithbear/Casino-Games
/Roulette Basic.py
1,488
4.28125
4
# Basic Roulette Mechanics # # Key attributes: # 1. Provide a player with a balance # 2. Take a player bet # 3. 'Spin' Roulette wheel # 4. Return result to player and update balance if necessary with winnings # # NB. This roulette generator only assumes a bet on one of the evens i.e. red of black to test a gam...
b07c42d4975cd4f5007808708ed3b292436e8653
vanshnarang1302/STUDENT-MANAGEMENT-SYSTEM-TKINTER-SQL-PYTHON
/fronthand.py
1,679
3.765625
4
import tkinter as tk from tkinter import Button import database from database import * mainWindow=tk.Tk() mainWindow.title("add data") mainheadinglabel=tk.Label(mainWindow,text='STUDENT MAGANGEMENT SYSTEM',padx=(30),pady=(30), fg='red') mainheadinglabel.grid(row=0 , column=2) headinglabel1=tk.Label(mainWi...
0a93bb20727c72e47ced880b91f812a4f11c2263
HensonGuo/learn_python
/testclass.py
1,694
3.671875
4
# coding=utf-8 __author__ = 'g7842' class Student(object): #限制属性的添加;节省内存 #__slots__ = ('__name', '__age', '__skill', 'nick', 'heigt', 'weight', 'score', '__count') #staticvar是类变量,可以由类名直接调用,也可以有对象来调用 staticvar = 0 def __init__(self, name, age, nick): self.__name = name self.__age ...
969b82540a98d9ad7a258120bfd3357beb65e2ed
kiernan16/bertrand_box
/bertrand_box.py
856
3.71875
4
#!/usr/bin/env python3 import random box_A = ["G","G"] #not needed, only for demostration box_B = ["G","S"] box_C = ["S","S"] #not needed, only for demostration x = 0 gold_picked = 0 while x < 10000: pick_box = random.randrange(0,3) if pick_box == 0: #box_A, automatic win gold_picked += 1 ...
11e8f7bf60f6fd72873787d8c4d6c5a376247174
kwright17/OLA
/treasure.py
2,157
3.765625
4
#OLA 108 by kres wright, CSCI 1170-009 #PROGRAM ID: treasure.py/ Following the Treasure Map Task #Remarks: This program allows Reeborg to follow clues to the 'treasure' #(distance corner with 5 beepers) #main function def main(): direction = beepers_on_corner() while direction != 5: distance = distance...
3eb04dd601286e6e593e18c02e3a2bb7dff00aa5
rick-eth0/curso-em-video-exercicio
/exercicios/ex017.py
194
3.578125
4
import math co = float(input('comprimento do cateto aposto: ')) ca = float(input('comprimento do cateto adiancnete: ')) hi = math.hypot(co, ca) print('A hipetenusa vai medir {:.2f}'.format(hi))
02beb464c74fdd64d8112853ac564deed09badfd
rick-eth0/curso-em-video-exercicio
/exercicios/ex04.py
361
3.734375
4
a = input('Digite algo: ') print('O tipo primitivo desse valor é ',type(a)) print('So tem espaços?',a.isspace()) print('É so um numero?',a.isnumeric()) print('É so um alfabetico?',a.isalpha()) print('É um alfanumerio?',a.isnumeric()) print('Esta em maiuscula?',a.isupper()) print('Esta em minusculas?',a.islower()) prin...
8c9b73b2964cc0492a6dcc6ab063492b334b4ebc
rick-eth0/curso-em-video-exercicio
/exercicios/ex029.py
337
3.78125
4
velocidade = float(input('Qual é a velocidade atual do carro ?')) if velocidade > 80: print('\033[1;31mMULTADO!\033[m voce excedeu o limite permitido que é de 80km/h') multa = (velocidade-80) * 7 print('Voce deve pagar \033[4;30muma multa de R${:.2f}\033[m'.format(multa)) print('Tenha um bom dia! Dirija com...
dcff13d99d85ec1fc86f71ff273756fa6655af7a
rick-eth0/curso-em-video-exercicio
/exercicios/ex064.py
268
3.828125
4
num = cont = soma = 0 num = int(input('Digite um numero [999 para parar]: ')) while num != 999: soma += num cont += 1 num = int(input('Digite um numero [999 para parar]: ')) print('Vce digitou {} numeros e a sima entres els foi {}.'.format(cont, soma))
780aadfeef07b67f84e962d06b7d04ab76526a28
IssacFish/DragonProject
/code/chart_generator.py
4,743
3.609375
4
# Filename: chart_drawer.py # Date: 2017/06/07 # Description: generate bar chart and flowchart import matplotlib.pyplot as plt import db_wrapper import pandas as pd from graphviz import Digraph # External function # generate bar chart with first 10 data and threshold line # inputData: DataFrame # threshold:...
c413add161722e8efad1b4319463ede4f5a3aff8
ramsundaravel/PythonBeyondBasics
/999_Misc/004_generators.py
1,140
4.375
4
# Generators - # Regular function returns all the values at a time and goes off # but generator provides one value at a time and waits for next value to get off. function will remain live # it basically yields or stops for next call # basically not returning all values together. returning one value at a time def gene...
55435b91021479a5c4dae6448688f8495aa0c637
ramsundaravel/PythonBeyondBasics
/002_oops_concepts/003_Decorators.py
4,993
4.21875
4
# Decorators - comes when a function is passed # maintain the additional functionalities in one place and resuse any number of times whereever needed # For example,below we are passing display function --> orginal function parameter # and display_decorator --> wrapper(). (as per first class function concept) # per clo...
1dbba8625f3f4a817922b604de56dc28adb1e3aa
ThomasDiGregorio/Python
/manual_exponent_function.py
308
3.828125
4
from functools import reduce """ manual_exponent (2, 3) #> 8 manual_exponent (10, 2) #> 100 """ def manual_exponent (num, exp): computed_list = [num] * exp return (reduce(lambda total, element: total * element, computed_list)) print(manual_exponent(2, 3)) print(manual_exponent(10, 2))
a461ba3c08de29f1e182037d58dcc88ebd20e9f0
AhmedElatreby/python_basic
/dictionaries.py
789
3.875
4
""" Dictionaries Adictionary is a collection of data that is: - Written with curly brackets, and have keys and values: - Uesd to sorte data values in key: value pairs - An ordered collection - Does not allow duplicates """ dictionary = {1: "rock", 2: "paper", 3: "scissors"} print(dictionary) print(type(dictionary)) p...
d70c7e14cb9974a1320850eb1e70fa2fb1e14dd7
AhmedElatreby/python_basic
/while_loop.py
2,392
4.4375
4
""" # While Loop A while loop allows code to be repeated an unknown number of times as long as a condition is being met. ======================================================================================================= # For Loop A for loop allows code to be repeated known number of loops/ iterations """ # impo...
7a2e1c426ae602bceb735e43ad3819b4412b4772
mbegumgit/cs50
/Lecture.8.Testing-CI-CD/prime.py
200
3.96875
4
import math def is_prime(n): """ Determines if a non-negative interger is prime.""" if n < 2: return False for i in range(2, int(math.sqrt(n) + 1)): if n % 1 == 0: return False return True
b8014bc73e1edbf94be15f17b37953961bb534da
siggimar92/ProgAssignment1
/__pycache__/Lexer.py
1,535
3.90625
4
from Token import Token import string __author__ = 'Hrafnkell' class Lexer(object): ''' Diagnoses each token and describes it for the computer ''' def nextToken(self, word): return self.get_tokencode(word) def get_tokencode(self, lexeme): if lexeme == "+": return Token("...
c280a315983c723140c8ceb7c188594021833cff
siggimar92/ProgAssignment1
/Interpreter.py
2,222
3.84375
4
import sys __author__ = 'Hrafnkell' class Stack: def __init__(self): self.items = [] def is_empty(self): return self.items == [] def push(self, item): self.items.append(item) def pop(self): return self.items.pop() def top(self): return self.items[len(sel...
63020ad9f50d80c503e9dd04d3dcf936537d1ba0
igor-kurchatov/python-tasks
/Warmup1/makes10/makes10_test.py
383
3.578125
4
################################# # Task 6 - testing # Desription: Given 2 ints, a and b, return True if one if them is 10 or if their sum is 10. # Author : Igor Kurchatov 5/12/2016 ################################# import TestCaseJson from makes10 import makes10 testjson = TestCaseJson.TestCaseJson() testj...
ca19fffb530532ff8d820ae69202b30483e2c072
igor-kurchatov/python-tasks
/Warmup1/diff21/diff21.py
801
4
4
################################# # Task 4 - definitions # Desription: Given an int n, return the absolute difference between n and 21, except return double the absolute difference if n is over 21. # Author : Igor Kurchatov 5/12/2016 ################################# def diff21(n): if n > 21: return abs(...
deccf22c609d850a0697a856ac8f2e62df2e7b4d
igor-kurchatov/python-tasks
/Warmup1/pos_neg/pos_neg_test.py
468
3.84375
4
################################# # Task 8 - testing # Desription: Given 2 int values, return True if one is negative and one is positive. # Except if the parameter "negative" is True, then return True only if both are negative. # Author : Igor Kurchatov 5/12/2016 ################################# import TestC...
4280063ba51d897bdb1049d6a1a84c6625ed0a39
igor-kurchatov/python-tasks
/Warmup1/pos_neg/pos_neg_run.py
355
4.1875
4
################################# # Task 8 - implementation # Desription: Given 2 int values, return True if one is negative and one is positive. # Except if the parameter "negative" is True, then return True only if both are negative. # Author : Igor Kurchatov 5/12/2016 ################################# from ...
f5c767494febbf67c7c1680fd66c524715f4ce41
anthonyho007/leetcode
/meetingRooms2.py
977
3.625
4
#!/usr/bin/env python # Definition for an interval. # class Interval(object): # def __init__(self, s=0, e=0): # self.start = s # self.end = e class TimePoint(object): def __init__(self, time = 0, entry = None): self.time = time self.entry = entry class Solution(object): de...
d367e17e8931b00d600455cf9e09ed8c852f1edf
anthonyho007/leetcode
/GameOfLifeO(N)Space.py
1,400
3.625
4
class Solution(object): def gameOfLife(self, board): """ :type board: List[List[int]] :rtype: void Do not return anything, modify board in-place instead. """ def interactCell(x, y, board): M = len(board) N = len(board[0]) n_live, n...
6a122ae813ac901114f7da362b8c1a73bd2138f4
anthonyho007/leetcode
/word-break.py
1,077
3.640625
4
#!/usr/bin/env python class Solution(object): def wordBreak(self, s, wordDict): """ :type s: str :type wordDict: List[str] :rtype: bool """ def cmpStr(s1, s2, start, end): if len(s1) > len(s2): return False while start < end: ...
08d1b2bb4a403a49fb41788d9d9c74f4e7118ee4
DiabCh/tictactest
/game/player_profile.py
2,906
3.8125
4
import getpass from pathlib import Path import json def verify_account(username, password): if username["password"] == password: print("Authentication successful!") return True else: print("Incorrect password, please try again") return False def login(): us...
d7f3be0d30fcc8f3aadb6cea317fb42baec84c0e
camel-master/GraphSearchWithPython
/Graph.py
2,664
3.96875
4
#from collections import deque from Stack import Stack from Queue import Queue def visit(n): print(n.data, end=' ') def dfs_recursive(node): if not node: pass node.marked = True visit(node) for n in node.adjacent: if not n.marked: dfs_recursive(n) class Graph: c...
0fe469e04d72b5e225fdc4279f6f4c9542031644
AmeyMankar/PracticePython
/Exercise2.py
462
4.28125
4
# Let us find the sum of several numbers (more than two). It will be useful to do this in a loop. #http://www.codeabbey.com/index/task_view/sum-in-loop user_input = [] sum_of_numbers = 0 choice=1 while choice != 2: user_input.append(int(input("Please enter your number: \t"))) choice = int(input("Do you want to add...
5d9a6cecb660ed16ce41cd982fca31b43a1082c0
zchen1018/LeetCode
/Algorithms/easy11-20.py
7,747
3.890625
4
# 83. Remove Duplicates from Sorted List # Given a sorted linked list, delete all duplicates such that each element appear only once. # For example, # Given 1->1->2, return 1->2. # Given 1->1->2->3->3, return 1->2->3. # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # ...
88251b94663e551f2865758a326ebba4679c77a0
zeroplusone/count_words
/count_words.py
1,712
3.5625
4
import re import sys import fileinput abbr = ["dr", "st", "no", "tennis.com"] symbols = [",", ".", "?", "!", ":", ";","\"", "(", ")", "[", "]", "$", "[", "]", "{", "}"] def process(word): word = word.lower() is_abbr = False for s in symbols: if word[-1] == s or word[0] == s: ...
eff269698643fbb2f05d2d2f3afec5ad2c3a0063
knghiem/Visualizing-Fraction
/domino.py
7,432
4.28125
4
#domino.py #Jessy Quint and Khanh Nghiem #Final Project #December 14,2016 #This program generates a domino-like image to represent the user-inputted fraction. #The program will also take in mouse clicks that cause the domino pips to change color. from graphics import * from buttonclass import * def drawCove...
81fec53e48b1aa5b21f6ca212ab0d2adace73a22
davidbrochart/mcmc
/mcmc/dist.py
4,994
3.96875
4
import numpy as np from scipy import stats def sample_from_population(population, nb=1): ''' Draw samples from a population. Parameters ---------- population: numpy array Population to sample from. nb: int Number of samples to draw. Returns ------- samples: numpy ...
60fd138c2deb7c55496d8b43607a948a1e14e37f
PnuLikeLion9th/Summer_algorithm
/janghun/8주차/백준1003.py
313
3.890625
4
sum0=[1,0,1] sum1=[0,1,1] a=int(input()) def fibonacci(n) : if len(sum0) <= n : for i in range(len(sum0), n+1) : sum0.append(sum0[i-1]+sum0[i-2]) sum1.append(sum1[i-1]+sum1[i-2]) print(sum0[n],sum1[n]) for i in range(a): N = int(input()) fibonacci(N)
49aa803a82f4eaf2914d84ef703a5509b38b6d17
PnuLikeLion9th/Summer_algorithm
/jisu/week4/크레인 인형뽑기 게임.py
998
3.515625
4
def solution(board, moves): answer = 0 stack = [] # 인형들 담을 바구니 for move in moves: for i in range(len(board)): if board[i][move-1] != 0: # 인형이 있다면 tmp = board[i][move-1] # tmp 변수에 잠시 담아둔다 board[i][move-1] = 0 # 인형을 집어 올렸으니 원래 인형이 있던 자리는 비게 됨 ...
91c3aed887798cccb761c97570219e80a6acd47d
PnuLikeLion9th/Summer_algorithm
/joonghoo/8주차/0810 Z.py
1,563
3.53125
4
# 백준_1074_Z_분할 정복_실버 1 # 정사각형 모양의 좌표를 4분면으로 분할한다는 점이 쿼드트리 문제와 비슷하다 # 하지만 시간제한이 0.5초라서 모든 좌표를 탐색하면 시간초과가 나온다 # 따라서 입력 받은 행과 열로 해당 좌표의 값을 뽑아 내야한다 def Z(m, size): global cnt, r, c # 한변의 길이가 2인 정사각형까지 분할 했을 경우 좌표의 위치에 따라 1,2,3을 더해준다 if m == 1: if r == 0 and c == 0: print(cnt) ...
7c6e1864e444e78e3be8cd8ef05ceec4959d8eaa
PnuLikeLion9th/Summer_algorithm
/kangwook/5주차/키패드 누르기.py
802
3.609375
4
def solution(numbers,hand): answer="" hL=10 # *=10 hR=12 # #=12 for i in numbers: if i == 1 or i == 4 or i == 7: answer+='L' hL=i elif i == 3 or i == 6 or i == 9: answer+='R' hR=i else: if i ==0: i=11 LL=ab...
8459bc9769e33602c1e93a569f49b9ac4b42003c
PnuLikeLion9th/Summer_algorithm
/joonghoo/5주차/0718 숫자 문자열과 영단어.py
949
3.59375
4
# 프로그래머스_숫자 문자열과 영단어_문자열_레벨 1 # isdecimal 함수를 이용해서 문자열의 원소가 정수인지 판별 # 정수라면 바로 result에 더하고, 정수가 아니라면 해당 문자가 나타내는 숫자를 딕셔너리로 불러와서 result에 더해줌 def solution(s): result = "" num = "" nums = {'zero': '0', 'one': '1', 'two': '2', 'three': '3', 'four': '4', 'five': '5', 'six': '6', 'seven': '7', 'eight'...
d58c6e9ca2bab9a1ffc96566b75a68829f529799
PnuLikeLion9th/Summer_algorithm
/joonghoo/3주차/0706 정수 제곱근 판별.py
583
3.703125
4
# 프로그래머스_정수 제곱근 판별_수학_레벨 1 # sqrt함수를 이용해서 n의 제곱근을 구한다. # 이때 n의 제곱근이 실수형태로 나타나는것을 이용하여 n이 양의 정수 x의 제곱인지를 판별한다 import math def solution(n): num = math.sqrt(n) if num == int(num): # n의 제곱근 num이 정수일때, 즉 x의 제곱일때 (num+1)^2 해서 return 한다 return (num+1)**2 else: # n의 제곱근 num이 실수일때 (ex 루트2는 1.414... 형태) ...
8cc44bc758d55bd9ff7631dd09188dd0c6c05e96
PnuLikeLion9th/Summer_algorithm
/mina/소수찾기.py
670
3.578125
4
#소수찾기이이이 #일단 에라토스테네스의 체 먼저 찾아봄 def prime_list(n): sieve=[True]*n m = int(n ** 0.5) for i in range(2, m + 1): if sieve[i] == True: for j in range(i+i, n, i): sieve[j] = False return [i for i in range(2, n) if sieve[i] == True] #풀이풀이 def solution(n): ...
31dfb6341d2aa4a4d9f0c3b6caa7d54de960cae8
PnuLikeLion9th/Summer_algorithm
/dongyeop/1주차/간격.py
474
3.625
4
# def solution(x,n): # answer=[] # for i in range(x,x*(n+1),x): # answer.append(i) # return answer # range의 세번째 파리미터 값에 의해 간격이 생긴다. # 위 처럼 풀었을 때 테스트케이스 8번에서 런타임에러가 발생하여 아래와 같이 풀었다. def solution(x,n): answer = [] for i in range(1,n+1): answer.append(i*x)#x만큼 늘어나게 만들어야함으로 x를 곱해줬다. ...
f3c930054151fb29ee3bcd4c03689a7d4076b1cf
PnuLikeLion9th/Summer_algorithm
/joonghoo/3주차/0706 이상한 문자 만들기.py
742
3.6875
4
# 프로그래머스_이상한 문자 만들기_문자열_레벨 1 # 공백을 기준으로 짝수, 홀수를 판단해야 하므로 공백이 올때마다 count=0 해준다 # 짝수번째 알파벳은 upper함수를 이용해서 대문자로, 홀수번째 알파벳은 lower을 이용해서 소문자로 변환한다. def solution(s): answer = '' count = 0 for i in s: if i == ' ': # 공백이 오면 count = 0 으로 초기화 answer += ' ' count = 0 conti...
4329ee952e263c9476e212e4fbc0fbebbbbabba6
PnuLikeLion9th/Summer_algorithm
/jiwoo/5주차/11866.py
506
3.5
4
from collections import deque n, k = map(int,input().split()) queue = deque([]) for i in range(1,n+1): # 1부터 n까지 배열 queue.append(i) print('<',end='') while queue: # n명이 모두 제거될 때까지 for i in range(k-1): # 순서대로 k번째 사람 제거 queue.append(queue.popleft()) if len(queue) == 1: ...
045f2ab5640f104e8d9f69ba510d15ad9f3dc407
PnuLikeLion9th/Summer_algorithm
/mina/10988.py
98
4.03125
4
word = list(str(input())) if list(reversed(word)) == word: print(1) else: print(0)
d36a27b78256ff3fd12d0cae6082b2977aed26f9
PnuLikeLion9th/Summer_algorithm
/kangwook/8주차/1003.py
305
3.578125
4
t=int(input()) a=[int(input())for _ in range(t)] def f(n): if n == 1 : return 0 elif n == 2 : return 1 fib_array = [0,1] for i in range(2,n+1): num = fib_array[i-1]+fib_array[i-2] fib_array.append(num) return fib_array[n-1] for k in a: print(f(k),f(k+1))
9197c8b974d216fd017876a03610998941a67eb8
PnuLikeLion9th/Summer_algorithm
/janghun/5주차/약수의개수와덧샘.py
175
3.53125
4
import math def solution(left, right): answer=0 for i in range(left,right+1): if math.sqrt(i)%1==0: i=-i answer+=i return answer
df9f4f11c483e78a45a2c77627f6a81de1c679f9
PnuLikeLion9th/Summer_algorithm
/seongeun/4주차/A+B-2.py
227
3.671875
4
#백준 50제 '''두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오. 첫째 줄에 A, 둘째 줄에 B가 주어진다. (0 < A, B < 10)''' a = input() b = input() print(int(a)+int(b))
1399fa95761ac0ae4b128aba55a7ba402dd72ffe
PnuLikeLion9th/Summer_algorithm
/dongyeop/8주차/2579.py
300
3.515625
4
n = int(input()) stair = [] dp=[] for i in range(n): stair.append(int(input())) dp.append(stair[0]) dp.append(max(stair[0]+stair[1],stair[1])) dp.append(max(stair[0]+stair[2],stair[1]+stair[2])) for i in range(3,n): dp.append(max(dp[i-2]+stair[i],dp[i-3]+stair[i]+stair[i-1])) print(dp[-1])
8e73dbe0e9e51ee8c94c53005e451cd5d1a26961
PnuLikeLion9th/Summer_algorithm
/joonghoo/6주차/0725 완주하지 못한 선수.py
717
3.65625
4
# 프로그래머스_완주하지 못한 선수_해시_레벨 1 # 두 list를 정렬하고 하나씩 비교한다. # 다른값이 존재할경우 그 값을 return # for문이 종료 될때까지 다른값이 없을경우 마지막값을 return def solution(participant, completion): participant.sort() completion.sort() for i in range(len(completion)): if participant[i] != completion[i]: # 다른값이 나올 경우 return par...
7857f6ca4bc22c811ed97048e88bd277a1ccd5bb
PnuLikeLion9th/Summer_algorithm
/janghun/2주차/콜라츠추측.py
228
3.578125
4
def solution(num): time=0 while num!=1: time+=1 if time==500: return(-1) elif num%2==0: num=num/2 elif num%2==1: num=(num*3)+1 return time
212de6f079a78b165040b077dd6b428f8022da6d
PnuLikeLion9th/Summer_algorithm
/kangwook/3주차/정수 제곱근 판별.py
318
3.671875
4
import math def solution(n): x=int(math.sqrt(n)) #n에 루트를 씌우면 정수와 소수 두 종류가 나올텐데 이를 다 정수화했다. if pow(x,2) == n: #만약 원래 정수였다면 이를 다시 제곱해도 n이 나올 것 answer=pow(x+1,2) else: answer=-1 return answer
99fd561caccda48c59c595e6e99f3969a4d07d60
PnuLikeLion9th/Summer_algorithm
/dongyeop/6주차/다트게임.py
2,197
3.625
4
# def solution(dartResult): 예전에푼거 # answer = 0 # stack = list() # check_int = "" # for i in dartResult: # if i == "S": # stack.append(int(check_int)) # check_int = "" # continue # elif i == "D": # stack.append(int(check_int)) # ...