blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
5fac869e7422502f5e5e4d0b53d81baa9fc7b6f8
YosukeKira/main
/Python/chapter6/6-2/override-test2.py
365
3.875
4
class SuperClass: def hoge(self, id): print("---") print("SuperClass.hoge=" ,id) class SubClass(SuperClass): def hoge(self, id): super().hoge(id) print("SubClass.hoge=", id) # 基底クラスのhogeメソッドの実行例 rc = SuperClass() rc.hoge(100) # 派生クラスのhogeメソッドを実行する sc = SubClass() sc.hoge(300)
78c691c11b674e50d258cf3e061dd1e740e0ee90
YosukeKira/main
/Python/chapter2/2-5/if-noelse.py
187
3.953125
4
level = int( input("レベルは?") ) if level >= 5: print("レベル5以上の人への補足アドバイス") if level >= 8: print("レベル8以上の人へのアドバイス")
9d266545b7b605d34c3b7ceb349d0035f41030cd
YosukeKira/main
/Python/chapter2/2-6/sum1to10.py
243
3.640625
4
v = 0 for i in range(1,11): v = v + i print(i,"を足すと",v) print("1から10を足すと・・・",v) v = 0 for i in range(1,11,2): v = v + i print(i,"を足すと",v) print("1から10の奇数のみを足すと・・・",v)
45f953e24949b7eb915b20b82d0a16ee02085bc1
YosukeKira/main
/Python/chapter2/2-5/if-cafe.py
120
3.734375
4
kion = float( input("気温は?") ) if kion >= 25: print("氷水を出す") else: print("熱いお茶を出す")
8bb62d6456171905cd4b75d70f289562a1056dde
YosukeKira/main
/Python/chapter2/2-4/hello-input.py
77
3.5
4
name = input("お名前は?") print( name + "さん、こんにちは!")
da233b443e759f9eec6b1088105360c74fd32c03
YosukeKira/main
/Python/chapter2/2-5/leapyear.py
505
3.90625
4
year = int( input("西暦何年?") ) # うるう年かどうか判定 is_leap = False # 4で割り切れたらうるう年 if year % 4 == 0: # 100で割り切れたらうるう年ではない if year % 100 == 0: # 400で割り切れたらうるう年 if year % 400 == 0: is_leap = True else: is_leap = False else: is_leap = True else: is_leap = False # 結果を表示 if is_leap: print("う...
71a799ce7bef8f29edbe5c99f9ad62487e669e15
YosukeKira/main
/Python/chapter3/3-6/gen-prime.py
897
3.953125
4
# 素数を返すイテレータ def genPrime(maxnum): num = 2 while ( num <= maxnum ): is_prime = True # 素数かどうかを管理する変数を定義 for i in range(2, num): # numが2のときは範囲に含まれる値がなく実行されない if ( num % i ) == 0: # 素数ではない is_prime = False break if (is_prime): yield num num += 1 # イテレータを変数に代入 it = genPrime(50) # 画面に表示 ...
b571b2d203f9f5d9df7352356721042638971237
Chesterrific/Unit-Testing
/Genera Unit Testing Examples/hw2.py
1,563
3.9375
4
import unittest from hw1 import * class Testhw1(unittest.TestCase): def test_score_equal(self): "General tests for score" self.assertEqual(score([(2, 'Clubs'),(8, 'Diamonds')]), 10) self.assertEqual(score([(10, 'Hearts'),(3, 'Spades')]), 13) def test_score_equal_face_cards(se...
b77cae0b2e9b9f6813b5b532468d53ec7131e80a
Freshield/LEARN_DATA_SCIENCE
/Introduction/chp1/test6.py
309
3.703125
4
class Person: department = 'School of Information' def set_name(self, new_name): self.name = new_name def set_location(self, new_location): self.location = new_location store1 = [10,11,12,2] store2 = [9,12,12,1] cheapest = map(min,store1,store2) for k in cheapest: print(k)
a526c0abe94a1c6d44323599f8f71d09c0daff29
semccomas/SummerProj
/keraswork.py
2,974
3.984375
4
#This is from the machine learning mastery keras tutorial. I commented the living shit out of this because it's my first attempt at using keras #testing a new push for github ignore this line ########## imports ############## from keras.models import Sequential from keras.layers import Dense import numpy as np #####...
472a39cc245432adc127b3d0a7e94148982a985d
mhoffman2016/Sudoku
/SudokuWindow.py
3,907
3.6875
4
from graphics import * class SudokuWindow(GraphWin): """ Graphical representation of the featured Board Attributes: featured - Board The Board to be drawn and used to update the graphic tiles - [[Text]] Matrix of all Text to appear on the featured Board message ...
c5b99e7837563827587115de66ea6d33679d38bd
nisaChampagne/Data-Structures
/queue_and_stack/dll_queue.py
872
3.515625
4
import sys sys.path.append('../doubly_linked_list') from doubly_linked_list import DoublyLinkedList class Queue: #LILO #the last item in a queue is the last item # to leave the queue #FIFO # first item in line will be the first out def __init__(self): self.size = 0 ...
7910279afc3e1e548a6bb4d20639326eeead32d8
spectrum556/playground
/src/homework_1_additional/h_add.9.py
378
3.8125
4
__author__ = 'Ihor' height = float(input('enter your height\n')) weight = float(input('enter your weight\n')) def perfect_weight(height): return height - 100 print('your perfect weight is', perfect_weight(height)) print('your weight is perfect')if perfect_weight(height) == weight \ else print('you have to...
b0436a9cd1ab679ac92b3fa3bd75786a3cb52067
spectrum556/playground
/src/homework_1_additional/h_add.7.py
566
4.25
4
__author__ = 'Ihor' month_num = int(input('enter the number of month\n')) def what_season(month_num): if month_num == 1 or month_num == 2 or month_num == 12: return 'Winter' elif month_num == 3 or month_num == 4 or month_num == 5: return 'Spring' elif month_num == 6 or month_num == 7 or m...
e6e2cbe0247b16513bb376ca59175b529d27bfa7
spectrum556/playground
/src/homework_1_additional/h_add.2.py
165
3.703125
4
__author__ = 'Ihor' num1 = float(input()) num2 = float(input()) num3 = float(input()) nums = [num1, num2, num3] for el in nums: print(el ** 3 if el > 0 else 0)
c1e0a3c70cfd90f4753bc9b46c101c2e7ad1227d
wardk6907/CTI110
/P5T2_FeetToInches_KaylaWard.py
520
4.3125
4
# Feet to Inches # 1 Oct 2018 # CTI-110 P5T2_FeetToInches # Kayla Ward # # Constant for the number of inches per foot. inches_per_foot = 12 # Main Function def main(): # Get a number of feet from the user. feet = int(input("Enter a number of feet: ")) # Convert that to inches. print(f...
d3f1e05fcb4907b15301dba4e8175028a0b459b7
zmlabe/predictGMSTrate
/Scripts/read_randomData_monthly.py
9,670
3.53125
4
""" Function(s) reads in monthly data that is generated from random noise in the shape of climate models and observations Notes ----- Author : Zachary Labe Date : 5 March 2021 Usage ----- [1] read_randomData_monthly(directorydata,variq,sliceperiod, sliceshape,slicena...
55accbf96df3236d8b55ada121259a0cf95daf99
PraveenMut/quick-sort
/quick-sort.py
783
4.15625
4
# QuickSort in Python using O(n) space # tester array arr = [7,6,5,4,3,2,1,0] # partition (pivot) procedure def partition(arr, start, end): pivot = arr[end] partitionIndex = start i = start while i < end: if arr[i] <= pivot: arr[i],arr[partitionIndex] = arr[partitionIndex],arr[i] partitionInd...
1a52c43a102debfdef94d893096310f0d08bb7b8
init-fun/Leetcode-prep
/Pattern-matching/X Unorganized/comparing_string.py
917
3.71875
4
def compare(a, b): x = new_fun(a) y = new_fun(b) return x == y def new_fun(arr): # single length string if len(arr) == 1: if arr[0] == "#": return "" else: return arr # more than one char res = "" fptr = 0 sptr = 1 rem_...
95b108b00f596796512879b13b6f2db438ef5612
init-fun/Leetcode-prep
/palindrome-linked-list/palindrome-linked-list.py
1,101
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 isPalindrome(self, head: ListNode) -> bool: # first go to the middle point of the lst # and then reverse the list and checkout wh...
53ac785b8cc9d49f06796c7105e4198b65e514c1
RockmanExe/Data-Structures
/linked_list/linked_list.py
1,727
3.765625
4
""" Class that represents a single linked list node that holds a single value and a reference to the next node in the list """ class Node: def __init__(self, value=None, next_node=None): self.value = value self.next_node = next_node def get_value(self): return self.value def get_next(self): ret...
6309b07245011e0be65035883fa3b46d63df4458
defnngj/pyif10
/mysite/tests/test_sub.py
487
3.5625
4
import unittest def sub(a, b): return a - b # 必须继承 unittest.TestCase class TestSub(unittest.TestCase): def setUp(self): print("测试用例开始之前执行") def tearDown(self): print("用例结束的时候执行") # 必须以“test”开头 def test_sub1(self): a = sub(5, 3) print("test_sub") self.assertEqual(a, 2) def test_sub2(self): a = ...
ed4bf2d14601305473a0e708b7933c28c679aed5
bscott110/mthree_Pythonpractice
/BlakeScott_Mod2_TextCount.py
1,366
4.3125
4
import string from string import punctuation s = """Imagine a vast sheet of paper on which straight Lines, Triangles, Squares, Pentagons, Hexagons, and other figures, instead of remaining fixed in their places, move freely about, on or in the surface, but without the power of rising above or sinking below it, v...
daaedc58d818c5017e376c432a9de124b21d72c1
kai21-meet/meetyl1
/lesson2.py
469
3.578125
4
def common_numbers(hi,hello): print (hello) print (hi) list3=[] for number in hi: if number in hello: list3.append(number) return list3 list1=[1,2,3,4,5,6] list2=[23,3,6,7,1] list4=common_numbers(list2,list1) print(list4) encoder_caesar = {'a':'d','b':'e','c':'f','d':'g','e':'h','f':'i','g':'j','h':'k','i...
9396ac5bb0f9635f187ccccaa6a6538a63ebe580
erldas/week3.1
/4-6.py
309
3.796875
4
# Пусть пользователь вводит два значения и вы сверяйте их, # и если совпадают то True, а # если нет то False. print (' Vvdedite znachenie: ') user1 = input() user2 = input() if user1 == user2: print('True') else: print('False')
3761e229afe57fdf5d3b64b295b1c06c8919470c
AndreaGraziosi/Python_for_everyone
/computepay.py
870
3.953125
4
# sh = input("enter hours!") # sr = input("enter rate") # # try: # fh = float(sh) # fr = float(sr) # except: # print("error, please enter numeric input") # quit() # # if fh > 40: # reg = fr* fh # otp = (fh - 40) * (fr * .5) # xp = reg + otp # else: # xp = fh* fr # print('pay:', xp) # h...
f0b9a7b8ea3eab6fa95b1ff043b8e782066429b3
jcgato93/python-essentials
/17-comprehensions.py
849
3.9375
4
# Comprehensions # Los comprehensions son una forma de transformar listas (map() en javascript) # comprehensions en listas number_list = list(range(100)) print("Lista de numeros {}".format(number_list)) pares = [numero for numero in number_list if numero % 2 == 0] print ("Lista de numeros pares {}".format(pares)) ...
b54d309379486f336fcd189b81a9a1df5fba77d0
AnirbanMukherjeeXD/Explore-ML-Materials
/numpy_exercise.py
2,818
4.28125
4
# Student version : https://tinyurl.com/numpylevel1-280919 # Use the numpy library import numpy as np def prepare_inputs(inputs): # TODO: create a 2-dimensional ndarray from the given 1-dimensional list; # assign it to input_array n = len(inputs) input_array = np.array(inputs).reshape(1,n) ...
4e62b74a2e82ee9f755d7b86a0cfed791f2ebcaf
voodoopeople42/for_check
/1/time.py
107
3.59375
4
n = int(input("Input number:" )) hours = n % (60 * 24) // 60 minutes = n % 60 print(hours, minutes)
183c214562494a3c9ade3e285d5a68dc8f0ba856
MikeDiaz93/Problems_VS_Algorithms
/Dutch_National_Flag_Problem/Dutch_National_Flag_Problem.py
1,949
4.15625
4
def sort_012(input_list): """ Given an input array consisting on only 0, 1, and 2, sort the array in a single traversal. Args: input_list(list): List to be sorted """ if input_list == None: return None if input_list == []: return [] aux1 = 0 aux2 = 0 middle ...
90eb2abcb88d0480d82081e3142cdff4c3a5f981
adityabads/interview-practice
/11-bit-manipulation/find_unique.py
610
3.671875
4
# Find unique # Given the list of IDs, which contains many duplicate integers and one unique # integer, find the unique integer. from functools import reduce from typing import List import unittest def find_unique(arr: List[int]) -> int: return reduce(lambda x, y: x ^ y, arr) class TestFindUnique(unittest.Test...
6e29bf362043cb6c6e6db600087f6a8d63f74054
adityabads/interview-practice
/02-hashing/4_top_scores.py
2,067
3.953125
4
# Top scores # Each round, players receive a score between 0 and 100, which you use to rank # them from highest to lowest. So far you're using an algorithm that sorts in # O(n lg n) time, but players are complaining that their rankings aren't # updated fast enough. You need a faster sorting algorithm. # # Write a funct...
2705ae734f8167d7a6a5306a8119885d78ab7caa
adityabads/interview-practice
/07-stacks-queues/2_queue_with_two_stacks.py
1,449
3.9375
4
# Queue with two stacks # Implement a queue with 2 stacks. Your queue should have an enqueue and a # dequeue method and it should be "first in first out" (FIFO). # # Optimize for the time cost of m calls on your queue. These can be any mix # of enqueue and dequeue calls. # # Assume you already have a stack implementati...
231e7e282d50f6a33ea607f926f44d6d3f17da48
adityabads/interview-practice
/06-dynamic-programming/1_string_permutations.py
1,314
3.984375
4
# Recursive string permutations # Write a recursive function for generating all permutations of an input string. # Return them as a set. # # Don't worry about time or space complexity—if we wanted efficiency we'd write # an iterative version. # # To start, assume every character in the input string is unique. # # Your ...
c8ec772b4bd093a8472a9fcfa0edd04119a2d06f
adityabads/interview-practice
/01-arrays-strings/1_merge_meeting_times.py
1,606
3.953125
4
# Merge meeting times # Write a function merge_ranges() that takes a list of multiple meeting time # ranges and returns a list of condensed ranges. # # Do not assume the meetings are in order. # # EXAMPLE # Input: [(0, 1), (3, 5), (4, 8), (10, 12), (9, 10)] # Output: [(0, 1), (3, 8), (9, 12)] # # BONUS # 1. What if we...
f7754142cebe7e721ca0cd13187d4025a625cdba
cbira353/buildit-arch
/_site/writer1.py
445
4.15625
4
import csv from student import Student students = [] for i in range(3): print('name:', end='') name = input() print('dorm:', end='') dorm = input() students.append(Student(name, dorm)) for student in students: print("{} is in {}.".format(student.name, student.dorm)) file =open("students.cs...
accc06ae16a0c1ff019206bf63a5205ec703c56c
zhuwenzhang/Python-base
/不同的读取方式.py
945
3.8125
4
def main(): infile = open("D:\\朱文章 文件\\朱文章 python\\第十三章习题\\zwz.txt", "r") print("(1)Using read():") print(infile.read()) infile.close() infile = open("D:\\朱文章 文件\\朱文章 python\\第十三章习题\\zwz.txt", "r") print("\n(2)Using read(number):") s1 = infile.read(1) print(s1) s2 = infile...
b2dcf755de8a4e16fffce1f08ae05729be700a1a
zhuwenzhang/Python-base
/打印列表的两种方式.py
233
3.96875
4
n = [[1, 2, 3], [5, 4, 2], [5, 6, 2]] for i in range(len(n)): for b in range(len(n[i])): print(n[i][b], end=' ') print() # 第二种 for i in n: for b in i: print(b, end=' ') print()
394aaf9a0a46902787ecd1db3cae64d802108f03
zhuwenzhang/Python-base
/列表加减乘除.py
173
3.890625
4
list1 = [1, 2, 4] list2 = [1, 5, 4] list3 = list1 + list2 list4 = list1 * 2 print(list3) print(list4) print(2 in list1) print(list1 in list4) print(3 in list1)
e56152c8e410e8ab043a6254110af68e64b2ad54
zhuwenzhang/Python-base
/回文串.py
330
3.5
4
def main(): s = input("input a string:").strip() if iss(s): print("Yes") else: print("No") def iss(s): low = 0 high = len(s) - 1 while low < high: if s[low] != s[high]: return False low += 1 high -= 1 return True ...
8c14af4842f633c8ef733f8312a4231fb098ab68
zhuwenzhang/Python-base
/继承1的子类.py
599
3.578125
4
from text12 import GeometricObject import math class Circle(GeometricObject): def __init__(self,radius): super().__init__() self.__radius = radius def getRadius(self): return self.__radius def setRadius(self,radius): self.__radius = radius def getArea(self...
59ca89a2c35a8b2ebb9f424e9554349800a9d942
camilleanne/rainmap
/map.py
1,280
3.515625
4
#!/usr/bin/env python from math import cos, sin, atan2, pi, sqrt from collections import namedtuple import json import shapefile import urllib2 Point = namedtuple('Point', 'lon lat') def center_geolocation(geolocations): """ Provide a relatively accurate center lon, lat returned as a list pair, givena list of li...
4d77ae38f9224eb9edde88e9a4cec78a154226d0
onizenso/College
/classes/cs350/wang/Code/Python/functions.py
5,222
4.5625
5
#!/usr/bin/env python # More examples demonstrating how Python handles functions # See test.py for background on data types, and basic structures, etc. ############################################################ # demonstrate basic parameter passing # ##################################...
94908555a5067b29f51bc69eb397cb1f3aace887
onizenso/College
/classes/cs350/wang/Code/Python/coroutines.py
1,990
4.5
4
#!/usr/bin/env python # demonstrate coroutines in Python # coroutines require python 2.5 """ this simple example is a scheduler for walking dogs the scheduler subroutine and main() act as coroutines yield hands off control, next() and send() resumes control """ def printdog(name): # a...
54085c915eebe42c2e4bccc029385deebf4582de
sonne8/AID
/tcp_timg_server.py
1,228
3.546875
4
""" 练习1: 从客户端上传一张图片给服务端,在服务端以 当前日期为名称存储。 比如: 客户端 将图片 timg.jpg 发送给服务端 服务端存储为 2020-11-13.jpg 即可 思路 : 客户端 打开文件 读取文件 发送文件 服务端 打开文件 接收内容 写入文件 """ from socket import * import time # 接收文件 def recv_image(connfd): filename="%d-%d-%d"%time.localtime()[:3] with open(filename,'wb')as f: whil...
2696488fbf8a0c27b5c410bdca8fab666eeaa213
BeniyamL/alx-higher_level_programming
/0x0A-python-inheritance/9-rectangle.py
1,166
4.34375
4
#!/usr/bin/python3 """ class definition of Rectangle """ BaseGeometry = __import__('7-base_geometry').BaseGeometry class Rectangle(BaseGeometry): """ class implementation for rectangle """ def __init__(self, width, height): """initialization of rectangle class Arguments: w...
37f0162910ed4541fbad07ba16b71d71b406449f
BeniyamL/alx-higher_level_programming
/0x03-python-data_structures/2-replace_in_list.py
384
4.3125
4
#!/usr/bin/python3 def replace_in_list(my_list, idx, element): """ replace_in_list - replace an element of a list @my_list: the given list @idx: the given index @element: element to be replaced @Return : the replaced element """ if idx < 0 or idx >= len(my_list): return my_list ...
aa512155ef7e45c98ed3d4c5f839822d7fb81fd4
BeniyamL/alx-higher_level_programming
/0x0C-python-almost_a_circle/models/rectangle.py
6,560
4.0625
4
#!/usr/bin/python3 """ Rectangle class definition """ from models.base import Base class Rectangle(Base): """ a rectangle class to define atributes and methods of a rectangle""" def __init__(self, width, height, x=0, y=0, id=None): """ function to initialize the rectangel class Arguments: ...
a7ce1f8eca0bed05c35f6cbaa0671ec1febea9df
BeniyamL/alx-higher_level_programming
/0x04-python-more_data_structures/6-print_sorted_dictionary.py
311
4.40625
4
#!/usr/bin/python3 def print_sorted_dictionary(a_dictionary): """function to sort a dictionary Arguments: a_dictionary: the given dictionary Returns: nothing """ sorted_dict = sorted(a_dictionary.items()) for k, v in sorted_dict: print("{0}: {1}".format(k, v))
0497d2f931697ad17a338967d629b2c430ece31b
BeniyamL/alx-higher_level_programming
/0x0B-python-input_output/100-append_after.py
660
4.28125
4
#!/usr/bin/python3 """ function defintion for append_after """ def append_after(filename="", search_string="", new_string=""): """ function to write a text after search string Arguments: filename: the name of the file search_string: the text to be searched new_string: the string to be...
feb030e81440d50c0cc28af715a9c2df23c70438
BeniyamL/alx-higher_level_programming
/0x0A-python-inheritance/100-my_int.py
539
3.921875
4
#!/usr/bin/python3 """ class definition MyInt """ class MyInt(int): """ class for my int """ def __eq__(self, val): """ function to invert equality arguments: val: the given value Returns: True if is not equal """ return (self.real != va...
ee769eb6ad867b1e9b7cb2462c2b48ac2abaf5b8
BeniyamL/alx-higher_level_programming
/0x07-python-test_driven_development/4-print_square.py
485
4.46875
4
#!/usr/bin/python3 """ print_square function """ def print_square(size): """ function to print a square of a given size Arguments: size: the size of the square Returns: nothing """ if type(size) is not int: raise TypeError("size must be an integer") if type(size) is in...
c4ea1dbd37672ec5cef16c213b1cdc3cfca33d32
BeniyamL/alx-higher_level_programming
/0x0B-python-input_output/3-to_json_string.py
299
3.96875
4
#!/usr/bin/python3 """ function defintion for to_json_string """ import json def to_json_string(my_obj): """ function to convert to JSON representation Arguments: my_obj: the given object Returns: JSON representatoin of an object """ return json.dumps(my_obj)
c3d0611e3b29ae8605ac93098c68388abd79292a
NK84/py4int
/ex7_2_read_from_file_find_count_average.py
363
3.6875
4
# Use the file name mbox-short.txt as the file name fname = input("Enter file name: ") fh = open(fname) pos = 0 count = 0 for line in fh: if line.startswith("X-DSPAM-Confidence:"): x = line.find(":") y = float(line[x+1:]) pos = pos + 1 count = count + y aver = count / pos ...
617087d1dc201a670e0ba48f512f5c4f6d7d96a2
NK84/py4int
/ex7_1_read_from_file_upper.py
146
4.09375
4
# Use words.txt as the file name fname = input("Enter file name: ") fhnew = open(fname) for line in fhnew: print (line.rstrip().upper())
f6ca8a3b98c91d23341970390ad2938937a9a189
mjtsai/leetcode
/1281_subtract_the_product_and_sum_of_digits_of_an_integer.py
782
3.9375
4
#!/usr/bin/env python3 # -*- coding: UTF-8 -*- import sys import os from copy import deepcopy import math class Solution(object): def subtractProductAndSum(self, n): """ :type n: int :rtype: int """ nl = [int(i) for i in str(n)] nlm = 1 for i in...
2589fcd5eba6130b20c8830ecd3d4f88bb74ebbb
mjtsai/leetcode
/1431_kids_with_the_greatest_number_of_candies.py
1,463
3.65625
4
#!/usr/bin/env python3 # -*- coding: UTF-8 -*- import sys import os from copy import deepcopy class Solution(object): def kidsWithCandies(self, candies, extraCandies): """ :type candies: List[int] :type extraCandies: int :rtype: List[bool] """ assert(len(...
bd9f8ceeae89ee4bdc206a7e69db169b6f3b2f79
mjtsai/leetcode
/1313_decompress_run_length_encoded_list.py
797
3.765625
4
#!/usr/bin/env python3 # -*- coding: UTF-8 -*- import sys import os from copy import deepcopy import math class Solution(object): def decompressRLElist(self, nums): """ :type nums: List[int] :rtype: List[int] """ derle = [] for i in range(0, len(nums), 2):...
5a4b8d1c875fb07ca6c978f140a0e92b541e235f
schaudhari0755/song-popularity-predictor
/utilities/modeling_utilities.py
5,031
3.5625
4
""" Contains utility functions necessary to analyze and build a model. Author: Stephen Kaplan (July 13, 2020) """ import seaborn as sns import matplotlib.pyplot as plt from math import sqrt import numpy as np from sklearn.linear_model import LinearRegression from sklearn.preprocessing import StandardScaler from sklear...
33c78cefb4c6bf276b565f9448e31c7c43ebfc63
ncrasta/python
/rename_pdf_files.py
603
3.5625
4
import os import argparse def rename_files(path_name): for idx, filename in enumerate(os.listdir(path_name)): name, ext = os.path.splitext(filename) print(idx) if filename.endswith('.pdf'): os.rename(os.path.join(path_name, filename), os.path.join(path_name, str(idx)+'.pdf')...
9d0153dd0541cb9a3c70343fee851bb54fe97932
stratumgs/stratumgs-python-client
/sgsclient/example/tictactoe/simple.py
1,800
3.515625
4
""" .. module sgsclient.example.tictactoe.simple An example client for TicTacToe that plays in the next available space. When executed directly it will call :func:`sgsclient.main` with ``supported_games = ["tictactoe"]``. """ from sgsclient import StratumGSClientInstance, main class TicTacToeClient(StratumGSClientI...
05e7d710dff49403af0052d3aca143cee32c8991
kingmolnar/DataScienceProgramming
/04-Pandas-Data-Tables/HW04/hw4_template.py
4,442
3.984375
4
# Solutions to homework 4 import numpy as np import pandas as pd # ____ _ _ _ # | _ \ _ __ ___ | |__ | | ___ _ __ ___ / | # | |_) | '__/ _ \| '_ \| |/ _ \ '_ ` _ \ | | # | __/| | | (_) | |_) | | __/ | | | | | | | # |_| |_| \___/|_.__/|_|\___|_| |_| |_| |_| # # Create a functi...
f57070e4eace8eee6e939d1dcf297ae929cbfc56
JanhaviMhatre01/pythonprojects
/distinct.py
526
4.0625
4
''' /********************************************************************************** * Purpose: A program with cubic running time. Read in N integers and counts the * number of triples that sum to exactly 0. * * @author : Janhavi Mhatre * @python version 3.7 * @platform : PyCharm * @since 22-12-2018 * **************...
2d55b3451ad2d1d344cb614b0b8ab8eb085fb125
JanhaviMhatre01/pythonprojects
/flipcoin.py
618
4.375
4
''' /********************************************************************************** * Purpose: Flip Coin and print percentage of Heads and Tails * logic : take user input for how many times user want to flip coin and generate head or * tail randomly and then calculate percentage for head and tail * * @author : Janh...
a3c03748534552e767bad2f55e307cd188716a35
JanhaviMhatre01/pythonprojects
/primefactors.py
422
3.984375
4
''' /********************************************************************************** * Purpose: Computes the prime factorization of N. * * @author : Janhavi Mhatre * @python version 3.7 * @platform : PyCharm * @since 21-12-2018 * ***********************************************************************************/ ''...
951038724553bbe9c1b0eb4b9987b62ae505a381
JanhaviMhatre01/pythonprojects
/bubblesort.py
547
4.03125
4
''' /********************************************************************************** * Purpose: Prints the harmonic value: 1/1 + 1/2 + ... + 1/N * * @author : Janhavi Mhatre * @python version 3.7 * @platform : PyCharm * @since 21-12-2018 * *****************************************************************************...
2a2b1d07d2924123f9ef6b0b805e68e4077f9a7f
JanhaviMhatre01/pythonprojects
/hashtable.py
1,866
3.765625
4
''' /********************************************************************************** * Purpose: Create a Slot of 10 to store Chain of Numbers that belong to each Slot to * efficiently search a number from a given set of number * @author : Janhavi Mhatre * @python version 3.7 * @platform : PyCharm * @since 3-1-2019 ...
65d88e7d92ca1e0ddde0bef59759663520c591fe
TAndrievskiy/Test_python
/hw4/longest_word.py
1,233
4.21875
4
""" 1. Вводится строка 2. Программа считает количество слов в введенной строке и выводит на экран. 2. Программа определяет самое длинное слово и его длину и выводит на экран. ___________________________________________________________________________ Например: ### Hello,world! I am learning py...
38003895f46c8d64b626005812e6a18b649d233b
TAndrievskiy/Test_python
/hw5/practice_1.py
1,704
4.25
4
""" Программу принимает на ввод строку string и число n. Выводит на экран строку с смещенными символами на число n. Весь код можно написать в одной функции main, но рекомендуется разбить код на несколько функций, например: - main - функция для получения не пустой строки. - функция для получ...
ea290da81a0c06058bba0beb1fafbe1837b3d704
Dmitriy21092000/task4
/Extract-text-using-PyPDF2.py
610
3.5625
4
#Извлечение текста с помощью PyPDF2 from PyPDF2 import PdfFileReader pdf_document = "source/Documentation-Python.pdf" with open(pdf_document, "rb") as filehandle: pdf = PdfFileReader(filehandle) info = pdf.getDocumentInfo() pages = pdf.getNumPages() print("Количество страниц в документе: %i...
f5d7e14954cf225d6a3cff3dd5baf69d8f1b5524
Dmitriy21092000/task4
/Splitting-PDF-files-into-pages.py
577
3.578125
4
#Разделение PDF‑файлов на страницы с помощью PyPDF2 from PyPDF2 import PdfFileReader, PdfFileWriter pdf_document = "source/Documentation-Python.pdf" pdf = PdfFileReader(pdf_document) for page in range(pdf.getNumPages()): pdf_writer = PdfFileWriter() current_page = pdf.getPage(page) pdf_writer.a...
43a73016334531429e765adac81f559e06e5bdcb
jenscui-1936485/LintCode-Problems
/Practice/rectangle.py
254
3.5625
4
from shape import Shape from circle import Circle class Rectangle(Shape): res = 0 def __init__(self, side1, side2): self.side1 = side1 self.side2 = side2 def getArea(self): return float(self.side1 * self.side2)
f50b417072cd3b7eb27bbd369ba16e97f6a8b652
jenscui-1936485/LintCode-Problems
/LintCode37.py
217
3.734375
4
class Solution: """ @param number: A 3-digit number. @return: Reversed number. """ def reverseInteger(self, number): # write your code here a=str(number) return int(a[::-1])
b51174980c3984102a21845405e5002a3022ed26
Sukhtaaj/ftp-client
/_commands/_ConnectionInfo.py
1,239
3.75
4
class Command(): def pull_connections(self): """ Command to display saved connections to user """ i = 0 text_file = open("../_commands/info.csv", "r") for line in text_file: fields = line.split(",") host = fields[0] username = fie...
3c90225ebdb5112f9cd870d765160819a3661073
Subhraj07/blog_codes
/2020-06-10-production_model_reload_without_shutting_download_app/predict.py
1,290
3.953125
4
# reference : https://www.learnopencv.com/pytorch-for-beginners-image-classification-using-pre-trained-models/ from torchvision import models, transforms import torch from PIL import Image def predicted_results(img, pymodel): img = Image.open(img) transform = transforms.Compose([ #[1] trans...
fc8f5cda197bf5b0209f2c18b3089d3dc7d08be9
elenabarreto/includeTec
/Situacion-S3.py
474
4.125
4
# -*- coding: utf-8 -*- print "___________________" print "-*- EJERCICIO 3 -*-" print "___________________" print " " print " " print " " print "_______________________________________________________________________________" print " " presion = input("Ingrese valor de presión: ") volumen = input("Ingrese valor de vo...
33afb22c0cbb6715962f7c1ee9db56fe09a73ee1
BlueCakeWithCows/Code-Samples
/ProgrammingQuestions/DailyCode4Hard.py
1,822
4.0625
4
"""Given an array of integers, find the first missing positive integer in linear time and constant space. In other words, find the lowest positive integer that does not exist in the array. The array can contain duplicates and negative numbers as well. For example, the input [3, 4, -1, 1] should give 2. The input [1, 2...
5c48d81a7239b054eefe57feef64e7d439718581
BlueCakeWithCows/Code-Samples
/ProgrammingQuestions/DailyCode10Medium.py
524
3.71875
4
"""This problem was asked by Apple. Implement a job scheduler which takes in a function f and an integer n, and calls f after n milliseconds.""" from threading import Thread from time import sleep def schedule(f, n): def helper(): sleep(n/1000.0) f() Thread(target = helper).start() ...
75f019f7c0d1720a1776d78ca02ae791813df8e0
Adii265/My-personal-digital-assistant
/calendar_jessica.py
2,114
3.796875
4
import os from datetime import datetime from datetime import date from datetime import time import time import calendar import sys import datetime import reboot #own import pyytsx3_jessica as pyt #own exit_words = ["thanks","thanku","back","end","exit","thank","quit","Quit","Thanks","Thanku","Back","End","Exit","Th...
844f77cef17e38f6d9f8cdbcc55d6348c6f3a3d8
Adii265/My-personal-digital-assistant
/diary_jessica.py
4,838
3.6875
4
import os from datetime import datetime from datetime import date from datetime import time from datetime import datetime import time import calendar import sys import datetime import reboot #own import pyytsx3_jessica #own import jessica_words as w reminder_path = "Dairy.txt" def diary(): print("Sciccy : Tell me ...
b593a4c4a44efca8cabc61eeccb3ebb0e7721b73
dhanuskarthikeyan/guvi
/Codekata/leave.py
84
3.640625
4
s1=raw_input() l=["Saturday","Sunday"] if s1 in l: print "yes" else: print "no"
c4115491b5a689fc754b60c78173c5e22c0d12f5
dhanuskarthikeyan/guvi
/Codekata/lexiord.py
95
3.671875
4
s = raw_input() le = list(s) s1 = "" le.sort() for i in range(len(le)): s1 += le[i] print s1
e1636994035323e76bfcc6974fc1c8a0c3e14372
dhanuskarthikeyan/guvi
/Codekata/oddsub.py
158
3.8125
4
num,n=(raw_input().split()) num=int(num) n=int(n) num=abs(n-num) if(num>=0): if(num%2==0): print "even" else: print "odd" else: print "invalid"
dda8729c6196087bb417041a9cb5d4a07044125f
dhanuskarthikeyan/guvi
/Codekata/median.py
226
3.640625
4
a=int(input()) ba=[] for x in raw_input().split(): ba.append(int(x)) ba.sort() length = len(ba) if (length % 2 == 0): median = (ba[(length)//2] + ba[(length)//2-1]) / 2 else: median = ba[(length-1)//2] print(median)
ed1940be69a32de4933afa5c194fb4d18794b818
dhanuskarthikeyan/guvi
/Codekata/kabalianagram.py
124
3.515625
4
nc=int(raw_input()) c=0 for i in range(0,nc): s=raw_input() if(sorted(s)==sorted("kabali")): c=c+1 print(c)
e983f236dc9906ecef70e349792b22de481b62e2
dhanuskarthikeyan/guvi
/Codekata/vowelstr.py
123
3.578125
4
a2=raw_input() v=["a","e","i","o","u"] co=0 for a in a2: if(a in v): co=1 if(co==1): print"yes" else: print "no"
4ecb88b9fa3f3e0d68bb5a8bcbb7c8844ce90aff
dhanuskarthikeyan/guvi
/Codekata/proeven.py
97
3.921875
4
b,a=(raw_input().split()) b=int(b) a=int(a) b=a*b if(b%2==0): print "even" else: print "odd"
10cb9f77f7bdc6b478723e1a507d584443596529
Thermostat-Skye/remote_python2004
/day1/chapter3/string_format1.py
189
4.09375
4
base = int(input('Enter Base: ')) height = int(input('Enter Height: ')) area = 0.5 * base * height print(f'The area of rectangle with a base of {base} and a height of {height} is {area}')
84c17c3c49ee229cfe8b196458b516fb358bc0aa
gauripatil20/FUNCTION
/FUN_SUM VALUE.PY
230
3.953125
4
# def sum_value(limit): # i=1 # s=0 # while i<=num: # if i%3==0 or i%5==0: # print(i) # s=s+i # i=i+1 # print(s) # num=int(input("enter the number")) # sum_value(10)
47d3f29c60f3ffb461ea20a74b923d03c1af3f75
gauripatil20/FUNCTION
/FUN_ELIGEBLE.PY
195
3.859375
4
# def eligible_for_vote(): # if x>=18: # print("eligible for voting") # else: # print("not eligible for voting") # x=int(input("enter the nubmer")) # eligible_for_vote()
e479e91c640fd2838deddf307b61234ff7544679
gauripatil20/FUNCTION
/FUN_ODD_EVEN.PY
345
4.0625
4
# def isEven(): # if(12%2==0): # print("Even Number") # else: # print("ODD Number") # isEven() # def show_number(limit): # i=0 # while i<=3: # if i%2==0: # print(i,"EVEN") # else: # print(i,"ODD") # i=i+1 # num=int(input("enter the num...
825238465b41ec4ac2979816c1ef236cc759048a
AvinashMishra1997/projects-for-all
/Dictionary.py
841
4.15625
4
from PyDictionary import PyDictionary dictionary = PyDictionary() print ('choose if u want the antonym or synonym or meaning or translations of a word') d=raw_input ("Enter 'a' for antonym 's' for synonym 'm' for meanings and 't' for translations : ") if d=='m': word=raw_input('Enter the word you want the meaning...
6487be5707ac852163d7ce85b495692b8881f89d
AvinashMishra1997/projects-for-all
/tic_tac_toe.py
1,181
3.71875
4
a=' ' b=' ' c=' ' d=' ' e=' ' f=' ' g=' ' h=' ' i=' ' q=print('while entering column number and row number, please do not leave any space in between them \n example (12) or (23), etc') t=('\t'+a+'|'+b+'|'+c+'\n\t___________\n\t '+d+'|'+e+'|'+f+'\n\t___________\n\t'+g+'|'+h+'|'+i ) print t for unknown...
fbf4cb1a1af672719b8131551091fb5d6af56cda
MrEngineerKenan/Pyhton_GlobalIOHub_-devlerim
/HOMEWORK-2.py
669
4
4
First_Name=input("First name:") Last_Name=input("Last name:") Age=input("Age :") Date_Of_Birth=input("Date of birth:") Age_counter=2020-int(Date_Of_Birth) # I writted "2020" I know I made mistake I can take date with datetime() method #for example; I can write "datetime.datetime.now().year" instead of "2020" #but a...
937fe9dc33720d298c5b9e590857a5728ad73593
mrliuminlong/note
/process/process_pool/map_pool.py
213
3.5
4
# from multiprocessing import Pool import time def fun(n): time.sleep(1) return n**2 pool = Pool() #使用map函数将事件放入返回池 r = pool.map(fun, [1,2,3,4,5]) pool.close() pool.join() print(r)
74b9a196f8634e9ab70921492c47d240f6341cf3
mrliuminlong/note
/IO/http/http_server.py
1,211
3.734375
4
#对客户端请求的响应 respnse from socket import * #执行函数,处理客户端请求 def handle(connfd): print("Connet from.....",connfd.getpeername()) request = connfd.recv(4096)# 获取http请求 request_lines = request.splitlines()#请求按行切割 for line in request_lines: print(line)#打印http请求的每一行 # data = ''' HTTP/1.1 200 OK # Co...
f13a05153de64ea52ee3918f996992012d4a8c99
mrliuminlong/note
/practise/patial_function/partial.py
539
3.78125
4
#求100内的奇数 # L = [] # for x in range(101): # if x%2 == 1: # # print(x) # L.append(x) # print(L) # L = [x for x in range(101) if x%2 == 1] # print(L) # def myodd(n): # return n%2==1 # fill = filter(myodd, range(101)) # for item in fill: # print(item) # print([item for item in filter(lamb...
59d26c2e126c3bcedad6cb443c915f226f885340
mrliuminlong/note
/practise/file_tran/copy/copy_file.py
1,467
3.53125
4
''' 本例复制文件 复制的文件分为上下部分,分开复制 @liu 2019-01-30修改 星期三 离农历猪年差5天了 为什么父进程复制不上文件???/ ''' import os import time filename = "/home/tarena/aid1811/python_net/practise/file_tran/copy/image.jpg" #获取文件大小 size = os.path.getsize(filename) #创建进程 pid = os.fork() if pid < 0: print("error") elif pid ==0: #复制上半部分 f = open(file...
4db46449945403d3af3715fbdf6fe02d2c83a853
jatkin-wasti/python_SQL_movies
/movies_crud.py
8,384
4.03125
4
import pyodbc # Importing pyodbc to connect with and manipulate our database import pandas as pd # Importing pandas to handle the csv file import csv # Importing csv to handle the csv file in a better way # Creating our class which will store all of the functionality class Movies: # Method to connect to our da...
b50629cd8b99ec34f5c3d347c24b9096d999961a
buweiqiang/AutotestCornerstone
/common/sort_algorithm.py
5,840
4.125
4
#!/usr/bin/env python # -*- encoding: utf-8 -*- ''' @File : sort_by_insertion.py @Contact : buweiqiang@civaonline.cn @MTime : 2020-12-21 17:21 @Author: buweiqiang @Version: 1.0 @Desciption: 插入排序法思想:假设已经有一个有序序列,将未排序的数组,逐个个的插入到有序序列的合适位置 ''' import random import time def sort_forward(array: list): ''' 正序插入:假设第...