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
e40b47abda70e3c2b25384f1caab9a798ddeb787
songszw/python
/python小栗子/t115.py
107
3.75
4
filename = input('请输入要打开的文件:') f = open(filename) for each in f: print(each)
44aecd0b58d63e3dcb6d706e9649acca9e3ebb22
DjBehera/Back-to-bascis-Part-1
/linear_reg.py
1,684
4.0625
4
import numpy as np import matplotlib.pyplot as plt import pandas as pd def get_data(): dataset = pd.read_csv('50_Startups.csv') X = dataset.drop(['Profit'],axis=1) Y = dataset['Profit'] categorical_list = ['State'] normaliztaion_list = ['R&D Spend', 'Administration', 'Marketing Spend...
e5d16675da8804ce7216e84aad4302b151ed4ca2
aswathisadanandan/python-excises
/factorial.py
84
3.9375
4
n=int(input("Enter the value")) num=range(1,n+1) f=1 for i in num: f=f*i print(f)
fa14fa1bfe8cd70523721eb4a955676fbbfcad02
jeremycook123/amifind
/amifind/util.py
1,380
3.875
4
""" This module provides utility functions for filtering lists of images """ import re import exceptions def filter_object_list(list_to_filter, attr_to_filter, re_string): """ Apply a regular expression to the specified attribute of each item in the list, returning a list of items whose attributes match th...
1731b5f96a40376c033e58d313370636248850f8
BaiFree/mri_super_resolution
/dicom/pydicom_process1.py
2,817
3.515625
4
""" James Golden jamesgolden1@gmail.com Task 1 - data manipulation 1. Read all the DICOM files in a directory 2. Build a 3D volume (3D numpy array) by sorting against each file’s Slice Location DICOM tag in ascending order 3. Converting the data from the input data type to 32-bit float data type and normalize the 3...
eb20db22e7bc782011469803c470713b84a26ca9
vladisemen/EGe
/24.py
203
3.5
4
file = open("text.txt") f = file.readline() M = 1 m = 1 for i in range(len(f)): if f[i] == ")" and f[i + 1] == ")": m += 1 else: if m > M: M = m m = 1 print(M)
c39eeb521f160cc5258a62194fe08f8fcdd9c7ae
willpetroff/hackerrank
/contests/hr_euler/python/even_fib_sum_hr2.py
400
3.515625
4
test_cases = [] tc_num = int(input()) for i in range(tc_num): test_cases.append(int(input())) for test in test_cases: first_num = 1 last_num = 2 even_sum = 0 temp_sum = 0 while last_num <= test: temp_sum = first_num first_num = last_num if last_num % 2 == 0: e...
714ed3a7c28c2bb43d95158603dde9c930452723
willpetroff/hackerrank
/python/strings_py/mutations_3.py
223
4.09375
4
""" Change a character at a given index to a given character. """ given_str = input() given_index, given_char = input().split() given_str = list(given_str) given_str[int(given_index)] = given_char print("".join(given_str))
c87222971c5f02ed6b761125073c9852625fdcb5
willpetroff/hackerrank
/python/strings_py/splitjoin_2.py
110
4.0625
4
""" Split a given string on space, join to hyphen. """ given_str = input() print("-".join(given_str.split()))
a4db7fb169c06b76bcc76396da49558d8ded1cb0
rachidtahiri/mission_4
/Tahiri_najid_balla_mission_4.py
2,006
3.953125
4
def is_adn(s): """ fonction qui verifie si la chaine donné est une suite d'ADN """ k=0 tes=False for i in s: if i=="a" or i=="t" or i=="c" or i=="g" or i=="A" or i=="T" or i=="C" or i=="G" : k=k+1 if k==len(s) and k!=0: tes=True return (tes) def liste(S): """ ...
d1b42ba29286c929bbe4e7bb77d25d15eb992d9e
RRFHOUDEN/tut-asr-voicecommand
/exp60p/mkgraph.py
1,296
3.5
4
import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import argparse ''' this is a simple script for graph making, wrote by peng usage: python mkgraph.py -xl 'xlabel_name' -x x1 x2 ... xn -yl 'ylabel_name' -y y1 y2 ... yn -f 'save_file_name' or python mkgraph.py --xlabel 'xlabel_name' --xvalue x1 ...
b8c3d251e41f70c843322fe346cd9b2a98e63d74
jberkow713/TurtleGamePython
/Adjacency.py
2,175
3.609375
4
# def neighbors(matrix, rowNumber, colNumber): # result = [] # for rowAdd in range(-1, 2): # newRow = rowNumber + rowAdd # if newRow >= 0 and newRow <= len(matrix)-1: # for colAdd in range(-1, 2): # newCol = colNumber + colAdd # if newCol >= 0 and newC...
51bd69cedc6085ea8a6c214e29a591450db237c9
mabogunje/preschool-poker
/deck.py
886
3.890625
4
''' @author: Damola Mabogunje @contact: damola@mabogunje.net @summary: Defines the classes necessary for a deck of preschool poker cards ''' from random import shuffle; class Card: ''' A Preschool Poker Card ''' (ONE, TWO, THREE) = range(1,4); class Hand: ''' Preschool Poker Hand Rankings ...
613b7a4d590b10829cb273192170ce92e13e4837
linda-jemni/Python-Linda-Jemni
/jour1/multiple3.py
582
3.96875
4
<<<<<<< HEAD n = int(input("Quel est le nombre ?")) if (n%2 == 0): print("ce nombre est paire") elif ((n%2 != 0) & (n%3 == 0) ): print ("ce nombre est impair mais multiple de 3") elif ((n%2 != 0) & (n%3 != 0) ): print ("ce nombre n'est ni pair ni multiple de 3") ======= n = int(input("Quel est le nombre ?")) if (...
3db6fbcb14c16503f5c6dbddcba388cf25db73d1
Alilujian/Election_Analysis
/Python_Practice.py
2,825
4.3125
4
counties = ["Arapahoe", "Denver","Jefferson"] if counties[1] == 'Denver': print(counties[1]) counties_tuple = ("Arapahoe", "Denver", "Jefferson") counties_dict ={} counties_dict["Arapahoe"] = 422829 counties_dict["Denver"] = 463353 counties_dict["Jefferson"] = 432438 counties_dict.items() counties_dict.keys() cou...
7a862c1042a5298bf6e812daeb235c96b2960e85
SeanGrady/interview-practice
/add_two_numbers/add_numbers.py
2,701
3.796875
4
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def create_linked_list(self, number: int) -> ListNode: number_list = [int(char) for char in str(number)] number_list.reverse() head = ListNode(numbe...
5d87158a58331a662336f0bfcb6bcdf780eebc0a
digisnow/PythonTraining
/Algorithm_and_DataStruct_for_ProgrammingContest/Part3/ALDS1_2_C_Stable_Sort.py
1,133
3.765625
4
""" input n (ex: 5) input A (ex: H4 C9 S4 D2 C3) """ import copy class Card: def __init__(self, suit, value): self.suit = suit self.value = value def bubble(A, N): for i in range(N-1): for j in reversed(range(i+1, N)): if A[j].value < A[j-1].value: A[j], A[j...
bad39abb80b5062fda5e7a3bd7cf3a69b81c5009
Potatology/coding
/structures/stack.py
736
3.71875
4
class Stack: def __init__(self): self.items = [] def pop(self): return self.items.pop() def isEmpty(self): return self.items == [] def peek(self): return self.items[len(self.items)-1] def push(self, item): self.items.append(item) d...
e50a1e66287467e7f26c8d97328d214fe4306c45
Potatology/coding
/structures/tree_ex.py
605
3.765625
4
class Node(object): def __init__(self, val, left = None, right = None): self.val = val self.left = left self.right = right def buildTree(data): if data == []: return val = data.pop(0) root = Node(val) root.left = buildTree(data) root.right = buildTree(data) r...
d083266a89cc218c32d2fe738553ec6e829381e8
Potatology/coding
/bfs/avg_of_levelsin_bin_tree.py
950
3.703125
4
# 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: def averageOfLevels(self, root: TreeNode) -> List[float]: if root.left == None and root.right == Non...
fac2f824a994e43ca7e44017ccf1b68f4523b7fd
Potatology/coding
/sierpinsky.py
1,064
3.59375
4
from turtle import * myTurtle = Turtle() window = myTurtle.getscreen() def drawTriangle(points, color, myTurtle): myTurtle.fillcolor(color) myTurtle.up() myTurtle.goto(points[0]) myTurtle.down() myTurtle.begin_fill() myTurtle.goto(points[1]) myTurtle.goto(points[2]) myTurtle.goto(point...
20796c2837ddff636ef0ffa066aa736cc5aa4d7e
Potatology/coding
/search/dijkstra.py
1,104
3.53125
4
graph = { 'a': {'b' : 4, 'c': 5, 'd' : 6}, 'b': {'e': 7}, 'c': {'e': 4}, 'd': {'f': 4, 'e': 2}, 'e': {'f': 1, 'g': 3}, 'f': {'g': 1}, 'g':{} } processed = [] parents = { k: [] for k in graph.keys() } for p in graph.keys(): for c in graph[p].keys(): parents[c].append(p) print(pa...
c902574dec55bdd2a5a972476f5f1e2ac8b8a504
Potatology/coding
/balanced_parents.py
837
3.671875
4
# ((()))) class Stack: def __init__(self): self.items = [] def isEmpty(self): return self.items==[] def push(self, item): self.items.append(item) def pop(self): return self.items.pop() def peek(self): return self[len(self.items) - 1] def size(self): ...
b6231221bef08ed43b2da574c0a2014ae2a7c348
Potatology/coding
/structures/graph_matrix.py
1,661
3.640625
4
from random import Random def gen_rand_list(x): res = [] rand = Random() quot = x // 2 if x <=6 else x//3 for _ in range(x): res.append(rand.randrange(0,quot)) return res def gen_rand_matrix(x): matrix = [] for _ in range(x): matrix.append(gen_rand_list(x)) return matri...
7db23702dea5db264933ef74fe06d67a5dc0240d
tyronecheng07/Courses-Google-IT-Automation-with-Python-Specialization
/course 2 codes interacting with OS/week 5 try and except errors.py
1,374
4
4
#example 1 of raising errors def character_frequency(filename): """Counts the frequency of each character in the given file.""" #first try to open the file try: f = open(filename) except OSError: return None ### try exercute a code, if failed raises the error we mentioned and ...
803c2ce97d7627ef4a053501b689695e3677a19f
pnandini/DP-2
/pyton_recursive_22.py
2,510
3.890625
4
# Recursive Programming # 17/27 test cases passes # time complexity =O(2^N) #space complexity=O(N) class Solution(): def change(self, amount, coins): return self.helper_func(amount, coins,0) def helper_func(self, amount, coins, i): #basecase if (amount == 0 ) or (amount == ...
d5ed2a5b8c599a693c41178f7096995589fa4dc0
s290717997/Python-100-Days
/day1-15/day7/day7_5.py
657
4.25
4
#练习5:计算指定的年月日是这一年的第几天 days_of_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] def if_leap_year(year): if year % 400 == 0 or year % 4 == 0 and year % 100 != 0: return True else: return False def which_day(year, month, day): sum = 0 for i in range(1, month): sum += da...
6345237f6c931de78ab2d0831a8228159e1a386d
danmadrock/for_tinkoff
/sudoku.py
14,278
3.59375
4
import random import pickle class Sudoku(): def __init__(self, side): self.side = side def menu(self): print(f""" Добро пожаловать в консольную игру – Судоку! В данной игре Вам придется решить Судоку – головоломку с числами на доске 9х9\n """) ask_load = str(input("Хотите загрузить игру?(да/Enter): "...
631dc16bdb746e7e6abbc5cc8641e309451b4a67
jamesbing/machinelearning
/KNN/file2matrix.py
1,003
3.71875
4
#!/usr/bin/env python # coding=utf-8 # this code segment is used to transform the data in a txt file in to a numpy supported matrix. # @author james::lengjiabing@gmail.com from numpy import * def file2matrix(filename): fr = open(filename) numberOfLines = len(fr.readlines()) #get the number of lines in...
f8a098698b1cf7059da37a6a1a3f0e0ca46301f0
jamesbing/machinelearning
/pythonlearning/practiceClass.py
531
3.5625
4
class Song(object): def __init__(self, lyrics): self.lyrics = lyrics def sing_me_a_song(self): for line in self.lyrics: print line happy_bday = Song(["Happy birthday toy you", "I don't want to get sued.", "So I will stop right there"]) countr...
fe9957a124a4a24657a63c3af0b10c3f1bb936ea
daseyun/magic8ball.py
/magic8ball.py
132
3.734375
4
from random import randint print("Enter your question") a = input() if randint(0,9)%2 == 0: print("yes") else: print("no")
b4800f4c14b8643003fadd5bd3da447ea1f333cb
VictorDamian/Python
/Condicionales.py
372
3.859375
4
fruta = "kiwi" fruta = "manzana" if fruta == "2" : print("si es kiwi") elif fruta == "manzana" : print("es otra manzana") elif fruta == "manzana" : pass else : print("no es l") msj = "bien" if fruta == 'kiwi' else "no es" print(msj) #si no tiene valor, es falso valor = None valor_2 = 20 if valor or valor_2 > ...
7853d925d3a90619c930a0580df7246d5482c35d
BareMetalHacker/PythonTools
/tk_window_config.py
514
3.578125
4
import tkinter from tkinter import * win = Tk() frame = Frame(win) frame.pack() frame2 = Frame(win) frame2.pack(side=BOTTOM) lb = Listbox(win) lb.insert(1,'python') lb.insert(2,'rattler') lb.insert(3,'asp') rb = Button(frame,text='Red',fg='red') rb.pack(side=LEFT) gb = Button(frame2,text='Green...
1e2b8c6e2752b633e674492b21b44b766f9dc7c7
phamvanhanh6720/Application-Algorithm
/Training1/G_sms.py
449
3.515625
4
count_dict = {'a': 1, 'b':2, 'c':3, 'd': 1, 'e':2, 'f':3, 'g': 1, 'h':2, 'i':3, 'j': 1, 'k':2, 'l':3, 'm': 1, 'n':2, 'o':3, 'p': 1, 'q':2, 'r':3, 's':4, 't': 1, 'u':2, 'v':3, 'w': 1, 'x':2, 'y':3, 'z':4, ' ':1} n = int(input()) lines = [] for i in range(n): lines.append(input()) for i in range(n): line = lin...
0d1c38937681a73764e48625d6e2d5cb9aab6c0b
patrick-bedkowski/Path-Finding-with-Dijkstra-s-Algorithm
/graph.py
8,537
3.625
4
from typing import List from random import randint class Node: def __init__(self, _cost: int, _cost_from_start: int, _visited: bool = False): self.cost = _cost # cost of node self.cost_from_start = _cost_from_start # cost from the start self.visited = _visited # has this node been visite...
6bc9fbe78bc4552fadbb3815d559bc45f08064c0
joesavak/learn-python
/euler12.py
1,797
3.546875
4
def get_triang(n): triang=0 for i in range(1,n+1): triang+=i return triang def primes_sieve(index,limit): limitn = limit+1 not_prime = [False] * limitn primes = [] for i in range(2, limitn): if not_prime[i]: continue for f in xrange(i*2, limitn, i): not_...
25dec3b6a2cff0954ca1e4b9434e99d0f6f21c41
Ravjot03/Face-Detection
/Code/Face_circle.py
1,355
3.609375
4
# OpenCV program to detect face in real time # import libraries of python OpenCV # where its functionality resides import cv2 # load the required trained XML classifiers # https://github.com/Itseez/opencv/blob/master/ # data/haarcascades/haarcascade_frontalface_default.xml # Trained XML classifiers des...
e2defc1b4568b4f52e7c4ac3249d6a67e17275b6
Krashex/pl
/Chapter5/DaddyChooseGame.py
2,264
4.53125
5
pairs = {'Oleg': 'Petr', 'Artur': 'Denis', 'Ivan': 'Petr'} choice = None print(""" Type 1 - if you want to know smb's father's name Type 2 - if you want to add new pairs Type 3 - if you want to remove sm pair Type 4 - if you want to chang...
480459999ba72856ec55c4b4dffae0e8026ab96c
sneha-del/Amoha
/amoha.py
3,339
3.5
4
import pyttsx3 import datetime import speech_recognition as sr import pyaudio import wikipedia import webbrowser import os #import pywhatkit import cv2 import sys engine=pyttsx3.init('sapi5') voices=engine.getProperty('voices') #print(voices[1].id) engine.setProperty('voice', voices[1].id) def speak(aud...
87d9de1c1d938d8dee917daee41d40c24d5c5c30
timschei/vogsphere-vogsphere.42.fr-intra-2018-activities-piscine_python_django_day_01-tscheid
/ex05/all_in.py
848
3.734375
4
#!/usr/local/bin/python3 import sys def func(lis) : arg = " ".join(lis.title().split()) states = { "Oregon" : "OR", "Alabama" : "AL", "New Jersey": "NJ", "Colorado" : "CO" } capital_cities = { "OR": "Salem", "AL": "Montgomery", "NJ": "Trenton", "CO": "Denver" } if arg in cap...
3ea7f150cffb89f8a8f017be163e645dbc7547d3
RobinVogel/On-Tree-based-methods-for-Similarity-Learning
/treerank/binary_tree.py
4,077
4.125
4
""" Simple binary tree that splits the space. """ import numpy as np class BinaryTree: """Implements a very simple binary tree.""" def __init__(self, parent=None): # All attributes are used directly in the treerank implementations. self.left = None self.right = None self.dat...
a5f53103324bf4569b5810f9b4dea333a120a860
RobinVogel/On-Tree-based-methods-for-Similarity-Learning
/treerank/split_space/diag_sym_splitter.py
1,719
3.5625
4
""" Symmetric diagonal splitter. """ import numpy as np from .coordinate_splitter import CoordinateSplitter class DiagSymSplitter(CoordinateSplitter): """ Coordinate space splitter with symmetry and optional special diag that take into account the fact that we want it to keep a diagonal proper...
2f152f3790cb49a7d0e59b8a10dc720b9657de95
jeffreire/deep-learning-study
/Neural_Networks/Multilayer/Neural_net_output_binary.py
4,155
3.71875
4
import numpy as np import pandas as pd # class rede neural para aplicacoes simples class NeuralNetworks: def __init__(self, epocas, entrada, saida, peso, peso1, momento, taxa_aprendizagem): self.epocas = epocas self.X = entrada self.y = saida self.w = peso ...
646fac395ed89531b3dff5078248ff9e65a02823
rfrenoy/advent_of_code2020
/test_day1.py
1,149
3.625
4
import unittest from day1 import create_array, sums_to_value, find_values_adding_up_to_value class TestDay1(unittest.TestCase): def test_create_array_should_create_array_from_buffer_entries(self): # Given buff = '1\n2\n3' expected = [1, 2, 3] # When arr = create_array(buff)...
632144ea0c2dc95a6a87d20d642528339be71a52
wilcerowii/mtec2002_assignments
/class10/labs/exceptions.py
1,367
4.21875
4
""" exceptions.py ===== To handle errors, use a try/catch block: ----- try: # do your stuff except SomeError: # deal with some error ----- optionally... you can continue catching more than one exception: ----- . . except AnotherError: # deal with another error ----- Substitute SomeError with the kind of error yo...
35a5840cefcb5714b8db0232ca3652c478d2773b
riku-akira/Prac_App
/project2.py
649
3.78125
4
import os def valid(check, pass_check): try: check = int(check) print #os.system("color 0a") #print "Its a whole number" pass_check = False print pass_check return pass_check except: print os.system("color 0c" ) os.system("cls") print "Please enter a whole number" print ...
16b6caae1db7b7ba1ff718408d08d04cb0926a1f
faa678/coding
/part-time/迷宫寻路/迷宫寻路.py
6,949
3.671875
4
# -*- coding: UTF-8 -*- # animation.py # 导入需要的模块 import pygame, sys from pygame.locals import * import random import pygame_textinput # 初始化pygame pygame.init() textinput = pygame_textinput.TextInputVisualizer() # 设置帧率(屏幕每秒刷新的次数) FPS = 5 #import random pre_route=list() #宽度搜索得到的节点 q=list() #队列结构控制循环次数 xx=[0,...
375cbc3fb2e2d6608da9197c6a271170b0076710
rodrigoframa/curso-python
/estruturas_controle/if_else_1.py
721
4.09375
4
#!/usr/local/bin/python3 def conceito_nota(valor): nota = float(valor) if nota > 10: return 'Nota invalida' elif nota >= 9.1: return 'A' elif nota >= 8.1: return 'A-' elif nota >= 7.1: return 'B' elif nota >= 6.1: return 'B-' elif nota >= 5.1: ...
2f47d837f21adb75575c08e8e8f0412404a23ee4
davvy10/testing.academy
/bin/guess.py
329
3.859375
4
#!/usr/bin/env python3 print("myslim si cislo od 1 do 20") secret = 8 print(f"tajne cislo je {secret}") tip = input("tvoj tip: ") tip=int(tip) print(f"tvoj tip je: {tip}") if tip < secret: print(f"moje cislo je vascie ako tvoje") elif tip > secret: print(f"moje cislo je mensie ako tvoje") else: print(f"...
90952d5c964ca74bb1c221b4cf93395799f1f564
jbrownxf/mycode
/wk1proj/gotime2
1,544
4.1875
4
#!/usr/bin/env python3 #imports import random #This is a board game. Every player rolls a dice from 1-12 first to 100 wins #By Josh Brown from random import randint #ask for number of players, creates a dic for every player num_player = input("How many will be playing Dicequest?(2-6 players) ") num_players =int(num...
1b6c4156e645bf1557794e15d8c3a038371f2969
jbrownxf/mycode
/mix-list2/mix-list2.py
813
3.84375
4
#!/usr/bin/env python3 #Lab 9 more list business proto = ['ssh', 'http', 'https'] protoa = ['ssh', 'http', 'https'] #print(proto) #proto.append('dns') # this line will add 'dns' to the end of our list #protoa.append('dns') # this line will add 'dns' to the end of our list #print(proto) proto2 = [ '22', '80', '443', '5...
862c2f92123eb1a3fe2dc5e38b64c35c682bbd23
LinusBF/kth-projects
/python/ackerman.py
611
3.828125
4
#! pyhton3 Ackerman function from datetime import datetime def ack(m, n): ans = 0 if m == 0: ans = n + 1; elif n == 0: ans = ack(m - 1, 1) else: ans = ack(m - 1, ack(m, n - 1)) return ans if __name__ == '__main__': print("Starting at " + str(datetime.now())) for ...
61afea5b84d577e8747770df03cf3cdf55508ef4
gwacter-zz/nwen241-python-automarking
/assignment2.py
4,770
4.40625
4
def add_vectors(vector_1, vector_2): """Returns a list object representing the result of adding two vectors together. Arguments: vector_1 -- list representing first vector vector_2 -- list representing second vector Error checking: Both arguments must be of type list. Bot...
bf97435a43ef312fe9409685d98167a92d9d7b77
sulyi/multivariate-hypergeometric
/mvhgd/core/grid.py
2,794
3.90625
4
from .draw import Draw from .level import Level class Grid ( object ): """ A generator enumerating Levels of Draws, see also there. """ __slots__ = [ 'algorithm', 'root', 'roof', 'm', '_generator', '_len_tab', '_iroot' ] def __init__( self, algorithm, supremum=[] ): self.algorithm = algo...
a3e73a270e980b508b3380a7318593e243316b35
laerson-hammes/bar-code-validator
/bar-code-validator.py
994
3.6875
4
def get_division_of_ten(result): for number in range(0, 10, +1): aux = result + number if aux % 10 == 0: return aux def validate(digit, code): if int(digit) == int(code.pop()): print(f"[+] {True}") else: print(f"[-] {False}") def validation(code): first = 0 ...
7d4e17d25cbb3fc7a0f06e2cc217190dc256da73
bazwilliams/gpsutils
/distance.py
577
3.53125
4
# Author: Barry John Williams # Creative Commons Attribute-Share Alike 2.5 UK:Scotland Licence import sys,math a1 = math.radians(float(sys.argv[1])) b1 = math.radians(float(sys.argv[2])) a2 = math.radians(float(sys.argv[3])) b2 = math.radians(float(sys.argv[4])) radius = 3963.1676 # Taken from http://www.mathforum....
0aee81c8f52ed4f78213b5329dec8c105c849fdd
sslockk/Ai_data_structure_base_main
/Lesson06/L06_work01.py
4,869
4
4
# 1. Подсчитать, сколько было выделено памяти под переменные в ранее разработанных программах в рамках первых # трех уроков. Проанализировать результат и определить программы с наиболее эффективным использованием памяти. import random from collections import Counter import sys def max_stolb_element(): """Програм...
08149998cd9cce86974db63c61d99de6efd903cd
sslockk/Ai_data_structure_base_main
/Lesson02/L02_work_02.py
499
3.65625
4
num = int(input('Введите натуральное число')) i = 0 v = 0 n = 2 chet_num = '' non_chet_num = '' while num != 0: n = num % 10 num = num // 10 if n % 2: # if n !=0: i += 1 non_chet_num += f'{n}' else: if n != 0: v += 1 chet_num += f'{n}' print(f'Ко...
6d2ace80756a8562f3105ae2e86873db8e40e02e
adnanhanif793/Python-Codes
/50 Python codes/PossibleCombinations.py
591
4
4
''' Created on 12-Dec-2019 @author: adnan.hanif ''' #Program to accept 3 distinct digits and print all possible combinations from the digits #Same can be used for string with some changes a=int(input("Enter first digit")) b=int(input("Enter second digit")) c=int(input("Enter third digit")) d=[] if(a!=...
b72374adfc79285a4a2d8bcbcd6cc0c1c662dc76
adnanhanif793/Python-Codes
/50 Python codes/DigitSum.py
206
4.0625
4
''' Created on 09-Dec-2019 @author: adnan.hanif ''' #Sum of digits n= int(input("Enter a number")) tot=0 while n>0: dig=n%10 tot+=dig n=n//10 print("The sum of digits is",tot)
8d0562f201051d917c6e66ae31e6922972c65f8f
adnanhanif793/Python-Codes
/50 Python codes/Table.py
145
3.84375
4
''' Created on 09-Dec-2019 @author: adnan.hanif ''' n=int(input("Enter a number")) for i in range(1,11): print(n,"*",i,"=",i*n)
f745f56706575fc6f3e565b026029103c51cca4a
adnanhanif793/Python-Codes
/Basic/com/Anagram.py
448
4.1875
4
''' Created on 18-Mar-2019 @author: adnan.hanif ''' def check(s1, s2): # the sorted strings are checked if(sorted(s1)== sorted(s2)): print("The strings are anagrams.") else: print("The strings aren't anagrams.") # driver code n=int(input...
d8d42bfd809fc298c7ea2d721dd1bf60d9be208d
shivanii10/python
/break_continue.py
114
3.65625
4
while True: line=input('>') if line == 'done' : break print(line,' input printed') print('Done!')
3043d49c09e87ff59adc9386745996dbfeccf057
jonalynnA-cs29/Intro-Python-I
/src/05_lists.py
2,269
4.53125
5
# For the exercise, look up the methods and functions that are available for use # with Python lists. ''' Python List append() Add a single element to the end of the list Python List extend() Add Elements of a List to Another List Python List insert() Inserts Element to The List Python List remove() Removes item fro...
9614b7ab3ad161aebeb6506c911e353fb7ee9ad6
TiagoCaldaSilva/FEUP-FPRO
/RE05/palindrome(RE05).py
1,146
3.78125
4
def palindrome(astring): count = 0 if len(astring) == 1: return "The string {} contains {} palindrome substrings." .format(count, astring) else: #começar por vr 2 a duas se são iguais ind = 0 for i in astring[:len(astring) -1]: if i == astring[(ind + 1)]: ...
aab8523d0a008acfcf9c374f688162322a97b7ac
Alferdize/15000
/Problem_#00001_bisect.py
649
3.578125
4
from bisect import bisect_left arr = [10, 15, 3, 7] k = 17 def two_sum(): arr.sort() for i in range(len(arr)): target = k - arr[i] j = binary_search(arr, target) if j == -1: continue elif j != i: return True elif j + 1 < len(arr) and arr[j + 1] ...
698c957da6315ef6124c57ca3b22aa7a6776df0b
nshattuck20/Data_Structures_Algorithms1
/ch9/9-1.py
630
4.59375
5
''' Section 9-1: Recursive Functions ''' #Example of recursive function #I used the code from the animation example in the course material def count_down(count): if count == 0: print('Go!') else: print(count) count_down(count -1) count_down(2) # recursively call count_down 3 tim...
efcb7864f7ec7260c361402910aea5a5b9cbb091
nshattuck20/Data_Structures_Algorithms1
/ch8/8-6.py
347
4.46875
4
''' 8-6 List Comprehensions: Form: new_list = [expression for name in iterable] 3 components: 1. The expression to evaluate each iterable component 2. A loop variable to bind to the components 3. An iterable object ''' #Example my_list = [5, 10, 15] my_list_plus5 = [(i + 5) for i in my_list] print('New list...
17786b5a311cfbb8e4c2e56f7bf0e9ce35e9269a
nshattuck20/Data_Structures_Algorithms1
/ch9/9-5-1.py
874
4.40625
4
''' 9-5-1 Write a program that outputs the nth Fibonacci number, where n is a user-entered number. So if the user enters 4, the program should output 3 (without outputting the intermediate steps). Use a recursive function compute_nth_fib that takes n as a parameter and returns the Fibonacci number. The function ha...
e881a6985c9fbbb2ffa32146866285e7b89f96af
nshattuck20/Data_Structures_Algorithms1
/Chapter5/5.5/membership_operators.py
992
4.09375
4
''' Data Structures and Algorithms 1 This unit goes into detail about: -membership operators -identity operators -identity operators vs relational operators ''' ''' Membership operators -Two membership operators #1. in #2. not in ''' ####Uncomment below to run the code##### ''' #Check if a c...
148c9c7ffecb1938db146f2c7e263e82bdfb741e
nshattuck20/Data_Structures_Algorithms1
/Chapter4/4.9/dictionary_basics.py
451
4.34375
4
''' Simple program demonstrating the basics of Dictionaries. ''' players = {'Lionel Messi' : 10, 'Cristiano Ronaldo' : 7 } print(players) #Accessing an entry uses brackets [] with the specified key print('The value of this player is :' + str(players['Cristiano Ronaldo'])) #Editing the value of an entry ...
dbff31c97e8f62da8e4642b1301a6466354a854c
nshattuck20/Data_Structures_Algorithms1
/ch7/7-4.py
446
3.65625
4
''' The main takeaway from this section is that there are two types of instances: 1. Class 2. Instance Class instances are like factories that produce instance level instances. Objects contain two types of attributes 1. Class attributes - visible to all instances 2. Instance attributes - visible only to that insta...
1fa915224e3880af57d0012bd843a6d76dc184ad
nshattuck20/Data_Structures_Algorithms1
/ch7/7-7.py
1,097
4.71875
5
'''Class customization * Referes to how classes can be altered by rhe programmer to suit her needs. * _str_() changes how to print the output of an object ''' class Toy: def __init__(self, name, price, min_age): self.name = name self.price = price self.min_age = min_age truck = Toy('Monster Truck ...
cdddcec194bbb01b91d42d936b6cf97bd6edc182
nshattuck20/Data_Structures_Algorithms1
/ch8/8-10.py
1,792
4.78125
5
''' 8-10: Nested dictionaries (Dictionaries within dictionaries) ''' # To declare a nested dictionary, do the following: students = {} # empty dictionary ''' #Create indexing operation with key 'John and value of another dictionary' print('John:') ###EXAMPLE#### ''' # students['John'] = {'Grade' : 'A+' , 'StudentID'...
1b687ab3dadc30588e953c7dad8e9d72f3185aed
nshattuck20/Data_Structures_Algorithms1
/ch13/HashTables/linearprobinghashtable.py
3,178
3.640625
4
# class to represent an empty bucket class EmptyBucket: pass # HashTable class definition using linear probing class LinearProbingHashTable: # Constructor with optional initial capacity. All buckets are # assigned with an EmptyBucket() instance called self.EMPTY_SINCE_START. def __init__(self, initi...
e186b3cd4a2563c77c9759c295d1d1dda441d911
ayeshaaamir/discrete-assignment1-63687
/fast_expo.py
263
3.921875
4
def expo(x, y, e) : res = 1 x = x % e while (y > 0) : if ((y & 1) == 1) : res = (res * x) % e y = y >> 1 x = (x * x) % e return res x = 3; y = 6; e = 14 print("Expo is ", expo(x, y, e))
4215974597e94fd94ca2079cd3d7cf41cccd544e
malachyenglish1/python-practice
/practice4.py
248
3.859375
4
from random import randint print (randint(1,6)) ''' Finding the average of 10,000 rolls of a dice ''' i = 0 for trials in range(0,10000): j = (randint(1,6)) i = i + j print("Total = ", i) print("Average = ", i/10000)
749979c042cf6df3dd7c34f16dd0a506fd4147f8
bsfraga/prog-web
/pessoa.py
963
4.25
4
class Pessoa: ''' Objeto pessoa e seus atributos. Objeto pessoa projetado para guardar em apenas um instância uma lista de ocorrencias do objeto Exemplo: list_pessoa: [ { 'nome':'ABCDE', 'idade':33, }, ... ] ''' def __init__(self): ''...
a9f682d674b39ca7bb8629ed7f9c9b0a4f4be11d
jj2249/maths
/single_pendulum.py
2,823
3.625
4
from math import * from tkinter import * from time import sleep class Pendulum(Tk): def __init__(self, m, a, r, omega): Tk.__init__(self) self.grid() self.m = m self.r = r self.a = a self.omega = omega self.play = True self.background = Frame(self) ...
fec2780da961048d328879778cce38e7aefcb48f
surbhandari/IORA
/scripts/compareHeader.py
1,628
3.53125
4
#!/usr/bin/python import psycopg2 as pq import re import getpass #cn = pq.connect('dbname=mydb user=postgres') #dataBase = raw_input("Enter the database name :") #usr= raw_input("Enter the User :") #host= raw_input("Enter the host :") #passwd= getpass.getpass('Password :') #conn = pq.connect("dbname="+dataBase+" us...
1769097f072cba6365ef5d2757f18eeb1e322ed3
DenZ0/-5
/Лабораторная 5/database.py
1,868
3.703125
4
import sqlite3 conn = sqlite3.connect('database.db') c = conn.cursor() c.execute("DROP TABLE books;") c.execute("CREATE TABLE books (id int auto_increment primary key, author varchar, title varchar, genre varchar);") lines = [["Есенин","Письмо к женщине", "Художественное произведение"], ["Есенин", ...
05899178a28cefced87990d6c3625b8e6e221420
bapi24/py4e
/data_structures/tuples/sort_tuples.py
986
4.03125
4
''' 10.2 Write a program to read through the mbox-short.txt and figure out the distribution by hour of the day for each of the messages. You can pull the hour out from the 'From ' line by finding the time and then splitting the string a second time using a colon. > From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 20...
9d294cd59ffe7934fdb4a7905e01690682413a8f
alex4reg/lesson1
/ld.py
3,005
3.96875
4
# phones = ['iPhone Xs', 'Samsung 10s','Xiaomi Mi8'] # print(phones) # phones_count = len(phones) # print(phones_count) # phones.append("iPhone 6") #добавить элемент, в конец списка # print(phones) # # подсчитать количество элементов в списке # print(phones.count("iPhone Xs")) #1 # print(phones.count("iPhone 9")) #...
b6428b43690c505dcb57fd1b7c07f23981a092c5
zpolina/pcombinators
/pcombinators/util.py
553
3.546875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu May 23 22:34:33 2019 @author: lbo """ import time def time_it(f): def f_(*args, **kwargs): before = time.time() r = f(*args, **kwargs) print(f, time.time()-before) return r return f_ def remove_unused_whitespac...
bd2bbcfb0007183a167fd04b705d3696b7df5c30
Timvrakas/FloridaVotes
/results/parse.py
2,235
3.53125
4
import csv import pandas as pd import logging from county_code_conversion import ocd_to_name def printData(data): for county,races in data.items(): print(county+":") for race,parties in races.items(): print(" "+race+":") for party,votes in parties.items(): ...
d48d39a3842a8e76affdb7ddbd62273b0976f25f
naklic0der/Git_learn_repo
/for_loops.py
146
3.5
4
print('intentionally modified') for x in range(3): print('I am in loop') print('done with for loops') print('wait what about while loops')
d1862b9afa74f4db7bf95365ee9e2123cadf53c3
sammul/CCYPProject
/tokenize.py
937
3.828125
4
#-*- coding: UTF-8 -*- ''' Created on Oct 23, 2014 @author: Wu Xia ''' import sys import re def main(): reload(sys) sys.setdefaultencoding('utf8') fn = sys.argv[1] #dict_name f = open(fn,'r') dic = set() for line in f: line = replace(line) dic.add(line) f.c...
906a5fdf384a4825b3cfa126777f35b9d1cb0b4c
mattprodani/letter-box
/Dictionary.py
1,049
4.15625
4
class Dictionary(): def __init__(self, dictionary, gameboard): """ Builds a dictionary object containing a list of words as well as groups them into a Dictionary separated by starting letter, where starting letters are in gameboard. """ wordList = [] self.wordGroups = {} ...
12193c9edbaa59025c4784d2759f6a3eab8e3e69
CB987/dchomework
/Python/Python104/nToMFor.py
109
3.796875
4
n = int(input("Start from: ")) m = int(input("End on: ")) count = n for count in range(m): print(count)
e0638d35fea87b4176d06cc0e33f136a805b7554
CB987/dchomework
/Python/Python104/blastoff3.py
237
4.1875
4
# countdown that asks user where to start n = int(input("From what number should start our countdown?")) #getting user input while n >= 0: #setting end condition print(n) #instructing to print number n -=1 #incrementing downwards
0102cb82b5896f07f46d8278346b9b4937ec9468
CB987/dchomework
/Python/Python109/crpg.py
1,905
3.9375
4
class Character: def __init__(self, name, health, power): self.name = name self.health = health self.power = power def attack(self, other): other.health -= self.power print("The %s has done %d damage to the %s." % (self.name, self.power, other.name)) if self.hea...
59c6d6de128a455c43a756ff527d25ce053e15ca
CB987/dchomework
/Python/Python104/blastoff2.py
365
4.4375
4
# create a countdown from 10 to 0, then prints a message n = 10 #start point of countdown while n >= 0: # set duration of countdown print(n) #printing the number n -=1 #Incrementing down, sends back up to print. loops until condition is false if n < 0: #instructing when to print the message print("M...
fe5cbb6020186299cbc4a68201b4b32c37939dd8
CB987/dchomework
/Python/Python108/Game of Thrones exercises/got6.py
342
3.546875
4
#What actor plays "Hot Pie" (and don't use IMDB)? from characters import characters for actors in characters: if actors["name"] == "Hot Pie": print(actors["playedBy"]) break with open("got6.txt", "w") as got6: got6.write("In the acclaimed HBO series, the character of \"Hot Pie\" is played...
9f2ffc8e3e7a874efb9d8192b20109f9b642c1fe
CB987/dchomework
/Python/Python103/degreeConversion.py
169
4.125
4
celsius = float(input("What is the temperature in degrees Celsius?")) fahrenheit = (celsius*9/5) + 32 print("The temperature is %.1f degrees Fahrenheit" % (fahrenheit))
6bb9de9e4a114d63f5135a92c7270c2bc99c1082
alisheryuldashev/playground
/Python/telephone-book.py
411
3.796875
4
#this snippet shows arrays in Python and prompts for your name to output this message: "calling, [your name]". import sys #import custom functions from CS50 library used in Harvard Introduction to Computer Science course. from cs50 import get_string book = [ "a", "b", "c", "d", "e", "f", ...
f675d32ecf2cf6d0afef4b975674d4adfdfd0bb2
alisheryuldashev/playground
/Python/classes.py
780
4.4375
4
#this snippet shows how to create a class in Python. #this program will prompt for information, append same into a class, and output a message. #create a class called Student class Student: def __init__(self,name,dorm): self.name = name self.dorm = dorm #import custom functions from CS50...
d56bdfbf76c0cbbce6c42a98844db12474e9c51b
Sandhie177/CS5690-Python-deep-learning
/ICP3/symmetric_difference.py
610
4.28125
4
# -*- coding: utf-8 -*- #A={1,2,3,4} #B={1,2} def list1(): n=eval(input("How many numbers do you have in the list?")) #takes number of elements in the list i=0 list1={0} #creating an empty set list1.remove(0) for i in range(n): x=int(input("enter a number\n")) list1.add(x) #adding ne...
015efad385e902e83ba1d21e2e4e7bf86d29a5a2
Sandhie177/CS5690-Python-deep-learning
/Assignment_1/Assignment_1c_list_of_students.py
1,271
4.4375
4
#Consider the following scenario. You have a list of students who are attending class "Python" #and another list of students who are attending class "Web Application". #Find the list of students who are attending “python” classes but not “Web Application” #function to create list def list1(): n=eval(input("Studen...
05dff7ea13a2d8bc8e5aeb714974bd24a9045cfb
Sandhie177/CS5690-Python-deep-learning
/Assignment_3/Assignment_3_problem_2.py
2,316
3.546875
4
#Implement Logistic Regression with any data set of your choice. #a. Show the graph in TensorBoard. #b. Show the Loss in TensorBoard. #c. Use score = model.evaluate (x_text,y_test) and then print (‘test accuracy’, score[1]) to print the accuracy. #d. Change three hyperparameter and report how the accuracy chang...
8d1080d06bdcb3cb4b16f93d439888be2497ba0b
ngrant7/110Project
/python projRECENT.py
3,543
4
4
''' READ THIS: Jeanna, This is a basic version of Hangman that I did today. It has no GUI components and still needs a few things to be added before we move to the GUI issues. I should note that I will not have time to work on this tomorrow (Saturday). \ If you do have time, here are some things you could work on: ...