blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
f676f4b6406063fd3d21855e32111e4179eaacd2
timeanddoctor/stentseg
/lspeas/utils/deforminfo.py
1,166
3.921875
4
class DeformInfo(list): """ Little class that enables storing a collection of numbers and show aggregates of it. """ def __init__(self, values=None, unit=""): self.unit = unit for v in values or []: self.append(v) def __repr__(self): r = super().__repr__() ...
d9e5e4991025f51fbbe3ac3c5ecbecaba3361692
satadhi/algorithms-in-python
/heapsort.py
1,089
4.03125
4
#!/usr/bin/env python # coding: utf-8 # Worst Case: O(n log n) # Best Case: O(n log n) # Average Case: O(n log n) def heapsort(a): """Run heapsort on a list a >>> a = [32,46,77,4344564,7322,3,46,7,32457,7542,4,667,54,] >>> heapsort(a) >>> print(a) [3, 4, 7, 32, 46, 46, 54, 77, 667, 7322, ...
a952c92b4112be63d26eb6b4e0a67764d0014bde
anchorhong/leetcode_python
/subjects/0106_buildTree/Solution.py
945
3.890625
4
# Definition for a binary tree node. from typing import List class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def buildTree(self, inorder: List[int], postorder: List[int]) -> TreeNode: if not postorder: return ...
d1725191f3315d32283ec18fd72b1b9569cbc273
KyleBrooks242/RideCompare
/jsonResponse.py
2,245
3.5
4
# This class will handle execution of api call and optional parsing of response import requests import json def executeJson (response, parse): if (response.ok): # Loading the response data into a dict variable # json.loads takes in only binary or string variables so using content to fetch ...
84d0d5a749057d9b4ad4bb0d86eea7e99ea233bd
KusanagiKuro/duplicate-file-finder
/find_duplicate_files.py
2,811
3.703125
4
#!/usr/bin/env python3 from argparse import ArgumentParser from os.path import isabs from scan_files import scan_files from group_files_by_size import group_files_by_size from group_files_by_checksum import group_files_by_checksum from group_files_by_read_buffer import group_files_by_read_buffers from json import dumps...
b37393c33d78356f8a77a7037df28a0e65634807
skills421/PythonMultiTrack
/FastTrack/BankingProject/26-Graphs/03_planet_scatter.py
945
3.640625
4
from matplotlib import pyplot as plt planets = [ ("Mercury", 57.91e+6, 2439.7), ("Venus", 108.2e+6, 6051.8), ("Earth", 149.6e+6, 6371), ("Mars", 227.9e+6, 3389.5), ("Jupiter", 778.5e+6, 69911), ("Saturn", 1.434e+9, 58232), ("Uranus", 2.871e+9, 25362), ("Neptune", 4.495e+9, 24622) ] # # extract da...
9c7b8cfc0b47feef053975c0b1e306fa2a2ea247
juanfranj/CodeWars
/python/6kyu/6kyu_PersistentBugger.py
427
3.640625
4
def persistence(n): ciclo = 0 while len(str(n)) > 1: mul = 1 #print(n) for i in str(n): mul *= int(i) n = mul ciclo += 1 return ciclo if __name__ == '__main__': n = 25 print(persistence(n)) ''' import operator def persistence(n): i = ...
dca2435e7050ee8c4d7ddc6a267abed6f3884b01
Aisha-Usman/WootLab-Devcamp
/Task_10.py
531
4.21875
4
#This program determins the character with highest occurences in a string. ASCII_SIZE =256 def MaxOccurChar(str): #creating array that keeps count of characters. #initializing count to zero count = [0] * ASCII_SIZE max = -1 a= '' for i in str: count[ord(i)]+=1; fo...
c5d0599bbce9756f9aa195daf8e18d96adef142a
Kiran-RD/leetcode_solutions
/add_two_numbers.py
1,299
3.6875
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode: ll1 = l1 ll2 = l2 l3 = ll3 = None carry_over = 0 ...
edcfac452774dac0b40c90a7ae8d698305cccfac
AdrianaES/Girls-Who-Code-Projects-
/Girls Who Code Work/Python/hangman.py
1,200
4.3125
4
def display(word, guessed_letters): new_str = "" for letter in phrase: if letter in guessed_letters: new_str += letter elif letter == " ": new_str += " " else: new_str += "_ " print(new_str) return(new_str) #Have a word/phrase phrase = "girls...
2e0381fb5822da4f401a38ef6a4b0dcf9f548eae
ajay1706/python-exercises
/python_exercises/class.py
480
3.796875
4
my_student = { 'name':'ajay', 'grades':[90,70,60,80], 'average':None#someshit } def average_grade(studnt): return sum(studnt['grades'])/len(studnt['grades']) class Student: def __init__(self,new_name,new_grade): self.name = new_name self.grades = new_grade def average(self): return sum(self.grades)/len(self...
ea09bafe20dfd8f23dbb6b5a819a29e998e6520f
xkolac11/DB_Iterator
/bin/iterator.py
1,352
3.8125
4
#! /usr/bin/python # -*- coding: utf-8 -*- from pymongo import Connection connection = Connection('localhost') db_connection = connection.example class project: """ Class encapsulates behavior of iterator. It's used to work out some mongoDB database from begin to end. """ test={} #:Testing variable. array=[...
441779d850e8fcb8380c31921ea9a675b14de832
0001SID/Python
/practice/pprint.py
242
3.5
4
import pprint message = 'This is just a string to check which character appeat how many time' count = {} for character in message: count.setdefault(character,0) count[character] += 1 # pprint.pprint(count) print(pprint.pformat(count))
fe6892b2974475b0a59f46f0b4524beae12aa7ea
caizix/code
/b/b1/b5.py
933
3.734375
4
# encoding:utf-8 # 一个猜数字的小游戏 import tkinter as tk import random window =tk.Tk() maxNo = 10 score = 0 rounds = 0 def button_click(): global score global rounds try: guess = int(guessBox.get()) if 0<guess<=maxNo: result = random.randrange(1,maxNo+1) if guess == re...
0885f0602ed06b0fa01d4bd4b06ca5657be298c5
qyx1996/JianZhiOffer
/JZ26. 二叉搜索树与双向链表.py
1,765
3.53125
4
# 输入一棵二叉搜索树,将该二叉搜索树转换成一个排序的双向链表。 # 要求不能创建任何新的结点,只能调整树中结点指针的指向。 # 递归方法 class Solution: def Convert(self, pRootOfTree): # 二叉树排序 中序遍历 # 1. 确定链表起始节点 一直 向左走 第一个左节点为空的节点为链表的起始节点 # 2. root.left = func(root.left) # 3. root.right = pre 更新记录pre节点 self.pre = None self.root...
313326fc082dd1f21b7678ae2aebce6214d5f1f6
DilipBDabahde/PythonExample
/Marvellous/C_P_Assignemnts/Ass_10/patternc.py
434
3.953125
4
''' Accept number of rows and number of columns from user and display below pattern. input: iRow = 3 iCol=4 output: 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 ''' def patternc(iRow, iCol): for i in range(iRow): for j in range(iCol): print(i+1,end=" "); print(); def main(): irow = int(input("Enter...
40e74a60d451cf9f0ad6d66a83b9faf04abce873
maguas01/hackerRank
/pStuff/Bigger_Is_Greater.py
961
3.875
4
''' Given a word w rearragne the letters of w to construct another word s in such a way that s is lexicographically greater than w. In case of multiple possible answers, find the lexicographically smallest one among them. ''' #!usr/bin/python def nextPermutation(word) : #moving backwards find non-increasing su...
9cc4a112afa3c3e1216856625ff4ce6356b46ad1
jorginazario/paradigms_final
/backup_files/cherrypy/tests/_movie_database.py
5,143
3.703125
4
#!/usr/bin/env python3 import sys import os class _movie_database: def __init__(self): # your code here self.movies = {} #initialize my movie dict self.users = {} self.ratings = {} self.images = {} self.track = {} # also write load_movies() and print_sorted_movies() def load_movies(self, movie_file): #loa...
e442c9db08f899a3b03ebbf43b1aedd7767adcca
asdarov77/Euler
/34_Факториалы_цифр.py
440
3.703125
4
# -*- coding: utf-8 -*- """ Created on Fri May 1 14:34:13 2020 @author: Admin """ def factorial(number): fnum=1 for i in range(1,number+1): fnum*=i return fnum mas=0 for i in range(3,100000): m=0 for l in str(i): m+=factorial(int(l)) # print(i,m) if i==m: ...
4a5717637b1d14c05d66892a5a75ec48fe66a958
dapazjunior/ifpi-ads-algoritmos2020
/Iteracoes/Fabio_03/f3_q01_numeros_1_a_n.py
245
3.984375
4
def main(): contador = 0 qtd_n = int(input('Digite um número: ')) # O valor digitado será o último número da sequência while contador < qtd_n: num = 1 + contador contador += 1 print(num) main()
df16450e42a05a1fe11a530c9cbb50d522ebf354
SaurabhPimpalgaokar/assignments
/exercises/Exe_second_a.py
580
3.796875
4
class Dictionary: Dict={} def __init__(self): self.Index_list=[1,2,3,4,5,6,7,8,9,10,11,12] self.Name_list=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'] def Add(self): for key in self.Index_list: #iterate through inde...
4ee4a681722c9fea98cfdace3a0dc7c8d8deee0b
PaulinaMoreno/FlightSearch_API
/flight_search_api.py
7,220
3.53125
4
import json import operator import memcache from tornado import gen, ioloop, web, httpserver, httpclient from tornado.httpclient import AsyncHTTPClient, HTTPClient # memcached Client host = 127.0.0.1 port=11211 mc = memcache.Client(['127.0.0.1:11211'], debug=0) # Providers flights List providers_list = ['Orbitz', 'Exp...
857d15597b70b1d9ba30d41dbc9c55bcf8c7b12a
BaijingML/leetcode
/zhaoshangxinyongka2019_zuixiaobushu.py
471
3.65625
4
#!/usr/bin/env python # encoding: utf-8 """ @version: python3.6 @Author : Zhangfusheng @Time : 2019/8/22 21:10 @File : zhaoshangxinyongka2019_zuixiaobushu @Software: PyCharm """ if __name__ == "__main__": M = int(input()) k = 0 s = 0 while s < M: k += 1 s += k dt = s - M ...
b04c6ba0334b6321108f64cff8b2a68a18e90676
mrchristensen/Censor
/cesk/values/concrete_char.py
1,798
3.515625
4
""" The char class""" import random from .factory import Factory from .base_values import ByteValue class ConcreteChar(Factory.getIntegerClass()): """ implementation of an char Type""" def __init__(self, data, type_of='char', size=None): if isinstance(data, str) and ('\'' in data): char = d...
6fac604865bc341146307abe0e20ce9a2b6b1769
tmemmerson/letsLearnPython
/first.py
3,316
4
4
import datetime myNow = datetime.datetime.now() print(myNow) myNumber =3 myText = "Tristan's favorite number is" x=10 y="10" z=10.1 sum1=x+x sum2=y+y sum3=z+z print(myText, myNumber) print(sum1, sum2, sum3) print(type(x), type(y), type(z)) list1=list(range(1,10)) """ gives output of 1,2,3,4,5,6,7,8,9 """ list2=l...
da0d7d6177a4a111e865c1e6ad54efd96980ffca
NataliaWojcik1/Python
/08/fitmeter_05.py
1,215
3.71875
4
import exceptions05 def get_weight(): while True: try: weight = int(input('Podaj wage w kg:')) except (ValueError, TypeError): print('To nie jest prawidłowa wartosc! Sprobuj jeszcze raz') continue if weight > 30: break else: ...
dd5d515ec3aebe2f2f4b8eb62878c1e763fd7a2b
mygoda/my-script
/aiohttp_test.py
641
3.5
4
# 测试 asyncio + aiohttp 的效果 import time import aiohttp import asyncio NUMBERS = range(12) URL = 'http://httpbin.org/get?a={}' async def fetch_async(a): async with aiohttp.request('GET', URL.format(a)) as r: data = await r.json() return data['args']['a'] if __name__ == "__main__": start = time...
1591e638160f216bc46b9fcc6f20886639bfd244
txcavscout/rockPaperScissors
/rps.py
3,189
3.953125
4
# Rock Paper simulator, will play best out of three. import random keep_going = 0 your_score = 0 pc_score = 0 play_again = True def pc_roll(): pc_options = (random.choice(['rock', 'paper', 'scissors'])) return pc_options def who_won(user_choice, pc_chose): #rock vs logic if user_choice == 'rock' an...
8598cd612c54adbfd22938587fb4ee7726fc147b
LinXunFeng/leetcode
/二叉树/_226_翻转二叉树.py
852
3.890625
4
""" 翻转一棵二叉树。 示例: 输入: 4 / \ 2 7 / \ / \ 1 3 6 9 输出: 4 / \ 7 2 / \ / \ 9 6 3 1 """ from TreeNode import TreeNode, TreeHander class Solution(object): def invertTree(self, root): """ :type root: TreeNode :rtype: TreeNode """ if ...
475b5755d3fce0f763f1da6fb3f95dd49dd6fba5
Sarbodaya/PythonGeeks
/Basics/Indention.py
946
3.84375
4
site = 'gfg' if site == 'gfg': print("Logging into geeksforgeeks .......") else: print("Retype the url ...................") print("All set .........") j = 1 while(j<=5): print(j, end=" ") j = j + 1 print('\r') a = 10; b = 20; c = b + a print(a); print(b); print(c) a = [ [1, ...
2e0fe4c93e975cb27cd290878cb81e2f38ee09c9
panda002/Python-Beginner
/MesoJarvis/Primelist.py
561
3.984375
4
c = int(input('Enter No :')) for num in range(0,c): if num > 1: for i in range(2,num): if (num % i) == 0: print(num,'is not prime') break else: print(num, 'is prime') print('enter the range') lower = int(input("lower range")) upper = int(input("Uppe...
65432f6c96203b3e7a40126ec6549c9c313ec2e9
The-Bambi/DIY_NeuralNetwork
/List.py
1,089
3.703125
4
class Node: def __init__(self, left = None, data = None, right = None): self.left = left self.data = data self.right = right def __repr__(self): return self.data def __add__(self,other): return self.data+other.data def __mul__(self,other): ...
5677d9c95b71af2d29cced7ae4c0add8b0a53c4b
Geo-Python-2017/exercise-6-dbharris92
/temperature_anomalies.py
4,285
3.8125
4
# -*- coding: utf-8 -*- """ Created on Thu Mar 15 19:48:53 2018 GeoPython Exercise 6 Assignment Problem 1: Import CSV of precipitation and temperature values from NOAA. Script prints several general values about the data Problem 2: Calculate monthly average temps @author: harrisab2 """ import pandas as pd ...
324f5fec27f5be3b0a14df93e7626a0a32737598
mcceTest/leetcode_py
/src/X113_PathSumII.py
1,439
3.890625
4
''' Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. Note: A leaf is a node with no children. Example: Given the below binary tree and sum = 22, 5 / \ 4 8 / / \ 11 13 4 / \ / \ 7 2 5 1 Return: [ [5,4,11,2], [5,8,4,5] ]...
bdbaec3499bade1fdf84942f345cc51ba7821ee1
FrancescoScarlata/DecisionTreeClassifier
/Source/CsvReader.py
1,606
4.28125
4
import csv class CsvReader: ''' This class will read and store the dataset and its headers ''' def __init__(self,filename_data, filename_header, numericColumns ): ''' This will start the class and read the lines from the file defined in the filename. The filename header is the file on which the headers ...
162f67a5b1462f9de999c77ccd1ec8e098e50a50
vinaybiradar1717/SL_lab
/three/three_b/three_b.py
952
4.25
4
# 3b. Python File Handling & List Comprehension: # Write a python program to read contents of a # file (filename as argument) and store number of # occurrences of each word in a dictionary. Display the top 10 # words with most number of occurrences in descending order. # Store the length of each of these words in ...
273c1236bee280a6eae5c278c39007aad475a615
BNNorman/PixelBot-Simulator
/Console.py
2,076
3.71875
4
""" Console.py provide a tkInter window to use for console messages Mainly used by print and println in robot scripts """ import time t0=time.clock() from tkinter import messagebox from tkinter import * import tkinter.scrolledtext as tkscrolled t1=time.clock() from ConsoleQueue import * import pygame from pygame.loca...
b496f95a4ba053c5dd987e4870bae1ead4a591b0
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_158/465.py
678
3.546875
4
import sys import math def fits( x, r, c ): val = int( math.ceil(x/2.0) ) squareFit = val <= r and val <= c lengthFit = x <= r or x <= c return squareFit and lengthFit def solve( x, r, c ): if r*c%x == 0 and fits( x, r, c): if (x,r,c) == (4,4,2) or (x,r,c) == (4,2,4): ...
8fde02213ecdcd5943d67be4cd7bb28ae6214906
JimGilmour/python
/easy3.py
231
3.890625
4
a = int(input('Введите Ваш возраст ')) if a > 18: print('Дооступ разрешен') else: print('Извините, пользование данным ресурсом только с 18 лет')
f156cbf8bf64242696a5951c2ee78d5d553c54ee
Neha-Nayak/Python_basics
/Basics/arithematic operators.py
386
4.03125
4
# -*- coding: utf-8 -*- """ Created on Mon Feb 1 00:25:10 2021 @author: Neha Nayak """ #operators print(20+10) print(4-3) print(10/3) print(10//3) print(10%3) print(10**3) print(10*3) #using variables x=10 x=x+3 print(x) x+=3 print(x) #precedence x=10+3*2 print(x) y=(10+3)*2 print(y) #comparison print(3>2) #logi...
66568fb610783195a32ba57466f628bb3383964f
ellinx/LC-python
/PalindromePartitioningII.py
984
3.8125
4
""" Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s. Example: Input: "aab" Output: 1 Explanation: The palindrome partitioning ["aa","b"] could be produced using 1 cut. """ class Solution: def minCut(self, s...
c7131f4b7d9eb3bcd8fd624dd5cc43edff1e33ac
danny-molnar/python-programming
/ops.py
250
4.1875
4
# Operations with numbers # Assignment operators, incrementing operators # Operator precedence print(10+3*2) # Comparison operators ops = [15<4, 10+3==13, False!=True] print(ops) print('Venus'.lower() == 'venus' and 'Saturn'.upper() == 'SATURN')
06c24bdcc37dcd5c87904eb10c480c20d6ecfc3d
Kbart2401/Catch-me-if-you-can
/backend/app/utils/haversine.py
649
3.640625
4
from math import radians, cos, sin, asin, atan2, pi def haversine(lon, lat, dist): lat, lon = map(radians, [lat, lon]) print(lat) east0 = sin(lat)*cos(dist/6371) east1 = cos(lat)*sin(dist/6371)*cos(90) west = asin(sin(lat)*cos(dist/6371) - cos(lat)*sin(dist/6371)*cos(270*(pi/180))) north = lon...
bab83597760c0d176a840c8abea9e8842e2b5256
AWangHe/Python-basis
/13.tkinter与银行系统实战/thinker/24.表格布局.py
608
3.53125
4
# -*- coding: utf-8 -*- import tkinter #创建主窗口 win = tkinter.Tk() #设置标题 win.title("魔兽世界") #设置大小和位置 大小400x400 距离左侧400,距离上侧100 win.geometry("400x400+400+100") label1=tkinter.Label(win,text="good",bg="blue") label2=tkinter.Label(win,text="nice",bg="yellow") label3=tkinter.Label(win,text="cool",bg="red") label4=tkinter...
2de9598886f5ff31e4a2ac1a7fa021e1c2622e8d
samoryad/gb_client-server_applications_messenger
/lesson_01/homework_01/homework_01_03.py
717
3.765625
4
# 3. Определить, какие из слов «attribute», «класс», «функция», «type» # невозможно записать в байтовом типе. byte_attribute = b'attribute' print(type(byte_attribute)) print(byte_attribute) # byte_class = b'класс' # print(type(byte_class)) # print(byte_class) # byte_function = b'функция' # print(type(byte_function)) ...
6a317714f3107eab6a95cc52182a00dd7f48b18f
CasaDeMill/Fractal2
/NEWTON.py
5,806
3.71875
4
from scipy import * from pylab import * from sympy import * from numpy import * """ Takes two functions containing variables x, y and computes Newton's method. """ # allows variables x and y to be inputs x, y = symbols('x, y', real=True) class fractal2D: def __init__(self, f1, f2, f1dx, f1dy, f2dx, f2dy, tol=1....
d7f20677bb3bb4e864ada9aa588e73425a1bd72c
raghavchitkara/Data-Structure
/towers of hanoi.py
478
3.75
4
# -*- coding: utf-8 -*- """ Created on Tue Jul 16 17:49:56 2019 @author: Raghav Chitkara """ def towers_of_hanoi(number_of_disks, startpeg=1, endpeg=3): if number_of_disks : print(startpeg, endpeg) towers_of_hanoi(number_of_disks-1,startpeg,6-startpeg-endpeg) print("move disk %d from peg %...
576e5ef952a0683b40f38954bd3c406f9450cd29
lukebor/hackerrank_python
/Encryption/Encryption.py
654
3.546875
4
#!/bin/python3 import math import os import random import re import sys # Complete the encryption function below. def encryption(s): res=[] res2=[] result='' s+=' '*(math.ceil(len(s)**0.5)**2-len(s)) for i in range(int(len(s)**0.5)): res.append(s[i*int(len(s)**0.5):i*int(len(s)**0.5)+int(l...
4eeb0aa398c4c67ab9ac28576717fe78b71651d5
mkhalid1/Basic-Python-Codes
/Pension_Calculator.py
6,960
4.25
4
#calculates employees age from his date of birth and current date def ageCalculator(birthDate, currentDate): age= int(currentDate[4:]) - int(birthDate[4:]) month= int(currentDate[2:4])- int(birthDate[2:4]) if month<0: #if the month in the current date is less than the month in employee's birthday, it means hi...
b7f904e7c8708f2f81910e6292ee7ad10fbc1bdc
manuhortet/CodewarsKatasPY3
/8 kyu/Calculate BMI.py
241
4.03125
4
def bmi(weight, height): bmi = float(weight / float(height)**2) if bmi <= 18.5: return "Underweight" elif bmi <= 25: return "Normal" elif bmi <= 30: return "Overweight" else: return "Obese"
1279f16616e6df7eaecbb5c0d4b1206e95550f2a
Lakssh/PythonLearning
/basic_learning/exercise_fruits.py
789
3.953125
4
class Fruits(object): def __init__(self): print("Fruits class instantiated") def nutrition(self): print("Fruits Nutrition is called") def fruit_shape(self): print("Fruits shape is spherical") class Strawberry(Fruits): def __init__(self): Fruits.__init__(self) ...
940b641e7e8461c89cc095663b26626f2150d225
flaviogf/courses
/coders/curso_python/funcoes/callable_object.py
416
3.84375
4
#!/usr/local/bin/python3 class Potencia: def __init__(self, expoente): self.expoente = expoente def __call__(self, base): return base**self.expoente if __name__ == '__main__': quadrado = Potencia(2) cubo = Potencia(3) if callable(quadrado) and callable(cubo): print(f'Qu...
b8703feac8c7aa5ba4f1dcc03f137c88c10e6e02
songuras/Tas_kagit_makas
/tkm0.5.py
8,050
3.8125
4
from random import choice from random import randint from time import sleep liste = ["tas","kagit","makas"] a = 1 print("ig : songur_as") print("github : songuras") while a != 0 : print("Taş kağıt makas oyununa hoşgeldiniz bilgisayara karşı oynamak için 1'i 2 kişi oynamak için 2'yi çıkış için 0'ı tuşlayın...
6f86ecb97763d2c36334e248a58d83633d0fbb70
tnakaicode/jburkardt-python
/r8lib/r8vec_even_select.py
2,118
3.59375
4
#! /usr/bin/env python # def r8vec_even_select ( n, xlo, xhi, ival ): #*****************************************************************************80 # ## R8VEC_EVEN_SELECT returns the I-th of N evenly spaced values in [ XLO, XHI ]. # # Discussion: # # XVAL = ( (N-IVAL) * XLO + (IVAL-1) * XHI ) / dble ( N - 1 ) #...
a5a5e5bb11e4ce261b14dee2f3322f264905f4c8
pyaephyokyaw15/PythonFreeCourse
/hello_world.py
194
3.671875
4
a = 9 b = 0.3-0.2 A = "Data" flag = False print("a is ",a , type(a)) print("b is ",b , type(b)) print("A is ",A, type(A)) print("Flag is ",flag, type(flag)) print("a+b ", a+b) print("a+b ", a+A)
92aae6bbbbc213bda89df21715290ca0a2d8b976
JoseArtur/phyton-exercices
/PyUdemy/Day20/SnakeGame/snake.py
1,113
4.0625
4
from turtle import Turtle, Screen class Snake(): def __init__(self): self.parts = [] self.create() self.head = self.parts[0] def create(self): for i in range(3): jonny = Turtle(shape="square") jonny.penup() jonny.color("white") jon...
f6c0824208dc3519518106ff02eef7a2656533b4
surajeet310/Assamese_Lemmatizer_Python
/Assamese_Tokenization/tokenization_assamese.py
495
3.546875
4
class tokenization_assamese: def __init__(self): self.word_list = [] def word_tokenize(self,sentence): word = '' lengthOfSentence = len(sentence) for i in range(lengthOfSentence): ch = sentence[i] if(ch == ' '): self.word_list.append(wo...
b4d0b4ccf16066708a5987ffe706ca12100acd38
moffetma/dark_castle
/saved_games/mynew/rooms/item_test.py
217
3.75
4
items = { "wooden_sign":"wooden_sign", "wooden sign":"wooden_sign", "woodensign":"wooden_sign", } print(items['wooden sign']) test_string ="wooden sign" if test_string in items: print(items[test_string])
2fa4c2251579d7d6d0a0a1ed0b7cfb64f57304f5
ironsketch/pythonSeattleCentral
/FinalPractice/rpsagain.py
1,301
3.921875
4
from random import randint def Turn(): # Meats Turn play = input('Type rock paper or scissors ') play = play.lower() # Computers Turn compplay = randint(0,2) if compplay == 0: print('c = rock') cplay = 'rock' elif compplay == 1: print('c = paper') cplay = 'p...
05231d54d7dad9b1a44ac58abec9325535d0e2d1
yazdanpanaah/count-aA
/counta.py
440
3.9375
4
lst1=["Alaska", "Alabama", "Arizona", "Arkansas", "Colorado", "Montana", "Nevada",'a'] #this is print number of both a and A togheter print(sum(list(map(lambda x : sum([ i.count('a') or i.count('A') for i in x ]) ,lst1)))) #this is print number of both a and A and put them in list as seprated numbers print([sum...
8e6c5703018b2a8fe065ec2037d64da0357d43de
Estenoor/Network-Protocols
/Lab-Five/httpclient.py
9,208
3.578125
4
""" - CS2911 - 0NN - Fall 2017 - Lab N - Names:Sam Ferguson, Leah Ersoy, Joe Bunales - - A simple HTTP client """ # import the "socket" module -- not using "from socket import *" in order to selectively use items with "socket." prefix import socket # import showbits file for debugging purposes import showbits # imp...
8e35fb5053379a134843dc3da8eb4fef139003d5
AvinashBonthu/Python-lab-work
/Lab4/lab3_11.py
192
3.703125
4
n=input("Enter the number of elements ") a=[] c=0 for i in range(n): r=input("Enter the element ") a.append(r) for i in range(n-1): if a[i]==a[i+1]: c+=1 print c
25fd0cc8ae079603e2602276f9e0027760a9b30f
joelmedeiros/studies.py
/Fase14/Challange59.py
700
4.09375
4
n1 = int(input('Write a number: ')) n2 = int(input('Write another number: ')) option = 0 while option != 5: option = int(input('''Choose an option: [1] Sum [2] Multiply [3] Greater [4] Change numbers [5] Exit ''')) if option == 1: print('The sum of {} and {} is {}'.format(n1, n...
6f0a8c2223d0d9139f77185c33a5753e5da2a5df
shi095/Python_lessons
/lesson1_6.py
1,464
3.84375
4
# 6. Спортсмен занимается ежедневными пробежками. # В первый день его результат составил a километров. # Каждый день спортсмен увеличивал результат на 10 % относительно предыдущего. # Требуется определить номер дня, на который общий результат спортсмена составить не менее b километров. # Программа должна принимать знач...
1bd339888e5a7a9d94a87c13b7864c791e60c959
kingbj940429/Coding_Test_Solution
/beak_joon/b_5534_unsolved.py
1,192
3.5
4
''' 5534번 간판 ''' ''' 해결못함 1. diff_index로 data[diff_index]에 간판이름이 있는지 체크 2. 하나라도 없으면 예외처리 ''' def check_possible_board(input_data): #간격을 체크해주기 위한 diff_index = 0 get_diff_index(input_data) def get_diff_index(input_data): diff_index = 0 temp_chars = [] first_index = 0 cnt = 0 k = 0 ...
4deb00f4b54359967b6deaf06d17cc815653ca1b
Dheeraj-1999/interview-questions-competitve-programming
/Comp pro qus and sol/gfg/general/arrays/4 Sort an array of 0s, 1s and 2s .py
551
3.734375
4
def sort(arr): # counts = {0:0, 1:0, 2:0} zero = 0 one = 0 two = 0 for i in arr: if(i == 0): zero += 1 if(i == 1): one += 1 if(i == 2): two += 1 for i in range(zero): arr[i] = 0 # print(arr) for i in range(...
b04a02534d7c306880e56f966b4081c837a1e34e
kristenweeks/chemmie-boi
/Finalproject2.py
6,257
3.53125
4
# -*- coding: utf-8 -*- import pandas as pd import sys import csv import webbrowser import numpy as np from scipy.signal import argrelextrema import matplotlib.pyplot as plt #Ask how many trials were ran to make the program generic for the spectrometer. Trialnumber=((int(input("How many trials does your CS...
e84af0717229ae07077ed58df55be85671f8d9ce
srineeey/neural_networks
/nn_func_reg/torch_net_class.py
2,731
4.0625
4
"""Neural Network class""" import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim import torch.utils.data """ the neural network class inherits from nn.Module the default functions init (constructor) and forward have to be defined manually """ class Net(nn.Module): """ ...
6eddaa20a520bab2fce53e5b9658c9d4a3574b35
AuguestGao/cs50ai
/unit0_search/tictactoe/tictactoe.py
5,305
3.890625
4
""" Tic Tac Toe Player AG 2021-01-08 """ import math import copy X = "X" O = "O" EMPTY = None def initial_state(): """ Returns starting state of the board. """ return [[EMPTY, EMPTY, EMPTY], [EMPTY, EMPTY, EMPTY], [EMPTY, EMPTY, EMPTY]] def player(board): """ Retur...
97542937702b63d852d769f2826d07b444fc4c19
Aasthaengg/IBMdataset
/Python_codes/p02272/s039785797.py
764
3.671875
4
INF = 10**10 def merge(ary, left, mid, right): lry = ary[left:mid] rry = ary[mid:right] lry.append(INF) rry.append(INF) i = 0 j = 0 for k in range(left, right): if lry[i] <= rry[j]: ary[k] = lry[i] i += 1 else: ary[k] = rry[j] ...
0f98e4ce65599d3f520d1ebf4a9ac27275f71576
nive927/Python-Algorithms
/order_pairs.py
564
3.671875
4
import random def countOutOfOrderPairs(arr, N): count = 0 for i in range(0, N): for j in range(i+1, N): if arr[i] > arr[j]: count += 1 return count Start = 1 Stop = 11 N = 5 arr = random.sample(range(Start, Stop), N) #arr = [5, 4, 3, 2, 1] print(arr) print("Unordered Pairs Count: ", countOutOfOrderPair...
1a9cf8af2c84542bd56b372d0d17b358ec29d30f
mihirkelkar/EPI
/Hash/Permute_To_Palindrome/permutePalindrome.py
627
3.8125
4
def permutePalindrome(string): string_dict = dict() even_string = 0 if len(string) % 2 == 0: even_string = 1 else: event_string = 0 for char in string: try: string_dict[char] += 1 except: string_dict[char] = 1 even, odd = 0, 0 for ii in string_dict.values(): if ii % 2 ...
1230f68ab65df39269f55eb33f9a425120d0d12c
TheWinczi/AI_Job_Change_Prediction
/classification/decision_tree.py
2,425
3.578125
4
import numpy as np from sklearn.tree import DecisionTreeClassifier from sklearn.model_selection import GridSearchCV from sklearn.metrics import accuracy_score def decision_tree(X_train: np.ndarray, y_train: np.ndarray, X_test: np.ndarray = None, y_test: np.ndarray = None): """ Decision Tree ...
757fd11e8858cdfc34b70a9729f3b0a3c672bfcd
CP317-SnapChef/SnapChef
/Backend_Code/Lambda/Recipe.py
2,725
3.59375
4
''' Created on Dec. 11, 2018 @author: Brandon Benoit @version: 2018-12-11 ''' class Recipe(object): recipeName = "" rating = 0 prepTime = 0 cookTime = 0 servings = 0 ingredients = [] instructions = [] description = "" peanutFree = False vegatarian = False ...
d1b546c7fb75101cbaf2f4b2efbca99630249595
FlorianTSUALA/data-structures-and-algorithms
/lists/problems/add_one.py
3,446
4.3125
4
""" ------------Problem Statement--------- You are given a non-negative number in the form of list elements. For example, the number 123 would be provided as arr = [1, 2, 3]. Add one to the number and return the output in the form of a new list. Example 1: input = [1, 2, 3] output = [1, 2, 4] Example 2: input = [9, ...
8e356a5419be5c60d2d3cfc747c56281089160b1
honghainguyen777/Learning
/Harvard_CS50_Introduction_to_CS/CS50-Pset6-master/caesar.py
674
3.828125
4
from sys import argv from sys import exit from cs50 import get_string # check the program running with one command-line argument if len(argv) != 2: print("Usage: python caesar.py k") exit(1) # obtain integer k k = int(argv[1]) # ask user input plaintext plaintext = get_string("plaintext: ") print("ciphertext:...
d6df9de68d8b0e16a8ae932f3f8c5d98093482a7
wuyijian123456/test1
/venv/case/demo2.py
927
3.640625
4
import json dict={} dict['name']='xiaoming' dict['age']=18 dict['sex']='f' dict['sex']='m' print(dict) dict2=dict.copy() print(len(dict)) dict2['telphone']='13720011992' print(dict,dict2) print(dict['name']) print('xiaoming' in dict.values()) #dict.clear() dict.pop('name') print(dict) print(dict.get('name1',100)) r=js...
3df4fc06ce58d0cbe41ff5ecf92259d1e1293074
ShutoAraki/Graph_Theory
/graph.py
3,320
3.53125
4
''' @author: Shuto Araki @date: 09/25/2019 ''' class Node(object): def __init__(self, id, name=""): self.id = id self.inflow = [] self.outflow = [] self.name = str(id) if name == "" else name def __hash__(self): return self.id def __eq__(self, other): return self.id == other.id ...
ba4d5eedd9238e6765e0da096cebd0921fd02889
dilipksahu/Python-Programming-Example
/String Programs/binaryOrNot.py
637
4.03125
4
# Check if a given string is binary string or not print("======= useing set() =========") def check(string): s = set(string) p = {'0','1'} if s == p or s == {'0'} or s == {'1'}: print("Yes") else: print("No") test_string1 = "101010000111" test_string2 = "geeks101" check(test_string1) c...
e991ff243dd63b6916b75190d2a1180b8d91594f
xymjeek/python
/python-7-day-Basics/7面向对象程序设计/page9.py
366
3.78125
4
class Swan: ''' 天鹅类 ''' _neck_swan = '天鹅的脖子很长' #定义保护属性 def __init__(self): print("__init__():",Swan._neck_swan) #在实例方法中访问保护属性 swan = Swan() #创建Swan类的实例 print("直接访问:",swan._neck_swan) #保护属性可以通过实例名访问
03558ab5d1655d6c35f904ac95a25a6d31dc1d03
ceuity/algorithm
/leetcode/1038.py
1,048
3.671875
4
# -*- coding: utf-8 -*- """ Created on Tue Mar 23 00:14:48 2021 """ # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: val = 0 def bs...
c81796d89a8e3997ef23eaf87f39630c70e568c2
WeiyiGeek/Study-Promgram
/Python3/Day1/demo1-1.py
223
3.921875
4
#!/usr/bin/python3 # -*- coding:UTF-8 -*- # 功能:验证Python多行语句 one = 1 two = 2 three = 3 add = one +\ two +\ three print("add =",add,end="\n") print(add,end="\n") #输出放在一行使用;分割
644990bdee378519a538fa8f3bafe97d72426008
coremedy/Python-Algorithms-DataStructure
/Python-Algorithms-DataStructure/src/leet/268_MissingNumber.py
560
3.515625
4
''' Created on 2015-10-10 ''' class Solution(object): def missingNumber(self, nums): """ :type nums: List[int] :rtype: int """ return len(nums) * (1 + len(nums)) // 2 - sum(nums) # A XOR B = C => C XOR A = B def missingNumber2(self, nums): ...
d4ca43944d0cef8bac533ddd281aaa755144d4df
jezhang2014/2code
/leetcode/SearchInsertPosition/solution.py
571
3.859375
4
# -*- coding:utf-8 -*- class Solution: # @param A, a list of integers # @param target, an integer to be inserted # @return integer def searchInsert(self, A, target): if not A: return 0 lo = 0 hi = len(A) - 1 while lo < hi: mid = (lo + hi) // 2 ...
0f1cdec3e99655d1fa7983874959d3e509cc3646
lyzz007/python
/learn_python/day5.py
954
3.84375
4
# score = int(input("输入你的成绩:")) # # print( 0 <= score <= 59) # if 0 <= score <= 59: # print("不及格") # elif 60 <= score <= 79: # print("及格") # elif 80 <= score <= 89: # print("良好") # elif 90<= score <= 99: # print("优秀") # elif score == 100: # print("特优") # else: # print("不合法的输入") # # # # a = int...
2b934795744a4983a2e20b7cb932870e489d8451
breaktime11/kfp-component-tests
/component_definitions/requirement-examples/kfp-components/template.py
1,006
3.71875
4
#!/usr/bin/env python3 import argparse from pathlib import Path # Defining and parsing the command-line arguments parser = argparse.ArgumentParser(description='My program description') # Paths must be passed in, not hardcoded parser.add_argument('--input1-path', type=str, help=...
42de428cfc7e14db61b207f2de381fc10d1c6a1b
pug-pb/eventos
/meetup/sorteio.py
671
3.546875
4
import random # biblioteca python para sorteios import csv # biblioteca python para ler arquivos csv com lista de convidados import sys with open('participantes.csv') as csvfile: reader = csv.DictReader(csvfile) participantes = [] for row in reader: if row['Presente'] == 'Sim': par...
0ec9520e891eac7b167507168776174a7d49a12f
mateusz0407/gitrepo
/kody w pythonie/silnia.py
571
3.953125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # # silnia.py # n! = 1 *...*n = N+ -{1} def silnia_it(n): wynik = 1 for i in (2, n + 1): wynik = wynik * i return wynik def main(args): """Funkcja główna""" n = int(input("podaj liczbę naturalną:")) assert type(n) == int assert siln...
5bb2c337267a433d2834d11761d836a66cac7174
tedye/leetcode
/Python/leetcode.281.zigzag-iterator.py
850
3.828125
4
class ZigzagIterator(object): def __init__(self, v1, v2): """ Initialize your data structure here. :type v1: List[int] :type v2: List[int] """ self.v = [] i = 0 j = 0 while i < len(v1) or j < len(v2): if i < len(v1): ...
785b1d8f911dc81452a5ef9cce94f6ad35c6e82c
akashsharma99/PyRock
/oopClassMethod.py
429
3.859375
4
''' Created on Feb 18, 2018 @author: akash ''' class Rectangle: def __init__(self,length,breadth): self.length=length self.breadth=breadth def area(self): return self.length*self.breadth @classmethod def square(cls,side): return cls(side,side) #def hell...
b1b0cee44c369e4105a2ea1c47e630d997e03db1
bsguedes/3dsnake
/BOTS/pysnake.py
3,255
3.53125
4
#!/usr/bin/env python # -*- coding: windows-1252 -*- ''' Created on 06/01/2014 @author: diego.hahn ''' import sys import pickle class Commands(): @staticmethod def Up(): print 'U' @staticmethod def Down(): print 'D' @staticmethod def Right(): print 'R' @staticmethod...
77ccc00b24763c0ea4c553aacd6328a24885bf0b
Deanna2000/PythonPractice
/guessing_number.py
841
4.1875
4
# Instantiate the correct answer and the number guessed variables correctAnswer = 870 numguess = 0 # Explain the game and capture the first guess numguess = int(input( """ Let's test your guessing skills. I am thinking of a number between 1 and a thousand. So, what is your guess? """)) # Set up loop for c...
b3126f3c066d28900dc45b1c5f3028a57ef8aafc
benrose258/Python
/Python 2.7 Files/Classwork/CS 110/Homework5.py
771
3.6875
4
#Question 2 #Part 1 def replace(x, y, mylist): newlist = [] for number in mylist: if number == x: newlist.append(y) else: newlist.append(number) return newlist #Part 2 def replace(x, y, mylist): def helpfunc(number): if x == number: return y ...
55104ad0fbfa8a599ed272237b0bb31d682ef56e
nmm131/python-fundamentals
/src/main/compute_taxes.py
1,924
4
4
def compute_taxes(): filing_status = eval(input("What is your filing status (\n 0: single filers" "\n 1: married filing jointly" "\n 2: married filing separately" "\n 3: head of household" "):...
4a5105a5705a137ee9ce7af36fa0b3c811bf6807
engelcituk/python-bases
/conceptos/operadores.py
970
4.1875
4
variableUno = 10 variableDos = 18 #Los operadores relacionales mayor = variableUno > variableDos menor = variableUno < variableDos mayor_igual = variableUno >= variableDos menor_igual = variableUno <= variableDos igual = variableUno == variableDos igual2 = variableUno is variableDos #tambien se pueden comparar si...
a2dd4147d502d81de201455842a689739159331c
WeikangChen/algorithm
/lintcode/111_climbing-stairs/climbing-stairs.py
433
3.65625
4
# coding:utf-8 ''' @Copyright:LintCode @Author: chenweikang @Problem: http://www.lintcode.com/problem/climbing-stairs @Language: Python @Datetime: 16-04-20 15:41 ''' class Solution: """ @param n: An integer @return: An integer """ def climbStairs(self, n): if n < 2: re...
63b6bbdf401a5b9485b93a5bd95f2a4163a8036a
AndreeaNenciuCrasi/Programming-Basics-Exercises
/First SI week/Modulo.py
293
3.84375
4
# Write a program which prints the top 25 three-digit natural numbers divisible by 7 or by 9. Each # number should be displayed in a separate line. list = [] i = 0 for x in range(100, 300): if (x % 7 == 0) and i < 25: i += 1 list.append(str(x)) print(x)
a2949fae1cc6d28f919c3e8a2e02b40acaad1463
seckcoder/lang-learn
/python/max_user.py
392
3.8125
4
#!/usr/bin/env python #-*- coding=utf-8 -*- # # Copyright 2012 Jike Inc. All Rights Reserved. # Author: liwei@jike.com class People(object): def __init__(self, name, age): self.name = name self.age = age p1 = People(name='liwei', age=1) p2 = People(name='seckcoder', age=2) p3 = People(name='wangda...
9d9a690d4a2cf70f5b477bcf5f3c4898a432b6d1
peterdsharpe/AeroSandbox
/aerosandbox/numpy/trig.py
939
3.75
4
import numpy as _onp from numpy import pi as _pi _deg2rad = 180. / _pi _rad2deg = _pi / 180. def degrees(x): """Converts an input x from radians to degrees""" return x * _deg2rad def radians(x): """Converts an input x from degrees to radians""" return x * _rad2deg def sind(x): """Returns the ...
dd1558f6f90ee12986cc5faa3ebe259ae205a490
VitekIvZ/Prometheus
/lab8_2.py
1,148
3.75
4
#-*- coding: utf-8 -*- """ Розробити функцію find_fraction(summ), яка приймає 1 аргумент -- невід'ємне ціле число summ, та повертає тьюпл, що містить 2 цілих числа -- чисельник та знаменник найбільшого правильного нескорочуваного дробу, для якого сума чисельника та знаменника дорівнює summ. Повернути False, якщо утв...