blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
a47f43022accb1f6750c72ec9a1ae49b5559d37d
razmanika/My-Work-Python-
/University/Fruit.py
3,906
3.53125
4
import random class fruit: def __init__(self,fruit_info,ripe,price): self.fruit_info = fruit_info self.ripe = ripe self.price = price def info(self): if self.fruit_info == 'แƒ•แƒแƒจแƒšแƒ˜': return '{} แƒจแƒ”แƒ˜แƒชแƒแƒ•แƒก แƒ แƒ™แƒ˜แƒœแƒแƒก แƒ“แƒ แƒ˜แƒก แƒแƒ แƒ˜แƒก แƒ›แƒฌแƒ•แƒแƒœแƒ” !'.format(self.fruit_info) el...
6f93edf0cd2b2178bc8c9345795d8ff7b770c2d9
heidili19/Home-Projects
/fib.py
418
3.984375
4
# Fib of n # fn = f(n - 1) + f(n - 2) def fib (n): if n < 2: return n else: return ((fib(n-1)) + fib(n-2)) #for n in range(0, 10): # print ("The bottom number is the fib of this " +str(n)) # print (fib(n)) print ("Enter the fib number you would like to calculate") userin = int(inpu...
3f1312b25d9defe8984c1338446e556dd45ec2a3
gie3d/algorithms-with-python
/sorts/insertion_sort.py
661
4.28125
4
def insertion_sort(collection): for loop_index in range(1, len(collection)): insertion_index = loop_index while ( insertion_index > 0 and collection[insertion_index - 1] > collection[insertion_index] ): collection[insertion_index], collection[insertion_ind...
b1d6fa28bd0d454fbbdcf2d15a4cfdc37d9a55a7
ravi4all/PythonAugReg_1-30
/01-OOPS/02-Members.py
386
3.75
4
# Members - Data Members and Member Functions class Emp: # Data Members/Class Variables id = 101 name = "Ram" age = 22 # Member functions/Class functions/Methods def printEmp(alpha,id,name, age): print("Emp details",alpha.id, alpha.name,alpha.age) print("Emp details"...
1497a85a4aaf21e3847c4f6b45527338f8151a2c
bogwien/mipt_labs
/3_turtle/14_stars.py
661
3.8125
4
import turtle # ะะฐั€ะธััƒะนั‚ะต ะดะฒะต ะทะฒะตะทะดั‹: ะพะดะฝัƒ ั 5 ะฒะตั€ัˆะธะฝะฐะผะธ, ะดั€ัƒะณัƒัŽ โ€” ั 11. ะ˜ัะฟะพะปัŒะทัƒะนั‚ะต ั„ัƒะฝะบั†ะธัŽ, ั€ะธััƒัŽั‰ัƒัŽ ะทะฒะตะทะดัƒ ั n ะฒะตั€ัˆะธะฝะฐะผะธ. def draw_star(pet, len, points): deg = 180 + 180 / points if points == 5: pet.pen(pencolor="red", pensize=2) for step in range(0, points): pet.forward(len) ...
360f699d555bde0507fabfef20529c40025a9509
FarkasGao/LearnPython
/Chapter3/Exercise/3_8.py
287
3.90625
4
place = ['TianJin', 'XiZang', 'WuZhen', 'TianShan', 'QianDaoHu'] print(place) print(sorted(place)) print(place) print(sorted(place, reverse=True)) print(place) place.reverse() print(place) place.reverse() print(place) place.sort() print(place) place.sort(reverse=True) print(place)
2c3a7c64597dceec031b674bbc7868eb3d0418be
kln-courses/popuplab
/code_py/web_dm_tutorial.py
5,517
4.125
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ tutorial in web data mining for Frontiers in DH March 30, 2017 @author: kln """ ### preamble - some practical stuff # import module ("collections of functions that as helpful") import os # make a working directory os.mkdir('/home/kln/Desktop/web_dm') # change to worki...
a616fbda4b1a51317ecf1401ca1f6ade7ee85bee
patthrasher/codewars-practice
/kyu8-4.py
514
3.859375
4
# Write a function to convert a name into initials. # This kata strictly takes two words with one space in between them. # The output should be two capital letters with a dot separating them. def abbrevName(name) : split = name.split() return split[0][0].upper() + '.' + split[1][0].upper() first, last = n...
9e46a2c56e9be1f1a8088a56fce38e6a61a437fe
KoYeJoon/python_basic
/ch6/exer06-3.py
352
3.6875
4
#exer06-3.py """ ๊ฒŒ์‹œ๋ฌผ์˜ ์ด ๊ฑด์ˆ˜์™€ ํ•œํŽ˜์ด์ง€์— ๋ณด์—ฌ์ค„ ๊ฒŒ์‹œ๋ฌผ ์ˆ˜๋ฅผ ์ž…๋ ฅ์œผ๋กœ ์ฃผ์—ˆ์„ ๋•Œ ์ดํŽ˜์ด์ง€ ์ˆ˜๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ """ def getTotalPage(m,n) : if m%n == 0 : return m//n else : return m//n + 1 print(getTotalPage(5,10)) print(getTotalPage(15,10)) print(getTotalPage(25,10)) print(getTotalPage(30,10))
73399dbccb4c01f649c6bd203741acd9345fbd46
alehpineda/bitesofpy
/Bite_8/rotate.py
498
4.5
4
""" Write a function that rotates characters in a string, in both directions: if n is positive move characters from beginning to end, e.g.: rotate('hello', 2) would return llohe if n is negative move characters to the start of the string, e.g.: rotate('hello', -2) would return lohel See tests for more info. Have fun! ...
0bea9115409be3c057bfa30100272fcf28250401
fishcakekelz/pastprojects
/moonlander/landerFuncs.py
2,437
3.71875
4
# Project 1 - Moonlander # # Author: Kelly Mok # Instructor: Mork def showWelcome(): print("\nWelcome aboard the Lunar Module Flight Simulator\n\n To begin you must specify the LM's initial altitude\n and fuel level. To simulate the actual LM use\n values of 1300 meters and 500 liters, respectively.\n\n ...
d3e8309fe03df21e200a5b6f202a94dd6b3c8495
selvi7/samplepyhon
/s25.py
146
3.90625
4
a23=int(input("enter the num:")) li=list(map(str,input("enter the num:")[:a23])) li.sort() li.sort(key=len) for i in li: print(i,end=" ")
2beec5ac96758d201b01058df92fe73484eadcd1
prashantchanne12/Leetcode
/kmp.py
1,039
3.546875
4
def init_arr(pattern): i = 0 j = 1 arr = [0 for x in range(len(pattern))] arr[0] = 0 while j < len(pattern): if pattern[i] == pattern[j]: i += 1 arr[j] = i j += 1 # first character did not match elif i == 0: arr[j] = 0 ...
c06773a6c1f155b794a19dd06b3e2c33b6aab6e5
lucmichea/leetcode
/Challenge_June_30_days_leetcoding_challenge/day10.py
908
4.0625
4
""" Search Insert Position Problem: Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may assume no duplicates in the array. Example 1: Input: [1,3,5,6], 5 Output: 2 Example...
55f354fbcd72b6c221a92a9bff6f96095344ddae
matchey/python2_tutorials
/count21.py
2,339
3.71875
4
# -*- coding:utf-8 -*- import random class Count21: def __init__(self, seq, total): if(seq < 1): seq = 1 if(total < 1): total = 1 self.seq = seq # ไธ€ๅบฆใซ่จ€ใˆใ‚‹ๆ•ฐใฎๆœ€ๅคงๅ€ค(ๆœ€ๅฐๅ€คใฏ1) self.total = total # totalใ‚’่จ€ใฃใŸๆ–นใฎ่ฒ ใ‘ self.opt_begin = 0 # CPUไฝ•ๆ‰‹็›ฎใ‹ใ‚‰ๆœ€ๅ–„ๆ‰‹ใงๆ‰“ใคใ‹ self.strategies = range((tot...
1751eedfabef7ac2449403805ce7cfdf7d1178a1
dgrin1/inclass_hw3_2020
/InClassSimonHarmonic.py
112
3.84375
4
sum = 0.0 max = float(input("say a number?: ")) for i in range(1,int(max+1)): sum += 1.0/i print(sum)
5ee4eb71c1fe839271808bb07bf1ead987dc29f4
047H-04EH/Python_crash_course
/Chapter5_if_statements.py
2,853
4.28125
4
#loops through a list and prints the item in #all caps if the condition is met cars=['audi','bmw','subaru','toyota'] for car in cars: if car=='bmw': print(car.upper()) else: print(car.title()) #using and to check multiple conditions #both conditions must be true for it to return true age_0=22 ...
910ad9e9ea6b9d5aec4e662bb51a888f76f8b15f
Charlie-Say/CS-161
/FINAL PROJECT/cryptofuncs.py
4,089
3.890625
4
#! /usr/bin/env python3 # # coding=utf-8 ''' This program will request the html of a given link. It will then scrape the html for tags to gather data and return each row of data. It will then create a data frame using pandas. Charlie Say CS 161 10:00AM ___PSEUDO__ request for downloaded html with provided link scrap...
0aad37a9d23e79360b69c6d6aa2e4023901f42e6
harishbharatham/Python_Programming_Skills
/Prob11_6.py
827
4.125
4
matrix1 = [float(x) for x in input('Enter matrix1:').split()] matrix2 = [float(x) for x in input('Enter matrix2:').split()] mat1 = [] while matrix1 != []: mat1.append(matrix1[:3]) matrix1 = matrix1[3:] print(mat1) mat2 = [] while matrix2 != []: mat2.append(matrix2[:3]) matrix2 = matrix2[3:] result = ...
f1ab6a2d09d70b0b2b8debe35058f2d275429157
JaxSoder/Python3-Quines-Ref
/Quines.py
1,002
4.4375
4
#Quick writeup on Python Quines to help me not forget this interesting topic. #This makes a string named "te" and prints it taking in "te" again using the % and prints #out "%s" at the end because it doesnt have another variable to take in. #NOTE: "%r" has to be used to take in RAW input. "%s" works but Quotes...
e3973926eadc9d45c268949d6340d8578b822550
redgatling/misc
/brackets.py
763
3.90625
4
def check_last(s1, s2): return (s1 == '(' and s2 == ')') or (s1 == '[' and s2 == ']') or (s1 == '{' and s2 == '}') def bracket_parser(sequence): bracket_stack = [] for sym in sequence: print(bracket_stack) bracket_stack.append(sym) if len(bracket_stack) > 1: ...
00dd5638d47ee5df574382f443d95a1d62852a52
mshero7/python_practice02
/prob04.py
643
3.78125
4
# # ๋ฌธ์ œ4 # ๋ฐ˜๋ณต๋ฌธ์„ ์ด์šฉํ•˜์—ฌ 369๊ฒŒ์ž„์—์„œ ๋ฐ•์ˆ˜๋ฅผ ์ณ์•ผ ํ•˜๋Š” ๊ฒฝ์šฐ์˜ ์ˆ˜๋ฅผ ์ˆœ์„œ๋Œ€๋กœ ํ™”๋ฉด์— # ์ถœ๋ ฅํ•ด๋ณด์„ธ์š”. 1๋ถ€ํ„ฐ 99๊นŒ์ง€๋งŒ ์‹คํ–‰ํ•˜์„ธ์š”. # # ์ž๋ฆฌ์ˆ˜ ๊ตฌํ•˜๋Š” ํ•จ์ˆ˜ def calc_digit(number, count): if number < 10: return count else: count += 1 return calc_digit(number // 10, count) def calc_three(number): number_map = map(int, str(number)) count =...
935c55bdeb62a257db33cf01dd7f4d7372d6a413
tomcdonald/cs50
/pset6/mario.py
317
3.9375
4
def main(): while True: n = input('Height: ') try: if 0 < int(n) < 9: break except: continue pyramid(int(n)) def pyramid(n): for i in range(1, n + 1): print((n-i)*' ', i*'#', '', i*'#') if __name__ == '__main__': main()
c74ce2e1edbf46f92e662aff5fb811ba96c85d10
stefanosbakas/IsagwgiStinEpistimiTwnIpologistwn
/Exercise 11/Exercise_11.py
1,421
4.0625
4
#BEST TESTED WITH input: [x,x,3,4,5,6] numbers=[] #ask for numbers print("Give numbers in order of priority") #check if input is digit and add it in a list i=0 while i <6: _input=input() if(_input.isdigit()): numbers.append(int(_input)) i+=1 else: print("Please, gi...
f7175f160c9f739349c01d7399d030ea584bc582
Moomers/penguins
/server/sensors.py
5,098
3.9375
4
#!/usr/bin/python import time from collections import deque class Sensor(object): """This class defines an interface that all sensors must implement""" pass class ArduinoConnectedSensor(Sensor): """A sensor connected to the on-board arduino on the robot""" def __init__(self, robot, key): Sens...
908d1a127bd58dfee9f5384972c1a45c1640e53d
bstrand/exercises
/oj.leet/minimum_depth.py
990
3.953125
4
minimum_depth.py # Definition for a binary tree node class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: # @param root, a tree node # @return an integer def minDepth(self, root): if not root: return 0 retur...
bb6a7d7b61a899548e574d352de6b8a28c9e7a51
ThreePointFive/aid1907_0814
/aid1907/mounth02/day01/poper.py
854
3.9375
4
class Car(): def __init__(self,name,speed,weight): self.name=name self.speed=speed self.weight=weight @property def name(self): return self.__name @name.setter def name(self,value): if value>10: self.__name=value else: raise R...
92f5a720dd74978d12becdbfb026656986b43150
shanku01/100-days-of-code
/Day 41/41.py
841
3.90625
4
# Day 40 of 100 daysof code #Binary Tree #Array Implementation of Binary tree #specifying size tree =[None]*20 #entering data at root def root(data): if tree[0]!= None: print("Root is here") else: tree[0]= data def setLeft(data,parent): if tree[parent]==None: print("Can't s...
f190ac7024c275b2c258973dc9db11c5c4a6cbdf
chikarl/Python4Dev
/task1.py
620
3.96875
4
string = input('Please enter a string : ') #string = string.split() num = [] def ifNumber(x): for i in string: if i.isdigit(): num.append(int(i)) return num print(ifNumber(string)) def isPrime(n): for i in range(2,n): if not(n%i): return False return True def fac...
5995c8e1888bf1be5466bcf388186490c6ffdd92
yordan-marinov/oop_packages_softuni
/movie_world/project/movie_world.py
2,095
3.59375
4
from project.customer import Customer from project.dvd import DVD class MovieWorld: def __init__(self, name: str): self.name: str = name self.customers: [Customer] = [] self.dvds: [DVD] = [] @staticmethod def dvd_capacity(): return 15 @staticmethod def customer_ca...
5a2f7ba60d196270e6a3baf843712b66c8287d94
gouthambaru/Python
/file1.py
1,460
3.78125
4
#!/usr/bin/env python3 #author : Pavani Krishna Goutham Baru(paba6303@colorado.edu) #name : file1.py #purpose : To take an abbreviation as an argument and print the planet name #date : 2015.11.10 #version : 3.4.3 import sqlite3 import os import sys if(len(sys.argv)!=2):#Checks for the number o...
2fb8fe81c8028741044cfb41346b0088925ec0da
NineOnez/Python_Language
/136_matplotlib_stackbar.py
365
3.515625
4
import matplotlib.pyplot as plt room = ["A", "B", "C"] boys = [10, 15, 5] girls = [20, 7, 15] # plt.bar(room, boys, label="Boys", color="blue") # plt.bar(room, girls, bottom=boys, label="Girls", color="orange") plt.stackplot(room, boys, girls, labels=["Boys", "Girls"], colors=["green", "pink"]) plt.xlabel("Room") p...
933fa1e6aca8b62807263e09fba0a87eb9dcdc52
guozhenjiang/Python
/matplotlib/org/05_ๅ›พๆ ทๆ ทๅผ.py
776
3.546875
4
# https://matplotlib.org/tutorials/introductory/usage.html#sphx-glr-tutorials-introductory-usage-py # sphinx_gallery_thumbnail_number = 3 import matplotlib.pyplot as plt import numpy as np x = np.linspace(0, 2, 100) plt.plot(x, x, label='linear') # Plot some data on the (implicit) axes. plt.plot(x, x**2, la...
6e260c0f266108fca49853195f3c3f8c7721266f
Kolokodess/switch_python_Ada
/Assignment1.py
718
4.375
4
balance = float(raw_input ("Enter Balance:")) Annual_interest = float(raw_input("Enter Annual Interest rate:")) min_payment_rate = float(raw_input("Enter Minimum payment rate:")) total_payment = 0 months = 1 while months <= 12: #m_m_p = minimum monthly payment m_m_p = min_payment_rate * balance monthly_interest =...
fdd815ab2812fac6737a82cdb69d8f6e159e0514
crazykuma/leetcode
/python3/1160.py
709
3.890625
4
from typing import List words = ["cat", "bt", "hat", "tree"] chars = "atach" class Solution: def countCharacters(self, words: List[str], chars: str) -> int: used_count = 0 d_chars = {} for c in chars: d_chars[c] = d_chars.get(c, 0)+1 for word in words: wor...
05af75afd8797d37d23cb5667899e904aa5aa52c
fpavanetti/python_lista_de_exercicios
/aula9_explicaรงรฃo.py
2,300
4.25
4
'''' AULA 9 - Manipulando Texto frase = 'Curso em Vรญdeo Python' 0123456789... FATIAMENTO DE STRINGS frase[9] (colchetes sรฃo os identificadores de uma lista) print(frase[9]) > V print(frase[9:13]) > Vรญde (o Python exclui o รบltimo nรบmero) print(frase[9:21]) > Vรญdeo Python frase[9:21:2] > o...
9ddf46eedd53be2093237d93ad9b770173cf2f32
wanghan79/2020_Python
/็™ฝไนฆ้“ญ2018012260/็ฌฌไบŒๆฌกไฝœไธš/randomDataSet_Decorators.py
4,001
4.09375
4
""" Author: ShuMing.Bai Purpose: Second Homework: Generate random data set by Decorators. Created: 5/28/2020 """ import random import string def dataSampling(func): def wrapper(dataType, dataRange, num, *conditions, strLen=8): """ :Description: Generate random data set samples.It's a decorator. ...
c2724e82dd28ac0c2e23197b9dad5b25b2163386
LinguList/hypergraph
/hypergraph/analytical.py
2,918
3.8125
4
from matplotlib import pyplot as plt from collections import Counter def prediction(graph, model="hypergraph", plot_results=False): """Predict diffusion on given graph using `model`. Parameters: graph: networkx graph or hypergraph model: name of model used to compute prediction, currently ...
accc2a154cd53e170d4f51c7020c9bda99cb4978
shivani1611/python
/BubbleSort/bubblesort.py
501
4.09375
4
#!/usr/bin/env python3 def display( l ): for i in range( len( l ) ): print( l[i] ) def bubbleSort( l ): for x in range( len( l ) ): for y in range( len( l ) - ( 1 ) ): if( l[y] > ( l[y + 1] ) ): str_buffer = ( l[y + 1] ) l[y + 1] = ( l[y] ) l[y] = ( str_buffer ) def main( ):...
ccf2835ec5b1cc5708ae07346a455c67154b2190
skyswordLi/Python-Core-Program
/Chapter8/datesDiff.py
2,436
3.984375
4
import datetime def diff_dates(date_str1, date_str2): month_days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] date1 = date_str1.split('/') year1, month1, day1 = int(date1[0]), int(date1[1]), int(date1[2]) date2 = date_str2.split('/') year2, month2, day2 = int(date2[0]), int(date2[1]), int(d...
8f5291aa2473121f142e14c2dcc2eee2af2c253c
Anushadsilva/python_practice
/Functions/func_pg5.py
285
4.21875
4
#Write a Python function to multiply all the numbers in a list. def my_fuc(): my_list = (8, 2, 3, -1, 7) total = 1 for x in my_list: total = x * total return total if __name__ == '__main__': final = my_fuc() print("mul of the given numbers is: ", final)
8f7bc6cf8c78b416285b7a8e58a57051c9f5e36f
csdankim/NLP_KATAKANA_ENG
/3. Viterbi decoding for POS tagging and Katakana-to-English (back)transliteration/decode_word.py
7,843
3.515625
4
#!/usr/bin/env python # coding: utf-8 # In[20]: # 1.The algorithm for jpron to english word is below: # Firstly, from jpron to epron: probably there are some potential words which has same pronunciation with epron, # if there is, record the highest probability(probability of jpron to epron times probability of epron...
922bcc4ab554bd6107c7a202bb4fa1b57babedc3
BoyanH/Freie-Universitaet-Berlin
/OOP/Python/Homework8/Aufgabe45.py
2,020
3.53125
4
class C: pass # "leere" Klasse exemplar1 = C() exemplar2 = C() #a) #Nein, es hat keine Auswirkungen, da exemplar1 zu einem Objekt in Speicher zeigt, und exemplar2 zu einem anderen. Die Klasse C wird dadurch nicht verรคnder, da #es zu eine total andere Adresse im Speicher zeigt, nรคmlich die Klasse selbst und ist damit...
f0ccf1e446d5385a3febed56e583a6b959a1ecec
ANDYsGUITAR/leetcode
/171-excel-sheet-column-number/excel-sheet-column-number.py
699
3.828125
4
# Given a column title as appear in an Excel sheet, return its corresponding column number. # # For example: # # # A -> 1 # B -> 2 # C -> 3 # ... # Z -> 26 # AA -> 27 # AB -> 28 # ... # # # Example 1: # # # Input: "A" # Output: 1 # # # Example 2: # # # Input: "AB" # Outpu...
85b083883ecb5233d4f4e2feb7dc2eea2a35478a
bhraiher/exercises_challenges_python
/Mundo 1/ex32.py
652
3.9375
4
'''Faรงa um programa que leia o ano para verificar se รฉ bissexto, ou tambรฉm verificar se o ano atual รฉ BISSEXTO atravรฉs da data do computador.''' from datetime import datetime ano = int(input('Informe o ano para verificar-mos se o mesmo รฉ Bissexto, ou digite 0 para pegar o ano corrente: ')) now = datetime.now() ano_ver...
c400bc64bb7f8f398c2dda28cc8a96d513fb8f21
Shelf0/Python-Challenge
/PyPoll/main.py
1,769
4.09375
4
#import dependencies import csv #import CSV csv_filepath = './Resources/election_data.csv' #setting Variables candidate_dictionary = {} total_votes = 0 max_popular_votes = 0 winner = "" # Open & Use CSV with open(csv_filepath) as csvfile: reader = csv.reader(csvfile) next(reader) for row in reader: ...
925727c8273f5f8fef5c45b0e1fd1d1f1f028850
astrebeck/Data-Structures
/linked_list/linked_list.py
1,521
3.515625
4
""" Class that represents a single linked list node that holds a single value and a reference to the next node in the list """ from numpy import inf class Node: def __init__(self, value=None, next_node=None): self.value = value self.next_node = next_node def get_value(self): return self.value def g...
395179488096c065ca1906c05a5d039409d3effe
sankeerthankam/Code
/Coderbat/1. Warmup - 1/4. Diff21.py
213
3.84375
4
# Given an int n, return the absolute difference between n and 21, except return double the absolute difference # if n is over 21. def diff21(n): if n > 21: return 2*abs(21-n) else: return abs(21-n)
e262c2b05fedf742dd45ded72bba1e19f2bac02c
siddharthadtt1/Leet
/IC/26-reverse-string.py
269
3.953125
4
def reverse(string): if len(string) <= 1: return string char_list = list(string) l, r = 0, len(char_list) - 1 print l, r while l < r: char_list[l], char_list[r] = char_list[r], char_list[l] l += 1 r -= 1 return ''.join(char_list) print reverse('abcd')
ce134fcfd37173edff21ebecd289fca163807a5d
VitaliiRomaniukKS/python_course
/Lesson 3/lesson03_hw06_2.py
143
3.8125
4
my_string= list(input ('ะ’ะฒะตะดะธั‚ะต ัั‚ั€ะพะบัƒ ')) my_string.reverse() print('ะŸะตั€ะตะฒะตั€ะฝัƒั‚ะฐั ัั‚ั€ะพะบะฐ:', ''.join(my_string))
875a2b8755015b8ca97c3364f37783ff97759a1e
Viktor-stefanov/Vigenere-cipher-hacking-tool
/python/vigenere_cipher.py
3,481
4.6875
5
from string import ascii_uppercase as LETTERS from random import randint import argparse def convert(operation, string, key, randomized): ''' function to convert a string into cipher text or cipher text into a string. Operation decision is based on the operation(e=encryption, d=decryption) ''' ...
3678c826c8c66c2acfa14d167753cd1905a5a048
LokIIE/AdventOfCode2020
/Day3/firstStar.py
288
3.515625
4
inputFile = open("input.txt", "r") grid = [] currColumn = 0 countTrees = 0 for line in inputFile: if line[currColumn] == "#": countTrees += 1 currColumn += 3 if currColumn >= (len(line) - 1): currColumn = currColumn % (len(line) - 1) print(countTrees)
c73e800648f7489efce87e386bba29793036f7cd
jedzej/tietopythontraining-basic
/students/arkadiusz_kasprzyk/lesson_06_dicts/distinct_words.py
239
3.96875
4
# distinct_words.py N = int(input("Number of lines: ")) words = set() for n in range(N): line = input("line {}: ".format(n + 1)) words |= set(line.split()) print(words) print("{} distinct words in given text.".format(len(words)))
f7ff02ec86061151a5651d7c61113f4a9669938f
kex243/print_numbers_over_image
/marker.py
1,974
3.78125
4
import os import csv import random print ("Enter first number to print:") first_number = int(input()) print ("Enter last number to print:") last_number = int(input()) print ("Font size:") font_size = int(input()) print ("Font: default will be 'arial', test any other that your system supports. Use '-' for two...
3db22a009a585c9956545822f92d787a0cd024cc
yun63/lighting-python
/base/lt_sort.py
728
3.625
4
# -*- coding:utf-8 -*- #################################################################################### # # Copyright ยฉ 2017 TU. All Rights Reserved. # #################################################################################### """ @File: lt_sort.py @Description: @Author: leiyunfei(leiyunfei@tuyoogame...
f27eb8776601c611ad8de0b9db5d11da97291a61
gorasu/netology_python
/task-6/main.py
1,635
3.59375
4
def clean_string(string): return string.strip() def recipe_format(recipe_list): result = dict() recipe_name = recipe_list.pop(0) recipe_ingridient_count = recipe_list.pop(0) result[recipe_name] = list() ingredient_list = list() for ingredient in recipe_list: ingredient = ingredient...
58d9b58c9a61f318c07ee0bc4e953771fd060509
msarefin/mypy
/list.py
1,613
4.375
4
# Dictionary is noting but a key value pair # A dictionary is a collection of unordered, changable and indexed di = {} # print(type(di)) d2 = {"Harry":"Burger","Arshad":"Fish","Ankur":"Cheese","Nasir":"cars","Syed":"Watches","Jimmy":"Perfume","Kathlyn":"Jewelry","Jennifer":{"A":"Flowers","B":"Burgers","C":"Cake","D":...
2621ab25c4c7670c16b7cfa6013a5ef1499635a2
mleers/Python-practice
/birthday_dict_json.py
800
4.25
4
import json birthday = {} with open("birthday_list.json", "r") as f: #json file made externally in python birthday = json.load(f) print("Welcome to the birthday selector. Birthdays of the following people are known: ") for x in birthday: print(x) choice= input("Who's birthday do you want to look up?").title() ...
59ed5682f45886ce5d3601e6fa4022face473bfa
eirihoyh/INF200-2019-Exercises
/src/eirik_hรธyheim_ex/ex_02/file_stats.py
605
4
4
def char_counts(textfilename): """Takes in a file and counts number of times a character is used""" file_opener = open(textfilename).read() liste = [0] * 256 for character in file_opener: i = ord(character) liste[i] += 1 return liste if __name__ == "__main__": filename = "fil...
e36d0df1605f7f133bf3cad71ffcf648ccd623c5
keiwachiri/iris
/iris/utils.py
809
3.5
4
""" This module contains the utility functions used internally in Iris. FUNCTIONS: is_valid_address(host, port) """ import ipaddress import socket def is_valid_address(host, port): """ Responsible for checking whether the given host port pair is valid. Host can be given either as an ip addr...
d7d5bd0bb992ed0e515f8115e808d1775ea8fb35
CurtCalledBurt/DS-Unit-3-Sprint-1-Software-Engineering
/acme.py
2,228
3.890625
4
""" ACME class to describe products that ACME makes """ import random class Product: """ An Acme product class """ def __init__( self, name: str, price: int=10, weight: int=20, flammability: float=0.5, identifier: int=random.randint(1_000_000, 9_999...
4d946095d041dd2b5dc52a36403aabf0222e7f8e
pratik7368patil/Coding-Questions
/HackerRank_Problems/generate_all_prime.py
505
4.03125
4
## generate all prime numbers upto N using Sieve if Eratosthenes def allPrime(n): if n == 1 or n == 0: print(None) sieve = [True] * (n+1) ## generate list upto N+1 and consider all as prime for p in range(2, n + 1): if (sieve[p]): print(p) for i in range(p, n+1, p): ##...
bf3e146851d1eb00cbb9ca2e1c0a781a83aac547
heiligbasil/Sprint-Challenge--Data-Structures-Python
/names/bst_tutorial.py
1,390
4.15625
4
# https://www.tutorialspoint.com/python_data_structure/python_binary_search_tree.htm class B_S_T: def __init__(self, data): self.left = None self.right = None self.data = data # Insert method to create nodes def insert(self, data): if self.data: if data < self.da...
7a2059f46badf6336431174dcb3e3d7685a21f06
amitsaxena9225/XPATH
/Pycharm/loop.py
305
3.828125
4
#for and while: #for i in range(0,15): # print (i) #for i in "pravin": #print (i) '''for i in [1,2,3,4,5]: print (i) ''' '''for i in {1:2,4:5,8:9}.values(): print (i) ''' #while a = 9 while a >=10: print (a) a = a-1 else: print ("please enter correct value")
de1143d9e1a9c842192c2cd60c427f1764565b65
pinstinct/wps-basic
/day6/calculator_decorator.py
934
3.515625
4
def print_args(func): def inner_func(*args, **kwargs): print('args : {}'.format(args)) result = func(*args, **kwargs) return result return inner_func def decorate_test(func): def inner_func(*args, **kwargs): print('test_inner_func') return func(*args, **kwargs) r...
b0bf64120dd8d498f7135c2a2fd599c73d16fd94
Nikkuniku/AtcoderProgramming
/ABC/ABC100~ABC199/ABC190/d.py
418
3.5
4
def make_divisors(n): lower_divisors , upper_divisors = [], [] i = 1 while i*i <= n: if n % i == 0: lower_divisors.append(i) if i != n // i: upper_divisors.append(n//i) i += 1 return lower_divisors + upper_divisors[::-1] n=int(input()) p=make_divi...
5cbe8365da27d7dc3865f800024860ed795e7cbe
NahLima/EstruturaSequencial
/ExerciciosListas/4-consoantes.py
719
3.90625
4
#Faรงa um Programa que leia um vetor de 10 caracteres, e diga quantas consoantes foram lidas. # Imprima as consoantes. listaInput = [] consoantes = 0 vogal = 0 print ('Informe os caracters') for i in range(10): lista = input('Coloque as letras aqui: ') listaInput.append(lista) characters = listaInput[i] ...
e76dd6180d0da4462a71bd22e58bfe201fe60410
icebourg/2020advent
/day_06/solve.py
1,521
3.703125
4
def parse_answers(file_name): answers = [] with open(file_name) as input: answer = [] for l in input: line = l.strip() answer.append(line) # this is a blank line, then the previous lines are part of a single group if line == "": a...
135987259a167cbdd92b22062bf6ac2a03967461
JacoKritzinger/SQL
/2. python refresher/startwith.py
336
3.796875
4
numbers = [1, 3, 5] doubled = [] for num in numbers : doubled.append(num * 2) friends = ['Bob', 'Rolf', 'Jen', 'Anne', 'Samantha', 'Sam', 'sharah'] starts_s = [friend for friend in friends if friend.startwith('S')] print(friends) print(starts_s) print(friends is starts_s) print('friends: ', id(friends), 'starts_s:...
bf5be10c4a44bc30958a7f85b2ed822af690bc14
lucky-verma/Journey-to-CP-Grandmaster
/DS & Algo/Coursera/ALGO TOOLBOX/week3_greedy_algorithms/7_maximum_salary/largest_number.py
501
3.984375
4
# Uses python3 import sys def largest_number(data): # write your code here n = len(data) for i in range(n - 1): for i in range(n - 1 - i): if data[i] + data[i + 1] < data[i + 1] + data[i]: data[i], data[i + 1] = data[i + 1], data[i] return data if __name__ == '__...
2c18e902df48818d638dfdcb69405075865a18e2
leosanchezsoler/bridge_datascience_JorgeGarcia
/week3_course_python_III/day2_python_VIII/exercises/classes_import/objects/ClaseHumano.py
868
3.765625
4
class Humano: def __init__(self, nombre, armadura, nivel, ataque, salud=100, ojos=2, piernas=2, dientes=32): self.nombre = nombre self.armadura = armadura self.nivel = nivel self.ataque = ataque self.salud = salud self.ojos = ojos self.piernas = piernas ...
e7ba8fa9b11a437351f76aca5faf61f5c11a0d10
DAMoskalev/lesson1
/answers.py
274
3.546875
4
def get_answer(question): try: print(answers[question.lower()]) except (KeyError): print("ะะตั‚") answers = {"ะฟั€ะธะฒะตั‚": "ะ˜ ั‚ะตะฑะต ะฟั€ะธะฒะตั‚!", "ะบะฐะบ ะดะตะปะฐ": "ะ›ัƒั‡ัˆะต ะฒัะตั…", "ะฟะพะบะฐ": "ะฃะฒะธะดะธะผัั"} get_answer(input())
52ae973cca8d6df1d48b7eda600940534cb3d343
HWALIMLEE/study
/review/keras21_ensemble1.py
2,457
3.71875
4
#1. ๋ฐ์ดํ„ฐ ๊ตฌ์„ฑ import numpy as np from numpy import shape x1=np.array([range(1,101),range(311,411),range(100)]) x2=np.array([range(501,601),range(111,211),range(100)]) y1=np.array([range(301,401),range(511,611),range(101,201)]) y2=np.array([range(101,201),range(411,511),range(811,911)]) #transpose x1=np.transpose(x1) x2=n...
b4dfb3c16249a7fea93230d3d79bf3704f5356e8
ejonakodra/holbertonschool-machine_learning-1
/math/0x00-linear_algebra/100-slice_like_a_ninja.py
414
3.921875
4
#!/usr/bin/env python3 """ defines function that slices a matrix along specific axes using numpy """ def np_slice(matrix, axes={}): """ returns numpy.ndarray, the slice of a matrix along specific axes """ dimensions = len(matrix.shape) slices_matrix = dimensions * [slice(None)] for axis, value in axes...
5237824145848bffdeeed8eb4339a1f39a7cdd23
DJRumble/PHD
/Analysis/KS-test.py
1,734
3.703125
4
""" this script runs the Kolmogorov-Smirnov test for one and two data sets""" import numpy as np ##################################################### #TWO #This function calculates the KS-test for two unique distributions. def two(data1,data2): """Inputs: Data set 1, data set 2. Returns K-S statistic 'D' and ...
327446b735da3a812134a77a2e61aceb6f9c545b
rmodi6/scripts
/practice/Hackerrank/electronics_shop.py
1,212
4.03125
4
#!/bin/python3 # https://www.hackerrank.com/challenges/electronics-shop/problem import os import sys # # Complete the getMoneySpent function below. # def getMoneySpent(keyboards, drives, b): # # Write your code here. # answer = -1 keyboards = sorted(keyboards) drives = sorted(drives) point...
a8e2e801db310b7e42bbc535c33579bafa31b741
alauda-zz/Python-Crash-Course
/Ch9-Classes/ClassCar.py
2,538
4.40625
4
class Car(): """A simple attempt to represent a car""" def __init__(self, make, model, year): self.make = make self.model = model self.year = year self.odometer_reading = 0 def get_descriptive_name(self): long_name = str(self.year) + " " + self.make + " " + self.mode...
b2eb2a8e1511d7e389c3c0997c2a2d067f7db9c7
sandrakorcz/PYTHON
/PYTHONv2/zadanie22.py
94
3.671875
4
x=input("Podaj coล›: ") lista=x.split(" ") print(lista) for i in lista: print(i)
613020588978bb79a28b6818206aac16cf33e1c8
gavrie/pycourse2019-07
/exercises/test_cities_03_exercise.py
1,196
3.53125
4
def get_fields(line): fields_quoted = line.strip().split(",") fields = [f.strip('"') for f in fields_quoted] return fields def get_cities(filename): csv_file = open(filename) _header = next(csv_file) cities = [] for line in csv_file: city = get_fields(line) cities.append(...
04e08d1679823face97bd547dd7ad3b91823601c
biancaoprisa/password-manager
/main.py
2,867
3.71875
4
from tkinter import * from tkinter import messagebox import random # ---------------------------- PASSWORD GENERATOR ------------------------------- # def generate_password(): letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'...
0f6b428c97cfda5acc0196504a26330b8a31c7f3
raizo07/backend_class_2021
/module_2/intro/password.py
251
3.9375
4
# Handling incorrect passwords scenario with loops correct_password = "Gabriel" password = input("Type in your password: ") while password != correct_password: password = input("Wrong password. TRY AGAIN: ") print("SUCCESSFULLY LOGGED IN")
ed85ec60c77c20407230cb942641ecb5f0c5b865
GeorgiIvanovPXL/Python_Oplossingen
/IT-Essentials/Hfst6/oefening6.7.py
417
3.640625
4
import random def encrypteer(tekst, random_getal): gรซencrypteerd = "" for letter in tekst: gรซencrypteerd += chr(ord(letter) + random_getal) return gรซencrypteerd def main(): tekst = input("Geef een tekst in: ") getal = random.randint(2, 24) while getal % 2 != 0: getal = rando...
f4c5f5fc3fec881bea6bb7df2398e9222679a15b
Dieterdemuynck/Informatica5
/Kerstvertier/Number walks.py
372
3.828125
4
from math import sin, cos, radians getal = input("Geef een getal: ") x_coor = 0 y_coor = 0 for number in getal: if number != ".": y_walk = sin(radians(int(number) * -36 + 90)) x_walk = cos(radians(int(number) * -36 + 90)) x_coor += x_walk y_coor += y_walk print("Number {} walks to positi...
b94eada435532907f459d06f6c6afe1faa217182
RamiJaloudi/Python-Scripts
/Math Input/math_input_1.py
832
4.03125
4
# Exercise using Luhn's Algorithim # x=int(input("Enter Your Fictitious Code?")) # Still need to test. Consider this for creating 3 level authentication protocol. def luhn_checksum(card_number): def digits_of(n): return [int(d) for d in str(n)] digits = digits_of(card_number) odd_digits = digits[-...
9b0a3af6eadce1ed46accc6db02b0023886f3d8e
LiliMeng/Algorithms
/ContainerWithMostWater.py
1,132
3.609375
4
# -*- coding: utf-8 -*- """ Spyder Editor This is a temporary script file. """ #Brute-force O(n^2) class Solution1(object): def maxArea(self, height): """ :type height: List[int] :rtype: int """ length = len(height) res = 0 for i in range(length): ...
df7e7f703772db858153b154130281199754fba7
partho-maple/coding-interview-gym
/leetcode.com/python/7_Reverse_Integer.py
968
3.546875
4
class Solution(object): def reverse(self, x): """ :type x: int :rtype: int """ if x >= 2 ** 31 - 1 or x <= -2 ** 31: return 0 reverseStr = '' isPositive = True if x < 0: x = x * (-1) isPositive = False elif x == 0: ...
3b3c788325ae28c4ea7b9ac2567e804bcc07f534
KKosukeee/CodingQuestions
/LeetCode/283_move_zeroes.py
871
3.953125
4
""" Solution for 283. Move Zeroes https://leetcode.com/problems/move-zeroes/ """ class Solution: """ Runtime: 52 ms, faster than 52.07% of Python3 online submissions for Move Zeroes. Memory Usage: 14.6 MB, less than 12.19% of Python3 online submissions for Move Zeroes. """ def moveZeroes(self, nums...
652adae068c1d4c067fccb99c9a08eb399f80676
zuzux3/Algorytmy-i-struktury-danych
/LAB13/Decimal_To_Binary_and_Hexadecimal.py
271
3.609375
4
from BinHex import DecToBin, DecToHex decimal = int (input ('Podaj liczbe dziesietna: ')) str_end1 = "Liczba {} w systemie binarnym to:" str_end2 = ",\na w systemie szesnastkowym to: " print(str_end1.format(decimal)) DecToBin(decimal) print(str_end2) DecToHex(decimal)
3d7b8d6a1de4cb751defb2b04acb377cd14bc421
ChocolaterToba/Checkio
/Repeating Decimals.py
1,023
3.953125
4
def convert(numerator, denominator): result = str(numerator // denominator) + '.' remainders = [numerator % denominator] while 0 not in remainders: numerator = numerator % denominator * 10 result += str(numerator // denominator) if numerator % denominator in remainders: i...
ea3a7f921493077bfb862e279f4c01704030e23f
ai-kmu/etc
/algorithm/2020/1201_Flatten_Nested_List_Iterator/youngjun.py
861
3.671875
4
class NestedIterator: def __init__(self, nestedList: [NestedInteger]): def generateNestedList(nestedList): #nestedList ์ž…๋ ฅ๋ฐ›์•„์„œ ์žฌ๊ท€ ํ˜•ํƒœ๋กœ ์›์†Œ ์ €์žฅ ans=[] for element in nestedList: if element.isInteger(): # ๊ทธ๋ƒฅ ์ˆซ์ž๋ผ๋ฉด ans.append(element.g...
24b3b222e37da45f5dbc1e77b3c817294318750d
BatchuDeepthi/PythonLearning
/Turtle-Race/Etch-a-Sketch-App.py
556
3.578125
4
import turtle as t tim = t.Turtle() screen = t.Screen() def mov_fwd(): tim.forward(10) def mov_bckwd(): tim.backward(10) def turn_left(): current_heading = tim.heading()+10 tim.setheading(current_heading) def turn_right(): current_heading = tim.heading()-10 tim.setheading(current_he...
e1be744f8ba312ff652e21beb8c88f5113fb87b1
rohitjoshi6/FDS_Programs
/Sorting_algo/Insertion_Sort.py
353
4.125
4
def insertionSort(arr): for i in range(1,len(arr)): currentvalue = arr[i] position = i while position>0 and arr[position-1]>currentvalue: arr[position]=arr[position-1] position = position-1 #print(arr) arr[position]=currentvalue arr = list(map(int,input().split(" ")...
62fcae6fc6cff5596a7e00ec0d5a9bac8d8e0336
EduardoGonzalezJr/MATH4330
/basicFunctions.py
8,348
4.125
4
import copy #works def two_norm(vector): """ Computes the two norm of a vector This function sums the squares of the elements of the vector, then takes the square root of the sum Args: vector: a list of numbers as a vector Returns: A scalar which is the 2-norm of the given vector...
f31b31d14b8dcf41319a1dfe51f40be5053d0911
zbarton88/Python-Physics-Euler-Problems
/Euler 19.py
250
3.609375
4
from datetime import date def problem19(): n = 0 for i in range(1901,2001): for j in range(1,13): day = date(i,j,1).weekday() if day == 6: n += 1 print (n) problem19()
ac1864400a6e20238abc5f7141c5cdc923ad4051
alcebytes/Phyton-Estudo
/Prandiano_Python I/04_estruturas_de_repeticao/bono.py
544
3.921875
4
""" Problema: em um sorteio de 2 nรบmeros aleatรณrios, qual a mรฉdia dos pontos? """ from random import * from numpy import * num_de_pontos = int(input("Digitar o nรบmero de pares de pontos aleatรณrios que deverรฃo ser gerados: ")) print("n / " + "x(1) | " + "y(1) | " + "x(2) | " + "y(2) | " + "Distรขncia") n = 0 distancia ...
c437f4519327d4ea0da9852f26ba34d213b56e68
wuhengliangliang/python
/ๆ‰พๆ•ฐๅญ—.py
505
3.734375
4
import time num_list=['1','3','5','7','9','10'] def find_num(num_list): print('-'*60) if len(num_list)==0: return "ๆฒกๆ‰พๅˆฐ" new_num=num_list.pop(0) if new_num=='10': return '%sๅทฒๆ‰พๅˆฐ'%new_num print('[%s]ไฝ ็Ÿฅ้“ๅœจๅ“ชๅ—๏ผŸ'%new_num) print("%s,ไธ็Ÿฅ้“๏ผŒๆˆ‘ๆ‰พๆ‰พ%s"%(new_num,num_list)) time.sleep(3) res...
168375bb202a263c15bfa9a1077fbe01902cc8c3
alisure-ml/python-study
/temp/study_thread/my_thread.py
1,743
3.5625
4
import threading from time import ctime, sleep def music(func): for i in range(2): print(func, ctime()) sleep(4) pass def move(func): for i in range(2): print(func, ctime()) sleep(5) pass if __name__ == "__main__": # ็บฟ็จ‹list threads = [] # ๅ‚ๆ•ฐdaemon : ...
6a2a402a8382d5ba109677bae58778ac42aa0444
ultrasuper/LearnPython
/playground/binary_search.py
588
3.859375
4
# -*- coding:utf-8 -*- from random import randint def binary_search(l:list, target:int) -> int: # return the index of the target number if len(l) == 0: return None low = 0 high = len(l) - 1 while low <= high: mid = int((low+high)/2) if target > l[mid]: low = mid elif target < l[mid]: high = mid el...
e302e3e51a2e5a3bfadd7504f1ee128bde31619b
younkyounghwan/python
/baekjoon_2556.py
207
3.984375
4
x = int(input()) if x == 1: print("*") elif x== 2: print("**") print("**") else: for i in range(0,x): for j in range(0,x): print("*",end="") print("")
efb8d2bb1fd8469a890aceaa756721e43b8e6656
yeonjudkwl/Algorithm
/swea/Union_๊ทธ๋ฃน๋‚˜๋ˆ„๊ธฐ.py
1,099
3.75
4
# ๊ฐ ํ•˜๋‚˜์˜ ์ง‘ํ•ฉ ๋งŒ๋“ค๊ธฐ def make_set(x): p[x] = x # ๋Œ€ํ‘œ์ž ์ฐพ๊ธฐ def find_set(x): if p[x] == x : return x else: return find_set(p[x]) # ๋‘ ์ง‘ํ•ฉ ํ•ฉ์น˜๊ธฐ(์—ฌ๊ธฐ์„œ ๋Œ€ํ‘œ์ž๋Š” x) def union(x,y): px = find_set(x) py = find_set(y) if rank[px] > rank[py]: p[py] = px else: p[px] = py if rank[px] == rank[py...