blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
53babe8a979f4acc2db6a73203a932cad985bce0
edutilos6666/PythonSciStudentProject
/encryption/User.py
498
3.875
4
import datetime class User: def __init__(self,userName="", password=""): """ constructor :param userName: string :param password: string """ self.userName = userName self.password = password def __repr__(self): """ This function is ca...
c62c6c41a6b72ae96a85eeb1f90e6a89cb8666d1
dwaraka118/Python-in-detail
/pattern.py
286
4.1875
4
number = int(input('enter the number of * you wanted : ' )) for i in range(number+1): print(i * '*') for i in range(number+1): i = i * " *" # with small variation print(i) for i in range(1,number+1,2): i = i * " *" # with small variation print(i)
46266ce3ecd0ece4502135371eb2d52f1b5bc646
dwaraka118/Python-in-detail
/exercise 2.py
465
4
4
def add(num1,num2): sum = num1 + num2 # print(f"sum of two given numbers {num1},{num2} is : {sum}") return sum def sub(num1,num2): substract = num1 - num2 # print(f"sum of two given numbers {num1},{num2} is : {sum}") return substract num1 = int(input("enter your first number : ")) num...
f91dc91d56c289fd39f66e966b7b9316e8665e61
indy905/python-algorithm
/AllAlgorithmsInPython/P04/p04-2-practice.py
974
3.890625
4
import unittest # 문제 1의 1부터 n까지의 합 구하기를 재귀 호출로 만들어 보세요. # 시간복잡도 : O(n) def sum_recursive(n): if n <= 1: return 1 return n + sum_recursive(n - 1) class unit_test_sum_recursive(unittest.TestCase): def test(self): self.assertEqual(55, sum_recursive(10)) self.assertEqual(5050, sum_rec...
8a248d01bb9bad643204621be8e17fa676463416
TimWeir/Python-Challenge
/PyPoll/main.py
3,003
3.515625
4
#PyPoll import os import csv #Fix file path for source file source_file = os.path.join("Resources", "election_data.csv") #Call the file to write results output_file = os.path.join("Analysis", "PyPoll_results.txt") #define objects candidates = [] votes = [] total_votes = 0 margins = [] most_votes = 0 #Open source fil...
53a8d02014f5f3bc4a63373c70d6d42b8df1c3ad
BrendanArthurRing/codewars
/21-sticks.py
1,303
4.09375
4
# https://www.codewars.com/kata/21-sticks/train/python ''' 21 Sticks The Game: In this game, there are 21 sticks lying in a pile. Players take turns taking 1, 2, or 3 sticks. The last person to take a stick wins. Like this: 21 sticks Bob takes 2 19 sticks Alice takes 3 16 sticks Bob takes 3 13 st...
0f5a6b1d49acedefa6b9e924931a4491092cde29
mtengi/project-euler
/Problem026.py
478
3.703125
4
def findcycle(num): mult = n cycle=[] while True: x = int((mult/num)%10) cycle.append(x) if len(cycle)%2==0: if check(cycle): return len(cycle)/2 mult*=10 def check(cycle): for x in xrange(len(cycle)/2): if cycle[x] != cycle[x+len(cycle)/2]: return False return True n = 1000 largest = (0,0) f...
e56f3b61e74ba26a8ffd0eff0c6fa17ee5fa8530
chyt123/cosmos
/coding_everyday/lc500+/lc757/csh.py
799
3.75
4
class Solution(object): def intersectionSizeTwo(self, intervals): intervals.sort(key=lambda x: x[1]) rst = list() print intervals for s, e in intervals: if len(rst) == 0 or rst[-1] < s: rst.append(e - 1) rst.append(e) elif rst[-...
02edfb5be37c518f9ac03340bd58dbe2a9b733ba
chyt123/cosmos
/coding_everyday/lc500+/lc869/ReorderedPowerof2.py
576
3.65625
4
import math from typing import List from collections import deque, defaultdict class Solution: def reorderedPowerOf2(self, n: int) -> bool: sto = defaultdict(list) for i in range(30): tmp = [i for i in str(2 ** i)] tmp.sort() sto[len(tmp)].append(tmp) ln...
b21cfa44b001c03ad6a1a978ea15d09ae01e73d5
chyt123/cosmos
/coding_everyday/lc500+/lc803/BricksFallingWhenHit.py
1,609
3.578125
4
from typing import List class Solution: def hitBricks(self, grid: List[List[int]], hits: List[List[int]]) -> List[int]: m = len(grid) n = len(grid[0]) def dfs(x, y): if not (0 <= x < m and 0 <= y < n) or grid[x][y] != 1: return 0 cnt = 1 ...
f7da848a102c50330a2dae074da848606961d48e
chyt123/cosmos
/coding_everyday/lc500+/lc725/csh.py
1,888
3.828125
4
# Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def print_list(self, listnode): node = listnode while node: print node.val, node = node.next print def ...
cb63306ced351a67eefb58ac7ba0c31013693e4f
chyt123/cosmos
/coding_everyday/lc1-100/lc39/Combination Sum.py
776
3.5625
4
from typing import List class Solution: def combinationSum(self, candidates: List[int], target: int) -> List[List[int]]: n = len(candidates) ans = [] def backtracking(level, cur_list, target): if target <= 0: if target == 0: ans.append(cur_l...
38fa59ac361c96b4575b381eec18bf4a4ec4b333
chyt123/cosmos
/coding_everyday/lc500+/lc812/LargestTriangle.py
479
3.515625
4
from typing import List from itertools import combinations class Solution: def largestTriangleArea(self, points: List[List[int]]) -> float: return max(self.calArea(*i) for i in combinations(points, 3)) @staticmethod def calArea(p, q, r): return abs(p[0]*q[1]+q[0]*r[1]+r[0]*p[1]-p[0]*r[1]-q[...
1891b7493afe561e3ff90bf684e0a69ac762d50a
chyt123/cosmos
/coding_everyday/lc1-100/lc48/RotateImage.py
944
3.703125
4
import copy import math from typing import List class Solution: def rotate(self, matrix: List[List[int]]) -> None: """ Do not return anything, modify matrix in-place instead. """ n = len(matrix) for diag in range(n // 2): l = n - 2 * diag tmp = [0] *...
842aeac72916b6a4fd88731f4ef43b92cd54ca7c
chyt123/cosmos
/coding_everyday/interview/ms/0713.py
592
3.71875
4
def my_sqrt(n): # neg: Raise error, >=0 if n < 0: raise RuntimeError('input must >= 0.') if n < 2: return n l, r = 0, n # [) mid = 0 flag = False while l < r: mid = (l + r) // 2 if mid ** 2 == n: return mid if mid ** 2 > n: ...
d83cb750153d3e018a63d3002268b35ff58e5e04
chyt123/cosmos
/coding_everyday/lc201-300/lc242/Range Sum Query - Mutable.py
356
3.59375
4
import bisect import collections from typing import List class Solution: def isAnagram(self, s: str, t: str) -> bool: return sorted(s) == sorted(t) if __name__ == "__main__": sol = Solution() test_cases = [ ["anagram", "nagaram"], ["rat", "car"], ] for i, j in test_cases:...
1cc12a693f207ba08878f75a49d425431f4a7341
curious-guy/kaggle_salary_predictor
/kaggle_salary_predictor.py
4,241
3.578125
4
# import related libraries import pandas as pd import numpy as np import matplotlib.pyplot as plt from math import sqrt from sklearn.model_selection import train_test_split from sklearn.metrics import mean_squared_error, r2_score from sklearn.linear_model import LinearRegression from sklearn import metrics # load...
b2ea483c20d4533856a5d91638f2ea2935d6041c
AP-State-Skill-Development-Corporation/Programming-using-Python-MB10
/Day10_17Dec2020/mymodule.py
167
3.84375
4
def evenodd(n): if n%2==0: print("even") else: print("odd") def add(a,b): c = a+b print(c) def hello(name): print("Hello"+" "+name)
f2ffb1e6949c9b99d3a3fd613e81a280e6d5c92d
adamkmcz/prework
/task.py
2,685
3.828125
4
# # # # print("Mam na imię <Adam>") # # # # a = 1 # # b = 1.2 # # c = "abc" # # d = True # # # # print(f'Zmienna a ma wartość {a}') # # print(f'Zmienna b ma wartość {b}') # # print(f'Zmienna c ma wartość {c}') # # print(f'Zmienna d ma wartość {d}') # # # # foo = True # # bar = False # # check = foo == bar # # print(...
895cfbabf9433a63a0f66f9593489f95d1cf27e1
isaquemelo/python-backup
/Traço de uma matriz.py
424
3.578125
4
count = 0 one = [] two = [] while count < 20: count += 1 number = int(input()) one.append(number) count = 0 while count < 20: count += 1 number = int(input()) two.append(number) inter = [] for i in one: for f in two: if i == f: if not i in inter: inter.ap...
dc021a6cef3e45d13e387b74d1f25422929ae317
isaquemelo/python-backup
/Brincando com Ambrosinho.py
1,708
3.5625
4
''' 1 2 3 4 5 6 7 8 9 LINHA, COLUNA -> LINHA, COLUNA 0,0 -> 0,2 0,1 -> 1,2 0,2 -> 2,2 1,0 -> 0,1 1,1 -> 1,1 1,2 -> 2,1 2,0 -> 0,0 2,1 -> 1,0 2,2 -> 2,0 Padrão colunas: De len(colunas) até 0 Padrão linhas: (De 0 até len(linhas)) * ''' entrada = input().split() linhas = int(entrada[0]) colunas = int(entr...
417c6c1a0bd3805b628690576832b4212ba5e802
isaquemelo/python-backup
/Jogo da Velha.py
2,137
3.828125
4
qty = int(input("Qual o número de partidas? ")) count = 0 linha1 = [] linha2 = [] linha3 = [] def verifica(listaHorizontal, listaVertical, listaDiagonal): def valida(lista): o = x = 0 for i in range(3): for f in lista[i]: if f == "x": x += 1 ...
8bcf7fd7ae59b9f5a9e1300e59254e73bb831820
lambduhh/challengeAccept3d
/practice1/simple_array_sum.py
415
3.9375
4
# # Given an string of integers, find the sum of its elements. # # Print the sum of the array's elements as a single integer. def simplearraysum(y): l = y.split() # type conversion str-> list of ints ml = list(map(int, l)) summ = sum(ml) return summ def print_res(n: int) -> None: print(n) i...
0decbda32186e7f10ab612142f015684302fe4f9
abimarticio/automate-boring-stuff-python
/lists/lists.py
4,481
4.6875
5
# list is a value that contains multiple values # values in a list are also called items # you can access items in a list with it's integer index # indexes start at 0 # You can get multiple items from list using a slice # slice has three index (start, end, step) spam = ['cat', 'bat', 'rat', 'elephant'] print(spam) # in...
082c634a74a3a656c0c5e9cb730a35d9d0eb2efe
abimarticio/automate-boring-stuff-python
/regular_expressions/sample_2.py
976
4.5625
5
# Regex Groups and Pipe character # Groups are created in regex strings with parentheses. # The first set of parentheses is group 1, the second is 2, and so on. # Calling group() or group(0) returns the full matching string, group(1) returns group 1's matching string, and so on. # Use \( and \) to match literal parenth...
73e7244382b44cfe0f10623f7cc889073317a6d6
jpmondet/pynet-course
/w5ex1a.py
912
3.859375
4
#! /usr/bin/env python3 """ Create an ssh_conn function. This function should have three parameters: ip_addr, username, and password. The function should print out each of these three variables and clearly indicate which variable it is printing out. Call this ssh_conn function using entirely positional argume...
95e7f0530408278f2be80fef32d899c5d4b6e82f
Ysh096/programmers
/D2/다리를지나는트럭/s1.py
1,335
3.5625
4
# def solution(bridge_length, weight, truck_weights): # bridge = [0]*bridge_length # bridge[-1] = truck_weights.pop(0) # time = 1 # while bridge: # 더 넣을 트럭이 없어질 때 까지 # bridge.pop(0) # time += 1 # if truck_weights: # if sum(bridge) + truck_weights[0] <= weight: # ...
92c9d0bf37a2b774b33fe7264d1b5165315b6bd4
bradfox2/CodeWarsSolutions
/pathfinder1/pathfinder1.py
2,521
3.515625
4
#bfs for pathfinder 1 with some commented code setting up a* def path_finder(maze): #unpack maze string into list of lists maze = [list(i) for i in maze.split("\n")] #calc the bottom right most dot (y,x) finish_coords = [len(maze)-1, len(maze)-1] #always square maze #one list for possible...
0fd50c0edf2b25e5fb654210be8e95fa337461d1
MelnykVladislav/Melnyk.FIT.126
/Lab№3.py
767
4.03125
4
print ("Привет друг, придумать тебе пароль?") a = "Если да, то нажми продолжить(ENTER)"; print (a) input('Press ENTER to continue') import random chars = 'abcdefghijklnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890' number = input('Количество паролей?'+ "\n") length = input('Длина пароля, ско...
bfa8280052fc7649b48a3d8dc04080e4c2bdc8d6
jw-develop/cs394-projects
/mlp/perceptron.py
1,701
3.921875
4
import numpy as np from random import uniform # The step function def step(x) : return -1 if x < 0 else 1 # The "logistic" function, often called "sigmoid" def sigmoid(x) : return 1 / (1 + np.exp(-x)) def sigmoid_deriv(x) : return x * (1-x) # We can adjust the sigmoid to make it range from -1 to 1 def ...
4a805a5da77b6aafd5f7be0c00c9405a5e7b53d8
IASBSWCL/FSO
/testRecoderFirstMethod.py
1,353
3.609375
4
from fieldArray import * from field import field def most_frequent(List): ''' returns the mostFrequent item and frequency percentage''' mostFrequentValue = 0 mostFrequentItem = List[0] for i in List: curr_frequency = List.count(i) if(curr_frequency > mostFrequentValue): mo...
6d07b86dd4e561720ad5b4a6975bb23d8826c4b4
akashsatardekar/program
/oop.py
1,332
3.953125
4
import csv def write_into_csv(info_list): with open('student_info.csv','a',newline='\n') as csv_file : writer=csv.writer(csv_file) if csv_file.tell()==0: writer.writerow(["Name","Age","Contact_Number","E-mail ID"]) writer.writerow(info_list) if __name__=='__main__': condition...
62397cef8aaec18d8281585101fd200a69a8b7df
KiemNguyen/machine-learning
/regression/03_polynomial_regression/polynomial_regression.py
2,090
3.984375
4
# Polynomial Regression # Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd # Importing the dataset dataset = pd.read_csv('Position_Salaries.csv') X = dataset.iloc[:, 1:2].values y = dataset.iloc[:, 2].values # Splitting the dataset into the Training set and Test set """f...
4e0e4b8fa9ce864287208d1b8739116ddfad6d9d
amirun573/genetic_algorithm
/terengganu.py
7,643
3.9375
4
def randomize(x): size = x cities = ['A','B','C','D','E','F','G','H','I','J','K','L'] population = [] for i in range(size): x = random.sample(cities, len(cities)) population.append(x) return population def return_location_Reverse(x): new=[] for i in x: ...
aa51bebb0b69aa0e4f83d015c769411cfb4ce98b
RITESHMOHAPATRA/Programs
/HackerRank/missing_numbers.py
543
3.8125
4
from collections import Counter import pprint def missing_number(l1,l2): freq1 = Counter(l1) freq2 = Counter(l2) missingNumber = [] for num in l2: if num not in l1 or freq1[num] != freq2[num]: if num not in missingNumber: missingNumber.append(num) for num in ...
47788fb14acb17b77ed6a3e8a14cdaae771e8a59
AyaPK/advent-of-code
/2015/day5/part2.py
1,063
3.703125
4
# def three_vowels(inp): # return sum(1 for x in inp if x.lower() in "aeiou") >= 3 # # def no_bad_strings(inp): # badstrings = ["ab", "cd", "pq", "xy"] # for st in badstrings: # if st in inp.lower(): # return False # return True # # def double_letter(inp): # for x in range(len(in...
a9659c59a3e55021b626a811cd233f72c777ff65
AyaPK/advent-of-code
/2021/Python/Day 2/part2.py
486
3.59375
4
class Submarine: def __init__(self): self.xpos = 0 self.ypos = 0 self.aim = 0 data = [x.strip() for x in open("input.txt", "r").readlines()] sub = Submarine() for i in data: instruction = i.split(" ")[0] amount = int(i.split(" ")[1]) if instruction == "forward": sub.xp...
4bdffc3f2e3e19cac206ddf37e193acb9f3ba764
AyaPK/advent-of-code
/2018/day5/day5.py
861
3.515625
4
indexes = [] def parse(input): parsed = 0 global output output = input notfound = True while notfound: for letter in range(0, len(output) - 1): notfound = False let = output[letter] if let.isupper(): if output[letter + 1] == let.lower(): ...
785f0d2b1a13f8b132621b57c675610f51772461
AyaPK/advent-of-code
/2019/day6/day6t2.py
257
3.609375
4
import networkx as nx graph = nx.DiGraph() for data in open("input.txt").readlines(): graph.add_edge(*[x.strip() for x in data.split(')')]) print(nx.transitive_closure(graph).size()) print(nx.shortest_path_length(graph.to_undirected(), "YOU", "SAN")-2)
47c0fc024dd9e9657d7e12eec8d264f857bc5a0e
kcolford/ProjectEuler
/py/35.py
413
3.671875
4
#!/usr/bin/python3 from util import * def check(lst): """Return true if the number in lst is curious.""" return all(isprime(num(i)) for i in rotations(lst)) numbers = list(map(int, '0123456789')) out = set() for i in range(500000): lst = digits(i) if check(lst): print(i) for r in rot...
e8f1e82ccbc260d88a0a340cf9e8ccd8ea23f57e
skirmer/python
/newproject2.py
2,956
4.125
4
import random import string import csv def weasel(): print('''This program will generate a set of randomized passwords to your specifications, and save them for you to import into the password manager of your choice.''') print("") a=raw_input('Do you want symbols? ') while (a.upper()=='Y' or a.upper()=="YES" o...
10920dfb9fe2d73189832a0e828e41257c0638ad
nlpjoe/NewStudents
/code-projects/jzzhou-example/word-seg-CN/fmm/trie_tree.py
774
3.953125
4
class TrieTree(object): """字典树实现""" def __init__(self): self.tree = {} def add(self, word): tree = self.tree for char in word: if char in tree: tree = tree[char] else: tree[char] = {} tree = tree[char] t...
0e7860b929be7b8913ba2c7104f2f0603a8f5baa
MagiicPants/RockPaperScissors
/RockPaperScissors.py
4,555
4.1875
4
import random import time items = ["rock", "paper", "scissors"] score = 0 comp_score = 0 game = input("Would you like to play Rock-Paper-Scissors? yes or no - ") if game == 'yes': print("\n") print( "\tINSTRUCTIONS:\nYou will select one of three items: rock, paper, or scissors.\nRock beats scissors,sc...
c3d9c1125591bb5a669f80181939d01fab595f80
PeterMitrano/upgoer5_madlibs
/upgoer5_madlibs/upgoer5_madlibs.py
1,095
3.890625
4
#!/usr/bin/env python import sys import argparse def read_input_text(filename): with open(filename, 'r') as f: lines = f.readlines() stripped = [l.strip("\n") for l in lines] return stripped def read_vocab(filename): with open(filename, 'r') as f: lines = f.readlines() ...
1edbcbcd6fdf021e06cce827ce27841749481242
gonzaprograma/variables_python
/ejercicios_practica/ejercicio_4.py
925
4.46875
4
# Tipos de variables [Python] # Ejercicios de práctica # Autor: Inove Coding School # Version: 2.0 # IMPORTANTE: NO borrar los comentarios # que aparecen en verde con el hashtag "#" # Ejemplos variables de texto # Ingrese tres palabras y arme un acrónimo con ellas # Si desea puede modificar el código para ingresar ...
1043fbd68a78b0bf810791799c6335aa2bf70a6c
nileshnn/practical
/program_2.py
302
3.75
4
def cmpString(list): bool = True for c in list[1]: if c in list[0]: pass else: bool = False break return bool str_1 = input('Enter first string: ') str_2 = input('Enter second string: ') list = [str_1, str_2] print(cmpString(list))
9032c314bbeb0faccb85a37d0d750a910b90a55a
SeedofWInd/LeetCoding
/Facebook/72_Edit_Distance.py
2,213
3.9375
4
""" (a)(Complete Choice): for every problem instance, at least one choice is consistent with an optimal solution. (b) (Inductive Structure): for each initial choice ck, show that making choice c leaves one or more strictly smaller subproblems with no external constraints relative to ck. (c) (Optimal Substructure): for ...
ae212d25de641a2a27cc3aa87bd1a969f4925135
SeedofWInd/LeetCoding
/Facebook/325_Maximum_Size_Subarray_Sum_Equals_k.py
1,808
4.0625
4
""" Description ___________ Given an array nums and a target value k, find the maximum length of a subarray that sums to k. If there isn't one, return 0 instead. Note: The sum of the entire nums array is guaranteed to fit within the 32-bit signed integer range. Example 1: Given nums = [1, -1, 5, -2, 3], k = 3, return ...
b3e4728b064ba447dbd57bb81f55d60cfe4e7b2d
sebhaugeto/Chess-In-Python
/Chess Classes.py
23,113
3.765625
4
#!/usr/bin/env python """ Contains all classes necessary for the chess game. #x in code = x-axis in visual representation #0,1,2,3,4,5,6,7 #y in code = y-axis in visual representation #0,1,2,3,4,5,6,7 """ __author__ = '@sebhaugeto' #Check me out on Instagram! import pickle import random class Color: PURPLE = '\03...
e4242390024466a6aacbea47f7acf48a15f6f379
hchen98/search-script-scrape
/scripts/45.py
989
3.5
4
# The number of security alerts issued by US-CERT in the current year import requests from lxml import html from bs4 import BeautifulSoup def getTotalSecurityCount(year): counter = 0 result = 0 flag = True try: while flag: url = "https://www.us-cert.gov/ncas/alerts/" + year + "...
5e9824385f47f2a6243f60264ef2207e9f121880
YuriyBodnarIvanovich/py_web
/Lab1-Sockets/Task-1/subtask-2/tcp-server.py
1,141
3.5
4
""" 1 - Send message to the server and print it with sended time. 2 - Send message to the server, which repeat this message after 5 sec. 3 - Send few message to the server; Server can stop connections after command. 4 - Server with few connections. 5 - Server with nonblocking mode. "...
caaa6ac831af543b3a53c2af39af830ffd283fd1
amanpant128/DataPreprocessing
/data_description.py
2,431
3.921875
4
import pandas as pd class dataDescription: tasks = ['\n1. Describe specific column', '2.Show properties per column', '3.Show Dataset'] def __init__(self, data): self.data = data # function which will show dataset in screen def showDataset(self): while(1): ...
52e40e675c7fd78a57455722f10a90f331ecca77
vmmqa/XenGT-CitrixServer-patch
/study/python/2.1.py
203
3.8125
4
A = set([1, 2, 3, 4]) B = set([3, 4, 5, 6]) print(A & B) # intersection print(A | B) # union print(A - B) # difference, element in A, and not in B print(A ^ B) # symmetric difference, (A | B) - (A & B)
4cd2e6d84b83a5e54ef3002fd452d533bf470288
penm284/comp_sci_year_1
/unit_one/warmups/helloworld.py
284
4.21875
4
#get used info #user name name = input("What is your name") my_age = 300 #get user's my_age user_age = input("What is your age") #change user_age from string to integer user_age= integer(user_age) added_age = my_age+user_age print("%s age plus my age is equal to %d"(name,added_age))
0a709f0b5f679411b99eba40d1c4f2333c2625b0
penm284/comp_sci_year_1
/unit_two/projects/weather_project/my_project.py
2,122
4.40625
4
temp = int(input ("What is the temperature today (in Farenheight)")) wind = input ("Is it windy today (yes/no)?") rain = input ("Is it raining today (yes/no)?") def check_wind_and_rain (): #check to see if it is windy if wind == "yes": #assign a true value if it is windy is_wind = True els...
324a4808d3ef7384f4e536814abe4a736ec1d751
muhammadhardiansyah/Python-Projects-Protek
/Praktikum 10/6.py
2,892
3.609375
4
def Caesar(huruf,n): a = ord((huruf)) b = a + n c = chr(b) return c while True: print('='*50) print("A. Buat file asli") print("B. Lihat file asli") print("C. Enskripsikan ke sandi caesar") print("D. Selesai") print("E. Cetak kunci (Opsional)") first = str(input("Pilih : "))...
4b857bfa5630d88e0f0da5af1c48045ddfb3577f
muhammadhardiansyah/Python-Projects-Protek
/Praktikum 05/praktikum 1/latihan_4.py
1,022
3.734375
4
kode = (input("Masukkan kode karyawan:")) nama = input("Masukkan nama karyawan:") golongan = input("Masukan golongan :") print("="*38) print("STRUK RINCIAN GAJI KARYAWAN") print("-"*38) print("Nama Karyawan :",nama, "(","Kode:",kode,")") print("Golongan :",golongan) print("-"*38) if (golongan == "A")...
5b7f782257aac1263902a16d9c9a6cea69637e1b
muhammadhardiansyah/Python-Projects-Protek
/Praktikum 09/2.py
192
3.78125
4
def bintang(n): for i in range (n): print(("*" * (1 + 2*i)).center(1 + 2*n)) try: n= int(input("Masukan n:")) except ValueError: print("n harus bilangan bulat") bintang(n)
d4fdabd76f37df84a425159649d2a996fb25e0ea
muhammadhardiansyah/Python-Projects-Protek
/Praktikum 08/PythonProject/4_project.py
1,648
3.78125
4
data_sayur = ["bayam","kangkung","wortel","selada"] while True: print("="*33) print("DATA SAYURAN") print("-"*33) A = print("A. Tambah data sayur") B = print("B. Hapus data sayur") C = print("C. Tampilkan data sayur") D = print("D. Tutup program") pilih = input("Pilihan Anda: ") pri...
3758dd8906d35c26f4b93f2ce79fb09636a39808
muhammadhardiansyah/Python-Projects-Protek
/Praktikum 05/praktikum 2/latihan2_3.py
278
3.71875
4
i = 0 ganjil= 0 angka = 0 Jumlah = 0 while True : i = i + 1 if (i % 2 != 0): print(i) ganjil = ganjil + 1 Jumlah = Jumlah + i if (i >= 100): break print("Banyaknya bilangan ganjil =", ganjil) print("Jumlah seluruh bilangan =", Jumlah)
dd37d1fbe8ad61b44c9dc6c67b04a1f0787af3c7
agacayan/AutomateTheBoringStuff
/Projects/adobeprogquestion.py
419
3.765625
4
# TODO: create a function that will remove duplicate numbers in lists and index itself. def unique(): number = [222, 333, 333, 222, 555] for i in range(len(number)): #x = number[i] d = 0 for nextarray in range(i): if number[i] == number[nextarray]: d = 1 ...
eabee76c3ee501cf77ca38f86283265bf5748f94
simrit1/My-stuff
/Fret finder/tunings.py
1,584
3.953125
4
"""How will we handle changing tuning? Just reuse the note changing code and assign it to tuning""" def tune(): while True: tunings = {'Standard' : ["E","A","D","G","B","E"], #Dictionary must be before input 'Drop D' : ["D","A","D","G","B","E"], 'D Standard' :...
5953369243728e5ec978b1f02ade1c4f9da16ecf
simrit1/My-stuff
/Fret finder/notes.py
7,254
4.21875
4
def get_notes(): while True: while True: #Loop that checks if a correct note is entered notes = ["A","A#","B","C", "C#","D","D#","E","F","F#","G","G#"] root = str(input("Enter one of the following notes (case-sensitive):\nA, A#, B, C, C#, D, D#, E, F, F#, G, G#\n: ")) ...
17373996c401d7c79e175ca9f1800f7151840714
ash92kr/s_code
/2018.12.18/string_test.py
1,133
4.09375
4
# python 과거(2버전) '일은 영어로 %s, 이는 영어로 %s' % ('one', 'two') # one과 two가 각각 %s로 들어간다 # python 현재(3버전) - pyformat '{} {}'.format('one', 'two') name = '홍길동' e_name = 'Hong Gil Dong' print("안녕하세요. {}입니다. My name is {}.".format(name, e_name)) # 변수의 순서 바꾸기 - 처음의 변수가 0, 나중의 것이 1 print("안녕하세요. {1}입니다. My name is {0}.".format...
e4b1f9443195f2ccf876cc667d7317cd6aabbd8d
ash92kr/s_code
/2019.01.28 - 문자열, 패턴매칭 알고리즘/연습1.py
541
3.828125
4
# 짧게 s = "Reverse this strings" s = s[-1::-1] print(s) # 길게 def my_strrev(ary): str = list(ary) # 불변 형태를 가변 형태인 리스트로 변경 for i in range(len(str)//2): t = ary[i] # 임시 변수 str[i] = str[len(str) - 1 - i] # i번째에 -1-i번째의 값을 넣음 str[len(ary) - 1 - i] = t # 임시 변수의 값을 -1-i번째에 넣음 ary =...
ced6c8d899e9209680f22340203591bb2877cedd
ash92kr/s_code
/2019.03.12 - 집합, 수식, 재귀, 병합 정렬, 동적 프로그래밍/조합.py
604
3.546875
4
def myprint(q): while q != 0: q -= 1 print(T[q], end=" ") print() def combination(n, r, q): if r == 0: myprint(q) # 프린트 함수 부르기 else: if n < r: # n보다 r이 크면 무시 return else: T[r-1] = A[n-1] # A의 원소를 T에 넣음 combination(n-1, r-1...
14e7424501f957184e001ee23a20e4ce26effddf
ash92kr/s_code
/2019.01.28 - 문자열, 패턴매칭 알고리즘/연습2.py
512
3.71875
4
# 길게 def strcmp(str1, str2): i = 0 if len(str1) != len(str2): # 길이가 다르면 바로 False return False else: # 길이가 같다면 while i < len(str1) and i < len(str2): # 무한 반복(인덱스는 문자열 길이보다 1 작음) if str1[i] != str2[i]: # 2개 문자열의 문자가 다르면 False return False i += 1 #...
f9a5d494ddb98bf5e96ca5e6763bae8188105c7c
anyway0/Python
/05_변수4.py
958
3.765625
4
''' 변수(variable) 1) 용도: 데이터 저장 2) 문법: 변수명 = 데이터값 3) 변경가능하기 때문에 변수라고 부른다. 4) 하나의 변수에 여러 데이터를 저장할 수 있다. 5) 변수=변수2=변수3=값 6) 변수, 변수2 = 값, 값2 7) 변수, *변수2 = 값, 값2,값3.... 8) 모든 변수는 참조형(reference)이다. ==> 변수에 저장된 값은 실제값이 아니고 주소값이다. ==> 주소값은 id(변수) ==> 하나의 데이터를 여러 변수에 참조할 ...
e9680ac3a9a3d7fbebe30d1286e9704f0e099720
ashfaquemd2002/beginner-projects
/guess-number/guess-num-user.py
529
4.0625
4
# guess-num-user.py # program for guessing number by user import random def guess_num_user(upper_limit): gen_num = random.randint(1,upper_limit) user_num = 0 while user_num != gen_num: user_num = int(input(f'Guess the number between 1 and {upper_limit}: ')) if user_num > gen_num: ...
6fd8f06ccd9576ea8560da033a7a370f2fafaafa
xcray476/Challenge_2
/Challenge 552021.py
280
3.953125
4
def color(x,y): x2 = str(x) y2 = str(y) if y2 in x2: rstr = "true" if y2 not in x2: rstr = "false" return rstr x2 = "My favorite color: red." print(x2) y2 = input("red.") print(y2) ans = color(y2, x2) print("color, ans") print("rstr")
8053cbcfa16aef0e4588e97ed52e8a296fbf56f1
nb312/LearnDog
/DeepLearning/Main.py
2,186
3.671875
4
# -*- coding: utf-8 -*- import numpy as np class Network(object): def __init__(self,sizes): """random is the object that can product random num with special rule. the function 'randn()' can product the random number from 1 to x as an array """ self.num_layers = len(sizes) self...
5804579b7971cd044d8fde58f2c59536b30ca258
nb312/LearnDog
/DeepLearning/NetWork2.py
5,743
3.5625
4
# this is test for network import random import numpy as np class NetWork(object): """ This is test for the network 1. Initialize the network,the __init__ function. 2. Previously propagation and back propagation with the mini batch,then return the derivative of w and b. 3. Us...
f4e4474009c2ecc86d13894683ddb541e7db2afc
supernavy111/Hacktoberfest2021
/voting.py
1,152
4.03125
4
nominee_1=input("Enter the nominee 1 name: ") nominee_2=input("Enter the nominee 2 name: ") nom_1_votes=0 nom_2_votes=0 votes_id= [1,2,3,4,5,6,7,8,9,10] num_of_voter=len(votes_id) while True: if votes_id==[]: print("voting session over") if nom_1_votes>nom_2_votes: percent=(nom_1_vot...
d9cefc7878884cf8bdf1dd245bb53886faa1209b
qayyumisaa/simple_py_programs
/factorial.py
423
4.3125
4
def find_factorial(num): factorial = 1 if num < 0: print('Factorial does not exist for negative number.') elif num == 0: print('The factorial for 0 is 1') else: for i in range(1, num + 1): factorial = factorial * i print('The factorial for ' + str...
452b3ce38262f6e8b3d5651e8a34d098897fe5dd
AhmedMagdyHendawy/Think-Like-A-Programmer-Course
/Exercises/Session 2/conver_to_lower.py
358
4
4
''' Python Course: Think like a programmer - Session 2 Excercise: Prompt the user to enter his name and convert it to be in lower case letters July, 2019 ''' s = input("Enter Your Name") s_new = "" for c in s: if c == ' ': s_new += c continue if (ord(c) < 97): c = chr(ord(c) + 32) ...
0075d2bbb9ccaf9bde63b03214c231d5abd749b6
weibominingdata/scripts
/test/TrioComparedWithParents.py
5,695
3.71875
4
import sys def aOverlapB(a, b): if (a[0]>a[1] or b[0]>b[1]): print "Wrong input" return False if (a[0] < b[0]): if (a[1] < b[0]): return False else: return True else: if (a[0] > b[1]): return False else: return ...
73c97e7305a0060025e2826a385b5d779a86e0d2
EzzElddin-AbdAllah/Problem-solving
/Codeforces/Sheet A/boy or girl.py
162
3.75
4
n = input() s = list() for i in n: if i not in s: s.append(i) if len(s) % 2 == 0: print('CHAT WITH HER!') else: print('IGNORE HIM!')
ccaa36fb5fd9d953c364317af4442ee4fed35de3
ryananggada/RyanKho_ITP2017_Assignment1-Driving-Simulation
/driving_simulation.py
1,066
4.03125
4
ini_vel = 0 time_on_road = int(input("Time spent on the road = ")) acc = int(input("Acceleration = ")) distance = int(input("Distance = ")) speed_limit = 60 for i in range(int(time_on_road+1)): star_rep = "" current_time = i final_vel = ini_vel + (acc * current_time) distance_travelled = 0.5 * acc * cu...
a35a7bdbc0010087ac174c181c7961dbc6e3bd9b
styler15/netflix_visualizations_capstone_datascience
/netflix.py
6,349
3.84375
4
#!/usr/bin/env python # coding: utf-8 # # Introduction # # In this project, you will act as a data visualization developer at Yahoo Finance! You will be helping the "Netflix Stock Profile" team visualize the Netflix stock data. In finance, a _stock profile_ is a series of studies, visualizations, and analyses that di...
a830240419cb74869712d241f57a8c8f9d876c6b
keily/SimplePython
/SimplePython/Basic/Except/__init__.py
828
3.5625
4
import time import sys t_len=3 class InputException(Exception): '''A user-defined exception class.''' def __init__(self,obj,length): Exception.__init__(self) self.obj=obj self.length=length if(len(obj)>length): print('Exception: %s more than %d chars' % (o...
2146c0817b899d6e0586ccb8e9d16f5eec0a0ecf
ritikagupta25051998/FSDP2019
/day4/untitled0.py
453
3.625
4
# -*- coding: utf-8 -*- """ Created on Thu May 9 14:32:41 2019 @author: HP WORLD """ dict1={} while True: item=input(">") if not item: break list1=item.split() keys1=list1[0:(len(list1)-1)] keys1=" ".join(keys1) value1=int(list1[-1]) if keys1 in dict1: x=dict1.get(keys1) ...
0ceff1af171fcff2a39f63c17d2fc469092f0110
BernhardW85/Basisschulung
/lesson3_textfile.py
356
3.6875
4
with open("exampletext.txt", "r") as sample_file: content = sample_file.read() print(content) with open("exampletext.txt", "r") as sample_file_two: content_two = sample_file_two.read().splitlines() for line in content_two: print(line) with open("text2.txt", "w") as sample_write: sample_wr...
70fd3f5d8669c778a9360ae542cfb29ab571ac01
naamameg/learning-python
/campus IL/season1/hangman/hangman unit4.py
257
3.953125
4
GUESE_A_LETTER = input('enter a letter\n') if not GUESE_A_LETTER.isalpha() and len(GUESE_A_LETTER) > 1: print('E3') elif len(GUESE_A_LETTER) > 1: print('E1') elif not GUESE_A_LETTER.isalpha(): print('E2') else: print(GUESE_A_LETTER.lower())
a058cf3c2b53f32e41cc6786e9df93ed5dbff4b8
peterjameskay/treenodeadventure
/treenode.py
611
3.953125
4
class TreeNode: def __init__(self, story_piece): self.story_piece = story_piece self.choices = [] def add_child(self, node): self.choices.append(node) def traverse(self): story_node = self print(story_node.story_piece) while len(story_node.choices) != 0: choic...
ecb9c3ed6e8ae2ae8807f1a3a3ba374aab5fa0dc
DorAzaria/OpenCV_Course
/draw.py
592
3.96875
4
import cv2 as cv import numpy as np blank = np.zeros((500, 500, 3), dtype='uint8') # 1. Paint the image # blank[200:300, 300:400] = 0,0,255 # cv.imshow('Green',blank) # 2. Draw a rectangle cv.rectangle(blank, (0, 0), (250, 250), (0, 255, 0), thickness=2) # or thickness = cv.FILLED # 3. Draw a circle cv.circle(blan...
50937564c1164ef23ca32416f37c3cd0a14223f2
JJWren/ViolentPythonScripts
/wrenJ_WK7-1_script.py
3,594
4.03125
4
''' A password hash value has been intercepted during an investigation. The hash value is of type md5 and is associated with a password that is used by the suspect. Your job is to brute force the password by generating all possible password combinations until you identify a matching password. A couple of additional ...
84385712bdbf969dc07c15bdd779aa965fd7ac5f
Tomaszgit16/Perceptron
/perceptron.py
629
3.84375
4
#wartości x_input = [1,0.5,0.2] #Wagi dla każdej z ocen powyżej od 1 do 3 w_weights = [0.4, 0.3, 0.6] #Wartość graniczna do przejścia przez granicę threshold = 0.5 def step(weighted_sum): if weighted_sum > threshold: return 1 else: return 0 def perceptron(): weighted_sum = 0 #Każdą wa...
85e7ac5de0aeef73e2c9a41ca38a72f2ba3520bf
apracapinheiro/tarefas
/collatz.py
307
4.1875
4
def collatz(number): if int(number) % 2 == 0: resultado = int(number) // 2 return resultado else: resultado = 3 * int(number) + 1 return resultado i = 2 numero = input("Digite um numero inteiro: ") while i != 1: i = collatz(numero) print(i) numero = i
66e91f061adc255bbf6dbc318840e8e8e09e5509
Mbdn/Python-Beginner
/ex6.py
481
3.75
4
# coding:utf-8 x = "there are %d types of people." % 10 字符串赋值 binary = "binary" do_not = "don't" y = "Those who know %s and thonse who %s." % (binary, do_not) print x #输出 print y print "I said : %r." % x print "I also said: '%s'." % y hilarious = False #赋值为布尔 joke_evalustion = "Isn't that j...
552ccf8a04c809928cdb283a26122bb8e9b8a0b7
patruk91/hangman
/hmfunc.py
11,160
4
4
import os import time import sys from random import randint def demo_mode(capital): """ Enter program in demo mode. Show randomly chosen capital. :param capital: chosen capital """ try: if sys.argv[1] == "--demo": print(capital[1]) except IndexError: pass def decr...
6daf18ba8a47318bbfd01d31c6cce65c3058cfe9
lturnbow/MAT361
/pdfreader.py
3,474
4
4
# This function takes a pdf and converts it to a binary file def readfilePDF(): file = open('bin.txt', 'wb') for line in open('example.pdf', 'rb').readlines(): file.write(line) file.close() # This function takes the file bin.txt which was converted from a pdf, and # converts it back into the same pdf def writefi...
6bd4dcde3740dfa3a194f4bc8346b8eccd47198b
jgornowich/project_euler
/002/002.py
725
4.34375
4
def compute_fibonacci_sequence(max_number): """Find the fibonacci sequence up to some max number""" value = 0 sequence = [1, 2] while value < max_number: value = sequence[-1] + sequence[-2] sequence.append(value) if value > max_number: sequence.pop() return sequence ...
ad46473fa6ca68621062cce2fabe9c0939bfef4d
geo-xiros/python-fun
/TicTacToe.py
2,889
3.765625
4
import random board = ['1','2','3', '4','5','6', '7','8','9'] winTests = (((2,3),(4,7),(5,9)), #1 ((1,3),(5,8)), #2 ((1,2),(5,7),(6,9)), #3 ((1,7),(5,6)), #4 ((1,9),(2,8),(3,7),(4,6)), #5 ((3,9),(4,5...
bcb63a549dc084f9adbe4359b98e9e13f5afa20b
wparedesgt/Master-Python
/11-Ejercicios/ejercicio3.py
313
4.03125
4
""" Ejercicio No. 3 - Programa que compruebe si una varible esta vacia y si esta vacia, rellenarla con texto y mostrarlo en mayusculas """ texto = '' if len(texto.strip()) <= 0: texto = 'hola soy un text en minusculas' print(texto.upper()) else: print(f'La variable tiene contenido: {texto}')
d1b999fd208d30f1e66aebd554e0818e97a334ee
wparedesgt/Master-Python
/10-sets-diccionarios/set.py
274
3.875
4
""" Un set e un tipo de datos para tener una colección de valores sin indice ni orden """ personas = { 'William', 'Manolo', 'Francisco' } print(personas) print(type(personas)) personas.add('Paco') print(personas) personas.remove('Francisco') print(personas)
62f762215e2088bf4f00ba49ba93f745ec5c3555
wparedesgt/Master-Python
/07-ejercicios/ejercicio8.py
243
3.90625
4
""" Ejercicio 8. Cuanto es el X por ciento de X numero? """ #Entrada porcentaje = int(input("Engrese Porcentaje: ")) numero = int(input("Ingrese Numero: ")) #Salida print(f"El {porcentaje} % de {numero}, es: {(numero*porcentaje)/100}")
986da7130c89defce539fb4ad10da0c28e7fe4a5
wparedesgt/Master-Python
/07-ejercicios/ejercicio1.py
355
4.09375
4
""" Ejercicio - Crear dos variables "pais" y "continente" - Mostrar su valor por pantalla (imprimir) - Poner un comentario diciendo el tipo de dato """ pais = "Guatemala" continente = "America" year = 2021 print(f"{pais} - {continente} - {str(year)}") print(f"El pais es de tipo {type(pais)} y el continent...
cc24ea00947eea0625b9724e6d6ca36ccc367570
wparedesgt/Master-Python
/11-Ejercicios/ejercicio2.py
462
3.90625
4
""" Ejercicio 2. Escribir un programa que añada valores a una lista mientras que su longitud sea menor a 120 y mostrar la lista Plus: Usar while y for """ coleccion = [] for contador in range(0,120): coleccion.append(f"Elemento-{contador}") print("Mostrando el: " + coleccion[contador]) print(coleccion) ...
e03097871c6e3b1a3f436cf0072ccdb542890119
wparedesgt/Master-Python
/07-ejercicios/ejercicio10.py
520
3.84375
4
""" Ejercicio 10. El programa tiene que pedir la nota de 15 alumnos y ver cuantos han aprobado y cuando suspendido """ contador = 0 aprobados = 0 suspendidos = 0 numero_alumnos = int(input("Cuantos Alumnos Tienes: ")) while contador < numero_alumnos: nota = int(input(f"Que nota quieres ponerle al 'alumno': {con...
df6f6075a3d2e02c9d20b436b98c0a056714fa88
jimiwang/AID1807
/学生管理系统02/s.py
739
3.5625
4
# s.py class Student: L=[] #用来存储学生信息 count = 0 #用来记录学生数量 def __init__(self,n,a,s): self.name = n self.age = a self.score = s self.__class__.count+=1 self.__class__.L.append(self) @staticmethod def input_student(): while True: n=input("...