blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
2644e3093e5ca01818aac8f7eac03f67bb8b882c
statisdisc/ncepAnalysis
/src/utilities/addData.py
1,821
3.984375
4
import numpy as np def addRollingMean(data, column, years=1): ''' Compute the rolling mean of a pandas data column over a timescale in years :param data: Pandas dataframe object with datetime index column. :param column: The column name to apply the rolling mean to, str. :param years: ...
1d27b54fee4eb09efa7dde5361391b3d316abc9f
mtrberzi/stringfuzz
/stringfuzz/util.py
913
3.8125
4
import random from stringfuzz.scanner import ALPHABET from stringfuzz.ast import ConcatNode, ReConcatNode __all__ = [ 'coin_toss', 'random_string', 'join_terms_with', 'all_same', ] # public API def coin_toss(): return random.choice([True, False]) def random_string(length): return ''.join(ran...
e7465b2661ff9d438261c8cffcdd386099797c64
yohira0616/python-til
/ef/generator.py
209
3.6875
4
value = [len(x) for x in open('./my_file.txt')] print(value) # generator it = (len(x) for x in open('./my_file.txt')) print(next(it)) print(next(it)) roots = ((x, x ** 0.5) for x in it) print(next(roots))
72616870d1abd8f6b89d073d31df9ebb4024fc75
yohira0616/python-til
/ef/use_class.py
460
3.5625
4
class SimpleGradeBook(object): def __init__(self): self._grades = {} def add_student(self, name): self._grades[name] = [] def report_grade(self, name, score): self._grades[name].append(score) def average_grade(self, name): grades = self._grades[name] return su...
cc4b871bb6271c460fdaf265f9e58d4609f7ccd8
yohira0616/python-til
/count_word.py
157
3.65625
4
with open('test.txt') as f: search = input() count = 0 for line in f: if line.find(search) > -1: count += 1 print(count)
a892fc1e770e2dd447f3399f09cc7f800d1589f4
E-Ozdemir/Python_Assignments
/Armstrong_Num.py
419
3.953125
4
###ARMSTRONG NUMBER#### x = input('Write a positive number: ') y =len(x) summ = 0 while not x.isdigit(): # Checks if a digit number or not print("It is an invalid entry. Don't use non-numeric, float, or negative values!") x = input("Type your age correctly:") for i in range(y): summ = summ + (int(x[i]))**y if su...
c13e883e8ec26b9f79004a2e276430a33a716f1a
mrwm/python-graphy
/line_graph.py
3,835
3.609375
4
#!/usr/bin/env python3 # line_graph.py # Author: William Chung # Last Updated: # Purpose: Creates line or bar graph(s) with the given data points # Program Uses: ./line_graph.py # Notes: # - Requires svgwrite python module # - The resulting graph located a bit off the viewbox, so scroll up a bit # import...
0fbe5463d5054d17c54fefc73779f74bdea932e1
saisuma98/Sample-Python-Programs
/venv/aq2_datatime.py
341
3.9375
4
import datetime import calendar now = datetime.datetime.now() print ("Current date and time : ") print (now.strftime("%Y-%m-%d %H:%M:%S")) def findDay(date): born = datetime.datetime.strptime(date, '%d %m %Y').weekday() return (calendar.day_name[born]) date = now.strftime("%d %m %Y") print("Day of the We...
3e1be8a673a2bd1703243e49ebd3f481865581f4
jaiswalanshul/Udacity-Data-Engineering-Projects
/Project 4 - Data Lake/home/.ipynb_checkpoints/unzip_files-checkpoint.py
665
3.59375
4
from zipfile import ZipFile def unzip_files(zip_file_paths): """ Unzip files, which prepares them to be sent to the s3 bucket """ for i in range(len(zip_file_paths)): with ZipFile(zip_file_paths[i][0], 'r') as zf: #display the files inside the zip zf.printdir() ...
59e370154de370a978d15df51f7705399ea6f1f0
RossCZ/PythonLearning
/topics/5_advanced/yield.py
721
3.859375
4
# Generators and coroutines def generator(n): for num in range(1, n): yield num ** 2 def division_coroutine(divider): print(f"Divider: {divider}") try: while True: quotient = yield print(quotient / divider) except GeneratorExit: print("Dividing finished....
1d3181b3a54b3e307df5d1187f8564ba10386c0a
RossCZ/PythonLearning
/topics/1_basics/5_string_split.py
329
3.859375
4
def example1(): txt = "a b c d" txt2 = "a-b-c-d" lst = txt.split(" ") print(lst) lst2 = txt2.split("-") for character in lst2: print(character) def example2(): data = "1,25.6,-8.3" print(data[1]) data_splitted = data.split(",") print(data_splitted[1]) example1() ex...
54420dd51d00da85f078c1f8087b797dc3cf80b3
RossCZ/PythonLearning
/topics/5_advanced/metaprogramming.py
5,249
4.5
4
# Metaclass create Classes and Classes creates objects # https://stackoverflow.com/questions/100003/what-are-metaclasses-in-python def classes_are_objects(): print("Classes are objects") class MyClass(object): pass def echo(o): print(o) # class is an object in Python print(MyClass...
42cf14d7537bcd9b5e1be5cfa4ecb44de87c63b4
RossCZ/PythonLearning
/topics/2_collections/5_list_sort.py
271
3.546875
4
import random my_values = [] for i in range(0, 100): my_values.append(random.randint(1, 100)) print(my_values) # razeni listu vzestupne my_values.sort() print("") print(my_values) print("") # razeni listu sestupne my_values.sort(reverse=True) print(my_values)
0f5b224713a286a70c1bf0d86f31a850f4db7de7
RossCZ/PythonLearning
/topics/5_advanced/references.py
1,226
3.71875
4
def list_reference_example(): def reassign(lst): # mutable type is reassigned (i.e. original value is not changed) print("reasign") lst = [0, 1] def append(lst): # mutable type is changed print("append") lst.append(1) lst = [0] print(lst) reassign(ls...
1305067e1be216889a3a3087e72c4113212dca76
RossCZ/PythonLearning
/topics/3_loops/6_fibonnaci.py
90
3.5
4
n2 = 1 n1 = 1 for i in range(10): n3 = n2 + n1 n1 = n2 n2 = n3 print(n2)
d8a2c7c1eb63395e54b8ba43104dc438d7cec328
RossCZ/PythonLearning
/data_analysis_libraries/numpy_lib.py
2,731
4.09375
4
import numpy as np from skimage import io import matplotlib.pyplot as plt # Numeric Python # https://numpy.org/ # https://towardsdatascience.com/the-ultimate-beginners-guide-to-numpy-f5a2f99aef54 # data # manual data = [ 3, 2, 1, 0, 1, 2, 3 ] print(data) # numpy array - basic entity in numpy # ndarray (N-dimensiona...
75659459de8b15c6e83032e542bdbc43b4ef42b6
gontatata/binance-python-api-trade-2021
/Part1_3.py
283
4.1875
4
# list = [1,2,3,4] # for element in list: # print(element) # print(element * 2) # num = 0 # while num < 5: # print(num) # num = num + 1 # num = 0 # for i in range(5) : # print(num) # num = num + 1 num = 0 while num < 5: print(num); num = num + 1;
3dfffc6384c57f00467e6af186949eecc017d966
mrdabanli/python
/scripts/word_finder.py
492
4.0625
4
programming_languages = { "C", "C#", "C++", "Python", "Java", "Swift", "Ruby", "Go", "Dart" } value = input("Aramak istediğiniz programlama dilini giriniz: ") def find_word(value, list): for word in list: if value in list: return "Kelime listede var." ...
217f8e5a500076b7fd552df2ddb6a0869ca850b2
D12020/my-first-python-programs
/hello.py
336
3.765625
4
# This program says hello and greets a person by name. # # Saleem # August 24, 2017 print("Hello.") print("What is your name?") name=input() print("It is good to meet you, " + name + ".") print (" Where were you born," + name + " ? ") born = input () print(" That is interesting. I'd like to visit " + born +...
9378848e73f92ecd5f43af759a8a3d667a1c2835
MHiggs13/MachineLearning
/LinearRegression/regression3BestFitSlope.py
3,219
4.34375
4
from statistics import mean import numpy as np import matplotlib.pyplot as plt from matplotlib import style import random style.use('fivethirtyeight') """ LESSON 8 - How to program the best fit slope LESSON 9 - How to program the best fit line LESSON 10- R Squared Theory - determining accuracy -uses squared error, th...
ed9bc8ccb4e95e31350b6f33dfba21c693b389f2
jlant/web-development
/lesson-02/play/valid_years.py
578
3.890625
4
import datetime now = datetime.datetime.now() def valid_year(year): if year and year.isdigit(): year = int(year) if year > 1900 and year <= now.year: return year def valid_year2(year): """ """ if year and year.isdigit(): year = int(year) if year > 1900 and yea...
bae4d37e55393145ebbd5a8b3db511da330af7bc
StephR547/PythonLearnings
/Week 1/hw1pr2.py
1,721
3.953125
4
# Filename: hw1pr2.py # Name: Stephanie Ramirez # Problem description: First few functions! from math import* def dbl(x): """Result: dbl returns twice its argument Argument x: a number (int or float) """ return 2*x def tpl(x): """Return value: tpl returns thrice its argument Argument x:...
64bb6f1cd508059ce663ff4cdc89acf5933ac192
wkrea/DistributedSystems
/opdracht3_SparkMapReduce/preprocessing/result/check_townmap_lhs.py
2,521
3.6875
4
import json def get_stop_towns(stops_filename): """ Retieve list of town names of the stops. """ towns = [] with open(stops_filename) as stops_file: for line in stops_file: town_name = line.split(";")[-1].strip() if not town_name in towns: to...
be33d6ae693d205b4fce871783d70a9f995cb8fc
AruranV/Guessing-Game
/game.py
1,247
4.1875
4
import random as rand # Messages for the user to print("Welcome To Guess Me!") print("---------------------") print("I'm thinking of a number between 1 and 100") print("If your guess is more than 10 away from my number, I'll tell you you're COLD") print("If your guess is within 10 of my number, I'll tell you you're WA...
f304c0071aebd275a2f3d3c7ccfccd18f1ba03cd
bjflamm/python
/python_practice/multiply.py
1,192
3.875
4
#leetcode problem to multiply 2 numbers (str type) and return the product as a string without using int() class Solution(object): def multiply(self, num1, num2): """ :type num1: str :type num2: str :rtype: str """ num_dict = { "0":0, "1":1...
0b937c867a06a22203a82eeaeb2fe555fbbd6fd4
bjflamm/python
/python_practice/space_replace.py
595
4.03125
4
#testcase: s = "Here's a string!" print(s) #creating new string and concatenating as we loop through given string def space_replace(s): new_str = "" for val in s: if val == " ": new_str = new_str + '%20'; else: new_str = new_str + val; return new_str; print(space_r...
437d2470bd09d3e87861d2501fd1e678f1b5d3b7
jchuemme/cs156-learning-from-data-hw
/hw1_pla.py
3,938
3.515625
4
import numpy as np class Line: def __init__(self, p1, p2): #input: 2 2-dim numpy arrays self.p1 = p1 self.p2 = p2 diff = np.subtract(p2, p1) if diff[0] <= 0.001: #if vertical (or close to it), just set slope to none self.slope = None self....
bea83c4aef079a51f645c60dbc93a5eded5dde37
Holovachko/Lab_7
/ex 4.py
388
3.5625
4
matrix = [] i = int(input('Кількість рядків = ')) j = int(input('кількість стовпців = ')) for m in range(i): b = [] for m in range(j): b.append(float(input('Введіть елементи матриці '))) matrix.append(b) for n in matrix: if matrix.index(n)%2 !=0: n.sort() print(n) else: ...
fcd5c16c1133c1115329ad1d2b2cc5ee7ff0c71c
Rocket-hodgepodge/written-exam
/test_4_ren.py
862
3.609375
4
# ren # 4:对下面的 json 字符串 serial 相同的进行去重。 my_list = [{ "name": "张三", "serial": "0001" }, { "name": "李四", "serial": "0002" }, { "name": "王五", "serial": "0003" }, { "name": "王五2", "serial": "0003" }, { "name": "赵四", "serial": "0004" }, { "name": "小明", "serial": "00...
812f9faa0b4134d35bb773fac5f421c3dbb661e9
wadikur/Trinary_morse_code
/main.py
5,204
3.71875
4
def trinary_encoder(inputs): string_lower=str(inputs).lower() output_string='' dictionary={' ': '0', 'a': '12', 'b': '2111', 'c': '2121', 'd': '211', 'e': '1', 'f': '1121', 'g': '221', 'h': '1111', 'i': '11', 'j': '1222', 'k': '212', 'l': '1211', 'm': '22', 'n': '21', 'o': '222', 'p'...
46bc0fa5cf0220b36fc19451b7010f40f0af74c9
edwardsonjennifer/Scratchpad
/.vscode/Module_9/lesson3_classes.py
4,100
4.6875
5
### Object Factories using Classes # Classes are similar to factories where you can stamp out similar objects # with similar attributes. # ## Creating Custom Classes # similar to function. Should us Camelcase or Caplitize the first letter in every word # Ex. This_Is_A_Class_Name # Format: # class <name> (<parent cla...
fbe4a9905db08b03c2892dca11483cb716fc5d45
edwardsonjennifer/Scratchpad
/.vscode/Module 6/passing_students.py
219
3.890625
4
# pass by referance, list are mutable and can be changed students = ['james', 'joe', 'sally'] print(students) def append_sue_to_list(my_list): my_list.append('sue') append_sue_to_list(students) print(students)
cc6bccdbef8a40c724a6b05e1a8395c28c5895fa
ngbooya/Socket-Programming
/sendfile/sendfilecli.py
4,180
3.875
4
# ******************************************************************* # This file illustrates how to send a file using an # application-level protocol where the first 10 bytes # of the message from client to server contain the file # size and the rest contain the file data. # ************************************...
919b100c0750bd99a6a15b3873980960115f2e97
mikej803/rpg-game
/hero_rpg.py
5,232
4.0625
4
# In this simple RPG game, the hero fights the goblin. He has the options to: # 1. fight goblin # 2. do nothing - in which case the goblin will attack him anyway # 3. flee # parent class class Character: def __init__(self, health, power, name): self.health = health self.power = power ...
de587e0dd5d5ac33b94a6eed21b92f8808d4d18c
mokunshao/learn-python
/Iterator.py
636
3.859375
4
class PowerOfTwo: def __init__(self): self.exponent = 0 # 将每次的指数记录下来 def __next__(self): if self.exponent > 10: raise StopIteration else: result = 2 ** self.exponent # 以 2 为底数求指数幂 self.exponent += 1 return result def __iter__(s...
45655dd5e69419e8f0f53fc351ee90584bfd70a4
mokunshao/learn-python
/generator.py
335
4.0625
4
def power_of_two(): for exponent in range(11): yield 2 ** exponent p = power_of_two() print(next(p)) print(next(p)) print(next(p)) print(next(p)) print(next(p)) print(next(p)) print(next(p)) print(next(p)) print(next(p)) print(next(p)) print(next(p)) print('----') p2 = power_of_two() for item in p2: ...
369eb372a95cc5df917396ba9f9fbff137192af2
nadianingtias/JCDS_01_fundamental_notes
/latihan1.py
8,659
3.65625
4
def getReverse(inputKal): kalimatReverse = '' listKata = inputKal.split(' ') for kata in listKata: # print(kata[::-1], end=" ") kalimatReverse += kata[::-1] + ' ' return kalimatReverse # mencetak pola bintang def star(x): star = '' for i in range(x): star +='* ' ...
7aa0ae87c5fcaf4d78c8896d94e4df85b6c36fd1
JayantSarvade/banking
/revese_digit.py
75
3.8125
4
n=input("entre given number") for x in reversed(n): print(x,end='')
c9838f396e5321f0ba6d69b1b002e7dc291c5239
blekinge/alpha-zero-general
/quatro/QuatroBoard.py
7,246
3.75
4
''' Board class for the game of Quatro. Default board size is 4x4. Board data: 16 pieces = 10000,10001,10010,10011,10100,10101,10110,10111,11000,11001,11010,11011,11100,11101,11110,11111 0=empty the format is binary color(black/white) ,height(tall/short), shape(round/square), surface(holed/smooth) first dim i...
942a1d1bbbc58bf7b44bad2e78c60d93231dd8e5
gmerced/python-pokemon
/ex45/pokemon_python_red.py
9,778
3.875
4
from pokemon_game_engine import Engine from pokemon import * player = { "Name" : " ", "Rival's Name": " ", "Party": [], "Party Fainted": False, "Game Over": False} class Scene(object): def __init__(self): pass def start(self, player): pass def conclude(self, player): pass ...
846cc2cf78ebedae37ae6f71cf59733a4787b7c0
Joseorina/machine_learning_regression
/DTR/decision_tree_regression.py
949
3.5625
4
#importing the libraries import numpy as np import pandas as pd import matplotlib.pyplot as plt #Importing teh dataset dataset = pd.read_csv('Position_Salaries.csv') X = dataset.iloc[:, 1:2 ].values y = dataset.iloc[:,2].values #Fitting the DTR to the dataset from sklearn.tree import DecisionTreeRegressor regressor =...
0f6321520e57026959deecef09461da2e31793d0
RanmaruSato/diveintocode-term0
/03-03-python-for.py
1,626
3.75
4
WEEK_LIST = ['月', '火', '水', '木', '金', '土', '日'] SUBJECT_LIST = ['Python', '数学', '機械学習', '深層学習','エンジニアプロジェクト'] #次の日の授業は前日の最後の次の授業から始まることに注意してください。 def output_schedule(study_time_list): '''今週の勉強予定を出力します''' #科目のインデックス subject_index = 1 #2つの配列の要素を2つの変数にアンパック for num,week_list_index in zip(study_time_list,r...
2694f7c6717569e6037a3aa78648e44b4423ca0f
pratik30pp/PythonGame
/PythonApp/PythonApp.py
56
3.578125
4
print ("hello") x = 5 y = "hello" + " world" print (y)
628fc8d9cedebe15b1b10e1e89383ba9a459b13f
timehzy/LeetCode
/3.无重复字符的最长子串.py
2,060
3.671875
4
# # @lc app=leetcode.cn id=3 lang=python3 # # [3] 无重复字符的最长子串 # # https://leetcode-cn.com/problems/longest-substring-without-repeating-characters/description/ # # algorithms # Medium (31.64%) # Likes: 2525 # Dislikes: 0 # Total Accepted: 234.6K # Total Submissions: 741.6K # Testcase Example: '"abcabcbb"' # # 给定一个...
d59df3bc5bb355cbdfca06908e93022cae2a1ec5
timehzy/LeetCode
/23.合并k个升序链表.py
3,089
3.75
4
# # @lc app=leetcode.cn id=23 lang=python3 # # [23] 合并K个升序链表 # # https://leetcode-cn.com/problems/merge-k-sorted-lists/description/ # # algorithms # Hard (54.79%) # Likes: 1248 # Dislikes: 0 # Total Accepted: 240.9K # Total Submissions: 439.6K # Testcase Example: '[[1,4,5],[1,3,4],[2,6]]' # # 给你一个链表数组,每个链表都已经按升序...
713f7329893141658e524f6d5d822b4943491901
timehzy/LeetCode
/101.对称二叉树.py
1,732
3.953125
4
# # @lc app=leetcode.cn id=101 lang=python3 # # [101] 对称二叉树 # # https://leetcode-cn.com/problems/symmetric-tree/description/ # # algorithms # Easy (48.72%) # Likes: 538 # Dislikes: 0 # Total Accepted: 77.9K # Total Submissions: 158.4K # Testcase Example: '[1,2,2,3,4,4,3]' # # 给定一个二叉树,检查它是否是镜像对称的。 # # 例如,二叉树 [1,...
7db6df89f71b62a19bb281013a9a7eb60661daf6
yougzzzz/algo
/exo3.py
144
3.984375
4
from math import * nb = float(input("Saisissez votre nombre :")) if nb <= 0 : print("Oh non pas ça Zinedine !") else : print(sqrt(nb))
62e53f3c0e4b7403edcb9f3f8c2839c7b7e12b18
SaiKou1223/algorithm-
/鸡尾酒.py
687
3.5
4
def cock(list): for i in range(len(list)//2): is_sorted = True for j in range(i,len(list)-i-1): if list[j] > list[j+1]: list[j],list[j+1] = list[j+1],list[j] is_sorted = False print(list,1) if is_sorted: break ...
7cb2bc22f5a1472d83ada22bcb533aa3b32a7961
Shoieb-and-Yash/Hangman-Game
/Hangman.py
4,907
4
4
import random from Words import * def ChooseCateg(): print("\n\n") print("Choose One of the Following Categories = ") print("1. Cars Brand Names") print("2. Bikes Brand Names") print("3. Tech Company Names") print("4. Country Names") print("5. Random Words(HARD LEVEL)") print("(Input nu...
5ad59cd3137a94ff1865697c71df0007d71e9fa0
bonkstok/prog
/python/jsondata/getweather.py
1,162
3.84375
4
#!/usr/bin/python3 import json import requests import sys def getWeather(): location = input("Please enter a city:") try: response = requests.get('http://api.openweathermap.org/data/2.5/weather?q={}&appid=44db6a862fba0b067b1930da0d769e98'.format(location)) #return response except requests.exceptions.Connection...
c856dc7b1814da5ba94524c8d383b0d671e2bbad
bonkstok/prog
/python/examples/recursion.py
223
4.09375
4
#recursion #when youre using recursion, remember to have an exit function to exit the loop. def addseq(x): if x == 1: return 1 else: return x + addseq(x-1) print('The sum of the first 10 sequence numbers is', addseq(5))
6cef48f567a5fb297e605933fa960a91686fb27a
bonkstok/prog
/python/examples/generators.py
965
4.25
4
#generators # to be a generator, the function must return a value using the yield keyword #the generator function uses the yiel keyword to get the next value in the container def fruits(seq): for fruit in seq: yield str(fruit) f = fruits(['Apple', 'Orange', 'Mango', 'Banana']) print('The list of fruits is:') for x...
6954ca8501ae5cfe02efca401b5dd0e165833c2b
bonkstok/prog
/python/database/sqllite/testsqlite.py
318
3.859375
4
import sqlite3 db = sqlite3.connect('sqlite3db.db') cursor = db.cursor() # a cursor can iterate through the database. cursor.execute(""" CREATE TABLE users(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, phone TEXT, email TEXT unique, password TEXT) """) db.commit() db.close()#always close your database!
eb3a5ceacaf53b3ee79d8a65543939e62999f80b
shangeethas/kaggle_notebooks
/NLP/5/how-to-preprocessing-when-using-embeddings.py
8,053
3.625
4
#!/usr/bin/env python # coding: utf-8 # In this kernel I want to illustrate how I do come up with meaningful preprocessing when building deep learning NLP models. # # I start with two golden rules: # # 1. **Don't use standard preprocessing steps like stemming or stopword removal when you have pre-trained embedding...
699d504c6568677b592963b1a6f0023958df4915
n-zav/DataScience
/datascience/tasks/task3.py
4,293
3.921875
4
def init_rivals_matrix(n): """ Initializes the matrix n x n, where n[i] is a list of possible rivals for player i. If n[i] == i, value is set to 0. """ possible_rivals = [] for i in xrange(1, n + 1): players = range(1, n + 1) players[i - 1] = 0 possible_rivals.append(pla...
ebd68c820f35b930fc6163ca32b74508aaf29816
pratikjadhao1965/python-utility-date-number-string-tuple-array-list-
/Array_module.py
3,918
3.921875
4
import array #Append function def Append(Array,Value): updatedArray=list(Array)+[Value] return array.array(Array.typecode,updatedArray) #Pop element from array def Pop(Array,Index=None): #If index is not pass in function call then pop last element of Array if Index==N...
0e14080ac8c27e34d498c3cb49e9f51cb47f0507
hmitch22/advent2020
/day_03/day_03.py
3,345
3.734375
4
# I'm bad at coding import sys def convert_file_to_array(file_name): # Note: this shouldn't be separated for efficient code. I chose to separate this for code reusability. try: file = open(file_name, "r") except FileNotFoundError: print("File", file_name, "could not be found. Skipping.") ...
6fca7da4f896786f8288863f1feaa6a0321a8dca
mttcnnff/coronet
/coronet/train.py
1,051
3.65625
4
""" Simple function to train net. """ from .nn import NeuralNet from .loss import Loss, MSE from .data import DataIterator, BatchIterator from .optimizers import Optimizer, StochasticGradientDescent from .tensor import Tensor def train(net: NeuralNet, inputs: Tensor, targets: Tensor, nu...
c6d9784147d76da318d42a6b2ffb494cc5ec3cb4
Klimushin/HW
/Lesson2+HW/FizzBizz(for).py
1,184
3.921875
4
# У вас есть три числа, они вводятся из консоли. # Первое число называется fizz, второе называется buzz. # До третьего необходимо досчитать от единицы. # Считая, надо выводить число. # Если число кратно fizz - надо выводить F вместо числа. # Если число кратно buzz - надо выводить B вместо числа. # Если число кратно и f...
65247564d4c6f2e5a579e3335c8c235405fa6ffa
Klimushin/HW
/Lesson3+HW/fizzbuzz_read_and_write.py
946
3.703125
4
# Написать fizzbuzz для 20 троек чисел, # которые записаны в файл input.txt. Читаете из файла # первую строку, берете из нее числа, считаете # для них fizzbuzz, результат записывается в файл output.txt. file_input = open('input.txt', 'r') file_output = open("output.txt", "w") for line in file_input: first, second...
bd17f354cdc840279d94eb96a5589b858b581a67
Klimushin/HW
/Lesson19/decor.py
1,899
3.65625
4
from datetime import date, timedelta class Employee: def __new__(cls, *args, **kwargs): return object.__new__(cls) def __init__(self, name, surname, mail, salary): self.name = name self.surname = surname self.mail = mail self.salary = salary def work(self): ...
ed852b60dbfb7ea544c3adb8610e6767d8a17276
Klimushin/HW
/Lesson6+HW/programmer.py
1,432
3.796875
4
# Создать структуру данных для студентов # из имен и фамилий, можно случайных. # Придумать структуру данных, чтобы указывать, # в какой группе учится студент (Группы Python, # FrontEnd, FullStack, Java). Студент может # учиться в нескольких группах. Затем вывести: # - студентов, которые учатся в двух и более групп...
c7eba5016168b3f6f1c1160a49869dec43e87378
imaination/My-Website
/PortfolioWebsite/Portfolio/STA141c/hw1_RurikoImai/Preprocessing.py
1,254
3.765625
4
#!/usr/bin/env python #import modules import pandas as pd import numpy as np import sys #get first argument as a csv file argument = sys.argv[1] #reading in datafile_csv data = pd.read_csv(argument, header = None, names = ["id","qid1","qid2","question1","question2","is_duplicate"]) #function to preprocess string d...
d87bd72b82665d64cf598d368a6581f02a3fd3e8
edoubt/cruft
/python/primesearch/primefinder.py
402
3.65625
4
import math lower = 2 upper = 331 primes = [] for x in range(lower,upper+1): factors = [] for i in primes: if i >math.ceil(x/2): break if math.fmod(x,i) == 0: factors.append(i) print (x,factors) if factors == []: primes.append(x) ...
70cafc142e592f2e51ed7461766de3513abb83ee
yuki2222/my_new_repo
/hangman.py
1,331
3.890625
4
import random def hangman(word): wrong = 1 stages = ["", "________ ", "| ", "| | ", "| O ", "| /|) ", "| / ) ", "| "] rlett...
508e8625fafc13e974aeee7a0da1764d6a6369f0
NDjust/Python_DataStructure
/Stack/ArrayStack.py
467
3.890625
4
class Stack: def __init__(self): self.data = [] def is_empty(self): return len(self.data) == 0 def push(self, item): self.data.append(item) def pop(self): if self.is_empty(): return "Stack is Empty!!" data = self.data[-1] self.data = self....
3fa74820f797e93cf0b7badb8108e74c4664a5ef
Hyunsu1227/Extraction-of-Log-Templates-From-Application-Source-Code
/lognroll_by_source_code/python/join_line_py.py
1,269
3.65625
4
def combine_into_one_line(line, left, right, fin): if line.find(left) != -1 and line[-2] != right: # print(line) line = line.rstrip() while True : string = fin.readline() # print(string) line += string.strip() try: if string[-2...
7eec8cd7112f46ab311e3b0c35e5525109f29bfb
filipjuszczak/python-gui-calculator
/app.py
12,528
4.34375
4
""" A standard GUI calculator using Tkinker. The calculator features: - addition - subtraction - multiplication - division - square root of a number - number to the power of 2 - 1 over number -> 1/3 = 0.(3) - percentages - memory - history """ from tkinter import * import math ...
0aef78dad628b255fb28d46031d4af9da884f29c
theahb/ISC-Project
/readwrite.py
302
3.578125
4
def read(): f = open("input", 'r') line = f.readline() split = line.split() c =float(split[2]) line = f.readline() split = line.split() b = float(split[2]) line = f.readline() split = line.split() c = float(split[2]) for line in f: print(line) #clean up f.close()
f6ef2ca57731d86e24b0825100693dbbd7fc9a7f
nandarahul/interview-challenges
/printEncoding.py
631
3.671875
4
def print_encoding(str, encoding): if len(encoding) == 0: print str return if not int(encoding[0]): print "INVALID Encoding" return if len(encoding) >= 2: if encoding[1] == '0': if int(encoding[:2]) > 26: print "Invalid Encoding" ...
a134242f682fb964ba528360f572659e2c02bc70
BrysonSeiler/Network-Generator
/network_characteristics.py
7,320
3.90625
4
import network_generation as generate def choose_network(): print(''' ---Generate Network--- List of supported network types: Classic Networks: 1. Erdős-Rényi 2. Newman–Watts–Strogatz (Small World) 3. Dorogovtsev-Goltsev-Mendes Lattices: ...
eabfc87ddccf6213f96af442705272ab0733aa9c
ArturoDLG/BakerChallenge
/Utileria/__init__.py
4,553
3.515625
4
# paquete para manejo de clases para el proyecto from pygame import display, time, event, mouse from pygame import Rect as Rectangulo, image, transform from pygame import MOUSEBUTTONDOWN, QUIT, KEYDOWN, K_ESCAPE from abc import ABCMeta, abstractmethod # Constantes de colores BLANCO = 255, 255, 255, NEGRO = 0...
820e507c8278f100544a45c17fb7196d2a10bd27
jeffaraujo/Python.Basico
/Python.Basico/Python.Basico.py
797
3.890625
4
import sys from math import sin, cos, radians def make_dot_string(x): return ' ' * int(10 * cos(radians(x)) + 10) + 'o' for i in range(360): s = make_dot_string(1) print s """multiple line commenting Example for importance of identation """ #Single commenting def spam(): eggs = 12 return eggs ...
a90dc4f1ca1e39e2ba6d7cdc0cf5641d3e2ab07c
gnidetsanna/homework
/Calculator/History.py
6,242
3.65625
4
import os import json import datetime import Keys file_of_users = '/Users/macuser/PycharmProjects/homework/Calculator/jj' def start(): first_answer = input('Are u a registrated user? T/F') if first_answer == 'T': auth() elif first_answer == 'F': second_answer = input('Do u want to registr...
4349d8299cdc3ba38464c3083253b118cfb2f4ef
TomasBahnik/pslib
/python/alp/lectures/pascal_triangle.py
456
4.03125
4
# -*- coding: utf-8 -*- def print_2d_matrix(a): for i in range(len(a)): print(a[i]) def pascal_triangle(N): """ Create a Pascal's triangle 'p' with 'N' rows, so that p[n][k] is 'n' over 'k' """ p = [[1]] for n in range(2, N + 1): prev = p[n - 2] # předchozí řada row ...
ae8285a2705030912f345f0f5256b3c467d7b4bd
TomasBahnik/pslib
/python/draft/t01/int_sum.py
716
3.859375
4
import sys # # soucet mocnin posloupnosti cisel # example # python int_sum.py 2 5 # # output # # k = 2, a = 5 # 0^2 = 0 # 1^2 = 1 # 2^2 = 4 # 3^2 = 9 # 4^2 = 16 # 5^2 = 25 # sum i^2 : i \in <0,5> = 55 # # k-ta mocnina : prvni argument k = int(sys.argv[1]) # druhy argument # a >= 0 : soucet od 0 do a (vcetne) # a <...
32b2618a0d1849c351fbb9b39a4473524ce4fd0b
TomasBahnik/pslib
/python/KUI/reversi/game.py
7,028
3.75
4
# import random import functools import random from collections import defaultdict import math cache = functools.lru_cache(10 ** 6) infinity = math.inf class Game: """A game is similar to a problem, but it has a terminal test instead of a goal test, and a utility for each terminal state. To create a game, ...
6ad5f12262e06ca93519dbd561ce11cdd3b508e9
TomasBahnik/pslib
/python/alp/cv01/soucet.py
103
3.515625
4
a = int(input()) k = int(input()) sum = 0 for i in range(1, a + 1, 1): sum += i ** k print(sum)
d823718523b9bc05ad9e985944e42be93cafeaca
TomasBahnik/pslib
/python/alp/test/anagram/anagram.py
2,360
3.65625
4
""" Program hleda dvojice anagramu UVOD anagram = textovy retezec(string), ktery pouzitim vsech pismen z puvodniho retezce zmeni jejich poradi napr. : debid card ---> bad credit VSTUP: txt soubor jako prvni argument - na kazdem radku tohoto souboru je string, ktery muze obsahovat mala/velka pismena a mezery ...
2fcae50ff91e54095f7388aadd74c3ec58b3109d
TomasBahnik/pslib
/python/draft/cv07/hw_07_light.py
1,210
3.6875
4
import sys from timeit import default_timer as timer n = int(input()) x = float(input()) DEBUG_PRINTS = True def debug_print(message): if DEBUG_PRINTS: print(message) hint = [] def r0(): return -1 def r1(y): return y def r2(y): return -y ** 2 def init_hint(y): hint.append(r0()) ...
de802698cca6ca139145ed50558f2453f13e7d6d
TomasBahnik/pslib
/python/alp/cv10/contents_bracket.py
951
3.84375
4
# def brackets(text): # stack = [] # for letter in text: # if letter in "[(": # stack.append(letter) # elif letter in "])": # top = stack.pop() + letter # print(top) # else: # if len(stack) > 0: # stack[-1] += letter # # # b...
eddead43d5a01f73d511417326df946421f00d2f
TomasBahnik/pslib
/python/alp/cv05/play.py
5,110
3.5625
4
import sys empty = 0 cross = 1 circle = 2 # how many solution is enough enough_num_of_solutions = 1 # num_of_solutions <= enough_num_of_solutions num_of_solutions = 0 def load_matrix(file): pole = [] with open(file, 'r') as f: for line in f: pole.append(list(map(int, line.split()))) r...
5667717b997cf32bfd980b95609ac761b3b83ab8
zaafirrahman/EngineeringEconomicTools
/NetPresentValueComparison.py
5,235
3.84375
4
# Run it only with Jupyter notebook or other Python IDE # Please only input numbers, and if it reaches thousands and above do not use dots # Continue to do the previous step as requested until it's finished # If there is a question that is not needed, please fill in the zero '0' # Especially for G (be it G1 or G2) if i...
0b5c6b953790fcf645c97ddd5c9d3ced54566a5c
apy444/Linear-regression-git
/Linear_regression.py
4,972
3.671875
4
# -*- coding: utf-8 -*- """ Created on Tue Sep 4 10:54:08 2018 @author: AndiGabi """ """ Machine Learning Problem Solving: Implementing Linear Regression with one varible This exercise based on Andrew NG: Machine Learning Coursera week2 assignement, which could only solved in MATLAB or OCTAVE. I used t...
0096c039215bcf2624f1a38fe5cb6393859d1dba
xanperi/project1
/Python Server/simple_server.py
1,268
3.53125
4
#!/usr/bin/python import http.server import io from os import curdir, sep, listdir, path PORT_NUMBER = 33333 #This class will handle any incoming request from #the browser class myHandler(http.server.SimpleHTTPRequestHandler): #Handler for the GET requests def do_GET(self): if self.path=="/": #print ("Path ...
2b5b329fbd0882d778499479bc9e96898b7546f2
Ayush-Malik/PracAlgos
/Array_rotation.py
277
3.96875
4
# https://www.geeksforgeeks.org/array-rotation/ arr = list(map(eval , input().split())) times = int(input("Enter the rotation value : ")) rotated_arr = [] for i in range(len(arr)): rotated_arr.append(0) rotated_arr[i] = arr[(i + times) % len(arr)] print(rotated_arr)
da336453687f7e9a60402c5e64f73fa439615467
Ayush-Malik/PracAlgos
/move_negative_numbers_to_beginning_and_positive_to_end_with_constant_space.py
774
3.859375
4
# https://www.geeksforgeeks.org/move-negative-numbers-beginning-positive-end-constant-extra-space/ arr = list(map(eval , input().split(', '))) pos_ptr = -1 neg_ptr = -1 def find_next_negative_number(start_index , arr): for i in range(start_index , len(arr)): if arr[i] < 0: # if current element is negative...
c2399f8fc2743a3af6c7e3d1a52bf95c0d1435ff
Ayush-Malik/PracAlgos
/maximum_even_numbers_in_any_subarray_of_size_k.py
758
4.21875
4
# https://www.geeksforgeeks.org/maximum-even-numbers-present-in-any-subarray-of-size-k/ arr = list(map(eval , input().split(', '))) k = int(input("Enter the value of k(size of subarray in which evens will be counted) : ")) # Counting initially how many evens are there in first window evens_count = 0 for i in range(...
ea1a5295e7371037a7230a330b25ede9cdfecb3e
junyi1997/TQC_Python
/4.第四類/PYD408.py
309
3.859375
4
# -*- coding: utf-8 -*- """ Created on Thu Jun 7 20:14:05 2018 @author: user 奇偶數個數計算 """ a=[] odd=0#奇數 even=0#偶數 for i in range(10): a.append(int(input())) if a[i] %2 ==0: even=even+1 else: odd=odd+1 print("Even numbers:",even) print("Odd numbers:",odd)
a10f5a394853b355e4b633d6f6a7bf76a5f27008
junyi1997/TQC_Python
/New code/class7/PYA708.py
678
3.875
4
# -*- coding: utf-8 -*- dic={} while True: print("key:",end="") key=input() if key == "end": break else: print("value:",end="") value=input() dic[key]=value a=dic.keys() b=dic.values() for i in a: print("{:}: {}".format(i,dic[i])) #key=[] #value=[] #whi...
dbd0d37fe4f345a23f096b60d54943d332a094de
junyi1997/TQC_Python
/New code/class7/PYA701-1.py
244
3.734375
4
# -*- coding: utf-8 -*- num=[] while True: num1=int(input()) if num1 == -9999: break num.append(num1) numn=tuple(num) print(numn) print("Length:",len(num)) print("Max:",max(num)) print("Min:",min(num)) print("Sum:",sum(num))
afd46d9722b7639e145d103242b42c8744d9d792
junyi1997/TQC_Python
/New code/class5/PYA109.py
120
3.734375
4
# -*- coding: utf-8 -*- import math s=eval(input()) a=(5*s**2)/(4*math.tan(math.pi/5)) print("Area = {:.4f}".format(a))
683b77b5f40eea69f0f0d7e84955f580ad769d1e
junyi1997/TQC_Python
/1.第一類/PYD105.py
235
3.8125
4
# -*- coding: utf-8 -*- #矩形面積計算 a=eval(input()) b=eval(input()) c=a*2+b*2 d=a*b print("Height = {:.2f}".format(a)) print("Width = {:.2f}".format(b)) print("Perimeter = {:.2f}".format(c)) print("Area = {:.2f}".format(d))
1e2096e9e837ac1e62e27ff241c58f00000cb40a
junyi1997/TQC_Python
/New code/class8/PYA807.py
175
3.9375
4
# -*- coding: utf-8 -*- a=input() s=a.split(" ") total=0 for i in s: total+=int(i) aver=total/len(s) print("Total = {:}".format(total)) print("Average = {:}".format(aver))
f06f1d4502ff6bed1fb6911911aa51e642581440
junyi1997/TQC_Python
/New code/class4/PYA406.py
408
3.90625
4
# -*- coding: utf-8 -*- while True: height=eval(input()) if (height==-9999): break weight=eval(input()) h=height/100 BMI=weight/(h**2) print("BMI: {:.2f}".format(BMI)) if BMI>=30: print("State: fat") elif BMI >=25: print("State: over weight") elif BMI >=18.5: ...
fdeca79482cc6da70651c18d30771f0bd57cc6b9
junyi1997/TQC_Python
/6.第六類/PYD606.py
284
3.765625
4
# -*- coding: utf-8 -*- """ Created on Thu Jun 7 20:16:15 2018 @author: user 二維串列行列數 """ def compute(): r=int(input()) c=int(input()) for i in range(r): for j in range(c): print("{:4}".format(j-i),end="") print("") compute()
cb25b3024dd56040ce78d95d60095f85d327b67c
junyi1997/TQC_Python
/New code/class2/PYA202.py
304
4.40625
4
# -*- coding: utf-8 -*- a=int(input()) if (a % 3 == 0): if (a % 5 == 0): print(a,"is a multiple of 3 and 5.") else: print(a,"is a multiple of 3.") else: if (a % 5 == 0): print(a,"is a multiple of 5.") else: print(a,"is not a multiple of 3 or 5.")
e263e8b216274c5a7734c2094c180070108800ba
junyi1997/TQC_Python
/New code/class5/PYA502.py
128
3.703125
4
# -*- coding: utf-8 -*- def compute(x,y): ans=x*y print(ans) return ans x=int(input()) y=int(input()) compute(x,y)
4aead0bb8fc916db2759ddce58870ba4c030b700
junyi1997/TQC_Python
/New code/class4/PYA409.py
524
3.828125
4
# -*- coding: utf-8 -*- Nami=0 Chopper=0 scrap=0 for i in range(5): poll=int(input()) if poll ==1: Nami=Nami+1 elif poll ==2: Chopper=Chopper+1 else: scrap=scrap+1 print("Total votes of No.1: Nami = ",Nami) print("Total votes of No.2: Chopper = ",Chopper) print("Total...
fe770d37c3f012383470ba567f00d7c563d70240
junyi1997/TQC_Python
/6.第六類/PYD608.py
571
3.609375
4
# -*- coding: utf-8 -*- """ Created on Thu Jun 7 20:16:26 2018 @author: user 最大最小值索引 """ data=[] d_max=0 d_min=99999 for i in range(3): data.append([]) for j in range(3): num=eval(input()) data[i].append(num) if num > d_max: d_max=num d_ind=(i,j) if n...