blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
fddeb74fb67991abac1ab3cd8846b4f17c03578e
mitsuki97/code
/python/图形化实验3.py
2,764
3.828125
4
#文件读入方法实现 import tkinter as tk import time import random class App(): N1,N2,N3,N4,N5=1,2,3,4,5 def __init__(self): self.root = tk.Tk() self.label1 = tk.Label(text="第一进程") self.label1.pack() self.label2 = tk.Label(text="第二进程") self.label2.pack() self.label...
d3393745af194d5598847322a769c6a7f22d1349
walln/algorithms
/data_structures/linked_list/linked_list.py
883
3.9375
4
class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def __str__(self): current = self.head nodes = [] while current is not None: nodes.append(current.data) cu...
797a28f379696143d163c63021fd2751da4176d7
labeee/idf_generator
/LHS.py
5,291
3.921875
4
# Para utilizar, crie um arquivo na mesma pasta chamado 'vectors.csv', e defina o tamanho da amostra pelo sampleSize import argparse import csv from pyDOE import lhs def csvToHash(vectors): # Reads the vectors file, and returns a dictionary with the values # of each vector, and the header firstTime = Tr...
c3c7308dd05dd242b866bfb78ad1b79c5d428466
PDSD-2014/stratulat-barbulescu
/pyserver/utils.py
2,404
4.25
4
import math import configuration import json import urllib2 def compute_distance(lat1, lng1, lat2, lng2, unit="km"): """ This function computes distance based on latitude and longitude between 2 points on Earth Returned result is given in unit. By default is in kilometers Code snipped is taken fr...
6cc209efb98c4de0b65efd9951915a3c94f879ea
nsk06/Socket-programming
/Q2/Server/server_nonpersistant.py
2,619
3.609375
4
# Connection is closed after a file is sent import socket import os port = 60007 #Here we made a socket instance and passed it two parameters. #The first parameter is AF_INET and the second one is SOCK_STREAM. #AF_INET refers to the address family ipv4 #Secondly the SOCK_STREAM means connection oriented TCP prot...
a1a7a89145499e27f03f70e3a8c664633b1cdd8b
cumhur9090/Small-projects
/flyer.py
1,218
4.03125
4
### ### Author: Cumhur Aygar ### Class: CSc 110 ### Description: Create a Wright Flyer using ASCII art ### ### size = int(input("Wright flyer size:\n")) p = int(size*1.2) height = (int(size/5) +1) #I created a second variable that equaled height so that after my initial loop, I would still have a varia...
a8f96eabdac97f07fbcba1692c4e09a02d766bbf
mmelk057/ConcentrationGame
/Concentration Game.py
8,384
4.09375
4
import random ############################## # Full name: Maxim Melkonian # # Student number: 300019652 # # Course: IT1 1120 # # Assignment Number: 3 # ############################## ############################################ # Additional Helper Functions # ###########################...
657d529bb2cdb34f4bf7b675d8c787f48b16167e
AndersonLongo/trabalho-1.1
/atv 3.py
1,050
4.125
4
# Faça um Programa que leia 2 números e em seguida pergunte ao usuário qual operação ele deseja realizar. # O resultado da operação deve ser acompanhado de uma frase que diga se o número é: # par ou ímpar; # positivo ou negativo; # inteiro ou decimal. valor1 = int(input('insira o primeiro valor: ')) valor2 = in...
f862ca5eae31d5ed5410421bff2e0ba023fca479
KVexcavator/py-learn
/mymodules/vsearch.py
455
3.796875
4
def search_vowels(phrase: str) -> set: """Возврашает гласные, найденные в указанной фразе.""" vowels = set('aeiou') return vowels.intersection(set(phrase)) def search_letters(phrase: str, letters:str='aeiou') -> set: """Возврашает множество букв из 'letters', найденных в указанной фразе.""" retu...
de9e0710624cf18b3e7655e3bfef736d42173635
hvaidsain/Leetcode-problems-and-challenges
/May-Challenge/cousinsInBinaryTree.py
1,886
4.03125
4
# In a binary tree, the root node is at depth 0, and children of each depth k node are at depth k+1. # Two nodes of a binary tree are cousins if they have the same depth, but have different parents. # We are given the root of a binary tree with unique values, and the values x and y of two different nodes in the tree....
1037b85a1d6e52ad957710553d151ecc56bcc349
byebyers/fill-in-the-blanks-quiz
/byers_fill_quiz4.py
5,643
4
4
#define input spaces test_blanks = ['__1__', '__2__', '__3__', '__4__'] #define questions for difficulties easy, medium, hard. easy_quest = "In the Lord of the Rings trilogy. We know that the main character's first name is __1__ Baggins and he was accompanied by his hobit friends (first names not nicknames) __2__ G...
787ca9617165216eca6f52e10ae9d2e66824346b
shalo1040/python
/code/python19.py
420
3.75
4
# 문자열을 입력 받아 같은 문자가 연속적으로 반복되는 경우에 그 반복 횟수를 표시하여 문자열을 압축하여 표시해 보자. str = input("문자열을 입력해주세요: ") ans = "" cnt = 1 for i in range(len(str)-1): if str[i]==str[i+1]: cnt += 1 else: ans += str[i] ans += f'{cnt}' cnt = 1 ans += str[len(str)-1] ans += f'{cnt}' print(ans)
6ea86c65951a25bff1e5c81c1f64ec4077668700
kartverket/kivyMaps
/sidepanel.py
8,798
3.625
4
''' Side panel: a panel widget that attach to a side of the screen ''' __all__ = ('SidePanel', ) from kivy.animation import Animation from kivy.uix.widget import Widget from kivy.uix.button import Button from kivy.clock import Clock from functools import partial class SidePanel(Widget): '''A panel widget that at...
edf93f2dd437525c4f94d14864adfab29138da5c
awulfing/127_Python
/Quizs/Adam-Wulfing-Quiz1.py
902
3.59375
4
# -------------------------------------- # CSCI 127, Quiz 1 | # Adam Wulfing | # -------------------------------------- import random def thething(): rowsize = input("How many rows? ") columnsize = input("How many columns? ") y = 0 x = 0 for y ...
92ca68cb76e7efb4258d072eed19f0ea020f621e
radicalsubject/adventofcode2020
/8 day/advent_8_both_parts.py
3,760
3.59375
4
from modules.PuzzlesAPI import PuzzleInput url = 'https://adventofcode.com/2020/day/8/input' input_conn = PuzzleInput(url) soup = input_conn.get_puzzle_input() def get_index_positions_by_condition(list_of_elems, condition): ''' Returns the indexes of items in the list that returns True when passed to condition()...
fd827051114ddbdc81fd902058b9f102268aa75f
Will1900/deeplearning_code
/newton.py
2,668
3.84375
4
import numpy as np from sklearn import datasets from sklearn.linear_model import LinearRegression class Newton(object): def __init__(self,epochs=50): self.W = None self.epochs = epochs def get_loss(self, X, y, W,b): """ 计算损失 input: X(2 dim np.array):特征 y(1 dim np.array):标签 W(2 dim np.array):线性...
322f8e59f559b577dce48b6aa52c0453e5e04237
terwebs/Python-learning
/enrollment_stats.py
1,159
3.921875
4
def enrollment_stats(universities): students = [] tuition = [] for n in range (len(universities)): students.append(universities[n][1]) tuition.append(universities[n][2]) return [students, tuition] def total(list): total_students = 0 total_tuition = 0 for n in range (len(list...
4816f14a215ce208def07f01d5a6925ffb70d8e7
terwebs/Python-learning
/lists_review.py
658
4.03125
4
desserts = ["ice cream", "cookies"] desserts.sort() print desserts print desserts.index("ice cream") food = [] food.extend(desserts) print food food.extend(["broccoli", "turnips"]) print desserts, food food.remove("cookies") print food[0:1] breakfast = ("cookies, cookies, cookies").split(", ") print breakfast # Defin...
a5cc0df32a7f61638d73525e6bf69981dc0b70bc
terwebs/Python-learning
/factors.py
350
4.0625
4
def factor(number): for n in range(1,number + 1): # Returns the remainder of any division. ex since 4 is divisible by 2 # 4 % 2 returns 0 if number % n == 0: print "{} is a divisor of {}".format(n, number) return number number = raw_input("Enter a positive integer:") number...
5dfced0f1a8823fecf2d450e79f93b495ff29bdb
salehgondal/tic-tac-toe
/tic-tac-toe.py
3,685
3.796875
4
import string from random import random def print_game(slots): print("\n") for i in range(len(slots)): for j in range(len(slots[i])): if j < len(slots[i])-1: print(slots[i][j]," | ",end=" ") else: print(slots[i][j]) if i == le...
2bc6a4ad3bac9a8da5114a666db1836a19068b30
Michael-Zagon/ICS3U-Unit4-02-Python
/integer_multiplication.py
828
4.46875
4
#!/usr/bin/env python3 # Created by: Michael Zagon # Created on: Sep 2021 # This program multiplies each whole number that goes up to the users number def main(): # This function multiplies each whole number that goes up to the users number counter = 1 the_product = 1 # Input integer_a_s = input...
82be81f80a1edea24a08cd48daa43f1b62075de9
Kolytics/yfinancedatagrab
/main.py
5,736
3.609375
4
#!/usr/bin/env python # coding: utf-8 # In[735]: import yfinance as yf import pandas as pd import numpy as np import math import time # In[879]: def fetch_max_history(ticker: str) -> pd.DataFrame: """Using yahoo finance, fetch max pricing history. Export to file and also return the data.""" # Histori...
bc5599ae3181989d46ebd03ed5a0997702b27317
sburstein/ML-River-Flow-Prediction
/Analysis_Regression&ML/RiverFlowModel.py
11,666
3.59375
4
# ClimateAi Coding Challenge # By Scott Burstein import pandas as pd from matplotlib import pyplot as plt import numpy as np # Part 1: Summary Statistics and Data Transformation df = pd.read_csv("RiverData.csv") plt.hist(df.flow, bins = 100) plt.xlabel("River Flow (m^3/s)") plt.ylabel("Frequency") plt.title("Measur...
7061809b76eb14b657457d569996560dc01be6fa
yangxiaomu/learnPython
/code8.py
373
3.515625
4
#!/usr/bin/python #coding=utf-8 # 题目:输出 9*9 乘法口诀表。 for i in xrange(1,10): a = [] for j in xrange(1,10): if j>i: break a.append(str(i)+"*"+str(j)+"="+str(i*j)) print a for i in xrange(1,10): print for j in xrange(1,10): print "{}*{}={}".format(j, i, j * i), ...
afd93efdd5fadea3d40f2bef3807adf5d3640321
yangxiaomu/learnPython
/code5.py
457
4.03125
4
#!/usr/bin/python #coding=utf-8 # 输入三个整数x,y,z,请把这三个数由小到大输出。 x = int(raw_input("Please input x:")) y = int(raw_input("Please input y:")) z = int(raw_input("Please input z:")) list = [] list.append(x) list.append(y) list.append(z) # # for i in range(0,3): # for j in range(i,3) : # if (list[i] >= list[j] ): # ...
21300a44cc6b47931c466220a83eb68b30d79cfa
anna-s-dotcom/python_grundkurse_meineNotizen
/math_uebung.py
574
3.6875
4
#erstelle zwei 4*4 Matrizen mit zufälligen Zahlen #erstelle eine Matrix, welche in jedem Element das Porduktder anderen Matrizen hat import numpy as np m1=np.random.randint(1,11, (4,4)) m2=np.random.randint(1,11, (4,4)) m3=m1*m2 print(m1) print() print(m2) print() print(m3) print() # a=[[1,2][2,3]...
89e37315d055d3a037a3036090ec6aa09a0e83ed
xalbec/PythonClassMaterials
/ PyPong/main/Ball.py
886
3.71875
4
import pygame class Ball: def __init__(self, x, y, vx, vy, screen): self.rect = pygame.Rect(x, y, 5, 5) self.vx = vx self.vy = vy self.screen = screen def display(self): pygame.draw.rect(self.screen, [255, 0, 0], self.rect) def move(self): # checks to see...
0e3c02719536f82f8dfff3e34d477bacc942a434
ZTertychny/python-gb
/gb_algorithms/lesson_02/les_2_task_4.py
387
4.03125
4
# Найти сумму n элементов следующего ряда чисел: 1, -0.5, 0.25, -0.125,… Количество элементов (n) вводится с клавиатуры number_of_el = int(input('Введите количество элементов: ')) res = 0 number = 1 for item in range(number_of_el): res += number number /= -2 print(res)
03908e9150cb76e4ce48ee6cf985748bab167700
ZTertychny/python-gb
/gb_algorithms/lesson_3/les_3_task_1.py
570
3.578125
4
# 1. В диапазоне натуральных чисел от 2 до 99 определить, сколько из них кратны любому из чисел в диапазоне от 2 до 9. # Примечание: 8 разных ответов. res = [0] * 8 for num_of_array in range(2, 100): for divider in range(2, 10): if num_of_array % divider == 0: res[divider - 2] += 1 counter =...
e6f037c5c336e95539607af7bceada313e705eaa
jwcrandall/galvanize
/DSI_g58/lecture/Week_1/panda_quiz.py
1,789
4.0625
4
## Warmup: Pandas Practice # **Include your code and answers in** `pandas_quiz.py`. # # 1. Load the `data1.tsv` into a `pandas` dataframe. Look at pandas various data [loading functions](http://pandas.pydata.org/pandas-docs/stable/io.html) and pick an appropriate one to use. Look at it's keyword arguments, they do s...
1f98d21c413636bbb2a0a03feb922cd84526d06b
jwcrandall/galvanize
/python-fundamentals/week2/day3-beyond_numerics/Ans_part2_4.py
806
4.125
4
# Write a script that makes every other letter of a user inputted # string capitalized. x1 = input("Enter your string: ") # for i in x1[1::2]: # print(x1) # x2 = x1.append(x1.upper()) # print(x2) # One way to do this. empty_lst = [] for idx, char in enumerate(x1): if idx % 2 != 0: empty_lst.append(...
d8ea75db7864c4f12e512490a6124a46f52c0101
jwcrandall/galvanize
/Galvanize-Intro-Python/Data_Science/cipher.py
1,575
4.375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Sep 2 18:30:17 2017 @author: rdelapp """ def cipher(text, cipher_alphabet, option='encipher'): ''' Run text through a particular cipher alphabet Parameters ----------- text: str Either the plain text to encipher, or the cipher text to decrypt c...
e591ffda718c17389c6a1f87ae0b34fbd75cc420
jwcrandall/galvanize
/Galvanize-Intro-Python/Data_Science/count_isograms.py
267
4.15625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Sep 2 19:50:56 2017 @author: rdelapp """ def count_isograms(list_of_words): list_of_words = list_of_words.lower() return([len(set(x)) == len(x) for x in list_of_words].count(True)) pass
4b591b9e1be354e4d02f6f8920262e9bf5aff012
WilliamMKLee/hackerrank-30-days
/30days_code_py/day1.py
508
4.21875
4
''' Input Format A single line of text denoting (the variable whose contents must be printed). Output Format Print Hello, World. on the first line, and the contents of on the second line. Sample Input Welcome to 30 Days of Code! Sample Output Hello, World. Welcome to 30 Days of Code! Explanation ''' # get a lin...
d68d07b312480db948ba36351647ba99a2860dec
WilliamMKLee/hackerrank-30-days
/30days_code_py/day11.py
888
3.6875
4
def sum_square(square, col, row): ''' sum square number except someone, S mean skip 111 S1S 111 ''' _total = 0 for c in range(col - 1, col + 2): for r in range(row - 1, row + 2): if (r == (row - 1) or r == (row + 1)) and c == col: continue _tot...
46ed1eeb617fe42523cfe05dc54a9e1c5a8262d7
abdullahshah97/python-exercises
/ch9_inheritance.py
1,204
4.25
4
class User(): """This is a class for Users""" def __init__(self, f_name, l_name): self.f_name = f_name self.l_name = l_name self.login_attempts = 0 def describe_user(self): print("First Name: "+self.f_name.title()+"\nLast Name: "+self.l_name.title()) def greet_user(self): print("Hello "+self.f_name.titl...
36e4ee7fc1d00c12254e5a3a7d02ea515a043480
abdullahshah97/python-exercises
/guess_the_number.py
1,331
4
4
from random import seed from random import randint def starting_option(): name = input("What is your name?\n") hard = input("Hello "+name+" try to guess my number between 1 and 20.\nDo you want limited tries (4)? (yes/no)\n") if "yes" == hard.lower() or "y" == hard.lower(): hard = 1 else: ...
b4d4ea2ffa01078c473462e53f3ac230e2660cd9
esltech/python_class
/Example/Data_Structure/Link-List/Single_Link_List_Dynamic.py
628
4.03125
4
# Create Link List dynamically as per the user input.(Example-2) class Node: def __init__(self): self.data=None self.nxt=None def assign_data(self,val): self.data=val def assign_add(self,addr): self.nxt=addr def_list=list() list_len=int(input("Please enter the no o...
f439a521c452c0ca54f43d6d73fc3a3841e5ce81
esltech/python_class
/prime_no_check_time_complexity.py
797
4.09375
4
#Checking of prime number: def checkPrime1(inp_num): flag=True print("Inside Method:1") for i in range(2,(inp_num-1)): #O(n) if inp_num%i==0: print("Number divisible by:",i) flag=False return flag import math def checkPrime2(inp_num): flag=True print("...
76a1fd798114867ba66546d6669b6bf1dab5c5b9
redplug/Study
/20190105_Python/programmers_lv1_star.py
88
3.703125
4
a = 5 b = 3 for i in range(0,a,1): for j in range(0,b,1): print('*', end='') print()
8aceb72ef55eefc1157d6f4c81a998d6510be0a4
redplug/Study
/20190105_Python/tuple_packingunpacking.py
425
3.75
4
a, b = 1, 2 ## a와 b로 만들어진 튜플이 만들어짐 c = (3,4) print(c) d, e = c ## 언패킹 : 패킹된 변수에 여러개의 값을 꺼내 오는 것 print(d) print(e) f = d, e print(f) ## 패킹 : 하나의 변수에 여러개의 값을 넣는 것 x = 5 y = 10 print(x) print(y) x, y = y, x ## 맞바꿀대 유용함. print(x) print(y) def tuple_func(): return 1, 2 q,w = tuple_func() print(q) print(w)
15aedf05fa47d3d5166df46f1cc649c87988754e
redplug/Study
/20190105_Python/function3.py
380
3.78125
4
def print_root(a, b, c): r1 = (-b + (b ** 2 - 4 * a * c) ** 0.5) / (2 * a) r2 = (-b - (b ** 2 - 4 * a * c) ** 0.5) / (2 * a) print('하는 {} 또는 {}'.format(r1, r2)) x = 1 y = 2 z = -8 print_root(x, y, z) x = 2 y = -6 z = -8 print_root(x, y, z) def print_round(number): rounded = round(number) print(rounded) ...
82ae0c4d8b7d371c59e4ff7943821b62e2580353
Tru-Dev/ScalableTicTacToe
/tictactoe_ui/t3sc.py
5,426
3.984375
4
""" t3sc: Tic Tac Toe Scalable Game classes for scalable Tic Tac Toe game. """ from enum import Enum, auto class TurnResult(Enum): """ Descriptive enum for the result of a turn """ SUCCESS = auto() FAILURE = auto() WINNER = auto() DRAW = auto() class TicTacToeScalable: """ Game cla...
dd365f28c0c032d09f90d710ae7f8d11a43e9bbd
priyablue/Python-Programming
/Chapter04/word_reverse.py
257
4.46875
4
# takes a word from user and prints it out backwards word = None print('Welcome to the word reverse program. Press enter to exit') while word != "": word = input('\nWhat word would you like reversed? ') print(word[::-1]) print('See you later!')
f6473f5dc7d506af1c8210f29137519a7154962d
priyablue/Python-Programming
/Chapter10/number.py
4,063
4.09375
4
# A simple Guess My Number game with a GUI import random from tkinter import * class Application(Frame): """GUI Application which lets a user play Guess My Number""" def __init__(self, master): super(Application, self).__init__(master) self.grid() self.create_widgets() self.res...
f681fbf95c3926d3eda7abbc5635d3e08d99c051
priyablue/Python-Programming
/Chapter05/character_creator.py
2,593
4
4
# This is a Character Creator program # it allows the user to spend a set amount of points on atributes # user can spend points, take points and reassign them too total = 30 user_input = None attributes = {"strength": 0, "health": 0, "wisdom": 0, "dexterity": 0} print(""" Welcome to the Character Creator! ...
0afd0c0973ddef29ffc8b88742195798c25f91da
ebrudiler/Assembly-Line-Balancing---Genetic
/maxone_genetic.py
3,763
3.546875
4
# -*- coding: utf-8 -*- from random import randint as rnd from random import uniform from random import shuffle import matplotlib.pyplot as plt N = 100 #chromosome size M = 1000 #population size crossOverRate = 0.8 mutationRate = 0.2 maxIteration = 500 def createChromosome(): return [rnd(0, 1) for _ in range(N)] ...
18221d2766ed44758bc609aa3e3676fcff394e8d
JaiBalaj/Programs-Practiced
/SumOfDigit.py
212
3.53125
4
def SOD(num): total=0 while num>0: digit=num%10 num=num//10 total+=digit return total if __name__ == '__main__': num=SOD(100) print("called") print(num)
824ccee54a04350b14d8171d4af03e388759519f
JaiBalaj/Programs-Practiced
/importChk.py
247
3.578125
4
import sys a=[1,2,2,7,8,9,4,5,3,99,24,6,677,677] largest=a[0] for i in range(len(a)): if a[i]>largest: largest=a[i] seclar=a[0] for i in range(len(a)): if a[i]>seclar and a[i]!=largest: seclar=a[i] print(seclar)
5b6bcf7d7b5868e14774a010cb31a719f9e21cf0
JaiBalaj/Programs-Practiced
/first.py
435
3.5625
4
if __name__=="__main__": a=[9,8,7,6,5,4,3,2,4,3,5,7,8,1,0] if(a[0]>a[1]): lar=a[0] sec=a[1] else: lar=a[1] sec=a[0] diff=lar-sec for i in range(2,len(a)): diff=lar-sec if a[i]>lar: sec=lar lar=a[i] else: ...
5a7d07bab2c8e346f5b6b530748a7da8d045bad8
JaiBalaj/Programs-Practiced
/formula.py
126
3.5
4
#(2n-1) for every digit upto n n=input("Enter Upto n: ") sum=0 val=0 for i in range(1,n+1): val=((2*i)-1)+sum
bc31ddadf81e291607691fe3c72f18a825bfd68d
JaiBalaj/Programs-Practiced
/brasis.py
617
3.6875
4
if __name__=="__main__": arr=input().strip() a='{' b='}' c="(" d=")" e="[" f="]" stack=[] strlen=arr.__len__() halflen=int((strlen/2)) cnt=0 if strlen%2!=0: print("False") else: for each in arr: if each in (a,c,e): ...
927f112c5db58cd6f77e4a078d5e664bd5ba8624
etadn/cshomework
/section-3.py
266
4.375
4
# Write a program to take as input a positive integer. # The program is to output integers counting from 1 to the number input. # For example, an input of 5 will output: 1 2 3 4 5 n = int(input('What is your positive integer? ')) for i in range(1,n+1): print(i)
fd05e5593c8ce5ce2f793ffa0737876367685185
EshbanTheLearner/100DaysofMLCode
/Day-44/value_iteration.py
1,582
3.765625
4
"Discount factor" gamma = 1 "Probability of home team winning" p = 0.4 "The number of states availabe" numStates = 100 "List for storing the reward value" reward = [0 for _ in range(101)] reward[100]=1 "Small threshold value for comparing the difference" theta = 0.00000001 "List to store the value function for all st...
5cea01d957eb1bb34412724fe601c0c9971454c2
EshbanTheLearner/100DaysofMLCode
/Day-45/fibonacci_memoization.py
298
3.953125
4
def fibonacci(n, lookup): if n==0 or n==1: lookup[n] = n if lookup[n] is None: lookup[n] = fibonacci(n-1, lookup) + fibonacci(n-2, lookup) return lookup[n] def main(): n = 10 lookup = [None]*(101) print('Fibonacci Number is ', fibonacci(n, lookup)) if __name__ == '__main__': main()
c8e06f0ab6e0f85874b8ffd9aae1b54293a99260
neizod/neizod.github.io
/scripts/draw_pascal_mod3.py
1,122
3.5
4
#!/usr/bin/env python3 from math import factorial from PIL import Image, ImageDraw choose = lambda n, k: factorial(n) // factorial(n-k) // factorial(k) class PascalMod3(object): def __init__(self, rows, radius): self.rows = rows self.radius = radius self.width = 1 + int(2*self.radius*s...
e274d81b382ff50bf3f099b358f7360be5e0514f
DonCo007/Sistem_de_demonstratii
/Prob6_2/Obiect.py
10,202
3.625
4
class Sistem_Demonstratii: def __init__(self, graph = None): if graph == None: graph = {} self.graph = graph def initializare_sistem(self): print("Cate expresii doriti sa intializati: ",end="") nr = int(input()) self.nr = nr lista_1 = list()...
f040a44f27fa25a467d036fcc0cb894580fb8a16
wayne9598/Sudoku-Creator-and-Solver
/create.py
2,180
3.515625
4
import random from utilities import check_availability, show_board, solve_board, find_num_of_answer def add(n): template = [ [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], ...
1de11f74b99de33a6b879e291a00ff04f5f5d269
yiruigao98/EECS545-WN2020
/assignments/HW1/Q1.py
1,726
3.515625
4
import numpy as np import math import matplotlib.pyplot as plt ############################## Part b ######################################## def sigmoid(X): return 1/(1 + np.exp(-X)) def log_likelihood(X, w, y): epsilon = 1e-5 p = sigmoid(X.dot(w)) return np.sum(y * np.log(p) + (1 - y) * np.log(1 -...
76555bbf0154078eca07ffddaea58d3da54a2206
AndyZ-Salz/Algorithm_On_Python
/C3/3.3.py
901
4.03125
4
# -*- coding: utf-8 -*- """ --------------------------------------- @file : 3.3 @Version : ?? @Author : Andy Zang @software: PyCharm @For : --------------------------------------- """ # History: # 2021/2/24: Create def word_pattern(wordPattern, input): word = input.split(" ") if len(word) != len(wo...
30d4408be482ddf72fb25baf38c3dacd1dd97ff9
VIMALJITHK/python_project
/matrixoperations.py
3,448
4.15625
4
class Matrices: def menu(self): ''' This function takes an option from user 1 for addition 2 for multiplication 3 for quit ''' option = input(''' 1: Addition 2: Multiplication 3. Quit make a selection from 1...
c634dfb85f8a379ae9de631c9212427b5ace32ee
Piressss/spoj_br
/FUROS/furos.py
2,145
4
4
#!/usr/bin/env python import sys import math import timeit #Funcao para calcular o diametro def diametro(centro=[],furo=[]): #calcula a distancia em X e Y x=furo[0]-centro[0] y=furo[1]-centro[1] #normalizo pois os valores nao podem ser negativos if x < 0: x=x*(-1) if y < 0: y=y...
2441334d5339f8cdfa42b3c12af673f6e053c562
MansourKef/holbertonschool-python
/0x04-python-more_data_structures/10-best_score.py
257
3.53125
4
#!/usr/bin/python3 def best_score(a_dictionary): if not a_dictionary: return None a = 0 value = "" for key in a_dictionary: if a < a_dictionary[key]: a = a_dictionary[key] value = key return value
9f958186d554b1be5ed7bdc53803864069664c43
MansourKef/holbertonschool-python
/0x0C-python-input_output/0-read_file.py
226
3.9375
4
#!/usr/bin/python3 """ Module 0-read_file.py """ def read_file(filename=""): """reads a file in UTF8""" with open(filename, 'r') as myFile: for line in myFile: print(line, end='')
755ef8f327789880428adf3f566d19ee43ccdfba
MansourKef/holbertonschool-python
/0x0B-python-inheritance/7-base_geometry.py
562
3.65625
4
#!/usr/bin/python3 """ Module that defines a BaseGeometry return {} """ class BaseGeometry: """This is An Empty Class Called BaseGeometry""" def area(self): """Return Area""" raise Exception("area() is not implemented") def integer_validator(self, name, value): """ val...
288e3241acbb8463d0547e3390770faf0f7037cb
MansourKef/holbertonschool-python
/0x07-python-test_driven_development/tests/6-max_integer_test.py
704
4.03125
4
#!/usr/bin/python3 """ Unittest for max_integer([..]) """ import unittest max_integer = __import__('6-max_integer').max_integer class TestMaxInteger(unittest.TestCase): def test_max(self): """Test When List Values Are in correct Form""" self.assertAlmostEquals(max_integer([1, 2, 3, 4]), 4) ...
6f045110675a7890a5e928c1879b4fe71811ffbe
LouieLouieZPC/hello-world
/Python基础/3.2程序流程控制语句小结/3.法二:统计字符串内元素类型的个数.py
1,086
4.03125
4
# 法二 ''' 使用自定义函数: 语法: def functionname( parameters ): "函数_文档字符串" function_suite return [expression] 规则: 函数代码块以 def 关键词开头,后接函数标识符名称和圆括号()。 任何传入参数和自变量必须放在圆括号中间。圆括号之间可以用于定义参数。 函数的第一行语句可以选择性地使用文档字符串—用于存放函数说明。 函数内容以冒号起始,并且缩进。 return [表达式] 结束函数,选择性地返回一个值给调用方。不带表达式的return相当于返回 None。 ''' def strnum(element): #...
b86ee9153e5a6e58c2a89933c6dd4b0f64cfdf98
LouieLouieZPC/hello-world
/Python基础/6.1面对对象编程/11.列表解析式与生成器表达式.py
337
3.984375
4
列表解析式,一次性输出一个序列:[expr for iter_var in iterable if cond_expr] 例:生成一个list来保护50以内的所有奇数 [i for i in range(50) if i%2] 当序列过长,每次只需要获取一个元素时,当考虑使用生成器表达式 生成器表达式:(expr for iter_var in iterable if cond_expr)
ca980633edbfbe8813ae7befa3bd1b4d28823305
LouieLouieZPC/hello-world
/Python基础/4.1函数/9.Taks3(计算列表中位数的函数).py
381
3.671875
4
def midnum(*args): args=list(args) args.sort() if len(args)%2==1: n1=len(args)//2 return('该列表元素个数为奇数,中位数为:',args[n1]) elif len(args)%2==0: n2=(len(args)//2)-1 m=n2+1 z=(args[n2]+args[m])/2 return('该列表元素个数为偶数,中位数为:',z) args=[3,1,4,2] print(midnum(*args))
221343d1adb9f9362c6f9ccef1c19e3ea5490cd0
LouieLouieZPC/hello-world
/Python基础/4.1函数/1.自定义函数.py
5,001
4.34375
4
''' 定义函数时,需要确定函数名和参数个数; 如果有必要,可以先对参数的数据类型做检查; 函数体内部可以用return随时返回函数结果; 函数执行完毕也没有return语句时,自动return None。 所以最好用return替代print,return('xxxxx',xxxx) 函数可以同时返回多个值,但其实就是一个tuple。 函数体内部的语句在执行时,一旦执行到return时,函数就执行完毕,并将结果返回 如果没有return语句,函数执行完毕后也会返回结果,只是结果为None。return None可以简写为return ''' #5.1 函数定义 >>> def my_function(paramete...
8f670fe121aac11b09ccb7d3dae4eca665c5f1b1
LouieLouieZPC/hello-world
/Python基础/2.2数据结构小结/操作题1.py
204
3.640625
4
#-*-coding:utf-8-*- list1=[5,8,-7,4,6,2,-3,0] print('列表的最大元素为:',max(list1)) x=min(list1) print(x) y=list1.index(x) del list1[y] list1[5]=abs(list1[5]) print('最后结果为:',list1)
363924cd139117beb4b4e9d1832e7b9795e1b988
LouieLouieZPC/hello-world
/Python基础/1.2基础知识小结/输入半径,输出面积及周长.py
413
3.90625
4
# 输入圆的半径,输出面积周长 import math # 调用数学 Π=math.pi # 定义Π r=input('输入该圆半径:') r=float(r) # input()函数输入的是字符串格式;转换为浮点数 C=2*Π*r S=Π*r**2 print('该圆面积为:',S,'该圆周长为:',C,) # 输出该圆的面积和该圆的周长
fb6b4b916a163523776a2e4ba0305a887d1ae43b
LouieLouieZPC/hello-world
/Python基础/3.2程序流程控制语句小结/2.法一:统计字符串内元素类型的个数.py
315
3.625
4
# 法一: intCount=0 strCount=0 otherCount=0 element=input('请输入一段字符串:') # 输入 for i in element: # for循环语句 if i.isdigit(): intCount+=1 elif i.isalpha(): strCount+=1 else: otherCount+=1 print(intCount,strCount,otherCount) # 输出
405f4deb9cd6223e72a190222117b9da5b7aea87
Bhavitg/image-search
/searchgui.py
1,818
3.515625
4
#PyQt5 is used for making GUI for taking imput from user from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QVBoxLayout, QLineEdit, QLabel from PyQt5.QtCore import * #sesearch is the name of file in which python code is written for searching image on google from sesearch import * #qtmoder header file is us...
83868cea2939b1d9b3e7aef124fd681929b202f1
kragebein/PythonFun
/zodiac.py
1,635
3.5
4
''' Get your daily horoscope here ''' from datetime import datetime import requests, json, random class stjerntegn(): def __init__(self): self.total = 365 self.stjerentegn = { 'Aries': ['80', '110'], 'Taurus': ['111', '141'], 'Gemini': ['142', '172'], ...
8e1cd926708914c8b33d9e1339f8c307581d691d
erkearney/minecraft_atomizer
/alpahabetize.py
1,284
4.3125
4
''' This module will take a text file and alphabetize it. Example ------- $ python alphabetize.py items.csv Alphabetizes items.csv by the first character on each line. ''' import argparse def get_file_to_alphabetize(): ''' Sets up command-line arguments and gets to file to be alphabeitzed. Attributs ...
3de3abe15550b666213d7d741b3b89000f9f55d9
nikita1610/100PythonProblems
/Problem05/Day5.py
383
3.71875
4
def sort_frequency(s): d={} ans="" for item in s: if item in d.keys(): d[item]+=1 else: d[item]=1 s1=sorted(d.items(),key=lambda item: (item[1], item[0])) sorted_keys = [ item[0] for item in s1 ] for item in sorted_keys: ans+=item*d[item] ...
e59bb33fc2372430d339a28f3e7c86a24a1c8f73
nikita1610/100PythonProblems
/Problem01/Day1.py
1,124
3.984375
4
# Approach 1 using separate lists for storing the sum from both right and left # Space Complexity : n # Time Complexity : O(n) def find_index1(a): sum_left=[] sum_right=[] sum=0 ans=-1 for item in a: sum+=item sum_left.append(sum) for item in a: sum_right.append(sum) ...
6a207d230fc7ee111efe2f6e77f1b501235854c5
nikita1610/100PythonProblems
/Problem02/Day2.py
446
3.828125
4
def find_set(a): a1=list(set(a)) # to avoid duplicates a2=[] for item in a1: a2.append(''.join(sorted(item))) ans=[] print(a2) for word in set(a2): indexes=[i for i,x in enumerate(a2) if x==word] temp=[] for index in indexes: temp.append(a1[index]) ...
2602fdc2f06983d4afc2101c5b17aec13b6b33fb
nikita1610/100PythonProblems
/Problem94/Day94.py
257
3.5625
4
from string import punctuation def get_pnc_count(strng): return len([ele for ele in strng if ele in punctuation]) def get_list(l): l.sort(key = get_pnc_count) return l l = ["Hello@%^", "Best!"] a=get_list(l) print(a)
78f9b04e2d9b99d3c2032eccefaa71af9952c5e5
nikita1610/100PythonProblems
/Problem42/Day42.py
378
3.578125
4
def print_factors(n): l=[] while n!=1: for i in range(2,n+1): if n%i==0: l.append(i) n=int(n/i) break s=list(set(l)) s.sort() print("Factor---------Power") for item in s: print(str(item) +" "+ str(l.count...
dced43b82e42c88a1e160dc90b88c67d817b06ae
nikita1610/100PythonProblems
/Problem88/Day88.py
432
3.75
4
def reverse_vowels(s): l=[i for i in s] n=len(l) start=0 end=n-1 v=['a','e','i','o','u','A','E','I','O','U'] while(start<end): if l[start] in v : while l[end] not in v: end-=1 l[start],l[end]=l[end],l[start] start+=1 end-=1 ...
f594a9025e11e6fc2be56af3bb88d02cef8ee645
nikita1610/100PythonProblems
/Problem67/Day67.py
236
3.859375
4
def check_rotated(s1,s2): n1=len(s1) n2=len(s2) if n1!=n2: return "NO" else: temp=s1+s1 if temp.count(s2)>0: return "YES" else: return "NO" s1 ="ABCD" s2 ="CDAB" ans=check_rotated(s1,s2) print(ans)
7f1ae6ff2ea82f491d2f92ffa3d599bf02c8f929
nikita1610/100PythonProblems
/Problem50/Day50.py
241
3.8125
4
def odd(x,n): res=0 z=0 y=0 for item in x: res=res^item set_bit= res &~(res-1) for item in x: if item & set_bit: z=z^item else: y=y^item return (z,y) x=[4, 2, 4, 5, 2, 3, 3, 1] n=len(x) print(odd(x,n))
2e19675b9fdbd3097d7569a1e088bf7409cdd7f6
newbieyxy/eight-puzzle
/PuzzleNode.py
901
3.75
4
# -*- coding: utf-8 -*- """ Created on Tue Oct 16 22:37:56 2018 @author: Xuyun Yang Puzzle node """ class puzzle_node(object): def __init__(self, new_puzzle): self.puzzle = new_puzzle self.father_node = None self.action = None # the action reaching this node self.h_v...
f995cf62fffd5198b46cf39549a255b34cab4338
alu0100826678/prct06
/src/programa2.py
590
3.6875
4
#!/usr/bin/python #!encoding: UTF-8 def funcion(n): suma=0.0 for i in range(1,n+1): a = float (i-1)/n b = float (i)/n x_i = (i - 0.5)/n fx_i = 4.0/(1.0+x_i*x_i) suma = suma+fx_i r = suma/float (n) return r n = int (raw_input('Intro...
80d8043e55f8cdc65b46c06e9687565179af187c
DanielDixon324/Learning-Python
/Test1_HelloWorld.py
178
3.84375
4
def Test1(): x = 35 y = "hello" if x == 35 and y == "hello": x = x + 1 y = y + " world" print (x) print (y) Name = input("What is your name? ") print (Name) Test1()
ac26fc9acc6c702c2850149b021febd0329c0b5c
BARDIAAAA/oc20
/tutorial/lesson 1/ball demon.py
800
3.53125
4
import pygame from pygame.locals import * # size = 640, 320 # width, hight = size width = 640 height = 320 size = (width, height) GREEN = (150, 255, 255) RED = (255, 0, 0) pygame.init() screen = pygame.display.set_mode(size) running = True ball = pygame.image.load('ball.gif') rect = ball.get_rect() speed = [2, 2]...
0053f29fe738fb927e1e1fbb9ac392b6125640c3
HolySeraphim/programming_practice_2020
/Homework/Week09/Vectors.py
876
3.875
4
class Vector(object): def __init__(self, x, y): self.x = x self.y = y def normal(self): print(self.x, self.y) def mult(self, k): print(k * self.x, k * self.y) def summ(self, k): print(k + self.x, k + self.y) def vlength(self): return (self.x ** 2 ...
fcb7b5c6ab9ec8c93a296e7bf107808cf63efaf4
HolySeraphim/programming_practice_2020
/Laboratory work/Lab 2/8.py
93
3.5
4
import turtle as t t.shape('turtle') for i in range(100): t.forward(4*i) t.left(90)
19b76d43a81cd5daffbe1b6fcb57c03f64896471
HolySeraphim/programming_practice_2020
/Laboratory work/Lab 3/1.py
150
3.6875
4
import turtle as t import random t.shape('turtle') t.color('red') while True: t.right(random.random()*360-180) t.forward(random.random()*100)
29db35a11be5c44c97404ce2d0d9478ef62715db
HolySeraphim/programming_practice_2020
/Laboratory work/Lab 2/6.py
122
3.796875
4
import turtle as t t.shape('turtle') for i in range(12): t.forward(100) t.stamp() t.back(100) t.left(30)
96b14fcf9811decd244e689aa404c4f969987aa8
encarju/PythonExercises
/Exercise7.py
1,219
3.765625
4
people_char = {"blue_eyed": {"Olivia", "Harry", "Lily", "Jack", "Amelia"}, "blonde_haired": {"Harry", "Jack", "Amelia", "Mia", "Joshua"}, "sensitive_smell": {"Harry", "Amelia"}, "sensitive_taste": {"Harry", "Lily", "Amelia", "Lola"}, "blood_type_o": {"Mia", "J...
a98859306d008411d13235649bfc51c1a0d5bb6e
jasminh925/intro_class
/filmapi.py
1,022
3.765625
4
from urllib2 import urlopen from json import load from movieinfo import MovieInfo #sf open data source: film location in sf apiUrl = "https://data.sfgov.org/resource/yitu-d5am.json?" #open the apiUrl and assign data to variable response = urlopen(apiUrl) json_obj = load(response) film_2002 = [] for film in json_o...
8c475b7cff0811cdbb0c0f41da7a2242467a49e5
Zavxoz/eduproj
/MemberofCouncil.py
525
3.890625
4
class MemberofCouncil(object): def __init__(self, fullname, birthdate, group, age): self._fullname = fullname self._birthdate = birthdate self._group = group self._age = age def changeinfo(self): print("Choose what info you want to change\n 1. Name \n 2. Group") ...
8505872b1b6cef09c274cb60c0c023e0b2080b36
OlegAvdienokTaskGit/OOP
/glass.py
1,266
4.21875
4
""" Создать класс стакан с полем объем и методами: добавить воды, добавить молока, вылить часть смеси, вывести количество смеси. Реализовать проверки на добавление отрицательного количества и на переполнение. """ class Glass(): def __init__(self, max_volume, current_volume=0): if current_volume < 0 or cu...
d7445ecc7c9d772822668d7617676667defc9907
Satyankar15/Python-Stuff
/OEFrequency.py
311
3.984375
4
# -*- coding: utf-8 -*- """ Created on Tue Sep 15 15:08:22 2020 @author: satya """ count=dict() arr=list() l=int(input("Enter number of values ")) for i in range(l): x=input("Enter number "+str(i+1)+" ") arr.append(x) arr.sort() for i in arr: count[i]=count.get(i,0)+1 print(count)
4035cd1e19ec7d7fb25977f04f98015e19301e38
EvergreenPython/C1-for-loop
/main.py
2,118
4.3125
4
''' ## Guessing Game In this assignment you will create a guessing game using user input, random, and conditional statements. You, the computer, will choose a random number between 1 and 10, then prompt the user to guess the number. Using the user's guess and comparing it to the computer's number, give the user fee...
0ee3292e24ac4115edc3ba3d02400fb1d42506de
FrozenChicken/Partofcoffemachine
/coffe_machine_part_3.py
2,954
4.09375
4
water = 400 milk = 420 coffe_beans = 120 cups = 9 money = 500 espresso = {water : 250, coffe_beans : 120, cups : 1, money : 4} def buy(): question = input("Write action (buy, fill, take): ") global water, milk, coffe_beans, cups, money if question =="buy": wtb = input("What do you want ...
639b8505fbf80d3b42bfb4796dffe37d6b1276e1
xywanhh/pythonPrimary
/pyService/classdemo/m7.py
2,212
3.5625
4
import json # loads和dumps dic = {'k1':'v1','k2':'v2','k3':'v3'} # 序列化:将一个字典转换成一个字符串 str_dic = json.dumps(dic) print(type(str_dic),str_dic) # <class 'str'> {"k3": "v3", "k1": "v1", "k2": "v2"} # 注意,json转换完的字符串类型的字典中的字符串是由""表示的 # 反序列化:将一个字符串格式的字典转换成一个字典 dic2 = json.loads(str_dic) print(type(dic2),dic2) # <clas...