blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
2da7bde88eade16264f44da084e65deaf5e09983
devnandans/Coding-Practice
/16.py
704
3.703125
4
#User function Template for python3 # https://practice.geeksforgeeks.org/problems/doubling-the-value4859/1/?difficulty[]=-1&page=1&query=difficulty[]-1page1# class Solution: def solve(self,n : int, a : list, b : int): # Complete this function for i in range(n): if a...
9b25c1ebf09f4a9812f986c6a4228233e2969034
Darja-p/python-fundamentals-master
/Labs/13_aggregate_functions/13_03_my_enumerate.py
387
4.25
4
''' Reproduce the functionality of python's .enumerate() Define a function my_enumerate() that takes an iterable as input and yields the element and its index ''' def my_enumerate(sequence, start=0): n = start result = [] for elem in sequence: # yield n, elem result.append((n,elem)) ...
2462bd608102c505a93f10343ba6294d226e6795
wookim789/baekjoon_algo_note
/동빈좌/tip/list/comprehension.py
424
3.90625
4
list_comprehension = [ x for x in range(10)] print(list_comprehension) list_comprehension = [ [x,y] for x in range(10) for y in range(2)] print(list_comprehension) list_comprehension = [ x for x in range(10) if x % 2 == 0] print(list_comprehension) list_comprehension = [ x for x in range(10) if x % 2 == 0 if x % 3 =...
48449fb6a2e629429ceadcd0e996c3d0855e33f4
Moussaddak/holbertonschool-higher_level_programming
/0x0A-python-inheritance/2-is_same_class.py
279
3.71875
4
#!/usr/bin/python3 ''' Documentation of Method is_same_class ''' def is_same_class(obj, a_class): ''' is_same_class is a method that checks if an object is an instance of a given class''' if type(obj) == a_class: return True else: return False
85e2551aa448f79a810b20b5cb2cc0e8211dddcb
GlaucoPhd/Python_Zero2Master
/PDFsWithPython214.py
712
3.625
4
# PDF is a Binary file and to read it we use rb # Count number of pages import PyPDF2 # Tell how many pages its on the PDF # with open('twopage.pdf', 'rb') as file: # reader = PyPDF2.PdfFileReader(file) # print(reader.numPages) # Tell all the objects it has the PDF # with open('twopage.pdf', 'rb') as file: # ...
731721d021acb735aa82f7034f15b36e6bac43c3
fseimb/moviebot-1
/moviebot/core/shared/utterance/utterance.py
2,177
3.84375
4
"""Utterance classes ======================= Classes that contain basic information about the utterance. """ from typing import Text, List, Dict, Any from abc import ABC import datetime from moviebot.nlu.text_processing import Token, Tokenizer class Utterance(ABC): """This is an abstract class for storing utter...
29bc1e2e6b4c555d44733a50dacff92c28941866
RashakDude/codechef_ps
/DSA Learning/Complexity Analysis + Basic Warmups/lAPIN.py
240
3.609375
4
for _ in range(int(input())): x = input() s1 = x[:len(x)//2] if len(x) % 2==0: s2 = x[len(x)//2:] else: s2 = x[len(x)//2+1:] if sorted(s1) == sorted(s2): print("YES") else: print("NO")
e7731e7039d5a7951363d6b10740221348961ab2
Sabbir2809/Python-For-Beginners
/Week1-Introduction/variables_and_assignment_statements.py
807
4.03125
4
# Variables and Assignment Statements x = 7 y = 3 print(x+y) total = x+y print(total) name1 = "Sabbir" name2 = "Shorna" print(name1, name2) print("\n") # Types x = 10 print(type(x)) x = 10.5 print(type(x)) x = "Sabbir" print(type(x)) print("\n") # Arithmetic operators multiplication = 7 * 4 print(multiplication) ...
74943c7131e864c098d06cbeb904751bed7c398e
MattCrook/python-book1
/lists/planet_list.py
1,066
3.859375
4
planet_list = ['Mercury', 'Mars'] planet_list.append("Jupiter") planet_list.append("Saturn") # ['Mercury, Mars', 'Jupiter', 'Saturn'] # print(planet_list) planet_list.extend(["Uranus", "Neptune"]) # print(planet_list) # ['Mercury, Mars', 'Jupiter', 'Saturn', 'Uranus', 'Neptune'] planet_list.insert(1, "Venus") plane...
eb7ed6cc5a52ac7415cd467f9d85fb511692fc90
mititer/python-study
/list3.py
562
4
4
data = [3, 5, 4, 6, 2, 2, 6, 4, 4, 4] def frequency_sort(data): dict = {} result = [] # count the frequency and save in dict dictionary for item in data: print(item) n = data.count(item) if not dict.get(item): dict.update({item: n}) # sort the dict...
2ebbedc3687b5f7a45b9039b2f8805a2f751bf85
koltpython/python-exercises-spring2020
/section3/solution/nerdySanta-solution.py
515
4.15625
4
age = int(input("Ho ho hooo! What is your age?:")) isPrime = True while age > 0: if age == 1: print("Sorry, I don't have a gift for you") else: for number in range(2, age): if age % number == 0: print("Sorry, I don't have a gift for you") isPrime = Fa...
1c644a78a4f6585294b217aa12158b890eaf54df
menglaili/Lidar_filter
/run.py
1,167
3.5625
4
from filter import range_filter, median_filter # from filter_withnp import range_filter, median_filter import argparse parser = argparse.ArgumentParser() parser.add_argument("--filter", "-f", help="filter type: 'r' for range and 'm' for median") args = parser.parse_args() if args.filter: if args.filter == 'r': ...
2baf917e5e3b6a18be43d838045aae429c9ddc89
jahumphr/Word-Search-Generator
/__main__.py
9,567
3.609375
4
# ============================================================================= # Word Search Generator Main # Created by Josh Humphries May 2020 # # GUI for WordSearch.py # Created in PyQt5 # ============================================================================= from PyQt5 import QtCore, QtGui, QtWidgets fro...
c423abe29e99d2df62b5c0b6cbd192c07ed6ff26
bencripps/euler
/python/6.py
353
3.59375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Author: ben_cripps # @Date: 2015-01-03 14:06:53 # @Last Modified by: ben_cripps # @Last Modified time: 2015-01-03 14:29:44 import math sum_of_squares = math.pow(reduce(lambda x,y: x+y, range(101)), 2) square_each = sum([math.pow(x, 2) for x in range(101)]) print(a...
b9daa162cf130db481ff0e2dcd9f0aebc0861acc
OhMesch/Algorithm-Problems
/48-Rotate-Image.py
1,059
3.9375
4
''' You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Note: You have to rotate the image in-place, which means you have to modify the input 2D matrix directly. DO NOT allocate another 2D matrix and do the rotation. ''' class Solution(): def rotate(self,arr): n=le...
3588b9081e58db0c2c416b8248d1a7812f88c7e9
Yue1Harriet1/GA-Data-Science
/Lab_20140910_Dictionaries.py
1,783
3.5
4
#Lab: Data Munging - Dictionaries import requests import csv web_request = requests.get('http://archive.ics.uci.edu/ml/machine-learning-databases/adult/adult.data') web_data = web_request.text #1. Get count of each instance of education (index 3) reader = csv.reader(web_data.splitlines()) EdDict = {} for row in rea...
4d860740ad16d4600f04a14ef81a384275f64a3d
gschen/sctu-ds-2020
/1906101031-王卓越/作业.py/20200301-text/选做-01.py
460
3.9375
4
# 6. (使用def函数完成)编写一个函数,输入n为偶数时,调用函数求1/2+1/4+...+1/n,当输入n为奇数时,调用函数1/1+1/3+...+1/n from fractions import Fraction def method(n): sums=0 if n%2==0: x=2 while x<=n: sums+=Fraction(1,x) x+=2 return sums else: x=1 while x<=n: sums+=Fracti...
ff7a815562be05eb391c00c5e77680844d3aba4b
Hikky-8man/SixthForm-Python
/streetly work/sorting/Sorting and searching pyglet/sortingAndSearching.py
12,153
3.671875
4
#The sorting and searching program but with a GUI #Date created: 10/03/2021 import pyglet from pyglet.window import key from pyglet.window import mouse class Window(): def __init__(self,width,height): self.window=pyglet.window.Window(width,height) self.batch=pyglet.graphics.Batch() ...
44b5ced3205ab981957c4a67d858138dd6018501
admarko/TicTacToe
/TicTacToe.py
7,327
4.25
4
''' Simple Tic Tac Toe game that lets users play in Terminal vs. 3 different AIs By Alex Markowitz github.com/admarko/TicTac/Toe Last Modified January 2019 ''' import random ############################# #### Board Class #### ############################# class Board: def __init__(self): self.game_board = [["-","-"...
95517cca4648410eed392796931934ae062ab4cf
listenzcc/kata_trainings
/Counting_Change_Combinations.py
1,490
4.1875
4
# code: utf-8 ''' Write a function that counts how many different ways you can make change for an amount of money, given an array of coin denominations. For example, there are 3 ways to give change for 4 if you have coins with denomination 1 and 2: 1+1+1+1, 1+1+2, 2+2. The order of coins does not matter: 1+1...
d47db1504e51fe3ac705bdc423d881a587e3e97f
Aasthaengg/IBMdataset
/Python_codes/p03998/s585111124.py
388
3.625
4
a=list(input()) b=list(input()) c=list(input()) order='a' while True: if order=='a': if len(a)==0: print('A') break else: order=a[0] a=a[1:] elif order=='b': if len(b)==0: print('B') break else: order=b[0] b=b[1:] elif order=='c': if len(c)==0: ...
adde0602c9bb25855809b05b56e30ab25a81490f
pasharik95/PythonTasks
/PracticalWork#1/task1.py
3,759
3.875
4
#!/usr/bin/env python """ Python. Practical Work #1 This code allows to send packages from input file to addressant(output file) """ END_PACKAGE = "end" FILENAME_EXTENSION = ".txt" # Addressants IVASYK = 'I' DMYTRO = 'D' OSTAP = 'O' LESYA = 'L' #...
f1e8a40404f58f979a280cf0eedb200b12397e85
evafengan/python06
/07/0702.py
3,273
3.59375
4
# import logging # from time import sleep, ctime # # # """单线程启动""" # #调用日志 # logging.basicConfig(level=logging.INFO) # # #设置2个线程 # def loop0(): # logging.info("start loop0 at " + ctime()) # sleep(4) # logging.info("end loop0 at " + ctime()) # # def loop1(): # logging.info("start loop1 at " + ctime()) # ...
c53e0d7ba455cc35b370c421e011a775a33d5d00
Vinayak7103/Text_Mining_Assignments
/Text_Mining_1.py
4,399
3.734375
4
#!/usr/bin/env python # coding: utf-8 # # Text Mining 1 # ### TASK: NATURAL LANGUAGE PROCESSING (TEXT MINING) # Perform sentimental analysis on the Elon-musk tweets (Exlon-musk.csv) # # IMPORTING LIBRARIES # In[1]: import numpy as np # linear algebra import pandas as pd # data processing, CSV file I/O (e.g. pd...
7e6120ee8b5d7ea063b553d902279bbe6bcaeb19
lkuehnl1/TextGame
/weapon.py
1,109
3.984375
4
#!/usr/bin/python # ------------------ Base class Weapon -------------------------------- class Weapon: def __init__(self, ammo = []): """ Baseclass Weapon Ammo: could have multiple types of ammo for one weapon """ self.ammo = ammo def desc(self): """ ...
96041da89b640b176e58ccc37309bd6dad18f76c
mostafa-asg/Algo
/geeksforgeeks/string/reverse-words-in-a-given-string/solution1.py
348
3.59375
4
def main(): test_case = int(input()) for t in range(test_case): sentence = input().split(".") for i in range(len(sentence)-1, -1, -1): print(sentence[i], end="") if i > 0: print(".", end="") else: print("") if __name...
d30d99322e41d9b590a802d695bfa893dc5cea6d
highlylea/python_skku
/1st/c_to_f.py
603
4.28125
4
""" 1차시도_두줄연습 temperature=float(input("This program converts Celsius to Fahrenheit. Celsius:")) print("It is", temperature*9/5+32, "in fahrenheit.") 2차시도_한줄연습 print('It is {}°F.'.format(float(input('This program converts Celsius to Fahrenheit. Celsius:'))*9/5+32)) #3차시도_함수연습_ def ctof(): c = float(input("섭씨 온도를 ...
4b633fbac37b0fb7cd71133ea7a8d7cbb53a5abd
NewMountain/algo_practice
/chapter_10/10_2.py
872
4.15625
4
"""Chapter 10: Sorting and Searching. Question 10.2""" # Create a sorting function such that anagrams are next to each other from collections import Counter test_data = [ "tar", "rat", "redrum", "study", "murder", "elbow", "below", "cider", "dusty", "cried", "fizz", "bu...
0f6e88bc71adb1d8c0311719a84751ef58fb02ae
phmartinsconsult/curso_python_3_luis_otavio
/Aula_32_Funções.py
922
4.09375
4
print("FUNÇÃO 1") print() def calcula(a, b=10): if a == 0: divide = a / b else: divide = a / b print(f'O resultado da sua soma é {divide}') ''' if divide: print(divide) else: print('Conta invalida') ''' som = calcula(0) print('FUNÇÃO 2') print() def funcao(var): return var v...
1757926fb9064d41f842f4adba60cc8c2b76779a
stonesteel1023/python_study
/test1/coding-ex5(list_compresive).py
545
3.9375
4
# List Comprehension(리스트를 만드는 쉬운 방법들) # append 시킬 변수 선언 x # []에 한 줄로 조건절 넣기 numbers = [] # 일반적인 방법 # for n in range(1 ,101) : # numbers.append(n) # print(numbers) # 리스트 컴프리헨션 numbers2 = [x for x in range(1, 101)] print(numbers2) # 응용 # 다음 리스트 중에서 '정' 글자를 제외하고 출력하세요. q3 = ["갑", "을", "병", "정"] # q3.remove(q3[3]) ...
ffed35cfab793fc7391da5fef16dfdeb2286d885
daniel-reich/turbo-robot
/Sdu9JRQtL45qXmJtr_7.py
1,197
4.5
4
""" **Mubashir** is getting old but he wants to celebrate his **20th or 21st birthday only**. It is possible with some basic maths skills. He just needs to select the correct number base with your help! For example, if his current age is 22, that's exactly 20 - in base 11. Similarly, 65 is exactly 21 - in base 32 ...
66222b02ece3c3ae2c8fec27d111e2efae973540
EltonK888/Multiway-Search-Tree
/Contact.py
751
4.03125
4
class Contact(): ''' This class constructs a structure to store people's contact information''' def __init__(self, phone, name): '''(Contact, str, str) -> NoneType constructs a contact by the given phone number and name. REQ: phone follows xxx-xxx-xxxx format''' se...
fc82fe576e031e6e9f2ceac2661e20d7eebb1c3e
naumovda/python
/daria.py
490
3.734375
4
class base: def get_name(self): raise NotImplementedError def get_cost(self): raise NotImplementedError class coffee(base): def get_name(self): return 'coffee' def get_cost(self): return 10 class tea(base): def get_name(self): return 'tea' def add_mil...
9ee10569a065db6da694aa5c8f01e0fdd2715980
SaintOops/my_python
/семестр - 2/ДЗ - 2/if_random_game.py
166
3.78125
4
import random num = int(input('number?')) x = random.randint(1,4) if num == x: print('won') elif num > x: print('lower, lose') else: print('upper, lose')
348fe3eb418e38034b7fb4ae64796945a7135520
nuggy875/tensorflow-of-all
/39. deep cnn using tf.layer.py
3,076
3.8125
4
# 39. deep cnn using tf.layer import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets("MNIST_data/", one_hot=True) # Check out https://www.tensorflow.org/get_started/mnist/beginners for # more information about the mnist dataset # hyper parameters learning_...
c58e77d295295c10dd553f42b57b8b4744d635c6
liamb315/CSE291
/probset2/run_softmaxregression.py
1,524
3.5625
4
'''Logistic Regression for 0/1 in MNIST dataset''' import numpy as np import helper_functions as fn import math_softmax as ms from softmaxregression import SklearnSoftmaxRegression from logisticregression import SklearnLogisticRegression from sklearn import linear_model import time import matplotlib.pyplot as plt #---...
f606276318a2351fc6e94fa08af7095cc6f451bc
geometryolife/Python_Learning
/PythonCC/Chapter11/e10_test_survey.py
1,576
3.671875
4
import unittest from e8_survey import AnonymousSurvey print("----------测试AnonymousSurvey类----------") # 验证: # 如果用户面对调查问题时只提供了一个答案,这个答案也能被妥善地存储。 # 使用assertIn()方法核实其确实存储在答案列表中。 class TestAnonymousSurvey(unittest.TestCase): """针对AnonymousSurvey类的测试""" def test_store_single_response(self): """测试单个答案会被妥...
8b7d906f6bde17ad7fdfc1e503ab8394732dd0de
sanjkm/Coursera
/Cryptography-I/assignment1/decrypt.py
4,194
4.03125
4
# decrypt.py # Program will take in encrypted messages as input, from file # It will decrypt the final message in the input file and output the # message. hexVal = 16 # Ascii code values mapping letters to decimal numbers upperCaseMin, upperCaseMax, lowerCaseMin, lowerCaseMax = 65,90,97,122 # Opens the input file,...
ba69971f1eb1eb1454233bfbd6b83f03171e5a38
Jaideep25-tech/AlgoBook
/python/string algorithms/Reversing a string using Recursion.py
213
4.28125
4
String = str(input("Enter a string: ")) def reverse(word): size = len(word) if size == 0 : return last_char = word[size-1] print(last_char,end='') return reverse(word[0:size-1]) reverse(String)
b8399941d845ea157a6c19d7a6e2a6bfac2f244a
Chansazm/Project_24_Competitions
/04-Data Structures/index3.py
437
3.859375
4
# Data Structures # Arrays arr = [1, 2, 3, 4, 5, 6] arr.pop() arr.pop() print(arr) arr.append(1) print(arr) # Set s = {1, 2, 3, 4, 5, 2} print(s) s.remove(5) print(s) s.add(6) print(s) print(len(s)) # Map or Object dictionary = {1: 2, 2: 3} print(dictionary) print(dictionary.keys()) print(dictionary.values()) p...
20aab5ed03358ecb3a260510c31a6689bbe83e26
dev9033/head-first-python-
/function.py
310
4.34375
4
# function in python def search_for_vowels(): """Display any vowels found in an asked-for word""" # doc string vowels = set('aeiou') word = input('give a word to check search for vowel') found = vowels.intersection(set(word)) for vowel in found: print(vowel) search_for_vowels()
16133fb2391e55e8ba39eef4d70b665f035dd27a
dlimeb/kids-projects
/cool.py
695
4
4
import random import re # ask for an acronym acronym = "" while not acronym: acronym = raw_input("Type in an acronym to use: ") letters = list(acronym.lower()) # put the dictionary into a list dict_file = open("/usr/share/dict/words", "r") dictionary = [] for line in dict_file: dictionary.append(line.rstrip...
e8bcbd59bd3bf40d35aea409adc3f30810c1b894
AaronDweck/all-Python-folders
/tests.py
208
3.96875
4
print ("welcome to my chat box") live = input("where do live? ") if live == "london": truth = input("are you sure? ") elif truth == "yes": print("ok but i dont baliev you") elif truth == "no":
8405d744c15f2cb722ed8e520844eaa065192eec
samuel-c/SlackBot-2020
/venv/Lib/site-packages/pyowm/weatherapi25/location.py
6,519
3.6875
4
""" Module containing location-related classes and data structures. """ import json import xml.etree.ElementTree as ET from pyowm.weatherapi25.xsd.xmlnsconfig import ( LOCATION_XMLNS_URL, LOCATION_XMLNS_PREFIX) from pyowm.utils import xmlutils, geo class Location(object): """ A class representing a locat...
c648b8fcd831129b3d1e50f43f23d4fb2a7f0709
AmitBaroi/Data-Visualization-Lessons
/DataCamp/4_Customization.py
455
3.6875
4
import matplotlib.pyplot as plt year = [1950, 1951, 1952, 2100] pop = [2.538, 2.57, 2.62, 10.85] # Adding new data: year = [1800, 1850, 1900] + year pop = [1.0, 1.262, 1.650] + pop plt.plot(year, pop) plt.xlabel("Year") plt.ylabel("Population") plt.title("World Population Projections") # Y ticks the numbers shown ...
78983dc4a61d0043d9dfbc188c45d586cebd4704
DanielOjo/Functions
/Classroom starters/Starter-Functions Task 4.py
272
4.0625
4
#Daniel Ogunlana (40730) #17-11-2014 #Starter-Functions Task 4 pay_rate = int(input("Please enter your pay rate: ")) hours_worked = int(input("Please enter the amount of hours that you work for in a week: ")) calculated_pay = pay_rate*hours_worked print(calculated_pay)
8bdf3df61118205a8d808acfeeda94a31455e558
tschart/python
/daily-programmer/revised-julian-calendar/src.py
523
3.625
4
#brute force emthod of calculating # of leap years def divis_by_4(year): return year % 4 == 0 def divis_by_100(year): return year % 100 == 0 def remain_by_900(year): return year % 900 == 200 or year % 900 == 600 def is_leap_year(year): return (divis_by_4(year)) and not ((divis_by_100(year)) a...
078405e18a59232315323308de1e67030ea029c0
Vinamra2009/Algorithms
/Language/Python/calendar.py
148
3.90625
4
#Program for printing calander import calendar yy=int(input("enter the year")) mm=int(input("enter the month")) print(calendar.month(yy,mm))
55a9ba26f2d57089b871f47d207a9112498f25ef
novas-meng/EmtionClassify
/item_emotion.py
540
3.75
4
def readWords(): f=open('train.csv',encoding='utf-8') item_emotion_map={} for line in f: array=line.strip().split(',') if len(array) == 3: #print(len(array)) #print(line) text=array[1] label=array[2] for item in text.split(' '): if item not in item_emotion_map: h={} h[label]=1 ...
50351ebcc69b8ef94015008dac686bbb52f949bf
pythonbyte/Interview-solved
/Important/given_string.py
492
3.875
4
# Given a string find out whether there are the same number of letters inside of it. def balanced(string): dict_word = {} for i in string: if i in dict_word: dict_word[i] += 1 else: dict_word[i] = 1 len_dict = len(dict_word.values()) sum_dict = sum(dict_word.va...
a16f6d80017b3a83eb9ad22cfd7c2eeaaac1dcbf
vishalnirmal/Data-Structures-and-Algorithms
/Data Structures/Doubly Linked List/DoublyLinkedList.py
5,919
3.78125
4
############################################## # Doubly Linked List # # by Vishal Nirmal # # # # A Doubly Linked List ADT implementation. # ############################################## class DLL: class DLLNode: ...
407214dc1cf7fc4b2efa7281ee0506478de3bd0f
thirihsumyataung/Python_Tutorials
/formatted_string.py
307
4.03125
4
first = 'John' last = 'Smith' message = first + ' [' + last + ']' + ' is a coder. ' print(message) #Formatted String #Note : To define formatted string, prefix your string with an F #and then use curly braces to dynamically insert values into your strings. msg = f'{first} [{last}] is a coder.' print(msg)
38911cb4f112fbf147a4188bb86fecda4ebcf422
mavenickk/ML-project-snippets
/train_test.py
739
3.5625
4
import pandas as pd from sklearn.model_selection import train_test_split # Read the data X_full = pd.read_csv('../input/train.csv', index_col='Id') X_test_full = pd.read_csv('../input/test.csv', index_col='Id') # Remove rows with missing target, separate target from predictors X_full.dropna(axis=0, subset=['S...
bccd404d9b75353dfc98b0d22624756183aa902f
DanLesman/euler
/p12.py
335
3.65625
4
def num_divisors(n): i = 1 divisors_count = 0 while i * i <= n: if n % i == 0: if i == n/i: divisors_count += 1 else: divisors_count += 2 i += 1 return divisors_count def first_with_n_divisors(n): i = 0 num = 0 while num_divisors(num) < 500: num += i i += 1 return num print(first_with_n_...
249e23c333a2b98c6dc142c1ffea3619e0bd2296
scan3ls/Markdown2HTML
/parser.py
4,895
3.8125
4
""" Parses Markdown text and returns html elements """ def get_tags(tag): """ """ open_tag = "<{}>".format(tag) close_tag = "</{}>".format(tag) return open_tag, close_tag def headings(line=""): """ headings - generate html headings from md headings Arguments ...
6335e19f65f28cc813a368afdd96444c755fb3c1
sandeepmanocha/myCheckIO
/roman_numerals.py
2,422
3.6875
4
def checkio(data): roman = {1: 'I', 5: 'V', 10: 'X', 50: 'L', 100: 'C', 500: 'D', 1000: 'M', 0: ''} converted = '' remainder = 1 div = 1000 remainder = data % (div) num = data - data % div # print(data, num, remainder) while remainder == data: div = int(div / 10) rema...
0c0d63552f75a42c0638e423a1e0f7511c686bef
ShubhangiDabral13/Text-Summarization-Through-NLP
/Extractive Text Summerization/src/split_text_to_sentences.py
492
4.03125
4
#we will split the text into different sentence and then append it to the list. def split_text(text): """ param text: it is the plain text return a list which consist of sentence present in text. """ from nltk.tokenize import sent_tokenize sentences = [] for s in text: sentences.app...
b2f6bfbd7fe78b75c5684a0b00bf8ab27b8b6954
arunkumaraqm/Mullers-Method
/MullersMethod.py
5,696
3.5625
4
""" Implementation of Muller's method Approximates one of the roots for an equation of the form f(x) = 0 This implementation supports complex functions and complex guesses. Contributors: Archana (ENG18CS0044) Arun (ENG18CS0047) """ from cmath import * # It provides access to mathematical functions for compl...
35c7c5abc2a95ba5bea9a6e27357a15ecb8ac1bb
Abhijnan-Bajpai/Budget-Estimation
/data.py
968
3.53125
4
import pandas as pd import random as ran def generate_expense(year, lst): if year >= 2001: generate_expense(year - 1, lst) base_num = ran.randint(10000,15000) lst.append(base_num * (year % 2000)) return lst else: return n = int(input("Data from 2001 upto w...
330f115c43701357390d13f6d305efc662b1c4d7
BobXGY/PythonStudy
/oj_py/CCF_CSP/201803-1.py
504
3.640625
4
if __name__ == '__main__': game = str(input()) op_list = game.split(" ") combo = False base_score = 1 total_score = 0 for op in op_list[:-1:]: if op == "0": break if op == "1": combo = False base_score = 1 elif op == "2": co...
6c7a058ff997b3211c80b69eb923c1bfb0acdb37
m7jay/Algorithms-in-Python
/Linear&BinarySearch.py
1,544
3.921875
4
#impletation of linear search alogrithm #only for illustration as sequence types like List, Tuple, Range # all implements the __contains__() and # allows to search simply by using 'in' operator from enum import IntEnum from typing import List, Tuple Nucleotide: IntEnum = IntEnum ('Nucleotide', ('A', 'C', 'G', 'T')) ...
193f4107eb47964999002a7a29a29b711d7598a3
orenzaj/Python-Basics
/doubler.py
207
3.828125
4
# This class will double whatever it's given as parameter. class Double(int): def __new__(*args, **kwargs): self = int.__new__(*args, **kwargs) return self * 2 print(Double(3))
bd09a87523a8d91924bc82313cf6f54264cadbd0
Chi-you/python_pratice
/staticmethod.py
1,230
4.46875
4
# static # when a variable is delared as static which means it has already been writen into the memory when class initialize # when to use static: # 1. we hope that some members is independent of instance # 2. because of using only one part of memory, so no matter how much instances there are, the space of the static m...
d8f849d1480f8aa65dde9df4d0b7437be9f889e2
Yvette995/twitter_hot_topic_Clustering
/web.py
2,749
3.5
4
import streamlit as st from function import * st.sidebar.header('Twitter Hot Finder') option = st.sidebar.selectbox('Choose',('input data','process data', 'show analyse'),index = 0) uploaded_file = st.file_uploader('Please upload twitter data(.csv):') if uploaded_file is not None: filepath = 'data.csv'...
641310e371de567a42734b4fb27e3f187a45bca5
c3c-git/O-Python
/error.py
657
3.53125
4
# module error """Сообщения об ошибках""" import loc import text def _error(pos, msg): while text.ch() != text.chEOL and text.ch() != text.chEOT: text.nextCh() print(' ' * (pos - 1), '^', sep='') print(msg) exit(1) def lexError(msg): _error(loc.pos, msg) def Expecte...
fa1b58f3b65cb4130eeee829fc8ad91cec51426a
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/hamming/0cd3f763788f4e6bbfa1c79a94287271.py
125
3.546875
4
def distance(s1, s2): distance = 0 for i in range(0, len(s1)): if s1[i] != s2[i]: distance += 1 return distance
cf868b828169e39c6c0a7191916895225b58b4b7
desve/netology
/tasks/3/3-2.py
175
3.796875
4
# Дробная чвсть print("Ввведите положительгое число") n = float( input()) m = int(n) m1 = n - m print("Дробная часть", m1)
dc011782edf811c9378946b8911dbe29a32253d5
rafaelblira/python-progressivo
/soma_media_colecao.py
560
3.84375
4
#Faça um programa que calcule o valor total investido por um colecionador em sua coleção de CDs e o valor médio gasto em cada um deles. O usuário deverá informar a quantidade de CDs e o valor para em cada um. quant = int(input('Digite a quantidade de CDs: ')) cont = 0 soma = 0 media = 0 produto = 0 while cont < quant: ...
fb0576dd2dd6b572a76a2a714fba3e081760ced0
Nurzhan097/lern_py
/files.py
712
3.703125
4
import zipfile import os # with open("file_test.txt", 'w', encoding="UTF-8") as f: # f.write("Hello page") # def read_dir(folder): # for root, dirs, files in os.walk(folder): # print(f"{root.count(os.sep) * '----'} [{os.path.basename(root)}]") # for file in files: # print(f"{root....
f519d6eb68d46fd367c80087dda3184bd5f55152
nla-group/slearn
/slearn/mkc.py
2,704
3.703125
4
# -*- coding: utf-8 -*- """This part is for string sequence generation""" import numpy as np class markovChain(object): def __init__(self, transition_prob): """ Initialize the MarkovChain instance. Parameters ---------- transition_prob: dict A dict object re...
3ec0030ddcd288e05199682b37179a2aff788701
JayWelborn/Grocery
/Main2.py
4,428
4.3125
4
import os class Grocery(object): def __init__(self, name, position): self.name = name self.position = position def __str__(self): print self.name # This Function gets a list of items from the user and puts them into a list def get_items(list1): item = raw_input(...
059c076210d921a896e6dc0c21aeacde1a3eaeb5
ConorFlanagan/210CTCW
/Week1/Q1_shuffle.py
345
3.65625
4
import random def shuf(List): for a in range(len(List)-1,0,-1): #For each index of array b=random.randint(0,a) #Selects random second index if b == a: continue List[a],List[b] = List[b],List[a] #Swap selected indexes return (List) #Run-ti...
c7a3a2dc607b8dedafe93e564d333bdeb5c3dcca
LizinczykKarolina/Python
/Loops and conditions/ex1.py
731
4.25
4
#1. Write a Python program to find those numbers which are divisible by 7 and multiple of 5, between 1500 and 2700 (both included). new_list = [] for i in range(1500, 1700): if i % 7 == 0 and i % 5 == 0: new_list.append(str(i)) print ",".join(new_list) #2. Write a Python program to convert temperature...
6bfc31c0159c04fac546d02b28ef0f66dd2950b9
andrewBatutin/p_nato_alp
/nato_alph.py
1,434
3.796875
4
#!/usr/bin/python import sys numbers = { "1": "One", "2": "Two", "3": "Three", "4": "Four", "5": "Five", "6": "Six", "7": "Seven", "8": "Eight", "9": "Nine", "0": "Zero" } letters = { "A": "Alpha", "B": "Bravo", "C": "Charlie", "D": "Delta", "E": "Echo",...
a3405cd836020b0b223484469d489e5e9b924e43
BrianTurnwald/DS201-With-Chyld
/2018-01-08/stats.py
2,430
3.90625
4
""" Module/file docstring Run: python -m doctest -v stats.py """ def add(num1,num2): return num1 + num2 def cubevol(length,width,height): return length * width * height def mean(numbers): #works sm = 0 for x in numbers: sm += x #print(sm) #print(len(numbers)) return sm / len(...
ced6c079a775a22e750e2c418869acc78f5bd85d
sbenning42/42
/PyMuse/TcpSocket.py
3,149
3.671875
4
import socket, struct #TcpSocket class is a socket.socket inherit, that handle TCP communication message way #All TcpSocket message are preffixed with the 4 bytes, big endian, unsigned size of that TcpSocket message #That way if a server and a client both use the TcpSocket's mthods for message communication #They can ...
896d02640ef7f7d66da3701dcf00bf743a0d7fec
RussellSB/mathematical-algorithms
/task1.py
3,415
4
4
#Name: Russell Sammut-Bonnici #ID: 0426299(M) #Task: 1 import random #used for choosing random pivot #class for storing pair's details class Pair: #initialises product pair def __init__(self,a,b): self.a = a self.b = b self.product = a*b #recursive method for sorting p...
e855bcd3abdfaeb6b7275b8e097530544c625e47
duducosmos/multiresolutionfit
/src/multiresolutionfit/countclass.py
1,873
3.8125
4
#!/usr/bin/env python3 # -*- Coding: UTF-8 -* """ Count Class function. Return a dictionary where key represents the class and value the total number of object in two scenes. Example ------- >>> from numpy.random import randint >>> from multiresolutionfit import countclass >>> scene1 = randint(256, size=(50, 50)) >>...
ef7d1c696cafe3041b8afb397def3ec0ebdd31dc
varunmiranda/Algorithms-Python
/Longest common subsequence - CLRS/LCS.py
1,442
3.828125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ @author: varunmiranda Citation: Introduction to Algorithms 3rd Edition, CLRS - LCS implementation (Dynamic Programming) """ "Reading the Inputs" X=['A','B','C','B','D','A','B'] Y=['B','D','C','A','B','A'] #X=[1, 0, 0, 1, 0, 1, 0, 1] #Y=[0, 1, 0, 1, 1, 0, 1, 1, 0]...
b26576613b62f6c3ab7379f6e7fcc55eb55b1e5a
Marta37937/EmployeeMerge
/database.py
2,105
3.765625
4
import sqlite3 class DatabaseContextManager(object): def __init__(self, path): self.path = path def __enter__(self): self.connection = sqlite3.connect(self.path) self.cursor = self.connection.cursor() return self.cursor def __exit__(self, exc_type, exc_val, ...
b4a1b796b4b64c11681bcebd8943c1df4edfa707
rutujak993/Rutuja_Python_Practice
/Reverse_The_words_from_Sentence.py
376
3.984375
4
#WAP to accept a sentence from user and reverse every word from the sentence def SentenceConversion(sentence): l1 = sentence.split(' ') for i in range(0,len(l1)): l1[i] = l1[i][::-1] return ' '.join(l1) def main(): String1 = input("Enter a sentance : ") print(SentenceConv...
ab5df4cf85b29ab9c3b63bd09d3de55d05d16109
raytso0831/unit-4
/functionDemo.py
525
3.953125
4
#Ray Tso #3/9/18 #functionDemo.py def hw(): print("hello, world") def double(thingToDouble): print(thingToDouble * 2) def bigger(a,b): if a>b: print(a) else: print(b) def slope(x1, y1, x2, y2): print((y2 - y1)/(x2 - x1)) slope(1,1,2,2) slope(True,True,False,False) #sketchy ...
d3a8de72c6610a9132794982dc124a57dfd7673d
Silent-wqh/PycharmProjects
/PyProjects/buy_pencil.py
1,090
3.59375
4
pens=[[],[],[]] total_money = [] total_num = int(input().strip()) pens[0] = list(input().strip().split()) pens[1] = list(input().strip().split()) pens[2] = list(input().strip().split()) def calcu(need_num, pens, current_money=0): for pen in pens: if need_num/int(pen[0]): curr_need_num = need_...
43be91ba6bfa59462665e3afb16091ef33a6a631
tommyyearginjr/PyCodingExercises
/delDel/delDel.py
420
3.921875
4
''' Given a string, if the string "del" appears starting at index 1, return a string where that "del" has been deleted. Otherwise, return the string unchanged. delDel("adelbc") --> "abc" delDel("adelHello") --> "aHello" delDel("adedbc") --> "adedbc" ''' def delDELETED(string): print('{} ---> {}'.format(string...
e5588a14c520de78a5553a3af9178caea7bf0271
Coobie/DADSA-2-Tennis
/solution/factor.py
812
3.59375
4
__author__ = "JGC" # Author: JGC if __name__ == "__main__": # File is opened directly print("This file has been called incorrectly") class Factor(object): """Class for a factor""" def __init__(self,amount,difference): """ Constructor for factor :param float amount: multiplier ...
1b95b893829705a8a8d24176beae9bc942fb8016
DiksonSantos/GeekUniversity_Python
/137_Deltas_De_Data_E_Hora.py
670
3.8125
4
""" Delta é a diferença entre uma data inicial Menos a Data Final: 03-04-2020 á 04-05-2020 -> Delta = 31 Dias """ """ import datetime data_hoje = datetime.datetime.now() Birthday = datetime.datetime(2021, 3, 24, 00) Res = data_hoje - Birthday print(Res*-1) # 365 days, 20:38:56.004360 -> Hoje é 23-03-2020 ...
d249030fd4dc952165f8ec5b8d48c11d5001db99
andclima/algoritmo
/aula-09/exemplo.py
354
3.859375
4
# Alô, som! nome = "Joao" idade = 21 valor = 29.31 idade = int(input(f"Informe a idade de {nome}: ")) print(f"{nome} tem {idade} anos e possui R$ {valor} na carteira") if idade < 21: print(f"{nome} ainda nao possui idade suficiente para maioridade civil.") else: print(f"{nome} ja pode ser declarado civilmente...
b8bc7711da99b6690b25d835294a79f4042226e9
SmileShmily/LaunchCode-summerofcode-Unit1
/ClassExercise & studio/chapter 14/Sameness.py
2,411
4.28125
4
'''For example, if you say, Chris and I have the same car, you mean that his car and yours are the same make and model, but that they are two different cars. If you say, Chris and I have the same mother, you mean that his mother and yours are the same person. When you talk about objects, there is a similar ambiguity. ...
32b112a4e815d327d9fc69407cd1fc31f27d3c56
jakehoare/leetcode
/python_1_to_1000/150_Evaluate_Reverse_Polish_Notation.py
1,050
3.59375
4
_author_ = 'jake' _project_ = 'leetcode' # https://leetcode.com/problems/evaluate-reverse-polish-notation/ # Evaluate the value of an arithmetic expression in Reverse Polish Notation. # Valid operators are +, -, *, /. Each operand may be an integer or another expression. # Push numbers onto stack. Apply operators to...
9fed9f09d8555aae4cf848cf99885164151f6cab
maximkha/peeks
/test3.py
499
3.921875
4
from Peeks import Peekstr s = "I am a string" #"I am a string" peeked = Peekstr(s) for c in peeked: if c == "": break #peeked does not throw a stop iterator!!! if peeked.peek(4) == "am a": print("I found the substring!") print(f"{peeked.Position}") break peeked = Peekstr(s) for c in p...
f95936c56c6abda10b2ea4623d385ee0e886ac5d
xboard/AoC
/2020/Day_15/rambunctious_recitation.py
2,651
3.84375
4
#!/usr/bin/env python3 """ Solves day 15 tasks of AoC 2020. https://adventofcode.com/2020/day/15 """ import argparse from typing import Sequence, List from collections import defaultdict SEQUENCE = [14, 3, 1, 0, 9, 5] def task(sequence: List[int], ith: int) -> int: """ Solve task 1 or 2. Parameters ...
62d96faf2d20070a5403801a793c24117d5ad151
goareum93/K-digital-training
/01_Python/18_OOP/05_클래스상속.py
1,985
3.921875
4
# 클래스 상속(inheritance) class Car: number = 0 def __init__(self, speed=0, color='white'): self.speed = speed self.color = color Car.number += 1 def __str__(self): return '이 자동차의 색상은 %s이고,\n속도는 %d입니다.' % (self.color, self.speed) # color 필드 값을 반환메소드 def getColor(self):...
dea15e3736111d09317f0d31765d1da04b09d427
iangraham20/cs108
/projects/03/triangle.py
1,608
4.21875
4
''' This program uses turtle graphics to create triangles with user input coordinates Created September 27, 2016 Homework 03 Exercise 3.2 @author: Ian Christensen (igc2) ''' # import necessary libraries import turtle import math # assign variables x1 = int(input('Please enter first x-coordinate')) x2 = i...
d6f00fac79bd16f714b7a9e0fc6b26b25fbd5584
kimdahyun0402/dao
/파이썬/4주차/4주차 1번..py
623
3.984375
4
list=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10] #정수의 list를 생성했고 리스트의 이름을 list로 했다 print(list) a=int(input("변경할 위치(0~9):")) #변경할 위치를 변수a로 설정하고 숫자로 전환시켰다 b=int(input("새로운 값:")) #변경할 값을 b라는 변수로 설정하고 숫자로 전환시켰다 list[a]=b #리스트의 a위치에 있는 값을 b로 변경시킴 print(list) c=int(input("추가할 값:")) #리스트에 추가할...
c5611c1c88d774cff605f146a1ef9ede52c37c16
AkmatovEldi/Init_Python
/lesson5.py
1,258
3.671875
4
# from datetime import datetime # # # def timeit(func): # def wrapper(): # start = datetime.now() # func # print(datetime.now() - start) # # return wrapper # # # @timeit # def one(): # l = [] # for i in range(10000): # l.append(i) # return f'{len(l)}' # # # @timeit # ...
843bc43c66d7f4eb279269279e4edc3a4bfeacb3
margaridav27/feup-fpro
/Plays/Play06/bagdiff.py
314
3.578125
4
# -*- coding: utf-8 -*- """ Created on Mon Nov 25 17:15:34 2019 @author: Margarida Viera """ def bagdiff(xs, ys): output = [] for n in xs: if n in ys: ys.remove(n) else: output.append(n) return output print(bagdiff([5, 7, 11, 11, 11, 12, 13], [7, 8, 11])) ...
6134d5e3919c7eb859b696c4da75b6791090a48b
tuoccho/Ph-m-Minh-c_python_C4E27
/BTVN_Techkid_B3/Bai2.py
784
3.734375
4
ls = [5,7,300,90,24,50,75] print("Hello, my name is Hiep and these are my sheep size") print(ls) for i in range(3): print("MONTH ",i+1) ls = [x + 50 for x in ls] print("One month has passed, now here is my flock") print(ls) print("Now my biggest sheep has size",max(ls),"let's shear it") a = ls.i...
4c4551d47baa1fb50816a8bd0dc21e29fd0b6cee
Timid-sauce/My-SilverBuddy
/SilverBuddy.py
8,153
3.703125
4
''' SilverBuddy Program Technica 2017 ''' import os.path Spending = [] endProgram = 0 print("Welcome to Your Personal SilverBuddy!") print("To begin you have 3 options: \n") option = input("Option 1: Take a Quiz to figure out your spending habits \nOption 2: Go to your personal SilverMonitor® \nOption 3: See your pas...
3eb8aabe87d5fffa9bf91e4bb22f6d0222c82aaa
rafaelperazzo/programacao-web
/moodledata/vpl_data/94/usersdata/188/55295/submittedfiles/mediaLista.py
86
3.578125
4
# -*- coding: utf-8 -*- n=float(input('Digite a quantidade de elementos da lista'))
c79236734e2701fca41e5777bf1a3c1fb4857e21
melody40/monorepo
/Pyhton/learnPythonTheHardWay/ZedAShaw/src/ex7.py
166
3.59375
4
print ("Mary had a little %s" % 'lamb') end1 = 'T' end2 = 'o' end3 = 'r' end4 = 's' end5 = 'h' end6 = 'o' print ( end1 + end2 + end3 + end4 + end5 + end6 )