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
56a61400c185d2b677c984d5d480e7bdddc17ec0
ottotexschang96/Login-with-Password-Setting
/20210326Chapter3LoginwithPasswordSetting.py
391
3.953125
4
# Login with Password Setting i = 0 while i < 3: password = input('Please input password:') if password == 'a123456': print('Successful login') break elif password != 'a123456': print('Wrong password') if 2-i > 0: print('and you still have remaining chance(s):', 2-i) else: print('Your account has b...
92aca135af4da75cb0cd32b9bfac71515384e04d
hakanguner67/class2-functions-week04
/exact_divisor.py
376
4.125
4
''' Write a function that finds the exact divisors of a given number. For example: function call : exact_divisor(12) output : 1,2,3,4,6,12 ''' #users number number = int(input("Enter a number : ")) def exact_divisor(number) : i = 1 while i <= number : # while True if ((number % i )==0) : ...
89aa00e1cd5480b1e976fe94a3bbd044f8f671de
hakanguner67/class2-functions-week04
/counter.py
590
4.21875
4
''' Write a function that takes an input from user and than gives the number of upper case letters and smaller case letters of it. For example : function call: counter("asdASD") output: smaller letter : 3 upper letter : 3 ''' def string_test(s): upper_list=[] smaller_list=[] for i in s: if i....
6e94f15c2c7d358cccbbc52a8cb6e10fa2fb4b23
dpew/advent2017
/2017/day13/day13p2-brute.py
2,592
3.546875
4
#!/usr/bin/env python import sys import pprint import re class Layer(object): def __init__(self, name, depth): self.name = name self.depth = int(depth) self.position = 0 self.direction = 1 def iterate(self): ''' >>> l = Layer(0, 3) >>> l.iterate...
2447be15084e1fd907a18e81c26ed3a864dcb4d3
dpew/advent2017
/2017/day14/day14.py
4,675
3.5625
4
#!/usr/bin/env python import sys def rotate(lst, count): ''' >>> rotate([0, 1, 2, 3, 4], 3) [3, 4, 0, 1, 2] >>> rotate([0, 1, 2, 3, 4], 0) [0, 1, 2, 3, 4] >>> rotate([0, 1, 2, 3, 4], -3) [2, 3, 4, 0, 1] >>> rotate([0, 1, 2, 3, 4], 5) [0, 1, 2, 3, 4] ...
ebd015860a3051d40b0bc1b7f43c9938e4fb354b
ddvalim/TrabalhoI-ED
/Fila.py
2,760
3.8125
4
from Elemento import Elemento class Fila: def __init__(self, limite:int): self.__limite = limite self.__fim = None self.__inicio = None self.__numero_de_elementos = 0 def get_inicio(self): return self.__inicio def get_fim(self): return ...
2842fcc1c1a4c7ebd6bf69f7fc736a91e757f019
danicon/MD2-Curso_Python
/Aula13/ex10.py
249
3.765625
4
print(20*'=') print('10 TERMOS DE UMA PA') print(20*'=') prim = int(input('Primeiro termo: ')) razao = int(input('Razão: ')) decimo = prim + (10 - 1) * razao for p in range(prim, decimo + razao, razao): print(p,end = ' \032 ') print('ACABOU')
4b80822b081642692f6d48f2354f1dc4f0aeb784
danicon/MD2-Curso_Python
/Aula12/ex05.py
290
3.96875
4
num1 = float(input('Digite a primeira nota: ')) num2 = float(input('Digite a segunda nota: ')) media = (num1 + num2) / 2 print(f'Sua média foi de {media:.1f}') if media < 5: print('REPROVADO!') elif media >= 5 and media <= 6.9: print('RECUPERAÇÃO!') else: print('APROVADO!')
b21508fdbec9795884be2b668a436c51b68d8183
danicon/MD2-Curso_Python
/Aula14ex/ex08.py
447
3.9375
4
c = 'S' soma = 0 cont = 0 maior = 0 menor = 0 while c == 'S': num = int(input('Digite um número: ')) soma += num if cont == 0: maior = num menor = num else: if num > maior: maior = num if num < menor: menor = num c = str(input('Deseja continua...
6af41e3ebf12ac657bf8383115e63be162a1282e
danicon/MD2-Curso_Python
/Aula12/ex01.py
435
3.875
4
casa = float(input('Qual é o valor da casa? R$')) salario = float(input('Qual é o seu salário? R$')) anos = float(input('Em quanto você vai pagar a casa? ')) emprestimo = casa / (anos * 12) parcela = (salario * 30) / 100 if emprestimo > parcela: print(f'Infelizmente o emprestimo de R${emprestimo:.2f} excedeu os 30...
3bee3ad2a12712f8426b3eb36fd113063f439327
jbial/convolution
/visualization.py
3,081
3.53125
4
"""Utilities for visualizing convolution outputs """ import numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation def visualize_conv1d_gif(f, g, response, filepath): """Plots gif of convolution output over each timestep WARNING: This function can be very taxing on your computer...
595ed60c0537d7fa84b5cb63572bd781acbc5dd1
vishaljudoka/python_learning
/Datatypes/Range.py
285
4.03125
4
#Range sequence representing an arthmetic progression of integar """ range(5) #stop range(1,5) #start ,Stop range(1,10,2) #start stop step """ for i in range(1,10,2): print(i) ###Enumerate (Index and value) a=[3,4,5,8,'a'] for i,v in enumerate(a) : print (f' i={i}, v={v}')
c9b09cff1cd7dd62be942f65b16582ba1fb1fe34
DYEkanayake/CO324
/Lab01/ex3.py
1,081
3.828125
4
from ex1 import * def load_course_registrations_dict(filename: str) -> List[Student]: #Dictionary of Student Objects studentDetails=dict() #To keep the read data of the line being read details=[] with open(filename) as f: for line in f: details= line.st...
7d2426812e648d9541c3b3a5c8b970539769d3ba
elf-deedlit/wxCalender
/ds/_Struct.py
1,699
3.65625
4
#!/usr/bin/python # vim:set fileencoding=utf-8: # # python で 構造体みたいなやつ # __all__ = ['Struct'] class Struct(): def __init__(self, *items, **attrs): for item in items: assert instance(item, (tuple, list)) assert len(item) == 2 name, value = item self.__dict__...
38ed49911be4adb634aa662aed898a56c244c5ac
mariadiaz-lpsr/class-samples
/5-4WritingHTML/primeListerTemplate.py
944
4.125
4
# returns True if myNum is prime # returns False is myNum is composite def isPrime(x, myNum): # here is where it will have a certain range from 2 to 100000 y = range(2,int(x)) # subtract each first to 2 primenum = x - 2 count = 0 for prime in y: # the number that was divided will then be divided to find rema...
120526d1004799d849367a701f6fa9c09c6bbe05
mariadiaz-lpsr/class-samples
/quest.py
1,314
4.15625
4
print("Welcome to Maria's Quest!!") print("Enter the name of your character:") character = raw_input() print("Enter Strength (1-10):") strength = int(input()) print("Enter Health (1-10):") health = int(input()) print("Enter Luck (1-10):") luck = int(input()) if strength + health + luck > 15: print("You have give ...
7251ebc79e8c4968588276efb33d05320b032750
mariadiaz-lpsr/class-samples
/names.py
1,010
4.3125
4
# it first prints the first line print("These are the 5 friends and family I spend the most time with: ") # these are the 2 list name names and nams names = ['Jen', 'Mom', 'Dad', 'Alma', 'Ramon'] nams = ['Jackelyn', 'Judy', 'Elyssa', 'Christina', 'Cristian'] # it is concatenating both of the lists names_nams = names...
a902676d106ef956530f77d114a30d5cd1f0dc58
mariadiaz-lpsr/class-samples
/guess.py
313
4.0625
4
import random guessnumber = random.randint(1, 5) print("I'm thinking of a number between 1 and 5. Enter your guess!") guess = input() if guess < guessnumber: print("Nope, too low! Guess again.") if guess > guessnumber: print("Nope, to high! Guess again.") if guess == guessnumber: print("Hooray, you won!")
434182c9ca2fa8b73c4f2fd0b4d9197720b7d406
pktippa/hr-python
/basic-data-types/second_largest_number.py
430
4.21875
4
# Finding the second largest number in a list. if __name__ == '__main__': n = int(input()) arr = list(map(int, input().split())) # Converting input string into list by map and list() new = [x for x in arr if x != max(arr)] # Using list compressions building new list removing the highest number print(max...
3c09d0c67801c8748794d163a275a6c6f5b88378
pktippa/hr-python
/itertools/permutations.py
678
4.15625
4
# Importing permutations from itertools. from itertools import permutations # Taking the input split by space into two variables. string, count = input().split() # As per requirement the given input is all capital letters and the permutations # need to be in lexicographic order. Since all capital letters we can directl...
542da4b047a76fd24855bdacfd14749bb9a2b56a
pktippa/hr-python
/strings/whats_your_name.py
261
3.90625
4
def print_full_name(a, b): print("Hello " + a + " " + b + "! You just delved into python.") # Using + operator for concatinating strings. if __name__ == '__main__': first_name = input() last_name = input() print_full_name(first_name, last_name)
0ff7d34d4052847acf9a11bf0e2017578ea13e57
pktippa/hr-python
/sets/check_subset.py
267
3.71875
4
for i in range(int(input())): a = int(input()); A = set(input().split()) b = int(input()); B = set(input().split()) # Or we can also use A.issubset(B) function directly if A.intersection(B) == A: print("True") else: print("False")
67d7f68e4f22f559371da94cf0ea0be9e8051132
pktippa/hr-python
/basic-data-types/lists.py
1,208
4.03125
4
list_to_handle=[] input_list=[] def do_insert(given_list): global list_to_handle list_to_handle.insert(int(given_list[1]), int(given_list[2])) def print_list(given_list): global list_to_handle print(list_to_handle) def remove_element(given_list): global list_to_handle list_to_handle.remove(int...
fc8492aca1595ba8df424f489c563b8c932edbde
pktippa/hr-python
/itertools/iterables_and_iterators.py
932
3.875
4
# Importing combinations from itertools from itertools import combinations # trash input not used in the code anywhere trash_int = input() # Taking input string split and get the list input_list = input().split() # Indices count indices = int(input()) # first way # Get the combinations, convert to list combination_lis...
e03cc807d94143ba7377b192d5784cbdb07b1abd
pktippa/hr-python
/math/find_angle_mbc.py
376
4.34375
4
# importing math import math # Reading AB a = int(input()) # Reading BC b = int(input()) # angle MBC is equal to angle BCA # so tan(o) = opp side / adjacent side t = a/b # calculating inverse gives the value in radians. t = math.atan(t) # converting radians into degrees t = math.degrees(t) # Rounding to 0 decimals and ...
bed0fc094ed0b826db808aa4449cbf31686cbd2a
aryakk04/python-training
/functions/dict.py
549
4.53125
5
def char_dict (string): """ Prints the dictionary which has the count of each character occurrence in the passed string argument Args: String: It sould be a string from which character occurrence will be counted. Returns: Returns dictionary having count of each character in ...
73ca8208af36edbc825de7e4579c8eb15ef1fcd6
habahut/GrocerySpy
/Source/ingredientParserBAK.py
12,462
3.75
4
#! /usr/bin/env python from ingredient import Ingredient ## these follow this form: # <num> |unit| {name} (, modifer) # so we split by " ". Then we check each thing for a comma. # if there is a comma, we now know where the modifier is. ## for now we are going to assume everything is of the form above ## i.e. t...
8f4737c5028b5237c809d24ee24fd3280d466d46
SamuelSebastianMartin/folder_tree_ac_eng
/make_google_folders.py
3,087
3.8125
4
#! /usr/bin/env python3 """ This may be a one-off program, depending on changes made to registers. It reads a SOAS Google Docs register (2019-20) into a pandas dataframe and creates folders necessary for all academic English student work. Student work/ | |___ SURNAME Firstname/ | | | ...
149b7cdf5c74d2bc96c2249ad192000659303926
edmartins-br/PythonTraining
/general.py
4,281
4.0625
4
#! /usr/bin/python3 #Fiibonacci a,b = 0, 1 for i in range(0, 10): print(a) a, b = b, a + b # ---------------------------------------------------------------- # FIBONACCI GENERATOR def fib(num): a,b = 0, 1 for i in range(0, num): yield "{}: {}".format(i+1, a) a, b = b, a + b for item ...
2d87b86197a7790b8596ee19e8099661d2a89536
ZinoKader/X-Pilot-AI
/pathfinding/navigator.py
2,045
3.6875
4
import math import helpfunctions class Navigator: def __init__(self, ai, maphandler): self.ai = ai self.pathlist = [] self.maphandler = maphandler def navigation_finished(self, coordinates): targetX = int(coordinates[0]) targetY = int(coordinates[1]) selfX =...
2bc03bbfed056ccd044b253e6e1430c59215d59a
ZinoKader/X-Pilot-AI
/excercises/exc3.py
5,294
3.5625
4
# # This file can be used as a starting point for the bot in exercise 1 # import sys import traceback import math import os import libpyAI as ai from optparse import OptionParser # # Create global variables that persist between ticks. # tickCount = 0 mode = "wait" targetId = -1 def tick(): # # The API won'...
8e18bf9cc041596acb023cd5d68c0933f432f6cd
hitsumabushi845/Cure_Hack
/addSongInfoToDB.py
1,167
3.65625
4
import sqlite3 from createSpotifyConnection import create_spotify_connection def add_songinfo_to_db(): db_filename = 'Spotify_PreCure.db' conn = sqlite3.connect(db_filename) c = conn.cursor() spotify = create_spotify_connection() albumIDs = c.execute('select album_key, name from albums;') s...
9d035da888745f18febd025b110dab7cb6f1f2d7
KarChun0227/PythonQuizz
/Expertrating/Word_sort.py
201
3.984375
4
input_str = input() result = "" word = input_str.split(",") sortedword = sorted(word) for x in sortedword: result = result + "," + x result = result[1:] print(result) # order,hello,would,test
a5bb0c599c2cb8e70b3d60a85932b9fd28b65780
KarChun0227/PythonQuizz
/Exercise/Ex8.py
747
3.953125
4
def winner(P1, P2): if P1 == P2: return 0 elif P1 == "S": if P2 == "R": return 2 else: return 1 elif P1 == "R": if P2 == "S": return 1 else: return 2 elif P1 == "P": if P2 == "S": return 2 ...
7d27fc42523b5ae8e1cb509c38d5538c85d959d5
KarChun0227/PythonQuizz
/Expertrating/exam.py
199
3.890625
4
import string input_str = raw_input() for i in range(1,6): password = input_str[i] if (password)<5: return False if " " in password: return False if "*" or "#" or "+" or "@" in
f4f03e85c8c0d572714451962e539fd4736c18c8
lulzzz/counter-1
/Counter/serv/report_python/reportmg.py
711
3.78125
4
import sqlite3 import re conn = sqlite3.connect('/Users/itlabs/db1.db') cur = conn.cursor() cur.execute(''' DROP TABLE IF EXISTS mega''') cur.execute(''' CREATE TABLE mega (dates TEXT, people TEXT)''') fname = '/tfs/report-MEGA.txt' fh = open(fname) count = 0 for line in fh: if not count % 2: people = ...
bf61860cd0381b0b6eb5563ff529da0b4a07c9bf
PavelErsh/Python-for-pro
/shop.py
896
3.6875
4
from datetime import datetime class Greeter: def __init__(self, name, store): self.name = name self.store = store def _day(self):#tace date return datetime.now().strftime('%A') def _part_of_day(self): current_hour = datetime.now().hour if current_hour < 12:...
766b98ad78790d5cb7436b20afc07ddc1b8fdd0e
Asakura-Hikari/assignment-2-travel-tracker-Asakura-Hikari
/a1_classes.py
4,745
3.65625
4
""" Replace the contents of this module docstring with your own details Name: Chaoyu Sun Date started: 31/july/2020 GitHub URL: https://github.com/JCUS-CP1404/assignment-1-travel-tracker-Asakura-Hikari """ # main() function is to open and save the file. def main(): print("Travel Tracker 1.0 - by Chaoyu Sun") ...
2e0deae0231338db84a2f11cd64994bf82900b33
seanakanbi/SQAT
/SampleTests/Sample/classes/Calculator.py
1,677
4.375
4
import math from decimal import * class Calculator(): """ A special number is any number that is - is between 0 and 100 inclusive and - divisible by two and - divisible by five. @param number @return message (that displays if the number is a special number) """...
af698f93e23c3d8a429b72ecc03bdb272de5d3b5
patrickgaskill/project-euler
/patrick.py
642
3.671875
4
from functools import reduce from operator import mul from math import sqrt def is_prime(n): if n < 2: return False if n == 2: return True if n == 3: return True if n % 2 == 0: return False if n % 3 == 0: return False i = 5 w = 2 while i * i ...
d9de3d0d4860d0ace81217ddf8fa23bd15c47c16
patrickgaskill/project-euler
/7.py
177
3.625
4
from patrick import is_prime N = 10001 primes = [2, 3] i = primes[-1] + 2 while len(primes) < N: if (is_prime(i)): primes.append(i) i += 2 print(primes[-1])
87d068764544cb2670704d56028940a1847bd061
TheUlr1ch/3-
/main3.py
655
3.984375
4
# 1-е задание myList = [1, 2, 3] myNewList = [i * 2 для i в myList] print(myNewList) # 2-е задание myList = [1, 2, 3] myNewList = [i * * 2 для i в myList] print(myNewList) # 3-е задание list = 'Hello world' для i в диапазоне(len(list)): if list[i] == " ": список = список.заменить("w"...
0df98d530f508a752e42a67ad7c6fe0a2608f823
JaiAmoli/Project-97
/project97.py
266
4.21875
4
print("Number Guessing Game") print("guess a number between 1-9") number = int(input("enter your guess: ")) if(number<2): print("your guess was too low") elif(number>2): print("your guess was too high") else: print("CONGRATULATIONS YOU WON!!!")
a71aa0afdb02234d87afe81f5b3b912748e66027
marcusshepp/hackerrank
/python/anagram.py
1,963
3.984375
4
#!/usr/bin/python # -*- coding: ascii -*- """ Your task is to help him find the minimum number of characters of the first string he needs to change to enable him to make it an anagram of the second string. Note: A word x is an anagram of another word y if we can produce y by rearranging the letters of x. Input Fo...
88794e943e08e346af71e6e3e8b398a22c6c4432
marcusshepp/hackerrank
/python/openkattis/ahh.py
177
3.78125
4
jon = raw_input() doc = raw_input() def noh(s): return [a for a in s if a != "h"] jon = noh(jon) doc = noh(doc) if len(jon) >= len(doc): print "go" else: print "no"
956019e0287fed6689e94f291add98e827fc9744
marcusshepp/hackerrank
/python/warmup/chocolate_feast.py
610
3.640625
4
""" Problem Statement: Little Bob loves chocolate, and he goes to a store with $N in his pocket. The price of each chocolate is $C. The store offers a discount: for every M wrappers he gives to the store, he gets one chocolate for free. How many chocolates does Bob get to eat? Input Format: The first line contain...
7b9c3c2cd1a9f753a9f3df2adeb84e846c9eb1b4
mschaldias/programmimg-exercises
/list_merge.py
1,395
4.34375
4
''' Write an immutable function that merges the following inputs into a single list. (Feel free to use the space below or submit a link to your work.) Inputs - Original list of strings - List of strings to be added - List of strings to be removed Return - List shall only contain unique values - Li...
c65d5f051adcb61c0b2b98e304551f4538779177
tethig/oyster_catchers
/oyster_catchers/gaussian_walk.py
1,001
3.65625
4
''' Generalized behavior for random walking, one grid cell at a time. ''' # Import modules import random from mesa import Agent # Agent class class RandomWalker(Agent): ''' Parent class for moving agent. ''' grid = None x = None y = None sigma = 2 def __init__(self, pos, model, sigma...
3df2910d100c84048bee5a5a965580cdea802811
susie9393/spaces
/spaces.py
1,413
3.796875
4
# spaces import numpy as np import random as rn def Spaces(no_rolls): # initialise an array to record number of times each space is landed on freq = np.zeros(14) # s denotes space landed on, 1 <= s <= 14 s = 0 # a counter has been set up to perform a check on total number of ...
6aaf293f5c0eb3ecbeac2a8844eae47189ed22b5
Romannweiler/hu_bp_python_course
/02_introduction/guess_a_number_rm.py
853
3.984375
4
# This is a guess the number game. import random guessesTaken = 0 print('Welcome to my Game') print('I am thinking of a number between 0 and 100!') number = random.randint(0, 100) while guessesTaken < 4: numTries = 3 - guessesTaken numTriesStr = str(numTries) print('you have '+ numTriesStr +' tries') ...
da4f38b16f878727966067fa8da540115169ad66
Nori1117/Recursion-lv.2
/MyLogic.py
1,075
3.890625
4
#Given a number n, write a program to find the sum of the largest prime factors of each of nine consecutive numbers starting from n. #g(n) = f(n) + f(n+1) + f(n+2) + f(n+3) + f(n+4) + f(n+5) + f(n+6) + f(n+7) + f(n+8) #where, g(n) is the sum and f(n) is the largest prime factor of n def find_factors(num): factors = []...
7473ceb49464bcf2268a790243b1dae6c671ec03
zhouxiongaaa/myproject
/my_game/congratulation.py
266
3.71875
4
name = input('你想给谁发祝福:') def cong(name1): a = list(map(lambda x: 'happy birthday to' + (' you' if x % 2 == 0 else ' '+name1+''), range(4))) return a if __name__ == '__main__': print(cong(name)) b = input('如要退出请输入exit:')
bac10c57ecb9bccb3a13cda38a104937d8bcd1b2
Goro-Majima/OpenFoodFacts
/pureBeurre.py
4,468
3.5
4
# -*- coding: utf-8 -*- """Starting program that calls insert and display functions from other file """ from displaydb import * from databaseinit import * from connexion import * from displayfavorite import * #query used to check if filling is needed CHECKIFEMPTY = '''SELECT * FROM Category''' CURSOR.execute(CHECKIFEM...
5c2bfd87eae9ecbf66be718816136f425a11fd24
NandanIITM/Pizzeria_Zearth_Sol
/Nandani_Garg/graph.py
4,709
3.671875
4
from collections import defaultdict import numpy as np # Class to represent a graph class Graph: def __init__(self, vertices): ''' Args: vertices : No of vertices of graph ''' self.V = vertices # No. of vertices self.graph = [] # default list to ...
2385bc762c835072e42a2e7bfdbbd66579f3ee84
amssdias/python-school
/classes.py
2,537
3.78125
4
class Student: id = 1 def __init__(self, name, course): self.name = name self.course = course self.grades = [] self.id = Student.id self.teachers = [] Student.id += 1 def __repr__(self): return f"<Student({self.name}, {self.course})>" def __str_...
00dfb0b8881dcccdd6f8ef059e0149956b6ed29b
ashleybaldock/tilecutter
/old/Script1.py
1,693
3.796875
4
import os class pathObject: """Contains a path as an array of parts with some methods for analysing them""" def __init__(self, pathstring): """Take a raw pathstring, normalise it and split it up into an array of parts""" path = pathstring norm_path = os.path.abspath(pathstring) ...
b30bc8c68c43339e91c03673aa98bd186fdee092
wheatgrinder/donkey
/donkeycar/parts/pitft.py
3,020
3.8125
4
#!/usr/bin/env python3 ''' donkey part to work with adafruitt PiTFT 3.5" LCD display. https://learn.adafruit.com/adafruit-pitft-3-dot-5-touch-screen-for-raspberry-pi/displaying-images classes display text on display So far I have only been able to find a methond to write to the display using the frame buffe...
3df6b8f9818261092de3b9df2143871c121fc360
leosartaj/thinkstats
/ch1.py
1,463
3.5
4
""" Chapter 1 """ import sys import survey import thinkstats as ts def live_births(table): cou = 0 for rec in table.records: if rec.outcome == 1: cou += 1 return cou def partition_births(table): first = survey.Pregnancies() other = survey.Pregnancies() for rec in table.r...
d47912664ed0a3d113d4d868ff9ecb16ae22e800
akhilharihar/optimus
/optimus/optimus.py
1,548
4
4
class Optimus: """ Arguments - prime - Prime number lower than 2147483647 inverse - The inverse of prime such that (prime * inverse) & 2**31-1 == 1 xor - A large random integer lower than 2147483647""" def __init__(self,prime, inverse, xor): self.prime = int(prime) self.i...
03e2d051ac1d3c734e5d4d2127a53ddf4187d7f9
Asritha-Reddy/2TASK
/positivenumbers.py
354
3.78125
4
#positive numbers list1=[12,-7,5,64,-14] print('List1: ',list1) print("Positive numbers in list1:") for i in list1: if i>=0: print(i, end=", ") print('\n') list2=[12,14,-95,3] print('List2: ',list2) print("Positive numbers in list2:") for j in list2: if j<=0: list2.remove(j) prin...
da9b9a622dbe2abc55064bb484c030c88f2587c8
Chearfly/-
/xiang_mu.py
1,010
3.609375
4
from tkinter import * from tkinter import ttk # from PIL import Image #建立模块对像 root = Tk() #设置窗口标题 root.title("人工智能项目") #设置显示窗口的大小 root.geometry("700x500") #设置窗口的宽度是不可变化的,但是他的长度是可变的 root.resizable(width = "true",height = "True") # l = ttk.Label(root, text="欢迎来到人工智能的项目", bg = "blue", font= ("Arial",15), width=30,\ ...
9f9ca4275f16934ecb0dc4b331dd3ed3cfa150be
alex123012/Bioinf_HW
/fourth_HW/hw_5.py
512
3.515625
4
k = int(input('Enter k number: ')) # wget https://raw.githubusercontent.com/s-a-nersisyan/HSE_bioinformatics_2021/master/seminar4/homework/SARS-CoV-2.fasta with open('SARS-CoV-2.fasta') as f: f.readline().strip() fasta = f.readline().strip() hash_table = {} for i in range(len(fasta) - k): j = i + k h...
511aac38c0edf5a12b6819d91b2bb20246581308
alex123012/Bioinf_HW
/first_HW/first_hw_1.py
1,231
3.71875
4
def quadratic_equation(a, b, c, rnd=4): """Solving quadratic equations""" if a == 0: if b == 0: if c == 0: return 'any numbers' else: return 'No solutions' else: return -c / b elif b == 0: if c <= 0: re...
27bdec3ef8bcff49ef41716fb4b2dd5fe0e39168
isabella0428/Leetcode
/python/695.py
1,383
3.5
4
class Solution: def maxAreaOfIsland(self, grid: 'List[List[int]]') -> 'int': def search(row, col, grid, num): grid[row][col] = 0 up = 0 if row == 0 else grid[row - 1][col] if up: num += search(row - 1, col, grid, 1) down = 0 if row == m - 1 els...
1fa0995dcf2c1f58e42c542e5cdc31c02bad6be1
isabella0428/Leetcode
/python/141.py
1,132
3.953125
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution1: def hasCycle...
cc17363e0989be93f817691c1b64e6968091eb8b
isabella0428/Leetcode
/python/81.py
2,919
3.609375
4
class MySolution: pivot = 0 ans = False def search(self, nums, target): """ :type nums: List[int] :type target: int :rtype: bool """ def findPivot(start, end, nums): if start == end: return mid = (start + end) >> 1 ...
734b98d18f175109c48e16afeec4b64cdea4d0ac
isabella0428/Leetcode
/python/413.py
890
3.671875
4
class Solution1: def numberOfArithmeticSlices(self, A: 'List[int]') -> 'int': # dynamic programming memo = [0 for i in range(len(A))] if len(A) < 3: return 0 sum = 0 for i in range(2, len(A)): if A[i] - A[i - 1] == A[i - 1] - A[i - 2]: ...
dac3c5e2a9f05e6ac34168e145ccb5b25f3d854f
isabella0428/Leetcode
/python/217.py
794
3.515625
4
class Solution1: def containsDuplicate(self, nums) -> bool: if len(nums) < 2: return False min_term = min(nums) for i in range(len(nums)): nums[i] += - min_term max_term = max(nums) stack = [-1 for i in range(max_term + 1)] for item in nums: ...
bc860577a7a9c6466fb1cf604dae49dcb08f89df
isabella0428/Leetcode
/python/86.py
904
3.609375
4
class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def partition(self, head: 'ListNode', x: 'int') -> 'ListNode': num = [] while head: num.append(head.val) head = head.next loc = 0 for i in range(len(num))...
24ab2e2b98b68d9b357a49b1c9816d1ee5cc9ba2
isabella0428/Leetcode
/python/22.py
1,845
3.640625
4
class Solution1: def __init__(self): self.result = [] def isValid(self, s): """ :type s: str :rtype: bool """ bal = 0 # if bal < 0 and bal !=0 at last returns False for i in s: if i == '(': bal += 1 else: ...
f4ce8e0353739753200f9742ff5be3ca3a971651
isabella0428/Leetcode
/python/5.py
1,339
3.546875
4
class Solution: def longestPalindrome(self, s): """ :type s: str :rtype: str """ def expandAroundElement(index, s): left = index - 1 right = index + 1 ans = str(s[index]) while left >= 0 and right < len(s): ...
eae3eb282eb9ea947d758ea1c59a3c4e0b2d0a85
isabella0428/Leetcode
/python/17.py
2,002
3.546875
4
class Solution1: def __init__(self): self.result = [] def letterCombinations(self, digits): """ :type digits: str :rtype: List[str] """ strs = [] s = [] dict = {2:['a','b','c'], 3:['d','e','f'], 4:['g','h','i'], 5:['j','k','l'], 6:[...
bfc6f9541b8b93b9eee437c24594552e1bc9da45
isabella0428/Leetcode
/python/34.py
1,804
3.6875
4
class Solution: def searchRange(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ def binarySearch(nums, start, end, ans, target): if start > end: return if nums[start] > target or nums[end] ...
eb7bdb086ac0f1932e9b66811db53f1d8957818d
isabella0428/Leetcode
/python/847.py
743
3.515625
4
class Solution: def shortestPathLength(self, graph): # use bits to represent states N = len(graph) dp = [[float('inf') for i in range(N)] for j in range(1 << N)] q = [] for i in range(N): dp[1 << i][i] = 0 q.append([1 << i, i]) while q: ...
c59b550736aeef6603de8b7406839051f495e7b6
isabella0428/Leetcode
/python/35.py
1,106
3.875
4
class Solution1(object): def searchInsert(self, nums, target): """ :type nums: List[int] :type target: int :rtype: int """ for i in range(len(nums)): if target == nums[i]: return i if target < nums[i]: return i ...
9ebdf9b2d26b2f720896b0281362f4f08318955f
isabella0428/Leetcode
/python/680.py
512
3.6875
4
class Solution: #greedy def validPalindrome(self, s): """ :type s: str :rtype: bool """ def isPali(s, i, j): return all(s[k] == s[j - k + i] for k in range(i, j)) for i in range(len(s)): if s[i] != s[~i]: # ~i = -(i + 1) ...
667e87890af57db213b90fa41a5027e46a404cfe
OliverOC/countryScratchMap
/functionLib.py
6,634
4
4
import json import os import matplotlib.pyplot as plt import pandas as pd from collections import defaultdict def if_no_json_create_new(file_name): """ This function checks whether a JSON file exists under the given file name. If no JSON file exists, a new one is created. :param file_name: Name of th...
d089ecb536c7d01e7387f82dbe93da65da98358c
yogabull/TalkPython
/WKUP/loop.py
925
4.25
4
# This file is for working through code snippets. ''' while True: print('enter your name:') name = input() if name == 'your name': break print('thank you') ''' """ name = '' while name != 'your name': name = input('Enter your name: ') if name == 'your name': print('thank you') """ ...
8837287f4ef533b32c594b35c8b432216cb8c628
yogabull/TalkPython
/ex3_birthday_program/ex3_program_birthday.py
1,221
4.28125
4
"""This is a birthday app exercise.""" import datetime def main(): print_header() bday = get_user_birthday() now = datetime.date.today() td = compute_user_birthday(bday, now) print_birthday_info(td) def print_header(): print('-----------------------------') print(' Birthday App')...
ce930feff941e3e78f9629851ce0c8cc08f8106b
yogabull/TalkPython
/WKUP/fStringNotes.py
694
4.3125
4
#fString exercise from link at bottom table = {'John' : 1234, 'Elle' : 4321, 'Corbin' : 5678} for name, number in table.items(): print(f'{name:10} --> {number:10d}') # John --> 1234 # Elle --> 4321 # Corbin --> 5678 ''' NOTE: the '10' in {name:10} means make the name var...
77ddf7f2e6d19a20ca71862d7507a72ed1cde4bd
rohitgang/MATH471
/rank_matrices.py
1,677
3.75
4
""" (Ranks of random matrices) Generate square (n x n) matrices with random entries (for instance Gaussian or uniform random entries). For each n belonging to {10,20,30,40,50}, run 100 trials and report the statistics of the rank of the matrix generated for each trial (mean, median, min, max). What do you notice? Pleas...
8a07ac0097bdfa92665a85be956b5dfc40b217dc
gregor42/python-for-the-stoopid
/diction.py
733
3.640625
4
#!/usr/local/bin/python # # diction.py - playing with dictionaries # import pri filename = 'templ8.py' # Say hello to the Nice People pri.ntc(filename + " : Start.") pri.bar() D = {'a': 1, 'b': 2, 'c': 3} pri.ntc(D) pri.bar() D['e']=42 pri.ntc(D) pri.bar() #underfined value will break #print D['f'] pri.ntc('f' i...
3a3bf87bc7aeede084d8df8e78331110b8f3e441
zumioo/tweet
/remove.py
1,203
3.671875
4
""" 使うときはコメントアウト外してね import tweepy import calendar import random import time def main(): consumer_key = 'XXXXX' consumer_secret = 'XXXXX' access_token_key = 'XXXXX' access_token_secret = 'XXXXX' auth = tweepy.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_token_key...
f08ec1974b033d5bd56b64b764f23541a811acbc
febin72/LearnPython
/oddoreven.py
149
4.28125
4
''' Find even or odd ''' import math print ('enter the number') x= int(input()) if (x%2==0): print ('the number is even') else: print('odd')
2550c545f6f0f73faef10670b3dde6f2235b21a1
febin72/LearnPython
/strings.py
509
3.9375
4
''' play with strings ''' import string print ('enter a string') a = str(input()) print ('ented one more string') one_more_string = str(input()) print ('entered strings length is ' , len(a) , len(one_more_string)) #print (a[2:6]) #print ('The length of the string entered is' ,len(a+one_more_string)) newstring = a + one...
c7fc3ced3296f7e181ba9714534800b59d20dd53
thevirajshelke/python-programs
/Basics/subtraction.py
586
4.25
4
# without user input # using three variables a = 20 b = 10 c = a - b print "The subtraction of the numbers is", c # using 2 variables a = 20 b = 10 print "The subtraction of the numbers is", a - b # with user input # using three variables a = int(input("Enter first number ")) b = int(input("Enter first number ")) c ...
ef45e2377ab4276345644789a17abdd20da69aca
johnehunt/computationalthinking
/week4/tax_calculator.py
799
4.3125
4
# Program to calculate tax band print('Start') # Set up 'constants' to be used BASIC_RATE_THRESHOLD = 12500 HIGHER_RATE_THRESHOLD = 50000 ADDITIONAL_RATE_THRESHOLD = 150000 # Get user input and a number income_string = input('Please input your income: ') if income_string.isnumeric(): annual_income = int(income_st...
fecc9d49fc1df51d7b793fb052c8defcbc86300e
johnehunt/computationalthinking
/week1/exammarks/main3.py
633
3.9375
4
# Alternative solution using compound conditional statement component_a_mark = int(input('Please enter your mark for Component A: ')) coursework_mark = int(input('Please enter your mark for Component B: ')) # Calculating mark by adding the marks together and dividing by 2 module_mark = (component_a_mark + coursework_...
8d7ca111c403010de98909a1850ae5f7a1d54b2b
johnehunt/computationalthinking
/number_guess_game/number_guess_game_v2.py
1,262
4.34375
4
import random # Print the Welcome Banner print('===========================================') print(' Welcome to the Number Guess Game') print(' ', '-' * 40) print(""" The Computer will ask you to guess a number between 1 and 10. """) print('===========================================') # Initialise the...
0f25b7552ca48fbdc04ee31bd873d899ffae26c6
johnehunt/computationalthinking
/week4/forsample.py
813
4.34375
4
# Loop over a set of values in a range print('Print out values in a range') for i in range(0, 10): print(i, ' ', end='') print() print('Done') print('-' * 25) # Now use values in a range but increment by 2 print('Print out values in a range with an increment of 2') for i in range(0, 10, 2): print(i, ' ', end=...
0e6908ec30831e4ea0218e8af6b0605dae3cef78
johnehunt/computationalthinking
/week4/ranges.py
171
4.1875
4
for i in range(1, 10): print(i, end=', ') print() for i in range(0, 10, 2): print(i, ' ', end='') print() for i in range(10, 1, -2): print(i, ' ', end='')
3a3069f8e96bf2bdcf973dececffb43dc0ca59c4
johnehunt/computationalthinking
/week2/numbers.py
1,867
3.734375
4
x = 1 print(x) print(type(x)) x = 10000000000000000000000000000000000000000000000000000000000000001 print(x) print(type(x)) home = 10 away = 15 print(home + away) print(type(home + away)) print(10 * 4) print(type(10 * 4)) goals_for = 10 goals_against = 7 print(goals_for - goals_against) print(type(goals_for - goals...
2acb0005b760b130fc4c553b8f9595c91b828c0e
tainagdcoleman/sharkid
/helpers.py
2,892
4.125
4
from typing import Tuple, List, Dict, TypeVar, Union import scipy.ndimage import numpy as np import math Num = TypeVar('Num', float, int) Point = Tuple[Num, Num] def angle(point: Point, point0: Point, point1: Point) -> float: """Calculates angles between three points Args: point...
33a375ed2fb0b278b1304dffb4815c4cfdf67982
rose60730422/writingTest
/writingTest.py
696
3.84375
4
def reverseString(t): reverseString = t[::-1] return reverseString def reverseWords(s): s = s.split(" ") for index, word in enumerate(s) : s[index] = reverseString(word) r = ' '.join(s) return r def countingFactor(n): cnt = 0 for i in range(n): if ((i+1) % 3 == 0) ...
0438c1b364eae318c527df99ea6b1959489e0fce
lakshmanboddoju/Automate_the_boring_stuff_with_python
/11/31-hello_txt_read.py
867
3.734375
4
#! python3 import shelve # Read Operation helloFile = open('C:\\Users\\lakshman\\Desktop\\hello.txt') #helloFileContent = helloFile.read() #print(helloFileContent) print(helloFile.readlines()) helloFile.close() # Write Operation helloFile2 = open('C:\\Users\\lakshman\\Desktop\\hello2.txt', 'w') he...
8079ac6be8a7cbfbda9230c0fffeb89170e04f8d
AshWije/Neural-Networks-In-Python
/WithPyTorch/ImageNet_ResNetX_CNN.py
9,451
3.53125
4
################################################################################ # # FILE # # ImageNet_ResNetX_CNN.py # # DESCRIPTION # # Creates a convolutional neural network model in PyTorch designed for # ImageNet modified to 100 classes and downsampled to 3x56x56 sized images # via resizing and croppin...
21e93a9e63969f1a8a0ff398cc8b5b1c94668317
dcronin05/timewaster
/main.py
212
3.859375
4
print("Hello world") class AClass(object): def __init__(self, a, b): self.a = a self.b = b def getter(self): return self.a newObj = AClass(3, "hello") print(newObj.getter())
c1c530035fcd38d5b23e00dd66f914206de5d313
iampaavan/Internet_Data_Python
/urllibdata_start.py
910
3.703125
4
# Send data to a server using urllib # TODO: import the request and parse modules import urllib.request import urllib.parse def main(): # url = 'http://httpbin.org/get' url = 'http://httpbin.org/post' # TODO: create some data to pass to the GET request args = { 'Name': 'Paavan Gopala', 'Is_...
0b8333949d8b4a32573cd24b8c83cedd9585e25e
pancham2016/ScubaAdventure
/bubble.py
1,042
3.921875
4
import pygame from pygame.sprite import Sprite class Bubble(Sprite): """A class that manages bubbles released from the diver.""" def __init__(self, sa_game): """create a bubble object at the diver's current position.""" super().__init__() self.screen = sa_game.screen self.setti...
62d9367a9114d703024070eee7b92f1d4c067f2a
xiaojin9712/data_strcture_review
/two_sum.py
1,005
3.671875
4
A = [-2, 1,2,4,7,11] target = 13 # Time Complexity: O(n^2) # Space Complexity: O(1) def two_sum_brute_force(A, target): for i in range(len(A) - 1): for j in range(i+1, len(A)): if A[i] + A[j] == target: print(A[i], A[j]) return True return False two_sum_brute...