blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
515607789779c24e6220e82fa088c690a880450d
vogtdale/python
/learnpython/loops/loop.py
611
4.25
4
# for loops allow us to iterate a set a number of times # while loops runs until a specific condition is met print("="*10) print("For Loop") print("="*10) print() for loop in range(5): # range(start, stop, step(increment by)) print(loop) print("="*10) print("For Loop length") print("="*10) print() x = [1,2,3,4]...
6ac800c4047bdaf3a7051f0ad6ef5c3a81a3c8df
hillolkallol/Problem-Solving
/Leetcode_7.py
1,365
4.125
4
''' Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 Example 3: Input: 120 Output: 21 Note: Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−231, 231 − 1]. For the pu...
98af3f1e9bc1821ae62b15e0d7a303e7edf408e1
theojam2/ted-hello-world
/cashier_Wk_4.py
3,305
4.3125
4
""" File: cashier_Wk_3.py Name: Theodore Thompson Date: 12/12/2019 Course: DSC510-T302 Introduction to Programming (2203-1) Desc: The program offer a simple menu. Press 1 to begin, zx to return to top menu. The program receives the name of the customer company and the number of feet of fiber opt...
03086018643c497d846befd40c9378896c63f5ad
GeGe-K/blog
/tests/test_comment.py
1,027
3.59375
4
import unittest from app.models import Review class TestComment(unittest.TestCase): """ This class will test the comments """ def setUp(self): """ This will create a new comment before each test """ self.new_comment = Comment(title = "Nice") def tearDown(self): ...
a46dc91737997e54d283a1bd7388c7a92ad1d08e
aagudobruno/python
/P5/P5E11.py
255
3.78125
4
"""AUTOR:ADRIÁN AGUDO BRUNO ENUNCIADO:Escribe un programa que pida un número e imprima todos sus divisores.""" N1=int(input('introducir un número: ')) L=[] for i in range(N1,0,-1): if (N1%i==0): L=L+[i] print ('los divisores de',N1,'son:',L)
1cde58867899cb763baf76cd7023141908fe6089
davidcwang/1337c0d3
/2020/20_Valid_Parentheses/solution.py
1,169
3.703125
4
""" Problem: 20. Valid Parentheses Url: https://leetcode.com/problems/valid-parentheses/ Author: David Wang Date: 05/26/2020 """ class Solution: def isValid(self, s: str) -> bool: open_stack = [] for c in s: if c in '({[': open_stack.append(c) # else we kno...
7baf4743ce2954c6a39cd377a96f9b5da6f1264d
Wbeaching/python_data
/3.正课/7.16/3.学生信息管理系统类重构版.py
2,264
3.765625
4
import sqlite3 class student(object): def __init__(self,name ='',age ='',tel = ''): self.name = name self.age = age self.tel = tel def say(self): print('我说:我的名字是'+self.name) def work(self): print(self.name +'是游戏主播') class DBAction(object): def __init__(self,dbnam...
bcd37cc6b94f6a754710b1ef74239276f5c65487
adwardlee/leetcode_solutions
/string/0409_Longest_Palindrome.py
667
3.59375
4
class Solution: def longestPalindrome(self, s: str) -> int: hashdict = dict() for x in s: if x not in hashdict: hashdict[x] = 1 else: hashdict[x] += 1 longest = 0 odd_flag = 0 for key, value in hashdict.items(): ...
da40a15863b69fbe992b5f8770693e9a42c7155a
psmilovanov/Python_HW_03
/Homework_03_6.py
683
3.609375
4
# Задание 6. error_mark = False def inc_func(word): global error_mark if word.islower() == False: error_mark = True print("Не удовлетворяет правилу ввода. Все буквы в слове должны быть маленькими") return '' else: return word.title() Req_str = '' user_str = input("Введит...
3e6b90e205710e926f77fae5b12c536d04bde811
BruceHi/leetcode
/month1/dayOfYear.py
612
3.734375
4
# 1154. 一年中的第几天 from datetime import datetime class Solution: # def dayOfYear(self, date: str) -> int: # t_end = datetime.strptime(date, '%Y-%m-%d') # t_start = datetime(year=t_end.year, day=1, month=1) # return (t_end - t_start).days + 1 def dayOfYear(self, date: str) -> int: ...
26fc9705d04e911cca814e208fe8a49d24654ef3
gabriellaec/desoft-analise-exercicios
/backup/user_143/ch35_2020_03_27_17_57_05_529545.py
78
3.796875
4
n=1 s=n while n!=0: n= float(input('Números:')) s=s+n-1 print(s)
01e42e111d6dbe6ec6b5bb6f50e96685ef7b2aea
5l1v3r1/algorithm_visualizer
/visualizer.py
2,132
3.640625
4
import cv2 import numpy as np from random import randint, shuffle def isSorted(l): previous = l[0] for i in range(1, len(l)): if l[i] < previous: return False previous = l[i] return True def insertion_sort(l): for index in range(1, len(l)): k = l[index] j = ...
aab1fa579cda81c15c1c516e6b91c4d8a66d3c33
alaa-ali/PySamples
/sortedSquaredArray.py
477
3.671875
4
import numpy as np def sortedSquaredArray(arr): results = [0] * len(arr) #np.zeros(len(arr)) left = 0 right = len(arr)-1 for i in range(len(arr)-1,-1,-1): if(abs(arr[left])>abs(arr[right])): results[i] = arr[left]*arr[left] left +=1; else: results[i] = arr[right]*arr[right] right...
026bd855a301af66a0ee25c5583915b9969f3c05
olincollege/markov-syllables
/plotter.py
3,860
4.0625
4
""" Plots graphs for the computational essay """ import matplotlib.pyplot as plt import numpy as np def plot_word_type_frequency(titles, analyses, scale=False): """ Plots a bar graph of the word types given in analyses Args: titles: A list of strings; the titles of the corpora analyses: A ...
9dd98b9562147e6572882d28e8a278d3438bc6b7
plasticroad/DataCamp
/Python/07.Cleaning-Data-in-Python/02.Tidying-data-for-analysis/01.Reshaping-your-data-using-melt.py
1,553
4.65625
5
''' Reshaping your data using melt Melting data is the process of turning columns of your data into rows of data. Consider the DataFrames from the previous exercise. In the tidy DataFrame, the variables Ozone, Solar.R, Wind, and Temp each had their own column. If, however, you wanted these variables to be in rows i...
d98706661787c5afe71c2bb3db9218192e2c071e
guilhermeagostinho22/exercicios-e-exemplos
/Pyton/exercicio1.py
91
3.609375
4
numeroInt = int(input("Digite um numero inteiro: ")) print("Número inteiro é:",numeroInt)
3bd5c06472cd94fb118ff07382ecb8a1f8e648e6
neham0521/CS-1
/Check point 1/sleep_in.py
359
4.1875
4
Day= input('Please enter what day it is').lower() Vacation = input('Are you on vacation-please enter yes/no').lower() #weekday[] = ['Monday', 'Tuesday', 'Wednesday', 'Thursday','Friday'] if (Day == 'saturday' or Day == 'sunday'): print('You can sleep_in!') elif Vacation == 'yes': print('you can Sleep_in!') ...
f847d1f390c28afc3d71a54dd92bce24769f199a
thestrawberryqueen/python
/3_advanced/chapter15/solutions/ch15_practice5.py
793
4.1875
4
""" The following code is not meant to be run because there's no input. Instead, analyze it's running time in terms of Big-O. The first two lines are already analyzed for you. Do the same for all the other lines. At the end, put the total running time of code. The input of the problem is ex_2d_list, and assume it has n...
f0ba9c0fbcb5623a961e7f6b324293d047514ce9
ssj2son-gohan-ne/testgit
/python_test.py
1,237
4.15625
4
# https://medium.com/quick-code/understanding-self-in-python-a3704319e5f0 class house_blueprint(): cfloorname = "class default floor" cfloornumber = 100 cfloorlevel = "default level" def __init__(self, mfloorname, mfloornumber, mfloorlevel): self.instance_floorname = mfloorname sel...
4e789c6cd53239abef8a432d95dbfd8f26a15432
dh-trier/coleto
/coleto/text_analyze.py
10,806
3.640625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Author: Christof Schöch, 2016-2021. """ Loads the file containing the collation results from Wdiff. Then, identifies various kinds of differences that can be observed. Assembles this information for each difference between the two texts. Part of coleto, see: https://gi...
769b4ab4dde7366aca35d84517b4ad0de6952da7
S-EmreCat/PythonKursuDersleri
/15-PythonModulleri-WebScraping/15.7-Requests-ExchangeApi-DövizUygulaması.py
569
3.546875
4
import requests import json api_url="https://api.exchangeratesapi.io/latest?base=" bozulan_doviz=input("Bozulan döviz türü:") alınan_doviz=input("alınan döviz türü:") miktar=int(input(f"ne kadar {bozulan_doviz} bozurmak istiyorsunuz?")) result=requests.get(api_url+bozulan_doviz) ## dövizz türünü belirled...
ff1a1ce38459e8dbe7b0e40fe5619b866183bcd1
IntroProgramacion-P-Oct20-Feb21/trabajofinal-1bim-Erika-Masa
/semana6/ejempl6.py
869
4.0625
4
nombre = input ( "Ingrese el nombre de una ciudad del Ecuador: \n " ) inicio = nombre [ 0 ] if( inicio == "a" ) or ( inicio == "A" ): print = "Nombre con inicial { inicio } de { nombre } \n " else: if ( inicio == "e" ) or ( inicio == "E" ): print = "Nombre con inicial {inicio } de { nombre } ...
d0f046ccf61aede1d7345e94ed361c26798396d3
786930/python-basics
/cross.py
803
3.9375
4
# Program name: cross.py # Your Name: Aerin Schmall # Python Version: 3.7.8 # Date Started - Date Finished: 9/2/2020 - 9/3/2020 # Description: prints lines of + increasing by 1 until there is as many as was designated def stars(cross): for i in range(cross): for y in range(cross-i): ...
8ec81795961b183b7c628afa96394dc2c72a41e3
MuhummadShohag/PythonAutomation
/OS_Module/os_system.py
792
3.90625
4
''' * os.system is used to execute os commands * if you execute your operating system coomand with python,it is helpful ''' import os # if you forget getcwd(), it is helpful os.system('dir'), show your directory and file on your operating system # print(os.getcwd()) # print(os.system('dir')) # print(os.system(...
384dedfd3b91571ebfde2eaa19ffd85afb2f145f
JasoSalgado/Hacker-Rank-Problems
/hex_color_code.py
1,618
4.34375
4
""" CSS colors are defined using a hexadecimal (HEX) notation for the combination of Red, Green, and Blue color values (RGB). Specifications of HEX Color Code ■ It must start with a '#' symbol. ■ It can have or digits. ■ Each digit is in the range of to . ( and ). ■ letters can be lower case. ( and are also vali...
201d0b744e69e22ead217f05b1615777cd0e3ad0
Ch4uwa/PythonPracEx
/three_largest.py
477
4.40625
4
"""Find and returns three largest numbers in array.""" from makearray import make_array array_in = make_array() def three_largest(array_1): """Return three largest""" return [find_largest(array_1) for _ in range(3)] def find_largest(array): """Return largest number and remove from array.""" max_num ...
bf5b2ac27bc87bf0168e13e2e7fb48f6f43c1e6e
pengyuhou/git_test1
/leetcode/面试题 01.02. 判定是否互为字符重排.py
317
3.828125
4
class Solution(object): def CheckPermutation(self, s1, s2): return sorted(list(set(s1)))==sorted(list(set(s2))) if __name__ == "__main__": s1 = "abc" s2 = "bad" print(Solution().CheckPermutation(s1,s2)) # a=sorted(list(set(s1))) # b = sorted(list(set(s2))) # print(a==b)
cf5fd312c5e61f411cec50b7927a5a48a5317cd1
rishitrainer/augustPythonWeekendBatch
/learn_day02/data_structure/TupleTest.py
185
3.75
4
sampleTuple = ("apple", "pineapple", "grapes", "bananas") # no addition # no remvoal print(sampleTuple[0]) for eachValue in sampleTuple: print(eachValue) del sampleTuple
cb1a11e494989404d8563093f64117f1c9808d14
riya2299/hackerranksolutions
/insertnodeatspecificpos.py
431
3.71875
4
def insertNodeAtPosition(head, data, position): node=SinglyLinkedListNode(data) if head==None: head=node elif position==0: node.next=head head=node else: prev=0 curr=head currpos=0 while(currpos<position and curr.next!=None): prev=curr ...
3ec6cf61cfba07a0510474b116b5c9f19f7948c0
chaojunhou/LeetCode
/Algorithm/Python/binary_tree_maximum_path_sum.py
1,541
3.765625
4
# Definition for a binary tree node class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None res=[] def printTree(self, root): if not root: return [] if root: self.res.append(root.val) if root.left: ...
ba0b19e8ba211aa2a7ca3c7eca8327a003acd381
thormiwa/alx-backend-python
/0x00-python_variable_annotations/1-concat.py
190
3.5625
4
#!/usr/bin/env python3 '''This module contains a concat function''' def concat(str1: str, str2: str) -> str: '''Concantenates two strings and return a string''' return str1 + str2
72ae1b23016538e886057ca910037a9059d899d5
atruslow/programming
/alex_answers/hackerrank/grid_challenge.py
416
3.609375
4
GRID = ['ebacd', 'fghij', 'olmkn', 'trpqs'] def grid_challenge(grid): is_col_sorted_list = [] for i, row in enumerate(grid): grid[i] = list(sorted(row)) for col_index in range(len(grid[0])): column = [i[col_index] for i in grid] is_col_sorted_list.append(column == list(sorted(...
98acce7d41edead508ce68aa1d743603f8921c07
cutejiejie/PythonFirstPro
/类/定义Python中的类.py
1,017
3.703125
4
''' class Student: #Student为类的名称(类名)由一个或多个单词组成,每个单词的首字母大写,其余小写 pass # Python中一切皆对象,Student是对象吗?内存有开空间吗? print(id(Student)) print(type(Student)) print(Student) ''' class Student: native_pace='吉林' #直接写在类里的变量,称为类属性 def __init__(self,name,age): #name,age为实例属性 self.name=name #self.name称为实体属性,进行了一个赋值操作,将...
c3acfb84ed761aa8d431dd10035c9b18f38170d6
BorG1985/OOP-vjezba-zbirka
/vjezba_1_4.py
966
3.953125
4
#Zadatak 1.4 Napraviti klasu Brojevi, koja sadrži 2 polja koja polja koja predstavljaju cele brojeve. # Koristiti konstruktor klase. Napraviti metode sabiranje, oduzimanje, množenje I deljenje(celobrojno) # koje vraćaju rezultat svake od operacija. Instancirati jedan objekat I pozvati metode nad njim. Iskoristiti ...
aca3540dcf89afc1ae454852b76520df3d7bed45
natahlieb/adventofcode2017
/Day1/day1.1.py
396
3.59375
4
import sys def main(value): inputList = list(value) print(inputList) sum = 0 for k in range(0, len(inputList)// 2, 1): print('k is {}, index to compare is {}'.format(k, k + len(inputList)//2)) if(inputList[k] == inputList[k + len(inputList)//2]): sum += int(inputList[k]) ...
d0069e9d5ef220838216b01abeaa568ff8b3d4ee
MagnusPoppe/Tensorflow-Interface
/generalized_artificial_neural_network/enums.py
4,728
4.03125
4
from enum import Enum class ActivationFunction(Enum): """ tf.nn.relu tf.nn.relu6 tf.nn.crelu tf.nn.elu tf.nn.softplus tf.nn.softsign tf.nn.dropout tf.nn.bias_add tf.sigmoid tf.tanh """ SIGMOID = 0 RECTIFIED_LINEAR = 1 HYPERBOLIC_TANGENT = 3 SOFTMAX = 4 c...
f7d77e6eb420d1e4d0625395b7bd5001f3477e47
bnoden/python
/13/13_01.py
869
4.3125
4
# 1. Name and Address # Write a GUI program that displays your name and address when a button is clicked. # The program’s window should appear as the sketch on the left side of # Figure 13-26 when it runs. When the user clicks the Show Info button, the program # should display your name and address, as sh...
d1b3ee6b38988020161c16a9061be4ee40e9028a
memiles47/UdemyPythonProgrammingMasterClass
/Section4/IfChallenge.py
258
4.09375
4
__author__ = "Michael E Miles" name = input("Please enter your name: ") age = int(input("How old are you? ")) if 18 <= age < 31: print("Welcome to the holiday {}".format(name)) else: print("I'm sorry {}, you can not go on holiday at this time".format(name))
01fc75626173df260218e066016a5c428bffb637
lixiang2017/leetcode
/leetcode-cn/0042.0_Trapping_Rain_Water.py
2,070
3.578125
4
''' DP Time: O(3N) = O(N) Space: O(2N) = O(N) 执行用时:72 ms, 在所有 Python3 提交中击败了10.73% 的用户 内存消耗:15.4 MB, 在所有 Python3 提交中击败了15.39% 的用户 ''' class Solution: def trap(self, height: List[int]) -> int: N = len(height) left, right = [0] * N, [0] * N left_max = right_max = 0 for i in range(N): ...
1c8f772ae9fe4ec5868acfcb5eb44fbd021cc2ae
cgurusm/Challenges
/Hackerrank/DataStructures/Stacks/balancedBrackets.py
1,262
3.828125
4
n = int(input()) # number of cases start = ['(','[','{'] end = [')',']','}'] def indexes(lst,symbol): return [i for i,x in enumerate(lst) if x == symbol] def isEmpty(stack): if len(stack) == 0 : return True else: return False for _ in range(n): accepted = True brackets = input(...
1dfb4136b6a3ac0b2f14223c03331f2e1b2d75da
sbtries/class_pandaaaa
/Code/Zach/PDX_6_14/Python/zach_lab_1.py
1,287
4.15625
4
#Zach Watts #Day 2 Lab 1 #Version 1 unit_converter = { "feet" : 0.3048 } feet = input("What is the distance in feet? ") feet = int(feet) print(f'{feet} feet is {round(feet*unit_converter["feet"], 4)} m') #Version 2 unit_converter_additional = { "ft" : 0.3048, "mi" : 1609.34, "m" : 1, "km" : 1000 ...
f4c404aead40ec93e878f34e95778c21e2a1cb76
maciekgamma/AdventOfCode19
/day6/solveB.py
1,150
3.515625
4
class Planet: def __init__(self): self.orbs = [] def count_orbs(self): all = 1 for p in self.orbs: all += p.count_orbs() return all def hasPlanet(self, planet): if planet in self.orbs: return True elif len(self.orbs)>0: re...
ddd2d51950a5f0ed1fd0d03f81a36d8e2e30e20b
pkss123/python-14-15
/args01.py
376
3.75
4
# 함수를 호출할 때는 함수 정의시에 자정한 인수(파라미터, 매개변수 # 입력값)의 개수 만큼 값을 전달해야 합니다 # 인수 개수가 달라지면 에러가 납니다 def add(n1, n2): return n1 + n2 def add_three(n1, n2, n3): return n1 + n2 + n3 result1 = add(3, 6) print(result1) result2 = add(3, 6, 9) print(result2)
8ff4615baed4bb3c5802a49c35a53aadf1de17f3
wojtekidd/Python101
/multiply_all_list_elements.py
240
3.9375
4
list_1 = [1, 2, 3, 4, 5, 6] mul = 1 for item in list_1: mul *= item print(mul) """Robimy silnie (n+1 zeby zero ominac)""" def factorial(n): mul = 1 for item in range(1, n+1): mul *= item return mul print(factorial(5))
dfdc7e5574f0ef5dde9148340057f043760f45fa
lutzleonhardt/bitbank-gekko
/blackbox-optimizer/blackbox.py
7,219
3.609375
4
import sys import multiprocessing as mp import numpy as np import scipy.optimize as op def get_default_executor(): """ Provide a default executor (a context manager returning an object with a map method). This is the multiprocessing Pool object () for python3. The multiprocessing Pool in python2...
75a7ccc2307773243241f2ba167b9f5881a4f565
Jamiebull27/Lattice-Vibrations
/LatticeVib.py
3,153
3.84375
4
#Program to simulate lattice vibrations in a 2 atom lattice# #Jamie Bull# #16/10/2017# import matplotlib.pyplot as plt from matplotlib import animation import numpy as np #---------------------------------------------------------------------------------# class Atom: SPRING_CONSTANT = 3000 SPRING_DAMPING = 200000...
e927abdd27d8eed334ac3b69c18c92061fc6697e
qijiahao0426/learnnote
/leetCode/205.同构字符串.py
434
3.5
4
# # @lc app=leetcode.cn id=205 lang=python3 # # [205] 同构字符串 # # @lc code=start class Solution: def isIsomorphic(self, s: str, t: str) -> bool: hashmap={} for i,j in zip(s,t): if i in hashmap and hashmap[i]!=j: return False elif i not in hashmap and j in hashm...
0daaab422952db9fa78e36353513482f3b61504b
m-and-ms/Competitve-Programming-and-algorithms-
/shortest_path_srource_target_bfs.py
977
3.71875
4
#bfs shortest path from source to target def bfs(src,tgt,adj): num_nodes=len(adj) visted=[False]*num_nodes dist=[-1]*num_nodes queue=[] visted[src]=True queue.append(src) dist[src]=0 while(len(queue)): parent=queue[0] queue.pop(0) if(parent==...
dbaeb49a573999b0db303ab2d9bb1bf280976a90
JamesBallam/PythonBasics
/PyGame/basic_game.py
2,186
4.125
4
"""First simple PyGame application.""" import pygame # Initialize the PyGame library pygame.init() # Create a screen of 800x600 pixels screen = pygame.display.set_mode((800, 600)) # Construct a game clock clock = pygame.time.Clock() # Specify a frame rate of 60Hz fps = 60 # Fill the screen with black screen.fill(...
1cc829e236aff29a8d536ddefd35f8aff3b2760c
GitJavaProgramming/python_study
/Python基础/类.py
388
3.703125
4
class Bird: def __init__(self): print('Bird init') self.age = 10 def eat(self): print('Bird eat') class SongBird(Bird): def __init__(self): print('SongBird init') super().__init__() def sing(self): super().eat() print(self.age) def eat(sel...
d41b4286fa5f3d3e08cb5ae8f59b5326c4e780d9
publicmays/LeetCode
/merge_sorted_array.py
736
3.953125
4
class Solution(object): def merge(self, nums1, m, nums2, n): k = m + n - 1 i = m-1 j = n-1 while i >= 0 and j >= 0: if nums1[i] > nums2[j]: nums1[k] = nums1[i] i -= 1 else: nums1[k] = nums2[j] j -= 1 ...
d714d6370801af5e827913cfd24761b5a8be9af3
Inimesh/PythonPracticeExercises
/5 List exercises/Ex_123.py
2,666
4.71875
5
## A function that converts from infix to postfix of a mathematical expression # e.g. from '3 + 4' to '3 4 +', taking a list of tokens as the argument and # returning a list of tokens in postfix form. Including a main program that # demonstrates the function by reading an expression from the user in infix form # and di...
2f19ccc5fd4f957d8ac363694fa3ef01fda44b49
julia-kraus/CarND-Behavioral-Cloning-P3
/model.py
2,769
3.5
4
""" Neural network for steering angle prediction. The model is based on NVIDIA's "End to End Learning for Self-Driving Cars" paper. Source: https://images.nvidia.com/content/tegra/automotive/images/2016/solutions/pdf/end-to-end-dl-using-px.pdf """ from keras.models import Sequential from keras.layers import Dense, Fl...
8b73aa1ba4098930f0724e9fd0308c5c97fd0cfb
agentnova/LuminarPython
/Luminaarpython/Multitasking/pgm2.py
359
3.578125
4
from threading import * import time def display(): for i in range(1, 10): time.sleep(5) print("child thread executing") print(current_thread().getName()) t = Thread(target=display) # creation of new thread t.start() for i in range(1, 10): time.sleep(4) print("main thread is executi...
56bc8c9b75b82e740075d81e0864a5a212427d2b
childofthefence/python_datasctructures_umich
/capitalize_all_the_words.py
151
4.21875
4
# Chapter 7 # Use words.txt as the file name fname = input("Enter file name: ") fh = open(fname) for lines in fh: print(lines.strip().upper())
4bb58d681a59ff8ace66808ff005c825b2ec6687
agrimaldoe/ST0245-032
/talleres/taller01/Taller01.py
1,809
3.96875
4
#!/usr/bin/env python # coding: utf-8 # In[4]: import math class Counter(): """counter.""" def __init__(self, ID): self.ID=ID self.count=0 def increase(self): self.count= self.count+1 def increments(self): return self.count def toString(self): print("I...
f54f533e79e48d6b86a1ef734a28287c9ebd13c2
basurohan/flask-restfull-sql
/repository/user_repository.py
1,081
3.609375
4
import sqlite3 from model import User def find_by_username(username) -> User: connection = sqlite3.connect('data.db') cursor = connection.cursor() query = "select * from user where username=?" result = cursor.execute(query, (username,)) row = result.fetchone() if row: # user = User(r...
c14642e61de958c337af93db6165559f82cdcf53
AvisTsai/homework1205
/main.py
1,489
3.828125
4
import sqlite3 connection = sqlite3.connect("ntub.db") def get_books(): #搜尋 c = connection.cursor() books = c.execute("select * from book").fetchall() c.close() return books def get_book(pk): c = connection.cursor() books = c.execute("select * from book where id =?", [pk]).fetchone() c...
64a5bea466c7997342676a9ac4b5b2e8220bc51c
anushaarivalagan/Anu
/extensionoffile.py
166
3.953125
4
filename=input("input the filename:") f_extens=filename.split(".") print("the extension of the file is:") input the filename:abc.py the extension of the file is:'py'
9530eca3ff5bf93e1d0146c629bea0edff452b68
PHB-CS123/graphene
/graphene/storage/base/relationship_type.py
2,057
3.71875
4
class RelationshipType: """ Stores components of a relationship type: inUse: Whether relationship type is in use type_block_id: ID of the block that stores string name of our type Along with the index where the relationship type is stored """ def __init__(self, index=0, in_use=True,...
9b20159c507123abcb4e8c4b58a98bdb67a0d905
rorygee/TwitBase
/Scooper.py
1,541
3.625
4
# coding: utf-8 # In[6]: import twython from twython import Twython ConsumerKey = 'DHvPpUKNhPBqmOoWHTioL8R8g' ConsumerSecret = 'HaCvbsQLXy61rdxbs1AuojrP0y9eunUQLYfzyzt3gOzek1BdkC' AccessToken = '2723648388-vUN5LPJCXUyM2juD5dVGegyX02gwjwOT66LisIe' AccessTokenSecret = 'Wfu5QgkHiLqdaPF7t3AcM3XCihVpxUJbrUk4dkKBjJCcZ' t...
a322bf331b06eb1590c5b195c35d556750c6d41b
giewev/Euler
/problems/problem_15.py
651
3.84375
4
import sys sys.path.insert(0, '../') from frameworks.comprehensions import factorial def grid_solve(m, n): 'Solves the problem by calculating the number of paths to each node' grid = [[0] * (n + 1) for x in range(m + 1)] for x in range(m + 1): grid[x][0] = 1 for y in range(n + 1): grid[0][y] = 1 for x in ran...
947d51c7974b20bee90cce2e2968cd8a3451367f
dhiraj-ydv/python-user-input
/firstproject.py
100
3.84375
4
x = int(input("Enter first number")) y = int(input("Enter second number")) z = x + y print(z)
3145552cf69761d84f0d7f1b28379344e95cb778
FernandoSVasconcelos/alurapy
/strings/extrator_cep.py
280
3.765625
4
import re endereco = "Rua Praguai 11, apartamento 12, Quisisana, Poços de Caldas, MG, 37701-244" padrao = re.compile("[0-9]{5}[-]?[0-9]{3}") busca = padrao.search(endereco) if(busca): cep = busca.group() print(f"CEP = {cep}") else: print(f"Padrão não encontrado")
f223ecd346487453e555f944ebedf812602e56f8
edenuis/Python
/Code Challenges/countTriplets.py
904
4.0625
4
#Challenge: Given an array of distinct integers. The task is to count all the # triplets such that sum of two elements equals the third element. #Idea: For each number in the array of integers, count the number of pairs of # integers that adds to the number. Return the total count. def countTripletsW...
0e981ab8dc791d131cf6a7fcfdfe753bb7ac6718
wafapathan/basicprograms
/Quadrant.py
612
4.0625
4
x=int(input("Enter x:")) y=int(input("Enter y:")) if (x > 0 and y > 0): print("x and y lies in 1st quadrant") elif (x < 0 and y > 0): print("x and y lies in 2nd quadrant") elif (x < 0 and y < 0): print("x and y lies in 3rd quadrant") elif (x > 0 and y < 0): print("x and y lies in 4th qu...
e1cd3c270928a756ebd3425a7da8f5e5c0418044
ritveak/Learning-NLTK
/5 . Chunking.py
2,369
4.15625
4
import nltk from nltk.corpus import state_union #state_union holds the addresses of presidents from nltk.tokenize import PunktSentenceTokenizer sample = "Hey! This is Ritveak, Trying to code and learn NLP." test = "My name is Ritveak, I am a Btech student. I want to learn NLP. And that is the reason why I am...
65deaef0299fc21fc97b0d0cc6e2aeabfa67931c
arshadumrethi/Python_practice
/5.py
118
3.53125
4
def unusual_five(): z = "abcde" count = 0 for i in z: count += 1 print count unusual_five()
436d1c3448570379969414d13243e1d11f6c26da
yue-w/LeetCode
/Algorithms/75. Sort Colors.py
698
3.90625
4
from typing import List class Solution: def sortColors(self, nums: List[int]) -> None: """ Do not return anything, modify nums in-place instead. """ zero, two, curr = -1, len(nums), 0 while curr < two: if nums[curr] == 1: curr += 1 ...
eee60168b067bf310248927ae477c21094251865
giovani-sarchesi/GGLocadora
/telas/AdicionarFrota.py
800
3.5
4
import sqlite3 import telas.Menu import telas.AdicionarFrota import os def main(): os.system("clear") conn = sqlite3.connect('./banco/dados.db') print("Adicionar frota:") nomecarro = input("Digite o nome da frota: ") precodiaria = float(input("Digite o valor da diaria da frota: ")) try: conn.execute(...
c42c8e72c78844546a640dcbe40ff4f86415f4e6
EMajec/PongonSteroids
/paddle.py
1,405
4.21875
4
import tkinter class Paddle: #develops the paddle class def __init__(self, c): #creates a drawing that is the size of the paddle self.__canvas = c self.__left = 200 self.__right = 300 self.__top = 570 self.__bottom = 590 self.__drawing = self.__canvas.cr...
23487935567799a2051f2018a124a90c6012461e
shaklevi/myProj1809
/hotel_Devops/hotel_funcs.py
2,034
3.6875
4
import datetime class hotel: roomfiles = [ "C:\\Users\\ShaharL\Desktop\\room1.txt", "C:\\Users\\ShaharL\Desktop\\room2.txt", "C:\\Users\\ShaharL\Desktop\\room3.txt", "C:\\Users\\ShaharL\Desktop\\room4.txt" ] def find_free_rooms(self): print("Finding free rooms") ...
9ef767ca04140f2d69cbca44120ecd76dc085846
RaglandCodes/Algos
/Add to Array-Form of Integer.py
313
3.53125
4
''' LeetCode 989. Add to Array-Form of Integer https://leetcode.com/problems/add-to-array-form-of-integer/ ''' class Solution: def addToArrayForm(self, A: List[int], K: int) -> List[int]: A = int("".join(str(i) for i in A)) return [int(i) for i in list(str(A + K))]
2f75b08f9685333b5b46011673f9be1d85fdb286
GuiRodriguero/pythonFIAP
/1 Semestre/Aula2ExExtra/exer8.py
275
3.796875
4
preco = float(input("Digite o preço de um produto: ")) desconto = float(input("Desconto: %")) desconto = desconto / 100 valorDesconto = preco * desconto novoPreco = preco - valorDesconto print("Valor do desconto: ", valorDesconto) print("Preço com desconto: ", novoPreco)
fb21ec7bc62d913feb698bb23795e67ef6d949ef
yxh13620601835/store
/继承/phone.py
1,497
3.796875
4
''' 1、定义老手机类, 有品牌属性,且属性私有化,提供相应的getXxx与setXxx方法, 提供无返回值的带一个Str类型参数的打电话的方法,内容为:“正在给xxx打电话...” 2、定义新手机类,继承老手机类, 重写父类的打电话的方法,内容为2句话:“语音拨号中...”、“正在给xxx打电话...” 要求打印“正在给xxx打电话...”这一句调用父类的方法实现, 不能在子类的方法中直接打印; 提供无返回值的无参数的手机介绍的方法,内容为:“品牌为:xxx的手机很好用...” 3、定义测试类,创建新手机对象,并使用该对象,...
71cc70cf7050cecd05c9ef6f6a278f7367ba0501
HugoAquinoNavarrete/python_scripting
/bin/08-autoincremento-variables.py
755
4.03125
4
# Script para explicar el uso del auto incremento de variables # Define variables Variable_1 = 5 print ("Valor inicial de \"Variable_1\": " + str(Variable_1)) Variable_1 = Variable_1 + 3 print ("Ahora el valor \"Variable_1\" es: " + str(Variable_1)) Variable_1 = Variable_1 // 2 print ("Ahora el valor de \"Variable_1\"...
3c3013cd3c0e624678be7b1914694bd9c3650d5d
KareliaConsolidated/Data-Structures-and-Algorithms
/33_Recursion_02.py
363
4.375
4
# Using Helper Method # Python program to print odd numbers in a List def collectOddValues(arr): result = [] def helper(helperInput): if len(helperInput) == 0: return if helperInput[0] % 2 != 0: result.append(helperInput[0]) helper(helperInput[1:]) helper(arr) return result print(collectOddValu...
6f04bc7c5484da0b4667d188f0a1f716500b7a8f
gjq91459/mycourse
/18 MetaClasses/10_extension_methods_for_builtins.py
585
3.953125
4
############################################################ # # binding methods to built-ins # ############################################################ # You can't bind extra methods to builtin classes or classes # defined in the C language. However you can inherit from # builtins and add methods to t...
81f461719908058d723607d468ed6d169f4c87c6
sinkingpoint/sythe
/tests/parsing/tokenizer_tests.py
2,060
3.6875
4
import unittest from sythe.parsing import tokenizer class TokenizerTests(unittest.TestCase): def test_tokenizer_tests(self): """ Tests that the string tokenizer tokenizes strings as we expect before parsing """ test_cases = [ #Test Empty strings don't have any to...
d27400c3ba9e15a677bfcc450f017439939bf88c
D3D53C/Android
/Code/Python/Terminal/Manuel.py
3,122
3.546875
4
import Basic.servo as Servo # noinspection PyCallByClass,PyCallByClass,PyCallByClass,PyCallByClass,PyCallByClass,PyCallByClass,PyCallByClass,PyCallByClass class ManuelC: def Kontrolle(self): x = 0 Auswahlstring = "Manuele Kontrollle \n" \ "Daumen 1,Zeigefinger 2,Mit...
bebc8e605a4b890fd255df79e076fddb60845f1e
iota-cohort-dc/Dorian_Bramarov
/Python_/Python_Fundamentals/multSumAvg.py
497
4.1875
4
#Use for loop to print count if mod 2 doesnt equal 0 for count in range (1, 1000): if count % 2 != 0: print count #Use for loop to print multiples of 5 up until 1,000,000 for mult in range (5, 1000000): if mult % 5 == 0: print mult #Prints the sum of all the values in the list a = [1,2,5,10,255,3] sum = 0 for ele...
5faa015f387fd3195b73fb97282e1b895ece6cd2
HanJenHsuEden/guessnumber
/guessnumber.py
483
3.71875
4
import random up = input('請輸入猜測數字的上限') low = input('請輸入猜測數字的下限') up = int(up) low = int(low) r = random.randint(low,up) count = 0 while True: count = count + 1 n = input('請在上下限之間猜一個數字:') n = int(n) if n == r: print('終於猜對了') break elif n > r: print('猜得比答案大') print('這是你猜的第',count,'次') elif n < r: print('猜...
f2b6a25d84fe3299ce1891249e09c947712e08d4
Python-Programming-Boot-Camp/TimGrogan
/lab_2.6.1.9py.py
468
4.1875
4
a = float(input("input value for a ")) # input a float value for variable a here b = float(input("input value for b ")) # input a float value for variable b here print(" a+b=", a+b) # output the result of addition here print(" a-b=", a-b) # output the result of subtraction here print(" a*b=", a...
0f00ad064d028d518baee5aee8fddc8af68fce4f
robinspollak/syllable-analysis
/main.py
1,153
3.65625
4
# -*- coding: utf-8 -*- import codecs from english import english_syllabify from spanish import * englishWords = open('english-words.txt') englishSyllableDict = {} for line in englishWords: word = unicode(line.strip()) numSyllables = english_syllabify(word) if numSyllables > 0: if numSyllables in englishSyll...
8c1822c4096872e620a090734fb3238573ec9c23
rashidbilgrami/piaic_studies
/sphere_volume.py
778
4.1875
4
import math ''' This code is for the study purpose the code is developed by Rashid Imran Bilgrami, If you have any concerns please email me at rashidbilgrami@hotmail.com or comments on GITHUB ''' # my own function for truncate, you can use format or round but both change the value ''' def truncate(f, n): ...
70251ad09550cc48925d1def5725829921d92539
zhuolikevin/Algorithm-Practices-Python
/VMware/knapsack.py
751
3.65625
4
# 0-1 knapsack problem class Solution: def maxValue(self, gold, silver, maxWeight): weight = gold + silver length = len(gold) + len(silver) price = [] for x in range(length): if x < len(gold): price.append(10*gold[x]) else: price.append(1*silver[x-len(gold)]) #print weight #print price ...
1216e580e8e5f14a1b3ffa65220dd75aa54f03d5
Laxmivadekar/dictionary
/15.py
390
3.84375
4
a=input('enter the name') i=0 d={} while i<len(a): d[a[i]]=a i=i+1 print(d) print('________________________________') a=[('yellow', 1), ('blue', 2), ('yellow', 3), ('blue', 4), ('red', 1)] d={} b=[] for i,j in a: d.setdefault(i,[]).append(j) print(d) # Grouping a sequence of key-value pairs into a ...
92ee62c7c5371343882d9e9336e704fde47aa69b
jRobinson33/Python
/booleans.py
791
4.15625
4
#python booleans #6/3/2019 #both True and False are capatalized a = 3 b = 5 print("Showing the boolean output of comparisons") print(a == b) print(a != b) print(a > b) print(a < b) print("Showing type of True and False") print(type(True)) print(type(False)) print("Showing that False is 0 and everything else is tr...
45c62a54ae02df2c520131e637c684d7714927e0
arshaver/Project-Euler
/euler45.py
680
3.65625
4
import time def ispent(number): pos = (1./6.)*(1+(24*number+1)**0.5) neg = (1./6.)*(1-(24*number+1)**0.5) if pos == int(pos) and pos > 0: return True elif neg == int(neg) and neg > 0: return True else: return False def ishex(number): pos = (1./4.)*(1+(8*number+1)**0.5) ...
64cdde9fd7e7cf150542307cfe4616bc1e950cce
rachit-0032/NN_from_scratch
/multi_layer.py
2,297
4.03125
4
# 2-layered Neural Network Functioning import numpy as np inputs = np.random.randint(-10, 10, (10, 4)) # Each input (3) has 4 features weights_layer1 = np.random.randint(-5, 5, (3, 4)) # For each feature we have one weight, finally giving output to 3 perceptrons biases_layer1 = np.random.randint(-...
69196cf1fc70d25f8f203e5536b10810a932e3ff
kburr6/Python-Projects
/Python Basics/Functions/factorial.py
595
4.53125
5
def factorial(n): ''' Returns the factorial of the input integer: n * (n - 1) * (n - 2) * ... * 2 * 1 Parameters ---------- n: {int} number to compute factorial of (must be greater than 0) Returns ------- n!: {int} factorial of n ''' factorial = 1 # check if the n...
14d6b7544924d4df466453fb61768fe66a4d8e17
jtruji68/BlackjackShell
/model/shoe.py
769
3.6875
4
import random class Shoe: def __init__(self): values = ["A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"] number = [[1, 11], 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10] suits = ["♥", "♠", "♦", "♣"] sh = [] for deck in range(6): for suit in suits: ...
bf89c9a6c2972ce7aff71a5200d8ebde5c49cad6
damianbao/practice_python
/Py_practice_pr8.py
1,915
3.8125
4
# -*- coding: utf-8 -*- """ Created on Sun Apr 15 17:15:31 2018 @author: staie """ play_again = 'y' while play_again == 'y': choice1 = int (input ('Player One! \n Choose your weapon!!!\n Enter 1 for rock.\n 2 for paper, \n Or 3 for scissors: ')) choice2 = int (input ('Player Two! \n Choose your weapon!!!\n En...
cade48689ce06467848919ca22008ba6555ebf83
vsdrun/lc_public
/co_apple/190_Reverse_Bits.py
1,213
4.1875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ https://leetcode.com/problems/reverse-bits/description/ Reverse bits of a given 32 bits unsigned integer. Example: Input: 43261596 Output: 964176192 Explanation: 43261596 represented in binary as 00000010100101000001111010011100, return 964176192 represented in bin...
d96247259085d0d6c9ae7a1a1441df23a7df51da
vedantnanda/Python-and-ML
/19_5_18/File Operations.py
702
4.15625
4
fo = open("file1.txt","r") print(fo.name) print(fo.read()) #fo.write("new data") error fo.close() fo = open("file2.txt","w") print(fo.name) fo.write("data written on file") #print(fo.read()) Error fo.close() #writing to a file fo = open("file3.txt","w") print(fo.name) fo.write("First Name: {0}\nRoll No:{1}\nColle...
b9d0fc763d09c35d15b56069c1904dd3869af1fb
Sem31/Data_Science
/5_matplotlib-practice/1_create_plot.py
253
3.96875
4
#creating plots in matplotlib import matplotlib.pyplot as plt import numpy as np x = np.arange(10) y = x*2 #x for x-axis and y for y-axis and r is for color plt.plot(x,y,'r') plt.xlabel('X Label') plt.ylabel('Y Label') plt.title('Title') plt.show()
cd9bf5da6c2927c0d5f3a57db3d6eb77dc409b04
ryanchao2012/frappuccino
/adventofcode/2017/day03_spiral_memory.py
7,864
4.3125
4
""" --- Day 3: Spiral Memory --- You come across an experimental new kind of memory stored on an infinite two-dimensional grid. Each square on the grid is allocated in a spiral pattern starting at a location marked 1 and then counting up while spiraling outward. For example, the first few squares are allocated like th...
ef4a3258d70869ba9b88484a7ccdd799ed77171a
kelvincaoyx/UTEA-PYTHON
/Week 2/richTask/linearQuadratic.py
2,390
4.375
4
''' Allows the user to input variables to solve a linear quadratic system ''' #Function to more easily check the value of a variable and will output an error if the variable is invalid def inputChecker(letter): value = input("Enter the value of parameter " + letter + ": ") if value == "": print("The va...
5be37daa332535f95b6dbb7737a96761eac67a50
ZLLVZY/Design-pattern
/组合模式/server.py
1,242
3.84375
4
class Company(object): def __init__(self,name): self.name=name def Add(self,c):#增加 pass def Remove(self,c):#移除 pass def Display(self,depth): pass def LineOfDuty(self): pass class ConcreteCompany(Company): def __init__(self,name): super(ConcreteCom...
14cde5e21db7dc6ee526fd1f9ebe6bc8cc03c956
ivklisurova/SoftUni_Fundamentals_module
/Exercises/Text_processing/letters_change_numbers.py
466
3.71875
4
def char_position(letter): return ord(letter) - 96 text = input().split() result = 0 for i in text: number = int(i[1:len(i)-1]) if i[0].isupper(): result += number / char_position(i[0].lower()) elif i[0].islower(): result += number * char_position(i[0].lower()) if i[-1].isupper()...