blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
4f143da7d7f56c7cb8c2723bd400768973e3aebc
jpslat1026/Mytest
/Section1/1.3/3.py
460
4.03125
4
#3.py #by John Slattery on November 15, 2018 #This script finds the weight of atoms import math def main(): print("This script will help you calculate the weight of atoms ") H = 1.00794 C = 12.0107 O = 15.9994 h = eval(input("How many Hydrogen atoms: ")) c = eval(input("How many carbon atoms: ")...
cc990f3e021f89e067f348600d317c0f3614f048
irimina/Python_functions
/TryExceptDebugging#5.py
1,669
4.34375
4
''' Compare the following programs below ''' # program 1 without try and except #Function to calculate discount and tax amount def price_calculator(price, discount): # discount_rate=discount/100 if you just let the user enter a number and not a .something discount_amount = price * discount. # change discount to...
a79b68e004c26f9f976fa129121fc5e7c7c20d4a
PrajwalGhadi/GFG-Leet-Code-Python-Practise
/GeekForGeek Practise/Pattern_Prac2.py
227
4.0625
4
'''Date - 11-06-2021 Author - Prajwal Ghadi Aim - Programs for printing pyramid patterns in Python.''' n = int(input()) k = n - 1 for i in range(0, n): for j in range(0, i + 1): print('*', end='') print()
c1772df4ad30822a95d9b0a565e254e71ca638c6
Anil-account/python-program
/lab exe2.py
4,378
3.921875
4
# 1 to find 5 present or not # l =[1,2,3,4,5] # for i in range (len(l)): # if 5==l[1]: # print("true") # else: # print("false") # 2 to print marks result # mark1 = int(input("Enter your math mark :")) # mark2 = int(input("Enter your science mark :")) # mark3 = int(input("Enter your english ...
7f17d15b0a2b3b1035983528196510a8da88d0b5
raineynw/25-TkinterAndMQTT
/src/m3_robot_as_mqtt_receiver.py
1,508
3.53125
4
""" Using a Brickman (robot) as the receiver of messages. """ # Same as m2_fake_robot_as_mqtt_sender, # but have the robot really do the action. # Implement just FORWARD at speeds X and Y is enough. import tkinter from tkinter import ttk import mqtt_remote_method_calls as com import time def main(): root = tkint...
f9ba449c88b528d2f9faa0d1050ccdb2e822ced6
rangera-manoj/IMDB-Movie-Review-Sentiment-Analysis
/clean_function.py
585
3.515625
4
def clean_text(texts): import re import nltk from nltk.corpus import stopwords nltk.download('stopwords') from nltk.stem import SnowballStemmer stop_words = stopwords.words('english') stemmer = SnowballStemmer('english') clean_review = [] for i in range(len(texts)): review =...
98fd8ea6474f1df8529eaa3d12ec3d5543308214
vivekworks/learning-to-code
/4. Discovering Computer Science/Python/Chapter 4 - Growth And Decay/Exercises 1/exercise417.py
1,567
3.640625
4
""" Purpose : Perform all the sections under 4.1.7 Author : Vivek T S Date : 29/10/2018 DCS, Python introduction """ def section1a(): """ Description: Print even integers from 2 to 100 Parameters: None Return value: None """ for even in range(2, 100, 2): print(even) def section2b(): "...
7320f1de5f6a04875d056e65cb499248b357f84b
sgiann/sleeplight
/flash_led_blink_thread_class.py
884
3.84375
4
import threading import time #param list #name : Give as name the colour of the LED to be handled. #pin_number - The pin number that the LED is hooked at. #dtime_mins - Give the desired time in minutes that you want the led to blink for. class LEDThreadStill(threading.Thread): def __init__(self, name, pin_number,...
c942a89886a06b9fd38c1ccce5c1d2f33d2bb496
clefego/python-codes
/lista5.py
217
3.625
4
teste = list() teste.append('Cleyton') teste.append(40) turma = list() turma.append(teste[:]) teste[0] = 'Lianne' teste[1] = 22 turma.append(teste[:]) print(turma) print(turma[0]) print(turma[0][0]) print(turma[0][1])
a7f85a8a4ed7affe287449bd085c7bd10509149f
IrisDyr/demo
/Week 1/H1 Exercise 1.py
813
4.1875
4
def adding(x,y): #sum return x + y def substracting(x,y): #substraction return x - y def divide(x,y): #division return x / y def multiplication(x, y): #multiplication return x * y num1 = int(input("Input the first number ")) #inputing values num2 = int(input("Input the second number "...
9cc746277adbc8f47323a39f386d3966eaa5ea73
spnarkdnark/i_be_learnin
/algorithm_file.py
1,786
3.84375
4
import math import random #insertionsort array1 = [1,5,3,7,9,5,6,9,23,5,57,83,100] def get_array(size): return [random.randint(1,101) for i in range(0,size)] def insertion_sort(array): for i in range(1,len(array)): for j in range(i-1,-1,-1): if array[j] > array[j+1]: arr...
347a62ca6b2709120f8b7dbd7555f6b1c4ad34ad
vanimirafra/python
/decotaror.py
267
3.71875
4
def decorator(func): def inner(*args,**kwargs): return 10 * func(*args, **kwargs) return inner @decorator def adder(x,y,z): return x + y + z x=int(input("enter number")) y=int(input("enter number")) z=int(input("enter number")) print(adder(x,y,z))
1eadf7c4a817267735a6647b319dd8e9bf14a83c
vztpv/Python-Study
/Chapter4/py011.py
416
3.703125
4
# 4 - 2 Problem 1, 2, 3, 4 input1 = int(input("first number")) input2 = int(input("second number")) total = input1 + input2 print("sum is {}".format(total)) str = input("numbers") numbers = str.split(',') print(numbers) sum = 0 for x in numbers: sum += int(x) print(sum) print("you", "need"...
727a32830e17711c132ee0724af6222e6045792e
malgorzata-kozera/Web-Crawler
/web_crawler.py
3,152
3.515625
4
import requests from bs4 import BeautifulSoup as bs from requests.exceptions import InvalidSchema, ConnectionError,MissingSchema import sys def site_map(enter_url): ''' Function takes as an argument site base url path (including 'http://') and returns mapping of that domain as a Python dictionary: ...
618a9b3ee816b2c346c57f764953431406cc66c2
stravajiaxen/project-euler-solutions
/project-euler-solutions/p22/euler22.py
1,379
3.671875
4
""" Copyright Matt DeMartino (Stravajiaxen) Licensed under MIT License -- do whatever you want with this, just don't sue me! This code attempts to solve Project Euler (projecteuler.net) Problem #22 Names scores Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand ...
91b149ac8f16f788e985b65265a479384d1e2d44
ravenusmc/trail
/merchant.py
2,644
4
4
from valid import * #I created this merchant class to help solve some problems that I was having wih the store file. #So far, it seems to help solve my problems as well as to increase my understanding of OOP. The methods #in this file may be long but they got the job done and help me solve my issue! class Merchant()...
1d47ead26cde42113bc511cfa05c6a97468c0ff2
47AnasAhmed/LAB-05
/LAB5_PROGRAMMING EX01.py
670
3.921875
4
print("Anas Ahmed(18b-116-cs),CS-A") print('Lab No.5') print('Programming Ex#1') def area(): import math radius = eval(input('enter value of radius= ' )) height = eval(input('enter value for height= ')) area = (2*math.pi*radius*height) + (2*math.pi*radius**2) print('The area of the cylinder ...
8ff1dd1a0ebd849ef3272208c41bc7be546e7622
sukantanath/ds_hr
/listComprehension.py
559
3.953125
4
#You are given three integers x,y,z representing the dimensions of a cuboid along with an integer n. #Print a list of all possible coordinates given by (i,j,k) on a 3D grid where the sum of (i+j+k) is not equal to n. # Here, 0< i < x, 0 < j < y ,0 < k < z. Please use list comprehensions rather than multiple loops. ...
7a2c1348dab1bad21d6a53dfc0d5aee5aaf5ad6f
snickersbarr/python
/python_2.7/LPTHW/exercise9.py
504
4.1875
4
#!/usr/bin/python ### Exercise 9 ### ### Printing, Printing, Printing ### # Example of using \n for new lines days = "Mon Tue Wed Thu Fri Sat Sun" months = "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug" print "Here are the days: ", days print "Here are the months: ", months # Example of how to print multiple lines in a r...
e9a7ce839868dc801fa4189cfae790ca003157db
rainandwind1/Leetcode
/mi_3.py
257
4.03125
4
def isPowerOfThree(n): if n == 0: print(False) if n == 1.0: print(True) return True if n%3 == 0: n = n/3 #print(n) isPowerOfThree(n) if n%3 != 0: return False print(isPowerOfThree(27))
f86a110ac1c8b2b262810bbc15cdf4550b45137b
Kumar72/PyBasics
/tictactoe.py
2,178
4.28125
4
# MILESTONE PROJECT 1: Tic Tac Toe Game # Build the Visual Representation # Get the User Input # Applying the logic for each input # Update Visual row1 = [] row2 = [] row3 = [] def play_game(): game_on = True # Welcome to the game message, Enter Player Name, Scores, etc. configure_game_options() # In...
5a2141f2850142672f7a6e4318fe9aa383a7f511
runzezhang/Code-NoteBook
/lintcode/0608-two-sum-ii-input-array-is-sorted.py
1,335
4.09375
4
# Description # 中文 # English # Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. # The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Please note...
498a4211105e2865d5fc812fb58b99b73c047115
Abdiramen/Euler
/python/finished/p10/problem10.py
326
3.90625
4
#!/usr/bin/env python3 from math import sqrt def primes(): prime = 1 while True: prime += 2 if all(prime % i for i in range(2, int(sqrt(prime)+1))): yield prime total = 2 for i in primes(): print(i) if i > 2000000: break total += i print("total: {}".format(to...
6f493c7353bc8e3ab89835143fc6752dfeb0ee54
savfod/d16
/agekht/7/koh.py
486
3.734375
4
import turtle import tkinter turtle.speed('fastest') def qwe(a1, a2, a3): if a1 > 0: qwe(a1 - 1, a2 / 3, a3) turtle.right(a3) qwe(a1 - 1, a2 / 3, a3) turtle.left(a3 * 2) qwe(a1 - 1, a2 / 3, a3) turtle.right(a3) qwe(a1 - 1, a2 / 3, a3) if a1 == 0: turtle.forward(a2) def rty(a1, a2): qwe(a1, a2, 60)...
91aa63fbf1b6c39b18fad3e413a2b6bdd1bf3bfd
TheJulius/python_back_end
/python3oo2/modelo.py
2,293
3.6875
4
class Programa: def __init__(self, nome, ano): self._nome = nome.title() self.ano = ano self._likes = 0 @property # metodo get def likes(self): return self._likes def dar_likes(self): self._likes += 1 @property # metodo get def nome(self): ret...
7b33fcced160331a2fcd001a422f6a6411a99f3b
oneoffcoder/books
/sphinx/python-intro/source/code/oneoffcoder/loop/foreachzip.py
109
3.890625
4
names = ['Jack', 'John', 'Joe'] ages = [18, 19, 20] for name, age in zip(names, ages): print(name, age)
03ffdab1e4e37a38880b0ef02fc1262f7749859b
CheshireCat12/hackerrank
/ai/bot_clean_large.py
1,302
3.609375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Sep 1 11:24:00 2019 @author: cheshirecat12 """ DIRTY_CELL = "d" def manhattan_dist(pos_bot, pos_dirt): return sum(abs(pos_b-pos_d) for pos_b, pos_d in zip(pos_bot, pos_dirt)) def next_move(pos_y, pos_x, dimx, dimy, boar): # Check if the ...
c6bdf025b51ccde7f462d0889f78dee44e67fc30
helenros/python2017
/two.py
537
4.125
4
#Input an array of n numbers and find separately the sum of positive numbers and negative numbers int_arr =list() totnum=input("Enter how many elements you want : ") print 'Enter the numbers in array : ' for i in range(int(totnum)): n=input("Number : ") int_arr.append(int(n)) print 'Entered Array : ', int_arr ...
ada12eff354cf602924f03a19a48f18b9a3278e3
MJZ-98/data_mining
/capsnet.py
35,540
3.765625
4
import keras.backend as K import tensorflow as tf from keras import initializers, layers class Length(layers.Layer): """ Compute the length of vectors. This is used to compute a Tensor that has the same shape with y_true in margin_loss. Using this layer as model's output can directly predict labels by usin...
98a08b41ef7c7c4f50a09e60371a143d60b7ff9e
chendingyan/My-Leetcode
/Basics/codes/KMP.py
917
3.546875
4
def gen_pnext(substring): """ 构造临时数组pnext """ index, m = 0, len(substring) pnext = [0]*m i = 1 while i < m: if (substring[i] == substring[index]): pnext[i] = index + 1 index += 1 i += 1 elif (index!=0): index = pnext[index-1] ...
75cfddd299526fa438eff331f8189b60e9cbe86f
zverinec/interlos-web
/public/download/years/2022/reseni/megaBludisko-solution.py
4,555
3.5625
4
from collections import deque from heapq import heappush, heappop DR = [-1, 0, 1, 0] DC = [0, -1, 0, 1] class Vertex: def __init__(self): self.dist = None self.next = [] def bfs(maze, si, sj): if maze[si][sj] == "#": return None r = len(maze) c = len(maze[0]) dist = [[None...
eb358a28fd77385b302ac37403b1e5dd53f89c31
behike56/learning-python3
/string_formatting/string_tow_formating.py
4,851
3.703125
4
# -*- coding: utf-8 -*- """\ PythonができるStringの事。中巻:format()の章 Pythonの基本を学習するためのソースコード Author: Hideo Tsujisaki """ import datetime """\ インデックスを指定するフォーマット方法 """ # インデックス指定1 formated_str1 = "安全性能:{0}、運動性能:{1}、燃費性能:{2}".format("A", "B", "C") # インデックス指定2 formated_str2 = "安全性能:{0}、運動性能:{1}、燃費性能:{2}".format("C", "A", "B...
c875aeeab3784397d8bb693edb92bf153cb897a3
dhruvmojila/sem-5
/pds/practical-2/p2_8.py
316
3.828125
4
a = ['d','h','r','u','v'] print("join method:", ''.join(a)) b = ','.join(a) print("split method:", b.split(',')) d = { 'neharika':{'birthday':'Jun 1'}, 'soham':{'birthday':'june 30'}, 'preyas':{'birthday':'July 7'}, 'divyam':{'birthday':'may 5'} } name = input("enter name:") print("birthday:", d[name])
dbfed2e4d728e2c9561f27f4d785ec0293586b77
chintu0019/DCU-CA146-2021
/CA146-test/markers/func_sum_range.py/test-1/func_sum_range.py
271
3.53125
4
import func_bsearch def sum_range(a, low, high): total = 0 i = func_bsearch.bsearch(a, low) while i < len(a) and a[i] < high: total += a[i] i = i + 1 return total if __name__ == "__main__": a = [1,2,4,4,5,5,6,7,8] print sum_range(a,3,7)
d4612f4d18582dfa9aafea4d8fc3ce668170764b
Izmno/Kalah
/kalah.py
4,125
3.625
4
class Kalah: def __init__(self, houses, seeds): self._houses = houses # half the size of the board, i.e. number of houses and the store # for each player self._halfsize = houses + 1 # full size of the board self._fullsize = 2 * self._halfsize # board: array...
545d6ef8257aa5a7acaa0443b8e48f96008e7073
NCavaliere1991/Spotify-Playlist
/main.py
1,420
3.5
4
from bs4 import BeautifulSoup import requests import spotipy from spotipy.oauth2 import SpotifyOAuth from pprint import pprint BILLBOARD_URL = "https://www.billboard.com/charts/hot-100/" CLIENT_ID = "ab85b014d9fe44bbac9a6dd8a2601deb" CLIENT_SECRET = "c3ebe9cfa7954b57b4989116dcec51be" date = input("Which year would y...
42b5e12eb7195ebdc40206fea4d2d5a98d0d212e
rivcah/100daysofPython
/lists.py
1,107
3.609375
4
##Use lista.getlist(t, path) in order to create a .csv file with names and ##ID numbers. class lista: def getid(): import random as r n = [] for i in range(5): n.append(str(r.randint(0,9))) ID = '' for i in range(len(n)): ID += n[i] ...
2bb80eca9e1ea7dc5742973b822d68e6ae88ff31
baayso/learn-python3
/function/def_func.py
3,125
4.03125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import math # 空函数 def nop(): pass def my_abs(x): if not isinstance(x, (int, float)): raise TypeError('bad operand type') if x >= 0: return x else: return -x def move(x, y, step, angle=0): nx = x + step * math.cos(angle) ...
b96d9d3b2fa30f2c2ff4472fec1f25859c09d25c
big-Bong/AlgoAndDs
/PythonPractice/CTCI/4_4_CheckBalanced.py
732
3.875
4
class Tree: def __init__(self,num): self.val = num self.left = None self.right = None def checkBalanced(root): if(not root): return False val = calculateHeight(root) if(val == -1): return False return True def calculateHeight(root): if(not root): return 0 l_height = calculateHeight(root.left) r_...
7bf254ecb7d5403c6470a4520b04cb12e80ceae7
Priya2410/Competetive_Programming
/Codechef/Beginner-Problems/FLOW004.py
172
3.6875
4
# cook your dish here test=int(input()) for i in range(0,test): n=input(); length=len(n); num=int(n); sum=num%10+int(num/pow(10,length-1)); print(sum);
0d8d1c23ee883c8ecb465b1ea25b9b2bf60bf01f
blueicy/Python-achieve
/00 pylec/01 StartPython/hw_5_2.py
358
4.1875
4
numscore = -1 score = input("Score:") try: numscore = float(score) except : "Input is not a number" if numscore > 1.0 : print("Score is out of range") elif numscore >= 0.9: print("A") elif numscore >= 0.8: print("B") elif numscore >= 0.7: print("C") elif numscore >= 0.6: print("D") elif numscore >= 0.0: pr...
7260c27e17c2decc78c8f6c3cd09b021a3ecf7b6
rajagoah/Python-Importing-From-Web
/ImportingFromWebExercise8.py
520
3.625
4
import requests from bs4 import BeautifulSoup #storing url in variable url = 'https://www.python.org/~guido/' #packaging, sending and receiving the response r = requests.get(url) #html_doc storing the html in text html_doc = r.text #converting to beauitfulsoup object soup = BeautifulSoup(html_doc) #finding all the...
88c865c43050ebd588de03d6771d64acac481584
ladezai/markov-model
/Markov/markov.py
8,832
3.921875
4
import numpy as np from math import isclose class StationaryMarkovChain(): """ It provides an implementation of stationary finite Markov chain `(l, P)` over the set of labels `S` (or nodes of the Markov chain). The following implementation emphasises that a Markov chain...
aadd229b33499ba43d42f7f71acc36c0ffbacdf3
Mengeroshi/python-tricks
/3.Classes-and-OOP/2.1string_conversion.py
284
4.03125
4
"""__str__ gets called when you try to convert an object to a string""" class Car: def __init__(self, color, mileage): self.color = color self.mileage = mileage def __str__(self): return f'a {self.color} car' my_car = Car('red', 37281) print(my_car)
2cefb9217bb6e74cc7da7948571a9d1ca9061f88
CodetoInvent/interviews
/dp/stock_iv.py
1,223
3.890625
4
# Say you have an array for which the ith element # is the price of a given stock on day i. # Design an algorithm to find the maximum profit. # You may complete at most k transactions. # Note: # You may not engage in multiple transactions at the same time. # algorithm: # i: transactions table # j: day # max( # ...
a75ae0872bf668529dfc7db2046aad3219505a5b
natanisaitejasswini/Python-Programs
/avg.py
95
3.625
4
a = [1, 2, 5, 10, 255, 3] sum = 0 for element in a: sum += element print 'final:', sum/len(a)
83a85a304850eb32ccea443264cacdc9e676b254
lade043/Projekttage
/user_IO.py
1,188
3.78125
4
import Formeln def user_input(): geg = {} ges = {} geginput = None gesinput = None while True: geginput = input("Welche Formelzeichen sind gegeben? Geben Sie immer nur EINS ein! \n" " Bestätigen sie Ihre Eingaben mit 'Fertig'\n") if geginput == "Fertig": ...
1d41215ee4e7f6ce498fd5d4c12c989f2cc2fc02
corrodedHash/brancher
/brancher/codegen.py
4,538
3.609375
4
"""Contains functions to generate C code""" import random from typing import List, Tuple from . import node, util class CodeGenerator: """Generates code""" def __init__(self, var_count: int, fun_count: int, indent: str = " ") -> None: self.variables: List[str] = ["var_" + str(x) for x in range(1, v...
181108037d88a964161d7452af6dc1422be55898
navyapp/python-MCA
/CO 1/co1 leapyear(2).py
202
3.546875
4
# co1, 2 y1 = int(input("ener the current year")) y2 = int(input("enter the last year")) for i in range(y1, y2 + 1): if (i % 4 == 0 and i % 100 != 0 or i % 400 == 0): print(i) i = i + 1
71ac9387476d51503059f903bbf242b76ed974de
ruifan831/leetCodeRecord
/92_Reverse_Linked_List_II.py
703
3.875
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def reverseBetween(self, head: ListNode, m: int, n: int) -> ListNode: pre=None node=head while m>1: pre=...
00339e63123de116e196fd20b8aaf96591051b0c
nsasaki128/advent_code_2020
/25_01.py
670
3.65625
4
def main(): s = 7 card = int(input()) door = int(input()) key = 20201227 card_loop = get_loop(s, key, card) door_loop = get_loop(s, key, door) print(f"card_loop: {card_loop}") print(f"door_loop: {door_loop}") ans_card = 1 for _ in range(door_loop): ans_card *= card ...
e8ee4886c905716f6b216b146b979d8a243e8ff2
op9494/Python-programs
/2reverse_str.py
112
4.125
4
def reverse(str): s ="" for ch in str: s=ch+s return s mystr =input() print(reverse(mystr))
08103978aa9f3232bbfccc6a0c902d6c46ceea7d
abhmak/Deeplearning-files
/2.Data_types.py
8,599
3.984375
4
# -*- coding: utf-8 -*- """ Created on Fri Jun 1 14:59:03 2018 @author: abhayakumar """ ############################################################################################### Strings fruit = 'orange' ########Indexing in strings letter = fruit[1] letter ########Length of the string length = le...
a794eeb38de6e98aef36a69992082bf7cd6dd7bc
DChandlerP/algos_python
/fourNumSum.py
746
3.546875
4
# https://www.geeksforgeeks.org/find-four-numbers-with-sum-equal-to-given-sum/ # https://leetcode.com/problems/4sum/ def fourNumberSum(array, targetSum): array.sort() print(array) result = [] for i in range(len(array) - 3): for j in range(i + 1, len(array) - 2): k = j + 1 ...
e0b6dd033737a1676b7b81b526a8fa1eec445cd9
freeprogramers/Polynomial
/polynomial.py
4,546
3.640625
4
def lex(n, x, y): #checks if x > y: returns x<=y x, y are terms with coef n is no. of variables for i in range(1, n+1): if x[i]==y[i]: continue else: if x[i]>y[i]: return -1 else: return 1 return 0 class Poly(object): ...
759c78d704361a2e00e63ed181d8bd52778bd89b
MichaelMcGrail1/cmpt120mcgrail
/IntroProgramming-Labs/rover.py
254
3.671875
4
# Michael McGrail # Introduction to Programming # A program calculating the time it takes to send pictures from Mars to NASA def main(): distance = (34000000) speed = (186000) time = (distance / speed) print(time) main()
216e432832008aa4acd91978d4864d8ed0f36fa1
ganga-17/programming-lab-python-
/course outcome 1/10areacircle.py
81
3.96875
4
r=int(input("enter the radius : ")) a=3.14*r*r print("area of the circle is ",a)
bd45afd45197a407bbb542179e4bbe8d86ec56d9
hellfish2/curso_plone-git
/susana/conecta.py
3,468
3.546875
4
#!/usr/bin/python #*.* coding = utf-8 *.* #Host Details host = "161.196.204.6" port = 5433 #You will need to change these to your specific connection details. user = "postgres" dbname = "prueba" passwd = "postgres" import pgdb def pgdbExample(): """See: http://www.python.org/peps/pep-0249.html""" # DB-API ...
4981e3ca9f8b88663e5edfca96ea2af7bae5d6cb
LouiseJGibbs/Python-Exercises
/Python By Example - Exercises/Chapter 12 - 2D Lists and Dictionaries/097 Select row and column from 2D list.py
683
4.09375
4
#097 Select row and column from 2D List simple_list = [[2,5,8],[3,7,4],[1,6,9],[4,2,0]] rowCount = len(simple_list) - 1 row = int(input("Please enter a row number between 0 and " + str(rowCount) + ": ")) while row > rowCount: row = int(input("Invalid number. Please enter a valid row number between 0 and " + str(r...
b1eb295cb31c6f97ec2d21cb692e873500777a70
MilkClouds/SCSC-2019
/거듭제곱 알고리즘.py
434
3.921875
4
A=2 B=10**50 C=12345 def pow_row(a,x): ret=1 for _ in range(x): ret = ret * a % C return ret def pow_recursive(a,x): if x==0: return 1 if x%2==0: return pow_recursive(a,x//2)**2 % C return a*pow_recursive(a,x//2)**2 % C def pow(a,x): r=1 while x: if x%2...
ff753f38c37dd74917699fe2f8397a67104290e2
nischalshk/IWPython
/DataTypes/42.py
94
4.03125
4
# Write a Python program to convert a list to a tuple l = [1, 2, 3] t = tuple(l) print(t)
fff7984342227204118024328c256e23c517bcd7
HexKnight/Amine-Projects
/tictactoe.py
4,717
3.859375
4
class Board: def __init__(self): self.board = [ [" ", " ", " "], [" ", " ", " "], [" ", " ", " "] ] self.turn = "X" self.available_actions = [[i,j] for i in range(3) for j in range(3)] self.terminal = False def move(self, x, y): ...
3264c4ad454b7a1ebd003efb6613896f23202a56
pk1397117/python_study01
/study01/day06/14-reduce的使用.py
1,028
3.71875
4
from functools import reduce # 导入模块的语法 # reduce 以前是一个内置函数 # 内置函数和内置类都在 builtins.py 文件里 # reduce 现在 是 functools 模块里的一个函数 scores = [100, 89, 76, 87] # reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5) print(reduce(lambda x, y: x + y, scores)) print(reduce(lambda x, y: x - y, scores)) print(reduce(l...
9843f33203dcd8b0b849faa3342d9d5f3aa108a6
PankillerG/Public_Projects
/Programming/PycharmProjects/untitled/Python_Start/contest6_K.py
138
3.546875
4
n = int(input()) sumCard = 0 for i in range(1, n + 1): sumCard += i for i in range(n - 1): sumCard -= int(input()) print(sumCard)
160b4c307cf84442147080ed2d69f6dfb3bf390b
tushar8871/python
/dataStructure/calendarr.py
1,203
4.25
4
#genrate calendar without usong module #method to generate calendar def calendar(noOfDays,weekDay): #create list of week day week=["sun","mon","tue","wed","thu","fri","sat"] #create list for dates date=[' ']*(noOfDays+1) for dayDate in range(1,(noOfDays+1)): date[dayDate]=dayDate #check...
f0591cf68b0c9a120ca277a31e92d934c50ae31a
brubribeiro/Python-WCC
/blackjack.py
333
3.5625
4
#Bruna Ribeiro - 21/11/2019 def blackjack(a,b,c): if a == 11 or b == 11 or c == 11: return sum((a,b,c)) - 10 elif sum((a,b,c)) > 21: print('BUST') else: return sum((a,b,c)) def blackjack1(a,b,c): soma = sum((a,b,c)) if 11 in (a,b,c): return soma - 10 elif soma > 21: print('BUST') el...
671821b972a812326633041a053b6df51a321ae5
gagahpangeran/DDP1
/lab/lab_1/lab01_B_ZZ_Gagah Pangeran Rosfatiputra_1706039566_pertarungan1.py
556
3.921875
4
import turtle panjang = int(input("Masukkan panjang setiap anak tangga: ")) t = turtle.Turtle() t.pendown() #Bagian Kuning t.color('yellow') t.left(90) t.forward(panjang) t.right(90) t.forward(panjang) #Bagian Biru t.color('blue') t.left(90) t.forward(panjang) t.right(90) t.forward(panjang) #B...
33d196debb6381f34cc1cd5f6988687bb3abb101
turab45/Travel-Python-to-Ml-Bootcamp
/Day 1/prime.py
250
4
4
# Muhammad Turab number = 100 i = 1 factor = 0 while number >= i: if number % i == 0: factor = factor + 1 i = i+1 if factor == 2 or factor == 1: print(number, " is a prime number") else: print(number, " is not a prime number")
bb2387f41b33e7156d3b21bd8521b1a8113a6e07
pubudu08/algorithms
/structures/binary_search_tree.py
6,820
4.25
4
class Node(object): def __init__(self, data): self.data = data self.left_child = None self.right_child = None class BinarySearchTree(object): """ TODO: Add detailed description about binary search tree operations O(logN) time complexity for search, remove and insertion It i...
cb19d90bd888a67fcd12032258670b93310877ab
Vivekyadv/DP-Aditya-Verma
/Longest common subsequence/7. longest repeating subsequence.py
1,219
3.859375
4
# Given a string, print the longest repeating subsequence such that the two subsequence # don't have same string character at same position, i.e., any i’th character in the two # subsequences shouldn’t have the same index in the original string. # Example: string = 'aabebcdd' ans = 'abd', len = 3 def func...
ee9950a25b6788fa77b6c5cc8e0c14e7a400648d
AkshataMShetty/Platform-20
/Training/Python_module/Assignment_1/assgn7.py
381
3.578125
4
string1 = "Global" string2 = "Edge" string3 = string1 +' '+ string2 print string3 print string3.find("Edge") length = len(string3) print "length of string3" print length print string3.split() print string3.replace('a','e') string4 = " messy string " print string4.strip() print string4.rstrip() print stri...
6504777c3c60cebb48a38bcf06ca9f2e7c1c4e9e
mcxu/code-sandbox
/PythonSandbox/src/misc/subarray_sort_indices.py
1,425
3.96875
4
''' Subarray Sort Indices Given array of integers, return [start,end] indices of the smallest subarray that must be sorted in order for the entire array to be sorted. Input array length >= 2. If array is already sorted return [-1,-1]. Sample input: [1, 2, 4, 7, 10, 11, 7, 12, 6, 7, 16, 18, 19] Sample output: [3, 9]...
4fd3677c8d3464e934baa4e4bb2558401e05ec12
csikosdiana/CodeEval
/Easy/clean_up_the_words.py
562
3.71875
4
data = ['(--9Hello----World...--)', 'Can 0$9 ---you~', '13What213are;11you-123+138doing7'] import string print string.ascii_lowercase print string.ascii_uppercase #import sys #test_cases = open(sys.argv[1], 'r') #data = test_cases.readlines() for test in data: l = len(test) sentence = '' for c in range(0, l): c...
5d1d157f3b919b8692115089262b691ed155dc52
ybcc2015/PointToOffer
/stack&queue.py
1,453
4.125
4
# 1.用两个栈实现一个队列 class MyQueue(object): def __init__(self): self.stack1 = [] self.stack2 = [] # 入队 def append_tail(self, value): self.stack1.append(value) # 出队 def delete_head(self): if len(self.stack2) == 0: if len(self.stack1) != 0: ...
0f345b332c92cd8999f980dae7af47f2ff8c31b6
marmara-technology/SIKAR-HA
/SIKAR-HA Control Panel/Programlar/entrykayit.py
3,510
3.671875
4
import tkinter.font from tkinter import * from tkinter import messagebox from tkinter import Menu import RPi.GPIO as GPIO import os wait=None rec=None GPIO.setwarnings(False) GPIO.setmode(GPIO.BOARD) #Numbers GPIOs by physical location def SetAngle(angle): # Angle paramater will be got from user print('go') def Se...
2a96172f93189733a5b57218b5fa6f7f3b87d2ed
kholann/python
/lesson3_task2.py
803
3.53125
4
# 2. Реализовать функцию, принимающую несколько параметров, описывающих данные пользователя: имя, фамилия, # год рождения, город проживания, email, телефон. Функция должна принимать параметры как именованные аргументы. # Реализовать вывод данных о пользователе одной строкой. def user_data(name, surname, birth_year, ci...
54ef88e4a8be18740c67491c0c3b8ae04128577a
Yabby1997/Baekjoon-Online-Judge
/10818.py
250
3.609375
4
numOfCases = int(input()) nums = list(map(int, input().split())) maximum = nums[0] minimum = nums[0] for each in nums: if each > maximum: maximum = each elif each < minimum: minimum = each print("%d %d"%(minimum, maximum))
bdaa840e04a13fb0efd052e5fff20e974653fc5f
gertoska/breakout
/wall.py
761
3.734375
4
import pygame from brick import Brick class Wall(pygame.sprite.Group): def __init__(self, number_of_bricks, width): pygame.sprite.Group.__init__(self) pos_x = 20 pos_y = 70 for i in range(number_of_bricks): color = 'orange' if i >= 45: color...
8a2f8084e54e949a6f8437305e6fcfc08079ddc3
chasethewind/dndDMG
/pythonProject/my_module/my_functions.py
5,158
3.65625
4
from random import randint import string def sneak_attack(lvl): """ Determines how much damage Shadar's sneak attack does. The amount of times she gets to roll for sneak attack increases by one every two levels, from a base of 1. """ print('Is sneak attack triggered?') sneak = input() if ...
7285c0fb59d55e4e9e26dd14eac3daffe7f7639d
kKunov/W3
/D2/Graph.py
1,671
3.78125
4
class DirectedGraph: def __init__(self): self.nodes = {} def add_node(self, node): self.nodes[node] = [] def add_edge(self, nodeA, nodeB): if nodeA not in self.nodes: self.add_node(nodeA) if nodeB not in self.nodes: self.add_node(nodeB) if n...
4cbd75520ded53d398bd1d52e026bf2cf12e7c58
Manish-Adhikari/Reminderapp
/rem.py
1,105
3.65625
4
import time import datetime import currentfile import os def reminderapp(date_entry,time_entry): year,month,day=date_entry.split('-') hrs,mins,secs=time_entry.split('-') year=int(year);month=int(month);day=int(day) hrs=int(hrs);mins=int(mins);secs=int(secs) epoch= datetime.datetime(year,month,day,hrs,mins,secs)...
13e7f3442783e8ff82db130b612a4bc033152a7d
Vputri/Python-2
/aulia.py
709
3.515625
4
def balok() : print " Menghitung Volume Balok " p= raw_input ("Masukkan Panjang Balok : ") l= raw_input ("Masukkan Lebar Balok : ") t= raw_input ("Masukkan Tinggi Balok : ") volume = int(p)*int(l)*int(t) print "Volume Balok adalah ",volume def lingkaran() : print " Menghitung Volume lingka...
dc23c9f349248c0c943cc38b9be6e6f88efff532
starrye/LeetCode
/A daily topic/2020/may/200516_25. K 个一组翻转链表.py
1,962
3.703125
4
#!/usr/local/bin/python3 # -*- coding:utf-8 -*- """ @author: @file: 25. K 个一组翻转链表.py @time: 2020/5/16 11:00 @desc: """ from typing import List """ 给你一个链表,每 k 个节点一组进行翻转,请你返回翻转后的链表。 k 是一个正整数,它的值小于或等于链表的长度。 如果节点总数不是 k 的整数倍,那么请将最后剩余的节点保持原有顺序。 示例: 给你这个链表:1->2->3->4->5 当 k = 2 时,应当返回: 2->1->4->3->5 当 k = 3 时,应当返回: 3->2-...
24253ee2e2a3f7295c5efb4d8f25dd8291710d21
rattanakchea/react-chat
/src/components/TabCoditor/files/python.py
131
3.921875
4
str = "hello" for i in range(len(s)) print s[i] ## for in for c in [str, array] ## enumerate for index, c in enumerate(array)
f16d9fdd26d0101a2f9f6cf52309962275ae0175
ppinko/python_exercises
/sort/hard_frugal_gentelman.py
861
3.59375
4
""" https://edabit.com/challenge/RWLWKmGcbp6drWgKB """ def chosen_wine(wines: list): if len(wines) == 0: return None elif len(wines) == 1: return wines[0]['name'] else: wines.sort(key=lambda x: x['price']) return wines[1]['name'] assert chosen_wine([{"name": "Wine A", "pr...
79e3d5ab6ab0de16fae130735b04ab6812ea96cf
yell/mnist-challenge
/ml_mnist/utils/_utils.py
3,057
3.84375
4
import sys import time import numpy as np class Stopwatch(object): """ Simple class encapsulating stopwatch. Examples -------- >>> import time >>> with Stopwatch(verbose=True) as s: ... time.sleep(0.1) # doctest: +ELLIPSIS Elapsed time: 0.100... sec >>> with Stopwatch(verbose=...
4d3b5093b02ef405ba6623ece411258c76446747
Gdango/Euler-Project
/Euler3.py
431
3.734375
4
'''The prime factors of 13195 are 5,7,13 and 29. %What is the largest prime factors of the number 600851475143? % 09/22/2018''' import math def isPrime(num): factor = 1 factorproduct = 1 while True: if factorproduct >= num: return factor - 2 elif num % factor == 0: ...
4cef225bf04670fd2a109752b441ffbe51c4d764
Hereiam123/Python-Data-Excercises
/Data Visualization with Seaborn/Seaborn Categorical.py
1,132
3.5625
4
import seaborn as sns import numpy as np import matplotlib.pyplot as plt tips = sns.load_dataset('tips') print(tips.head()) # Aggregate Categorical Data via a specific method, average by default #sns.barplot(x='sex', y='total_bill', data=tips, estimator=np.std) # Count plot, estimator is specifically number of occur...
24c6a2bdf7eb2a0302372e4a65dda1764f0c0efb
Shinkovatel/python_lesson
/lesson 3/Home missions.py
7,009
3.921875
4
number = int(input('Введите число ')) number += 2 print(number) number = int(input('Введите число ')) while True: if number > 10: print('Число больше загаданного, введите от 0 до 10') number = int(input('Введите число ')) elif number < 0: print('Число меньше нужного, введи...
9caf748ce9b2078fe6a557d3d0b57c1d718075a3
crushdig/Data-Science-In-Practice-Project
/LB_project/src/helpers/data_dictionary.py
2,407
3.609375
4
from os import path import pandas as pd from datetime import datetime def save(dataset, # The source dataset. summary, # User defined summary str. include='all', # Summarise all cols in df. ...
b10012bc373e0239b4a19ed7c725417c4bf36332
bushki/python-tutorial
/lists.py
729
4
4
# List is a collection like JS array, allows dupes # create list numbers = [5,3,1] fruits = ['apples', 'oranges', 'grapes', 'bananas'] print (type(fruits)) # using constructor numbers2 = list((4,7,3)) print(numbers, numbers2) # get value print(fruits[2]) # get length print(len(fruits)) # append to end list fru...
e10a0415651b0398cb41981685927f070530a074
Bardia95/daily-coding-problems
/code-signal-arcade-universe/intro/python3/sum_up_numbers.py
817
4.25
4
import re def sum_up_numbers(s): numbers = re.findall(r"\d+", s) return sum([int(x) for x in numbers]) """ CodeMaster has just returned from shopping. He scanned the check of the items he bought and gave the resulting string to Ratiorg to figure out the total number of purchased items. Since Ratiorg is a bot...
3fb7e27addfa650e87a1fda52e18adf299bbedd2
tcano2003/ucsc-python-for-programmers
/code/lab_05_Important_Trick/lab05_2.py
377
3.546875
4
#!/usr/bin/env python """Interactive vowel counter.""" import lab05_1 import sys def main(): while True: sys.stdout.write("Phrase: ") count_this = sys.stdin.readline() if count_this == '\n': break sys.stdout.write("... has %d vowels.\n" % ( lab05_1.CountVowe...
bff7bec5517f455a14205b4c02a9397423d50dbd
theharshitgarg/leetcode_challenges
/practice/add_numbers_linked_list.py
2,035
3.859375
4
# Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None def get_linked_list(arr): lst = None for key, val in enumerate(arr): new_node = ListNode(val) if lst: new_node.next = lst lst = new_node return lst class Solution(object)...
37b877f57e7baa836650839f2d577cc66ae795f1
akshaybab/phrase-playlist-generator
/playlist.py
4,192
3.75
4
# This file contains functions that interact with the Spotify API for non-authentication actions # such as creating a playlist and searching for songs def create_playlist(sentence, spotify): """Creates the phrase playlist. Args: sentence (str): the phrase that will be turned into a playlist. ...
3de29705377d3e93b0eb2b547e8bdcf02c679ee9
cosmosZhou/sympy
/axiom/sets/el/imply/el/inverse/interval.py
1,378
3.625
4
from util import * @apply def apply(given): x, self = given.of(Element) a, b = self.of(Interval) if a.is_positive: domain = Interval(1 / b, 1 / a, left_open=self.right_open, right_open=self.left_open) elif b.is_negative: domain = Interval(1 / a, 1 / b, left_open=self.right_open, right...
c0e435ecca28feb41f535336072b36ebfdc473b0
ChemicalMushroom/MyFirstPython
/zjazd2/kolekcje/zadanie4.py
373
3.65625
4
# napisz program wypisujący wszystkie liczby od 0 do 100,podzielne przez 3 lub podzielne przez 5.Wypisz także jak dużó takich liczb wystąpiło w tym przedziale ile_podzielnych = 0 for i in range(101): if i % 3 == 0 or i & 5 == 0: ile_podzielnych += 1 print(i) print(f'W przedziale 0-100 jest {ile_p...
6ad14ae8773e269b7d1209f215e96d0f7ba6bac7
iausteenlova/HACKER-RANK
/PYTHON/students-marks.py
532
3.984375
4
#!/usr/bin/env python # coding: utf-8 marksheet=[] scorelist=[] if __name__ == '__main__': for _ in range(int(input("Enter no. of students"))): name = input("name :") score = float(input("marks :")) marksheet+=[[name,score]] scorelist+=[score] ...
82755ff6facdda95a0120e3766982aa29e4ea3db
Sen2k9/Algorithm-and-Problem-Solving
/leetcode_problems/559_Maximum_Depth_of_N_ary-Tree.py
1,693
3.734375
4
""" Given a n-ary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. Nary-Tree input serialization is represented in their level order traversal, each group of children is separated by the null value (See examples). Exam...
07172c6b0ba35bedb7200aaccc1359f0406b52a1
dundunmao/lint_leet
/mycode/lintcode/Binary Search/414 divide-two-integers.py
2,380
3.5625
4
# coding:utf-8 # 将两个整数相除,要求不使用乘法、除法和 mod 运算符。 # # 如果溢出,返回 2147483647 。 # # 您在真实的面试中是否遇到过这个题? Yes # 样例 # 给定被除数 = 100 ,除数 = 9,返回 11。 # 第一次减9,第二次减9+9=18,第三次减18+18 = 36,第四次减36+36=72,第五次减72+72=144>100了,所以从100-72=28重新减9 class Solution(object): def divide1(self, dividend, divisor): """ :type dividend: i...