blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
1cdd62d5899d4e7671e09458c7de2a2e4f084992
mohsinzafaruk1996/firecode.io
/primeornot.py
162
3.828125
4
n=int(input("Number please")) x=range(2,n) a=[n % i for i in x] if 0 in a: print("Not a prime") elif n==1: print("Not a prime") else: print("prime")
87427b05507ead1e6a6b329e1b82f25bb74c5a1c
ivshyam98/SL-LAB
/B5/5.py
723
3.921875
4
from functools import reduce import operator words=dict() with open('myfile.txt','rb') as file: for word in (word for line in file for word in line.split()): if word in words: words[word]+=1 else: words[word]=1 words=dict(sorted(words.items(),key=lambda x:x[1],reverse=True))...
e889e92e2eb2177f62f4ff50bab19d065144e023
ashaheedq/Python-assignments
/Problem sets/7/ps7image/ps7pr3.py
4,086
4.15625
4
# # ps7pr3.py (Problem Set 7, Problem 3) # # Image processing with loops and image objects # # Computer Science 111 # from cs111png import * def invert(filename): """ loads a PNG image from the file with the specified filename and creates a new image in which the colors of the pixels are inverted...
911478f4bc705ae83f0d367779a2ced52c4e3fe3
ashaheedq/Python-assignments
/Problem sets/4/ps4pr1.py
998
4.0625
4
# # ps4pr1.py - Problem Set 4, Problem 1 # # # name: abdulshaheed alqunber # email: asq@bu.edu # # #Function 1 def dec_to_bin(n): """takes a non-negative integer n and uses recursion to convert it from decimal to binary – constructing and returning a string version of the binary representation of that number....
843218442cc559a58758d074925190b17eb4b770
ashaheedq/Python-assignments
/Problem sets/2/ps2pr6.py
2,158
4.09375
4
# # ps2pr6.py - Problem Set 2, Problem 6 # # Fun with recursion II # # name: abdulshaheed alqunber # email: asq@bu.edu # # This is an individual-only problem that you must complete on your own. # #Recursion 1 def double(s): ''' takes a string as an input and double every signle char in it ''' if s ==...
91f366098cedade02682c7341c728e1ce2d663cf
ashaheedq/Python-assignments
/Problem sets/8/ps8partI/gol_graphics.py
11,112
3.65625
4
# 2011-10-23 Rick Zaccone. Based on code supplied by HMC. # Minor modifications by Dave Sullivan. # This code assumes that there is a function named next_gen in the # file ps8pr2.py. import time from turtle import * from ps8pr1 import * from ps8pr2 import * def getMousePosition(mouse_x, mouse_y): """ Returns the ...
4585d9c998c7312a8a2541259970987d700b45ab
Scorch116/PythonProject---Simple-calculator
/Calculator.py
1,261
4.25
4
'''Simple calculator used to perform basic calculator functions such as addition, subtraction,division and multplication''' def Addition(value1, value2): # this function will add the two numbers return value1 + value2 def subtract (value1, value2): return value1 - value2 def Divide(value1, value2): retur...
9b936148a1ddbe1a8aa609de0be4bd02c5b26d1c
Nagasai524/xzceb-flask_eng_fr
/final_project/machinetranslation/translator.py
1,153
3.53125
4
""" This translator.py module is used to convert text from French to English and Vice versa. """ import os from ibm_watson import LanguageTranslatorV3 from ibm_cloud_sdk_core.authenticators import IAMAuthenticator from dotenv import load_dotenv load_dotenv() apikey = os.environ['apikey'] url = os.environ['url'] aut...
a1be0ebdf01c22ce08c647ccf120489dfcf1ee60
RavenDuffy/Pong-Syllabus
/PongBase.py
6,215
3.65625
4
import random import pygame import sys class PongMechanics: pygame.init() def __init__(self): self.WHITE = (255, 255, 255); # white colour self.BLACK = (0, 0, 0); # black colour self.clock = pygame.time.Clock(); # game clock for framerate self.FONT = pygame.font.SysF...
5b1c9d1ad36af18dbce6a3055a08e37b4864067d
zzwerling/DailyCodingProblemSolutions
/challenge1.py
294
3.78125
4
# Problem 1 # Given a list of numbers and a number k, return whether any two numbers from the list add up to k. def adds_up(list, k): for i in range(len(list)): for j in range(i+1, len(list)): if list[i] + list[j] == k: return True return False
d6374434fb6c9d67a684c3db37d6bc34e7701fd9
abhinavmittal93/Week1_Circle_Radius
/Week1_coding.py
320
4.1875
4
import math import datetime def calc_radius(): radius = float(input('Enter the radius of the circle: ')) area = math.pi * radius**2 print(f'Area of the circle is: {area:.2f}') def print_date_time(): time = datetime.datetime.now() print(f'Today\'s date: {time}') print_date_time() calc_radius()
9b31816c42dc2107fdbe3af38c21992213168768
danel2005/triple-of-da-centry
/Aviel/8.3.3.py
675
4.3125
4
def count_chars(my_str): """ returns a dict that the keys are the letters and the valus are how many of them were in the string :param my_str: the string we want to count every letter :type my_str: str :return: a dict that the keys are the letters and the valus are how many of them were in the strin...
b37418b1873488e4cf3b9397273f344e0768fd7b
danel2005/triple-of-da-centry
/Aviel/7.3.1.py
814
4.125
4
def show_hidden_word(secret_word, old_letters_guessesd): """ Show the player his prograssion in the game :param secret_word: the word the player need to guess :param old_letters_guessesd: the letters that the player is already guessed :type secret_word: str :type old_letters_guessesd: list :...
3df51c410f0cfd4c7b2d15a933f7251c6ac83877
danel2005/triple-of-da-centry
/Aviel/5.3.7.py
333
3.875
4
def chocolate_maker(small, big, x): num = x - small - big * 5 if num > 0: return False elif num == 0: return True elif abs(num) <= small: return True elif (abs(num) % 5) <= small and abs(num) - (abs(num) % 5) <= big * 5 + (small - (abs(num) % 5)): return True retu...
1c6125e33f932902b101c449ffd44c5236788bc0
danel2005/triple-of-da-centry
/Aviel/6.4.2.py
876
4.15625
4
def try_update_letter_guessed(letter_guessed, old_letters_guessed): """ Adds the letter guessed to the array of letters that has already been guessed :param letter_guessed: the guess that the user inputing :param old_letters_guessed: all the letters the user already guessed :type letter_guessed: str...
2c772ed45516775c12da8c4ae9ba0d6330ab5105
danel2005/triple-of-da-centry
/Aviel/6.4.1.py
651
4.1875
4
def check_valid_input(letter_guessed, old_letters_guessed): """ Checks if the guess is valid or not :param letter_guessed: the guess that the user inputing :param old_letters_guessed: all the letters the user already guessed :type letter_guessed: string :type old_letters_guessed: array :retu...
c889e0e9d7f44f7c13658bfeaebdb60e6ffaea8c
danel2005/triple-of-da-centry
/Aviel/7.2.2.py
677
4.28125
4
def numbers_letters_count(my_str): """ returns a list that the first number is the numbers count and the second number is the letters count :param my_str: the string we want to check :type my_str: str :return: list that the first number is the numbers count and the second number is the letters count...
ecbdcb145bf41c63716abcc840bc6d79f565e673
danel2005/triple-of-da-centry
/Aviel/ex3.4.2.py
147
3.78125
4
str = input("Please enter a string: ") first_letter_d = str.find("d") print(str[:first_letter_d + 1] + str.replace("d", "e")[first_letter_d + 1::])
df09532ab55fcc24116c0e7dd8e80ccdbaebf679
terryhu08/MachingLearning
/src/python/MapReduce/WordCount.py
2,799
3.5
4
#coding:utf-8 ''' created on 2017/12/03 author@BigNewbie 参考学习: MapReduce实现词频统计 https://www.cnblogs.com/rubinorth/p/5780531.html#undefined Write your first MapReduce program in 20 minutes http://michaelnielsen.org/blog/write-your-first-mapreduce-program-in-20-minutes/ 实现功能: 使用MapReduce统计词频 ''' print(__doc__...
76cde6d34c1a99e235e6c828c1aa0495810947ec
mossi1mj/SentenceValidator
/SentenceValidator.py
882
4.21875
4
import string # take in sentence as variable sentence = input("Enter a sentence: ") # take words in sentence and place in array[] with split() function word = sentence.split()[0] # first word in array will be 0 capitalWord = word.capitalize() # capitalize() function puts first character of a string to uppercase # ...
021d6cb4358bd2f0f806061294fb30200713bc82
kephircheek/async-vkontakte-bot
/aiovkbot/components.py
3,215
3.71875
4
import json class Keyboard: """ Example: Create keyboard with one row and append one button in frirst row: >>> keyboard = Keyboard(1); keyboard[0].append(CommandBtn('start', 'Start!')); print(keyboard) {"one_time": false, "inline": false, "buttons": [[{"color": "secondary", "action": {"type":...
ee1cde94885aa117f20ceb90a8860ade6430638c
mrcapasso/PythonCodingPractice
/'Finished' Practice Projects/Phone and Email Parser.py
10,426
4.03125
4
#Goal: Create an email and phone number parser that takes clipboard input and outputs filtered phone numbers and emails to clipboard. import re #Used in phoneNumParser() and emailParser() for parsing import pprint #Used in main function to format parsed lists import os #os.system('cls'), os.system('pause') import sys...
fd0a0e9f5a5d179ed49259e4257f5c53a867dcb9
Elong11/simple_bank_account_app
/simple_bank_account.py
1,020
3.78125
4
class Account(): def __init__(self, owner, balance=0): self.owner = owner self.balance = balance # Deposit Cash def deposit_cash(self, amount): self.balance = self.balance + amount print(f'{self.owner}, ${amount} has been added to your account balance.') # With...
8a874c6e58bc64db61455aca7d9996c46967b30c
primelos/cs-module-project-hash-tables
/lecture_notes/notes2.py
3,277
3.609375
4
def djb2(key): hash = 5381 for char in key: hash = ((hash << 5) + hash) + ord(char) # hash =((hash * 33) + hash) + ord(char) return hash my_hash_table = [None] * 8 class HashTableItem: def __init__(self, key, value, next=None): self.key = key self.value = value ...
460428faf223f278d8d72bf333b1895d6729483f
Uhanjali/Python_Practice_beginners-
/character_input.py
441
3.875
4
name = input("Please enter your name:") age = int(input("Hi, {} please enter your age:".format(name))) n = int(input("Please enter how many times you want to repeate the message:")) now_year = int(input("Please enter current year:")) year = (now_year + 100) - age # for i in range(0,101): # sum=age+i # if(sum==1...
ce0603847a6f6c57818ab1a8d0751b3051e2679a
iambyuuu/ujian
/randomdadu.py
1,360
3.8125
4
import random print('Mari Mengocok Dadu') angkadadu= random.randint(1,6) arrayDadu = [angkadadu] print(angkadadu) inputUser = input('Apakah mau mengacak lagi? [y/n] : ') mengulang = True pengulangan = int(input('Mau Mengocok brp kali?')) def getStatistik(arrays): arr1, arr2, arr3, arr4, arr5, arr6 = [], [], [], ...
4dbb260eeaf848931629196a1085e6e39c5da7ef
HTCho1/CodingTest
/4. 구현/2007년(BOJ).py
734
3.859375
4
x, y = map(int, input().split()) day = 0 monthList = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] weekList = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"] for i in range(x - 1): day = day + monthList[i] day = (day + y) % 7 print(weekList[day]) #----------------------------------------------------------...
6542507fcc7239674f5ef23bb9d2cc3a854df1cc
HTCho1/CodingTest
/Programmers/Level 1/2016년(level 1).py
1,117
3.859375
4
# 프로그래머스 Level 1 # 2016년, 연습문제 import sys import datetime a = int(sys.stdin.readline()) b = int(sys.stdin.readline()) def solution(a, b): days = ['MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 'SUN'] return days[datetime.date(2016, a, b).weekday()] print(solution(a, b)) #------------------------------------------...
87f62c3f4b196134c1a9103a0fd277d901fa7694
aleks-sidorenko/code-challenge
/challenge/hackerrank/detect-whether-a-linked-list-contains-a-cycle/main.py
682
4.03125
4
""" Detect a cycle in a linked list. Note that the head pointer may be 'None' if the list is empty. A Node is defined as: class Node(object): def __init__(self, data = None, next_node = None): self.data = data self.next = next_node """ def iter(it, num = 1): for i in range(0...
559bd0997565ae0f5c2d82ed0c71b5f6afeaec62
aleks-sidorenko/code-challenge
/challenge/hackerrank/ctci-is-binary-search-tree/main.py
557
3.90625
4
""" Node is defined as class node: def __init__(self, data): self.data = data self.left = None self.right = None """ MIN_INT = -1 MAX_INT = 10000000 def is_binary_search_tree(node, start, end): if node is None: return True if node.data < start or node.data > end: re...
29928662f5862a097dbff0b312ad818db150abb6
AbhilashPal/Hackerrank-DS-Track
/Trees/LowestCommonAncestor.py
809
3.953125
4
""" Node is defined as self.left (the left child of the node) self.right (the right child of the node) self.data (the value of the node) """ def lca(root , v1 , v2): if root.data > v1 and root.data > v2: # The required root will always be in the middle of v1 and v2, having an intermediate return lca(...
8bfc1edca39b32aa5c4e06ae5307322be25d74c8
SunTXone/PythonCodes
/NameAgeTenn.py
297
3.765625
4
#一楼祭天 # name=input("输入你的名字:") age=input("输入你的年龄:") print("你的名字是“"+name+"”。") print("你的年龄是"+age+"岁。") after_ten_age=int(age)+10 print("十年后你的年龄是"+str(after_ten_age)+"岁。") input("按回车结。")
9431c066289d9e511f48955f98ea2d0883df601b
nmaize/PythonChallenge
/main.py
1,826
3.5625
4
#Dependencies import csv import os #Load and output files Loadfile = os.path.join("Resources", "election_data.csv") Outputfile = os.path.join("Resources", "election.txt") #Create variables for calculations votes = 0 candidate_options = [] c_votes = {} winning_candidate = "" counter = 0 # Read the csv ...
5b1c132a185d6e92f5dd073844ad57f41659dde7
alejogonza/holbertonschool-higher_level_programming
/0x01-python-if_else_loops_functions/1-last_digit.py
592
3.984375
4
#!/usr/bin/python3 import random number = random.randint(-10000, 10000) # extraer el numero negativo if number < 0: newn = number % -10 # extraer el numero positivo elif number >= 0: newn = number % 10 # si es mayor que 5 if newn > 5: print('Last digit of {:d} is {:d} ' 'and is greater than 5'.for...
71c3ff132b6f03400fbec6349709ff5e54821589
alejogonza/holbertonschool-higher_level_programming
/0x06-python-classes/mains/6-main.py
251
3.59375
4
#!/usr/bin/python3 Square = __import__('6-square').Square my_square = Square(3, (0, 1)) my_square.my_print() print("--") my_square = Square(3, (1, 1)) my_square.my_print() print("--") my_square = Square(5, (3, 2)) my_square.my_print() print("--")
4a055d153e0ee522642ddaa2485b02f6aceaf130
alejogonza/holbertonschool-higher_level_programming
/0x01-python-if_else_loops_functions/6-print_comb3.py
290
3.59375
4
#!/usr/bin/python3 for conv in range(0, 10): for rang in range(conv + 1, 10): if conv != rang: print('{}'.format(conv), end='') if conv == 8: print('{}'.format(rang)) else: print('{:d}, '.format(rang), end='')
487f4437196e77afa158e7be0e1b0e6f5235ea82
alejogonza/holbertonschool-higher_level_programming
/0x01-python-if_else_loops_functions/9-print_last_digit.py
194
4
4
#!/usr/bin/python3 def print_last_digit(number): stri = str(number) last = stri[-1:] laststri = str(last) intl = int(last) print('{:d}'.format(intl), end='') return intl
e9cf929eb3f418b403cbebf5b171db97ef597d76
alejogonza/holbertonschool-higher_level_programming
/0x0A-python-inheritance/1-my_list.py
316
4.125
4
#!/usr/bin/python3 """ 1-my_list """ class MyList(list): """ prints to stdout list in order """ def print_sorted(self): """ prints the list """ sorted_list = MyList() for item in self: sorted_list.append(item) print(sorted(sorted_list))
5b95e5d8f00ccc36f756e6185bad22a6c998b192
alejogonza/holbertonschool-higher_level_programming
/0x04-python-more_data_structures/102-complex_delete.py
227
3.75
4
#!/usr/bin/python3 def complex_delete(my_dict, value): mark = [] for key in my_dict: if my_dict[key] == value: mark.append(key) for delet in mark: del my_dict[delet] return (my_dict)
fb85f8b1dc9d7a3c0c93c6d9eb29bd739a9dc67b
aetos1918/practice
/Prac_Develop/git_practice.py
649
3.75
4
def add(a,b): return a+b def difference(a,b): return a-b def multiply(a,b): return a*b def divide(a,b): return a/b def modu(a,b): return a%b def big(a,b): if a>b: return a elif a<b: return b else: return "equal" if __name__ == '__main__': print(add(45, 29)) print(big(34, 25)) print(difference(34,...
71b497bd42480dd803ae4f0be2a6d3c92fea71de
ArjunaReddy/face-detection
/src/face_detect.py
676
3.671875
4
import numpy as np from cv2 import cv2 def detect_function(): face_cascade = cv2.CascadeClassifier('src/hf.xml') #running the pretrained classifier img = cv2.imread('media/images/sachin.jpg') #reading the image gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) #converting it to grayscale faces = face_cas...
4186a3593bf1d085f9bc58093d82d543e5ae2b5e
masa48326/opp_practice01
/bmi.py
818
4.0625
4
""" class BMI: 関連しそうな属性: - 身長 - 体重 - BMIという値そのもの ルール: - 10以上40以下<-- 常識的な範囲 - 表示するときは、小数点第二位まで - ex: 23.678 --> 23.68 - ex: 23.671 --> 23.67 できること: - ??? """ # クラス名はUpperCamelCaseが普通 class BMI: def __init__(self): self.v...
7dd786bf2ea88d22fc5fe28f4000f310158c30f3
aylna/ML_functions
/linear_regression_1D.py
1,564
3.5
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Nov 30 01:10:05 2018 @author: aylin """ #linear regression : 1D prediction import torch w = torch.tensor(2.0, requires_grad = True) b = torch.tensor(-1.0, requires_grad = True) def forward(x): yhat = w*x + b return yhat #predict y = 2x-1 at...
418bd4702c00cf7a85705eeee0a4af0657872724
datascience-mobi/2021-topic-04-team-05
/SVM_Segmentation/pixel_conversion.py
922
3.875
4
import numpy as np import math def one_d_array_to_two_d_array_df(extended_data_frame): """ A function to convert a 1D Array back to 2D Array from data frame. :param: Data Frame of flattened arrays :return: Data frame of 2D Array """ for i in range(len(extended_data_frame)): # the ...
ef778eb426dee0a6d25f602dc24c3f28ac445088
bsolino/2017-MAIR-word-segmentation
/bigram_segmentation/bigram_utils.py
3,992
3.84375
4
# -*- coding: utf-8 -*- """ Created on Mon Oct 16 11:24:06 2017 @author: Breixo """ import matplotlib.pyplot as plt # text: Array of lines of the text # @returns bigrams: Dictionary bigram -> number of occurrences def find_bigrams(text, bg_separator): bigrams = {} for line in text: line = clean_line(...
6193332f6b7725238405cb178676c2d44099c0b2
andersberggren/AdventOfCode2018
/src/main/dec17/parser.py
1,222
3.515625
4
import re from aoclib.filereader import getFileAsListOfString from dec17.world import World def getWorldFromFile(fileName): world = World() for line in getFileAsListOfString(fileName): (x, y, width, height) = stringToRectangle(line) world.addClay(x, y, width, height) return world def stringToRectangle(s): ""...
a291b2ca273d89c5e6824a24c5a147050ab1d3c6
andersberggren/AdventOfCode2018
/src/main/dec05/dec05.py
1,669
3.8125
4
import re import string ############# # Functions # ############# def getPolymerFromFile(fileName): with open(fileName) as f: return f.read().strip() # Reduce the polymer by removing adjacent units of the same type and opposite polarity, # i.e. adjacent characters of the same letter where one is upper case and the...
8be5a7aa6f87cb3a3fe9fa1c2bb4dd36976034ae
rrohrer/ProjectEuler
/src/Problem0007.py
208
3.875
4
from prime_utils import is_prime #start counting prime numbers until N is found counter = 1; x = 3 while True: if is_prime(x): counter += 1 if counter == 10001: print x exit() x += 2
1a297ec0a386c63f0d3c912dec870cfd2086f7ab
IgorTelles9/ufrj
/COS110/exc15.py
678
3.6875
4
""" Esse programa checa se duas entradas são anagramas Exercício 15 dos laboratórios de Alg. Prog Outubro de 2020 """ def eh_anagrama(palavra_1, palavra_2): checkeds = [0]*len(palavra_1) if len(palavra_1) != len(palavra_2): return False equals = 0 for i in range(len(palavra_1)): ...
2b24622ced0a5a85d6062fc31488366a5129d743
IgorTelles9/ufrj
/COS110/exc2.py
678
3.703125
4
""" Dado um número n, este programa mostra todos os primos até n. Exercício 2 dos laboratórios de Algoritmos e Programação - ECI. Rio, setembro de 2020. """ n = int(input()) #7 primos = [] numero_atual = 1 while (numero_atual <= n): if (numero_atual < 3): primos.append(numero_atual) els...
d819f50f47c4ac2a60e90af1f556bf62cae5807a
IgorTelles9/ufrj
/COS013/hanoi.py
349
4.0625
4
""" Solving the Hanoi Tower Problem """ def print_step(start, end): print(str(start) + '->' + str(end)) def hanoi(n, start, end): if n == 1: print_step(start, end) else: other = 6 - (start + end) hanoi (n-1, start, other) print_step(start, end) hanoi(n-1, ...
cdc1faef873db756d2cac3c19ae3e4659516c760
shamansaban/python-algoritmalar
/Arama/dogrusal_arama.py
923
3.78125
4
# -*- coding: utf-8 -*- """ Created on Wed Jan 27 20:24:08 2021 @author: saban.m """ def dogrusal_arama(liste_array: list, hedef: int) -> int: for index, item in enumerate(liste_array): if item == hedef: return index return -1 if __name__ == "__main__": liste = input("Numaral...
0729b4b0c57ab881e8464fe9a2c061e14a27e7e4
dryairship/stegano_in_py
/stegano-encoder.py
3,027
3.515625
4
import sys from PIL import Image def encode(visible_image,hidden_image,output_file): # create an output image of the same size as the visible image output_image = Image.new('RGB',(visible_image.width,visible_image.height)) # this array will store the rgb values of the encoded file pixels = [] w = hidden_image.wi...
e92ccc244be00c3e6239ec2dd6b0f51f0cac924b
Gsynf/PythonProject
/hanoi/hanoi.py
482
4.03125
4
#!usr/bin/env python3 #coding:utf-8 __author__ = 'hpf' #汉诺塔 count = 0 #n号小圆盘从src到dst,mid作为过渡 def hanoi(n, src, dst, mid): global count if n==1: print("{}:{}->{}".format(1, src, dst)) count +=1 else: hanoi(n-1, src, mid, dst) print("{}:{}->{}".format(n, src, dst)) coun...
504c7494ca1e1b0bc0b3814afaf40ef62e2d48d5
wesenu/COP3035-CGS5935-Introduction-to-Programming-Using-Python
/eliza.py
2,432
3.96875
4
# ------------------------------------------------------------------------------- # Eliza - the very famous and totally free psychotherapy program # ------------------------------------------------------------------------------- # control some optional output with this flag TESTING_ON = True def main(): ...
9ef602b0e1df3f4111037ecd84e1d78d5994fffb
wesenu/COP3035-CGS5935-Introduction-to-Programming-Using-Python
/myPrograms/Chapter_4_exerciseSolution/ex4_14.py
903
4.21875
4
###################################################### # 4.14 # ###################################################### rows = 7 for r in range (rows): for c in range (rows-r): print ('*', end = ' ') print() ##################################################### # end = ' ' m...
15f146f69ea979780ba6d2a9610f064e0c327cc8
wesenu/COP3035-CGS5935-Introduction-to-Programming-Using-Python
/loopExerciseStarter.py
382
4.1875
4
inputPIN = 0 validPIN = False userPIN = 9999 # for example use only ! inputPIN = int(input("Please enter your PIN -> ")) validPIN = (inputPIN == userPIN) while not validPIN: inputPIN = int(input("Please try again. Enter your PIN -> ")) validPIN = (inputPIN == userPIN) # know complement is true...
0a37d926644309e050c26e816ff47207220f59e8
Gwaing/coding-for-study
/week-01-python/test-04.py
586
3.5
4
# 구현 내용 # 아래 도형을 구현 합니다. # 00100 # 01110 # 11111 # 01110 # 00100 # 도형을 설명하면 5x5 좌표에, 다이아몬드를 그리고 있습니다. ## 힌트 # 반복문(for-loop)은 중첩해서 사용할 수 있습니다. # 1 # 11 # 111 # 1111 # 11111 # for a in range(1, 6): # for b in range(1, 6): # print() # print("1" * a) # 10000 # 11000 # 11100 # 11110 # 11111 # for a in rang...
29f9ff769ac8209b1171b3dba835788caf9c2afd
KarthikGH07/Tkinter_ToolTips
/demo.py
2,968
3.75
4
import traceback, tkinter as tk, tkinter.ttk as ttk, tkinter.font as tkFont import ToolTips # demo GUI try : # create the application window app_window = tk.Tk() app_window.title("Tooltip Demo") app_window.rowconfigure(0, weight=1) app_window.rowconfigure(1, weight=2) app_window.rowconfigure(3, weight=2) app_wi...
bdaf30da4fac0162de7138740b961307b6efd035
morgworth/pygameprojects
/ch6.py
845
4
4
print('Problem 1') for i in range(10): print('*', end = ' ') print() print('Problem 2') for i in range(10): print('*', end = ' ') print() for i in range(5): print('*', end = ' ') print() for i in range(20): print('*', end = ' ') print() print('Problem 3') for i in range(10): for j in range(10): print('*', end = ...
5e6a9753882b55f3b9b5cdfa246301d6ebe3d2b1
morgworth/pygameprojects
/lab1/TempFtoC.py
131
3.796875
4
fTemp=input("Temperature in Fahrenheit? ") fTemp=float(fTemp) cTemp=(fTemp-32)*(5/9) print("The temperature in Celsius is ", cTemp)
6f23a36e31a48c47833956e0b8abc07027c6e1d0
lelilia/RC_stuff
/mastermind2.py
1,962
3.8125
4
# Mastermind in python 3 import random color = [1,2,3,4,5,6] guesses = [] clues = [] def make_code(): return [random.choice(color) for _ in range(4)] def get_guess(): print ("Make a guess") guess = list(map(int,list(input().replace(" ","")))) return check_if_guess_is_allowed(guess) def check_if_gue...
b459d9a58f870a783da817220657edf282f65d24
a31415926/geekhub
/HT_3/6.py
384
3.875
4
"""Вводиться число. Якщо це число додатне, знайти його квадрат, якщо від'ємне, збільшити його на 100, якщо дорівнює 0, не змінювати.""" def func_name(n): res = n if n > 0: res = n*n elif n < 0: res = n+100 else: res = n return res n = float(input()) print(func_name(n))
b2717f6eb3a010b10b42adf705ebccdf488bfa34
a31415926/geekhub
/HT_3/8.py
1,524
3.953125
4
"""Написати функцію, яка буде реалізувати логіку циклічного зсуву елементів в списку. Тобто, функція приймає два аргументи: список і величину зсуву (якщо ця величина додатня - пересуваємо з кінця на початок, якщо від'ємна - навпаки - пересуваємо елементи з початку списку в його кінець). Наприклад: fnc([1, 2...
9006ed364165731414611b16377251897a15232d
a31415926/geekhub
/HT_2/6.py
1,040
3.890625
4
"""Маємо рядок --> "f98neroi4nr0c3n30irn03ien3c0rfekdno400wenwkowe00koijn35pijnp46ij7k5j78p3kj546p465jnpoj35po6j345" -> просто потицяв по клавi Створіть ф-цiю, яка буде отримувати рядки на зразок цього, яка оброблює наступні випадки: - якщо довжина рядка в діапазонi 30-50 -> прiнтує довжину, кiлькiсть букв та цифр ...
f1834a2a485cafa0a29057d6299b4504730155bc
a31415926/geekhub
/HT_1/f6.py
191
3.984375
4
"""Write a script to check whether a specified value is contained in a group of values.""" test_data = [1, 5, 8, 3] val = int(input()) if(val in test_data): print(True) else: print(False)
04046a61e92fbc4d15a3ec0098c0cf7bdb662063
a31415926/geekhub
/HT_11/hw_2.py
509
3.703125
4
class Person(): def __init__(self, age, name): self.age = age self.name = name def show_age(self): return self.age def print_name(self): return self.name @property def show_all_information(self): return self.__dict__ a = Person(10, 'Dima') b = Perso...
f3aa728702626bfd830e8208edefa8d295d0f5b0
samdwise1367/natual_language_processing
/Lemmatizing.py
173
3.5
4
#Very similar to stemming. The end result will be a real word from nltk.stem import WordNetLemmatizer lemmatizer = WordNetLemmatizer() print(lemmatizer.lemmatize("Cats"))
4b7420b58f37c31da20c16cf3e2ac0628458cfbc
VanessaCalimag/Sandbox
/password_entry.py
224
4.09375
4
"""Vanessa Calimag""" def main(): password = input("Enter a password: ") if len(password) < 10: print("Minimum number of characters is 10 - Enter a password.") else: print('*').format(password) main()
ef1b1ba2cdf205fea87d97e2c956d91a73af9c42
narru888/PythonWork-py37-
/觀念/LeetCode/Easy/Roman_To_Integer(羅馬數字轉整數).py
948
3.515625
4
""" 將羅馬數字轉為整數。 特殊情形: I可以放在V (5)和X (10)的左邊,來表示4和9。 X可以放在L (50)和C (100)的左邊,來表示40和90。 C可以放在D (500)和M (1000)的左邊,來表示400和900。 """ # 自己寫的(u秀) class Solution: def romanToInt(self, s: str) -> int: ROMAN_dic = { "I": 1, "V": 5, "X": 10, "L": 50, "C": 100, "D": 500, "M": 1000 } ...
b8465312a69a2fcbe6aff158dbf9ec524b4c4efb
narru888/PythonWork-py37-
/進階/資料結構/Linked_List(鏈表).py
1,588
4.25
4
""" Linked-list的資料則散落在記憶體中各處,加入或是刪除元素只需要改變pointer即可完成, 但是相對的,在資料的讀取上比較適合循序的使用,無法直接取得特定順序的值(比如說沒辦法直接知道list[3]) """ # 節點 class ListNode: def __init__(self, data): # 資料內容 self.data = data # 下一個節點位置 self.next = None # 單向鏈表 class SingleLinkedList: def __init__(self): # 鏈表頭...
4108e3aeb18c96e6d9ded60bf08972664cb1c6bc
narru888/PythonWork-py37-
/Testing/Selenium/200518_First_demo.py
4,787
3.5
4
from selenium import webdriver # 啟動瀏覽器驅動和瀏覽器,返回的是WebDriver對象 # 參數為chrome驅動的路徑 wd = webdriver.Chrome(r'd:\Programming\WorkPlace\PythonWork(py37)\Testing\Selenium\chromedriver\chromedriver.exe') # 跳轉頁面 wd.get(url='https://www.google.com.tw/') # 因為有可能會遇到一種情況,就是web server尚未向我們(用戶)的瀏覽器返回頁面時,我們的程序繼續運行下一行代碼,導致找不到要的Element。...
4ddf189218dc017ce6bc7ac8e7160cad41802eb7
narru888/PythonWork-py37-
/觀念/LeetCode/Easy/Remove_Duplicates_from_Sorted_List(去除列表重複元素).py
1,176
3.734375
4
""" 給定一個排序數組,你需要在原地刪除重複出現的元素,使得每個元素只出現一次,返回移除後數組的新長度。 不要使用額外的數組空間,你必須在原地修改輸入數組並在使用O(1)額外空間的條件下完成。 範例: 給定nums = [0,0,1,1,1,2,2,3,3,4], 函數應該返回新的長度5,並且原數組nums的前五個元素被修改為0, 1, 2, 3, 4。 你不需要考慮數組中超出新長度後面的元素。 """ from typing import List # 高手寫的 # 思路(雙指針法): # - 初始時,後指針為0,前指針為1 # - 當前指針和後指針指向的數字相等,前指針向前一步 # ...
c5dd6f9fe4a2814a0e4303a3c7f85aa310795343
narru888/PythonWork-py37-
/基礎/200427_函數作用域&匿名函數.py
1,476
3.96875
4
# ---------------- 作用域 ---------------- # # ※ 函數運行方式 => 函數內存位置+() # def foo(): # print("in the test") # return foo_1 # 返回test_1內存位置 # def foo_1(): # print("in the test_1") # # res = foo() # => in the test,res獲取test_1函數位置 # res_1 = res() # => in the test_1,res()=test_1() # print(res_1) # => None,test_1無r...
65a585fac6b14b0197ee36fcc904c8cc79892dd1
Marcos-Barranquero/MAT-AV-UAH
/alg_euclides.py
2,598
4.0625
4
""" Algoritmo extendido de euclides """ def imprimir_matriz(columna1, columna2): """ Dada una matriz definida por sus columnas, la imprime """ print("-----------") print("(", columna1[0], ",", columna2[0], ")") print("(", columna1[1], ",", columna2[1], ")") print("(", columna1[2], ",", col...
8473c0e3d9e55ca2e091b37a2e8abe4e27a357cc
qnn5342/nguyennhatquang-lab-c4e15
/session 8/f-math-problem/freakingmath.py
617
3.640625
4
from random import * from ex1 import * def generate_quiz(): # Hint: Return [x, y, op, result] x = randint(1,10) y = randint(1,10) op = choice(['+','-','*','/']) m = randint(-1,2) n = randint(-1,1) error_list = [0,0,0, m, m] error = error_list[n] result = eval(x,y,op) + error re...
87ccf1bbef79f6b7fa31f7f97d0f3e6811675570
kuaikang/python3
/基础知识/1.语法基础/14.函数高级.py
395
4.0625
4
# 将函数绑定到不同的名称 def hello(): print("Hello World") func = hello func() def fun(abs, x, y): # 将函数作为参数 return abs(x) + abs(y) print(fun(abs, 10, -2)) # 将函数作为返回值 def outer(): def inner(n): sum = 0 for i in range(1, n): sum += i return sum return inner inner = ou...
c8385a123d4676ff39c7e5fd5eb3fcb5a91f55ec
kuaikang/python3
/基础知识/2.字符串解析/字符串格式化.py
281
3.546875
4
msg1 = "my name is {} , and age is {}" msg2 = "my name is {0} , and age is {1}" msg3 = "my name is {name} , and age is {age}" print(msg1.format("tom", 24)) print(msg2.format("jack", 24)) print(msg3.format(name="lucy", age=22)) print(msg3.format_map({"name": "lily", "age": "19"}))
32ce5c25d74eb2a7ad91346b8183cce163868df1
kuaikang/python3
/基础知识/1.语法基础/17.装饰器.py
526
3.625
4
import random, time def decorator(func): def wrapper(*args, **kwargs): print(func.__name__) stime = time.time() return func(*args, **kwargs) etime = time.time() print("cost", etime - stime) return wrapper def bubble_sort(li): for i in range(len(li) - 1): ...
1f837bcd421e72b30c4bcb544f19bc3a196d1d6c
kuaikang/python3
/基础知识/算法与数据结构/2.冒泡排序.py
780
3.96875
4
import random,time def bubble_sort(list): for i in range(len(list)-1): for j in range(len(list)-i-1): if list[j] > list[j+1]: list[j],list[j+1] = list[j+1],list[j] # 优化版 如何执行一趟没有发生交换,则列表已经是有序,可以结束排序 def bubble_sort_perfect(list): for i in range(len(list)-1): exchange...
783d97d8d3c3586668f7c39bb60093e5e69bbe7a
kuaikang/python3
/基础知识/3.面向对象/class.py
1,263
4.34375
4
class People: name = "我是类变量,所有实例共享" def __init__(self, name, age, phone): # 构造函数,在类被实例化的时候执行 self.name = name # 实例变量,为每个实例所独有 self.__age = age # 在变量前面加__,表明这是私有变量,可以通过方法访问私有变量 self.phone = phone def get_age(self): # 定义一个方法来访问私有变量 return self.__age p = People("tom", 23...
7f922ab634729d0648a22cda32d4aaea2ea27b95
kuaikang/python3
/工作/题库统计/题目数,知识点数,知识点题目数.py
4,519
3.53125
4
from 基础知识.文档操作.excel import excel_util from common.mysql_util import mysql def book_count(subject_code): """查询某个学科信息""" with mysql(db="uat_exue_resource", host="192.168.121.159", user="juzi_yxy", password="nimo)OKM", port=42578) as cur: sql = "SELECT b.subject_name,gb.grade,b.book_name,u.unit_name,c.c...
efbeefe6473a173c4758fc19da4f96ccfdaacb06
kuaikang/python3
/基础知识/队列/利用redis构建任务队列/part1/input.py
272
3.578125
4
from 基础知识.队列.利用redis构建任务队列.part1.redis_queue import RedisQueue import time q = RedisQueue('rq') # 新建队列名为rq for i in range(5): q.put(i) print("input.py: data {} enqueue {}".format(i, time.strftime("%c"))) time.sleep(1)
c44584b3566501a1b834632fbec57cbf0016c70a
kuaikang/python3
/基础知识/4.文件操作/1.打开和关闭文件.py
1,493
3.90625
4
# 新建一个文件,文件名为:test.txt f = open('test.txt', 'w') # 关闭这个文件 f.close() with open('test1.txt', 'w') as f: f.write("hello world") # 文件打开模式 # r 以只读方式打开文件。文件的指针将会放在文件的开头.这是默认模式 # w 打开一个文件只用于写入.如果该文件已存在则将其覆盖.如果该文件不存在,创建新文件 # a 追加写入 # rb 以二进制格式打开一个文件用于只读.文件指针将会放在文件的开头.这是默认模式 # wb 以二进制格式打开一个文件只用于写入,如果该文件已存在则将其覆盖.如...
b204f613c5d75993b0b85c25deac88bb8dd9c7a8
kuaikang/python3
/基础知识/8.线程、进程、协程/进程/多进程.py
436
3.53125
4
from multiprocessing import Pool import time def task(n): time.sleep(2) print("this is task", n) if __name__ == '__main__': p = Pool(5) for i in range(5): p.apply_async(task, args=(str(i))) # 将任务放进进程池 p.close() # 调用join()之前必须先调用close(),调用close()方法后就不能添加新的任务 p.join() # 等待所有子进程执行完毕 ...
70e8f7d6612bd6ddda2b9f40f952a72d56d357d2
kuaikang/python3
/工作/题库统计/章节知识点统计.py
2,291
3.546875
4
from 基础知识.文档操作.excel import excel_util from common.mysql_util import mysql def book_count(subject_name): """查询某个学科信息""" with mysql(db="sit_exue_resource") as cur: sql = "SELECT b.subject_name,gb.grade,b.book_name,u.unit_name,c.chapter_name,b.edition_id,c.chapter_id," sql += "CONCAT(e.press_nam...
6470864fa7c6917b0aadd6459532b5edf5ae78d0
bryants/challenges
/misc/fizzbuzz.py
527
3.625
4
def fizz0(): global fizz fizz = fizz1 return "Fizz" def fizz1(): global fizz fizz = fizz2 return "" def fizz2(): global fizz fizz = fizz0 return "" def buzz0(): global buzz buzz = buzz1 return "Buzz" def buzz1(): global buzz buzz = buzz2 return "" def buzz2(): global buzz buzz = b...
2fdb4c0df269b6d846fab9520ead8d5f49b7a071
caBrer24/Side_Projects
/Textual_Driving.py
749
3.984375
4
started = False while True: command = input('> ').lower() if command == "start": if started: print('Already started!') else: started = True #Is the car started? print('Car started... Ready to go!') elif command == "help": #Display helps comm...
9d537b70017364728986f353504a07033f069b36
1020196987/my_leetcode
/test.py
448
3.828125
4
import re # p1 = re.compile('^[0-9]*$') # number = p1.match("3") # if number: # print("yes") # else: # print("no") # for index, item in enumerate('abcd'): # print(str(index)+ ' ' + item) # # # print('abcd'[0:]) # if 2 in [2,4]: # print('aa') # arr = [1,3,4] # a = arr.pop(0) # print(a) # print(arr) ...
17737b6a6874c55944c777f30d74d353b5d8c1ed
1020196987/my_leetcode
/Array/第三周/Rotate Image.py
773
3.96875
4
class Solution: def rotate(self, matrix): """ :type matrix: List[List[int]] :rtype: void Do not return anything, modify matrix in-place instead. """ # print(list(zip(*[(2, 1), (2, 1), (2, 1)]))) # a = [2, 2, 2] # b = [1, 1, 1] # print(list(zip(a, b))) ...
779f444e43bae81aa973f00cf6f2662dfc882de7
pravinahire/DS
/LevelWiseBtree.py
659
3.8125
4
from queue import Queue from queue import EnQueue from queue import DeQueue from queue import DispQueue from queue import IsEmptyQueue from BinaryTree import Node from BinaryTree import insertNode from BinaryTree import DispTree r=insertNode(None,20) r=insertNode(r,30) r=insertNode(r,40) r=insertNode(r,50) r=insertNo...
9444101d257c2e0c18251db3a4a45437264b8e33
pravinahire/DS
/isBST1.py
736
3.953125
4
# Program to check given tree is BST or not from queue import Queue from queue import EnQueue from queue import DeQueue from queue import IsEmptyQueue from BalancedBTreeCreate import BalancedBTreeCreate def inOrderList(root,list): if root is not None: inOrderList(root.left , list) list.append...
a2e1e2268e9f8e6f56c497db9b4a3f8ec8eb1fef
CREESTL/AlienInvasion
/bullet.py
1,336
4.03125
4
''' Файл отвечает за полет пули''' import pygame from pygame.sprite import Sprite # спрайты объединяют связанные элементы и позволяет работать с группой class Bullet(Sprite): # дочерний класс def __init__(self, settings , screen, ship): super(Bullet, self).__init__() # это значит что он наследует от класса ...
3527ae76abbc54d96bfdeefa30d9d52f96716685
Breccia/s-py
/sp/fibo.py
1,288
3.546875
4
#!/usr/local/anaconda3/bin/python import matplotlib.pylab as plt def fibo(n): series = [] ratio = [] x = [] start = 0 if (n == 0): series = [0] x = [0] ratio = [0] return x,series,ratio elif (n == 1): series = [0] x = [0] ratio = [0] ...
6117ad401c4cb0a17e1f04a62622750929b7822e
Breccia/s-py
/sp/pm.py
1,534
4
4
#!/usr/local/anaconda3/bin/python import matplotlib.pylab as plt import math import random # Projectile Motion graph # Horizontal velocity = Uh cos(x) # Vertical velocity = Uv sin(x) - gt # Velocity change on x, Vh = Uh cos(x) t # Velocity change on y, Vv = Uv sin(x) t - (0.5) g(t**2) # Time to reach max height is w...
cb4b1078392d780cbb6d7a5b6374d556dda2598e
sbu-python-class/test-repo-2018
/demoPercentMinCircle.py
4,897
3.734375
4
from matplotlib import pyplot as plt import numpy as np import minmaxradiuscircle import functions # This demo presents the minimum radius enclosing ball using the specified percent of data and the minimum radius # enclosing ball of 100% data. # Input: the starting coordinate and the percent of data points that user w...
c22167ee72352ce55dfb2b3db6108857776f6c7c
lyannjn/codeInPlaceStanford
/Assignment2/hailstones.py
829
4.5
4
""" File: hailstones.py ------------------- This is a file for the optional Hailstones problem, if you'd like to try solving it. """ def main(): while True: hailstones() def hailstones(): num = int(input("Enter a number: ")) steps = 0 while num != 1: first_num = num # Even nu...
5f5bab69e0422741ccc6d2bc393437d0fa743ea4
jenny920/exercise-7
/ex5-1.py
754
3.65625
4
# -*- coding: utf-8 -*- """ Created on Fri Oct 28 21:42:08 2016 @author: root """ with open("data.csv", "r") as infile: data = infile.read() datalist = data.splitlines() # Create empty lists to store file data Year = [] Name = 'AA-' Filename = '' # Loop over lines in file, append to lists for line in datal...
d72b2fe658d5c3a976bd64bc6b602a3eda43661c
cja769/cs373-collatz
/Collatz.py
3,256
4.1875
4
#!/usr/bin/env python3 # --------------------------- # projects/collatz/Collatz.py # Copyright (C) 2014 # Glenn P. Downing # --------------------------- # ------------ # collatz_read # ------------ cache = [0] * 100000 cache_len = 100000 def collatz_read (r) : """ read two ints r is a reader return a ...
83e0cd383f22f7f9483622e7df9acf195e790103
NithinRe/slipting_current_bill
/Power_Bill.py
1,043
4.15625
4
print("----------------Electricity Bill---------------------") x = int(input("what is cost of current : ")) y = int(input("Enter Number of units used : ")) z = x/y print("Each unit is charged as : ",z) print("-----------------------------------------------------") meter1 = int(input("First floor number of units u...