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
934fd8dd801234fe1796494cf56134366ed8b1a9
Gauravsahadev/Udemy-Python3-BootCamp-Practice-Problems
/Loops/simpleWhile.py
138
3.546875
4
msg=input("Whats the secret password?") while msg!="Zebra": print("Wrong !") msg=input("Whats the secret password?") print("Correct !")
47b92c822f1383e712ce51b7d30a7e6f56c41750
Gauravsahadev/Udemy-Python3-BootCamp-Practice-Problems
/Debugging/raise.py
301
4
4
def colorize(text,color): pass colors=("red","blue","green","black","cyan") if type(text) is not str: raise TypeError("Text must be a instance of string") if color not in colors: raise NameError("color is not present") print("The {} is {} colour".format(text,color)) colorize("hello","red")
cae7d27d96f0a9e4f1bf2b751e44c84f07d85641
poohpeer/linked_list
/list.py
3,296
4.125
4
from my_exceptions import EmptyNodeException class LinkedList(object): """Linked list implementation""" def __init__(self, nodes=None): self._root = None # If nodes passed, add them while constructing if nodes: self.add_nodes(nodes) @property def root(self): ...
c1337b3f967c6c2a1529150c4b19579d4e62c993
AP-MI-2021/lab-2-CiobanVasile
/main.py
3,200
3.671875
4
def is_prime(nr): ''' -Determina daca un numar este prim sau nu Input: n,numar intre Output: True, n prim False, n neprim ''' if nr < 2: #daca numarul este mai mic decat 2 nu este prim return False for i in range(2, nr,1):#o metoda mai eficienta ar fi sa mergem...
13d9185928c7d0844a0988f3be20f48f5ca375e6
abiradar27/First_python
/test_code/demo1.py
264
3.59375
4
import sys print("Hello ABC client") age=27 a='ABC for TECH' print(a[0:3]) print(a[:3]) print(a[0:]) print(a[::2]) print(a[::3]) print(a) print(a[4]) print(a[-7]) print(type(age)) print("ABC for tech") print(sys.argv[0]) # print(sys.argv[1]) # print(sys.argv[2])
f00f55dcd7bc55809392ecc2917c766cdef7d18d
airorair/DataStructure
/recursion.py
1,625
3.6875
4
# -*- coding: utf-8 -*-# #------------------------------------------------------------------------------- # Name: recursion.py # Description: 递归算法 # Author: xuanguoke # Date: 2019/10/17 #------------------------------------------------------------------------------- """ 案例一: 斐波那切数列:1,1,2,3,...
a32b037eb8730aaa5f117ddc5bc819204086005f
Diviyan-Kalainathan/python-course
/Exercices/Basic/Ex7.py
204
3.796875
4
# Ex7: multiply each element of a List # 1. Create a function ´multiply(l, x)´ that takes as argument a list 'l' and a float ´x´ # and outputs a list of all elements of l that are multiplied by x
272d6b26253dfb3573be18709097920d1dbb07ab
cb-kali/Python
/Day13.py
1,021
4.1875
4
''' Introduction to python class: Class --> it's like a blueprint of codedesing. class method --> A function writen inside a class is called a method. attributes --> a variable writen inside a class is called an attributes. Introduction of a class/object ''' # req:- ''' You have to create a class, it should your ...
8d3c263120c50b3e0000a91adbba869f9c7d9678
EErikas/smk_oop_test_grader
/submission_tests/correct_answers_2/ex2.py
504
4
4
def pythagorean_checker(a, b, c): return c ** 2 == a ** 2 + b ** 2 def triangle_checker(a, b, c): sides = [a, b, c] s = sum(sides) for side in sides: if s - side < side: return False return True if __name__ == '__main__': print(pythagorean_checker(3, 4, 5)) print(pyth...
51255afd6661fab0a929279034e8bd62e4a85261
sissokom0936/cti110
/P2T1_SalesPrediction_SissokoMady.py
370
3.75
4
# Program to calculate anual profit of a company # Friday,21 February 2020 # CTI-110 P2T1 - Sales Prediction # SissokoMady # #Get projected Total Sales total_sales= float(input('Enter projected sales:')) #Calculate the profit as 23 percent of total sales. profit = total_sales * 0.23 #Display the profit. ...
405ca2949a380a94d514ef4e368b748a0f4bfe85
nicozorza/speech-to-text
/src/utils/sentence_utils.py
1,194
3.59375
4
from typing import List def levenshtein(a, b): n, m = len(a), len(b) if n > m: a, b = b, a n, m = m, n current = list(range(n+1)) for i in range(1, m+1): previous, current = current, [i]+[0]*n for j in range(1, n+1): add, delete = previous[j]+1, current[j-1...
e30021ae1da6638da17b8aba30b0adc92bac9f47
hhhhhhe/myStudyCode
/07 合并排序的数组.py
835
3.796875
4
# -*- coding:utf-8 -*- __author__ = "leo" # 给定两个排序后的数组 A 和 B,其中 A 的末端有足够的缓冲空间容纳 B。 编写一个方法,将 B 合并入 A 并排序。 # 初始化 A 和 B 的元素数量分别为 m 和 n。 class Solution: def merge(self, A, m, B, n): A[m:] = B A.sort() class Solution1: def merge(self, A, m, B, n): sorted_ = [] pa, pb = 0, 0 ...
0915dc0da8ec05928d24d989536cc8c134c34edb
BrandtRobert/BlackJackAI
/src/Player.py
3,149
3.75
4
# Implements a Player # A Player has a hand, and they also have a set of valid moves they can make # Author: Courtney Schulze import copy from src.Deck import BlackJackDeck # from Deck import BlackJackDeck class Player: #creates a new Player and gives them an empty hand def __init__ (self): self.h...
e4063d8bc9fa4a3a89eb99209c699aa2c667b722
GibsonCool/python_Basis
/ptythonProject/python_basis/knowledgePoint/1.list_tuple_dict_set.py
734
4.34375
4
""" list 一个可变的有序表 """ listSimple = ['a', 'b', 'c'] print(listSimple) print(listSimple[2]) print(listSimple[-2]) # print(listSimple[3]) # 会奔溃,越界 listSimple.append("sss") print(listSimple) listSimple.insert(2, "555") print(listSimple) """ tuple 一个不可变的有序表""" tupleSimple = (1,) # 为了避免歧义定义只有一个元素的tuple时候需要在末尾加个逗号 prin...
5107df9089c13654010da7dc262f5812d84fd508
GibsonCool/python_Basis
/ptythonProject/python_basis/knowledgePoint/13.浅拷贝、深拷贝.py
944
4.34375
4
""" ==:比较的是值 is:比较的是地址值 """ a = [11, 22, 33] b = [11, 22, 33] print(id(a)) print(id(b)) print(a == b) print(a is b) print("__________________________________________________________________________________") """ 浅拷贝(copy.copy()):正常的赋值操作,只拷贝地址值或者叫内存引用,如果有多层只拷贝第一层,如果第一层是不可变比如元组,那么一层都不拷贝直接复制 深拷贝(copy.d...
d0abe34ab4df834cafa74536b190c53667fee5d8
RobertoBarrosoLuque/CTA-Health
/text_ui.py
5,430
3.578125
4
''' An application module that allows a user to create a plot of two side-by-side maps of the city of Chicago: one map with a public health indicator that is of interest, and another with a socioeconomic or demographic indicator that is of interest. Both maps will highlight the census tracts underlying one or more el...
23e25efead58db27ba653d65fe000a122179751d
chenjingtongxue/python
/11/division.py
92
3.703125
4
a=float(input('被除数:')) b=float(input('除数:')) print("%f ÷ %f = %f"%(a,b,a/b))
2e4183ff392d4a330a2365a178621a10a51bc7ca
chenjingtongxue/python
/11/期中练习/answertest1_1.py
169
3.84375
4
x = int(input("x=")) y = int(input("y=")) if (x==y): print("两数相同!") elif (x > y): print("较大数为:",x) else: print("较大数为:",y);
8809f1654aa3491b72f50389b3ed24ff0a334e4a
chenjingtongxue/python
/5-3-5-write/fw.py
258
3.59375
4
f=open('word.txt','w') #如果电脑有这个文件就写进这个文件没有就新建,如果把w换成a就是追加内容 f.write('world') f.close() #在进行 写 的操作时一定要关闭文件 f=open('word.txt','a') f.write('python') f.close()
d1c7c81fc1a8d4d88a409d1006acafdc0c27b245
charlie-wt/user-model
/ls.py
513
3.5625
4
''' ls a few simple functions to help with manipulating lists. ''' def get ( ls, id ): for item in ls: if item.id == id: return item return None def index ( ls, id ): for i in range(len(ls)): if ls[i].id == id: return i return None def save ( ls, item ): idx = index(ls, item.id) ...
9777f034f0cdc63b9b2f5fed04ba1e5c21fbefa7
Cosmin013/Facultate
/Python/pregTest/lab10.py
3,563
3.5625
4
import sys import datetime import random import math import timeit def ex1_aux(args): if args[2] == '+': return int(args[1]) + int(args[3]) if args[2] == '/': return int(args[1]) / int(args[3]) if args[2] == '*': return int(args[1]) * int(args[3]) if args[2] == '%': retu...
29e91abac0e3e1202cd2fef2f4666bfe681dc9be
robert0525/Python-
/hello.py
393
4.1875
4
first_name = input("What's is your first name? ") print("Hello", first_name) if first_name == "Robert": print(first_name, "is learning Python") elif first_name == "Maxi": print(first_name, " is learning with fellow students in the Comunity! Me too!") else: print("You should totally learn Python, {}!".form...
6ef9fd850e58c2eed598c65722ec0cf3f30acc46
kimthanh932000/Bicycle
/bikeshop/BikeShop.py
1,180
3.90625
4
class BikeShop: __inventory = [] __profit = 0 def __init__(self, name): self.name = name # add bike to inventory def add_to_inventory(self, bicycle): bicycle.price = bicycle.cost + bicycle.cost * 0.2 self.__inventory.append(bicycle) # get inventory def get_inventor...
33df9297e9a8f4f8951228870b3c8f1d38cfc517
JonasJF360/Projetos_Python
/Mostrar_numeros.py
603
3.5
4
#-*-coding:utf8;-*- #qpy:console import androidhelper droid = androidhelper.Android() # Define um estilo para o título. def titulo(self): ln = '=' * 38 x = (38 - len(self)) / 2 cent = round(x) * ' ' print('\n%s\n%s%s\n%s\n' % (ln,cent,self,ln)) valor = droid.dialogGetInput('MOSTRAR SÓ OS NÚMEROS', 'Co...
295a016ed0cc549d126c7ed82bb7a594c4894c1c
JonasJF360/Projetos_Python
/IMC_Ideal.py
4,605
3.859375
4
print(''' CALCULADORA DE IMC E PESO IDEAL: Baixo peso, muito grave = abaixo de 16. Baixo peso, grave = entre 16 e 16,99. Baixo peso = entre 17 e 18,49. Peso normal = entre 18,50 e 24,99. Sobrepeso = entre 25 e 29,99. Obesidade grau I = entre 30 e 34,99. Obesidade grau II = entre 35 e 39,99. Obesidade grau III = maior q...
fa355c0d0f06854e511a753d58ac8727dc7aec44
ks2019575001/python
/9.py
124
3.6875
4
def str2int(): s = input("문자열 :") if s.isdigit(): print(s) else: print("None") str2int()
a02ccd18017be5708364315fc16bd0a166302496
cbrownley/OLD-foundations-for-analytics-with-python-OLD
/csv/7csv_reader_column_by_index.py
638
3.625
4
#!/usr/bin/python """ Copyright 2014 Clinton W. Brownley Available at https://github.com/cbrownley License: GNU GPLv3 http://www.gnu.org/licenses/gpl.html """ import csv import sys input_file = sys.argv[1] #output_file = sys.argv[2] my_columns = [0, 3] with open(input_file, 'rU') as csv_in_file: #with open(output_fi...
060bc431da5579abc483fdb00079f966ac2c59fc
cbrownley/OLD-foundations-for-analytics-with-python-OLD
/csv/5csv_reader_value_matches_pattern.py
752
3.53125
4
#!/usr/bin/python """ Copyright 2014 Clinton W. Brownley Available at https://github.com/cbrownley License: GNU GPLv3 http://www.gnu.org/licenses/gpl.html """ import csv import re import sys input_file = sys.argv[1] #output_file = sys.argv[2] regexp = re.compile(r'(?P<my_pattern>^001-.*)', re.I) header_row = True wit...
667b928475a3942174b887a588f75508aa5e66b1
smitmil2/Homework-4
/part1/cube_volume.py
585
4.0625
4
def calculate_volume(w, h, l): try: w = float(w) h = float(h) l = float(l) except: raise Exception('invalid type', 'w, h, l must be numbers') if l <= 0 or w <= 0 or h <= 0: raise Exception('invalid number', 'dimension must be greater than zero') return w ...
43fe9449dbeb07be18199a978a42272392fd2cac
ryanfzy/projecteuler
/9.py
419
3.6875
4
def _square(n): return n * n def find_triplet(): a_max = 332 + 1 for a in range(1, a_max): b_max = (1000 - a) / 2 for b in range(a+1, b_max): square_c = _square(a) + _square(b) c = 1000 - a - b if square_c == _square(c): print [a, b, c] ...
698c56301d69d88334b7f7bce0bf92dc3de500a0
ryanfzy/projecteuler
/13.py
380
3.640625
4
""" this is easy because python can handle very large number for other langauges that doesn't have this kind of native support (e.g. c/cpp) could be difficult """ def sum(): result = 0 with open('13.txt') as f: for line in f.readlines(): num = int(line.strip()) result += num ...
192294740d5317d3b0c1d0e48f3880df9c5902d4
ryanfzy/projecteuler
/15.py
1,022
3.875
4
import math """ both find_path and find_path2 works but find_path2 is fast because it has the power of math """ PATH_DICT = {} def find_path(start, end, path): global PATH_DICT #global PATH if str(start) in PATH_DICT: return PATH_DICT[str(start)] if start[0] == end[0] and start[1] == end[1]: ...
f8e5035714c7046018e49ef5d275a61674b848e5
dharanidurairaj/codevita-practice-problems
/date valid or not.py
383
3.515625
4
d,m,y=map(int,input().split("/")) if(m<13): if((m==1 or m==3 or m==5 or m==7 or m==8 or m==10 or m==12) and (d<32)): print("Valid") elif((m==4 or m==9 or m==11) and (d<31)): print("Valid") elif(m==2 and d<29): print("Valid") elif(m==2 and d==29 and y%4==0): print("valid")...
ccaf1605eeb29742739d8eb7a57e146ef1d2a1bb
dharanidurairaj/codevita-practice-problems
/hackerrank cls qns.py
2,224
3.96875
4
You are given an infinite 2-d grid with the bottom left cell referenced as (1,1). All the cells contain a value of zero initially. Let's play a game? The game consists of N steps wherein each step you are given two integers a and b. The value of each of the cells in the co-ordinate (u, v) satisfying 1 ≤ u ≤ a and 1 ≤ ...
6b7e6ed934229c7ce680537e75ffa8cec371e047
chechung/otu_proj
/otu_proj/data_proc.py
7,298
3.765625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ data_proc.py Process OTU data to generate phylogenetic abundance group bar plot General steps: 1. separate values based on control/treatment category 2. calculate mean and standard deviation values for phylogenetic groups per control/treatment group 3. ge...
945fee82eba86be81fe0184bc9c351d956375d55
ronaldorueda/ShiftRotations
/main.py
1,465
3.734375
4
from myEmailSend import * from rotations import * UINum = 1 while (UINum != 0): print("1. Perform rotations and send email.") print("2. Perform rotations only and create file.") print("3. Perform rotations only and see it.") print("4. See current schedule/rotations.") print("0. Quit program.") ...
055d86ae3c6bde04725bf619b201e8a7e98ffe97
sxuya/summary_machineLearnig
/miniProgect_naiveBayes_optimalClassifier.py
3,753
3.953125
4
#------------------------------------------------------------------ # # Bayes Optimal Classifier # # In this quiz we will compute the optimal label for a second missing word in a row # based on the possible words that could be in the first blank # # Finish the procedurce, LaterWords(), below # # You may want...
bec1cfc658938e4e8fc7c692899ffcee6f69961a
kdorr/FloodProject
/analyze.py
1,260
3.5625
4
# -*- coding: utf-8 -*- """ Created on Fri Mar 10 13:10:31 2017 @author: Kimberly """ def monthlyAverage(floodForeclosures): #for each flood, subtract month n from n+1, store that value into a list individualDifferences = averageIndividual(floodForeclosures) #find the average difference and store that in ...
a418d91736abcdd34fc5ee876670eb4ce970fcfc
pilkaj/codeeval
/codeeval_easy/easy_armstrong_numbers.py
664
3.984375
4
"""Sample code to read in test cases: """ import sys with open(sys.argv[1], 'r') as test_cases: for test in test_cases: # ignore test if it is an empty line # 'test' represents the test case, do something with it # ... # ... number = test.strip('\n') power...
19b2b314b7568ee996403026b07bc01daeaa31e3
eakhawkeye/SimpleProjects
/Vigenere/vigenere.py
2,945
3.84375
4
#!/usr/bin/python # Quick Vigenere Ciphering with iterations # # Cipher: ( plain_text_letter.index + key_letter.index ) mod total_character_count = cipher_text_letter.index # Decipher: ( cipher_text_letter.index - key_letter.index ) mod total_character_count = plain_text_letter.index # ##############################...
30b3dd3eb450e0242d64693b180ff310b4f0e753
ArthurGoodman/python_parser
/subexpr.py
4,539
3.515625
4
import readline class BinaryNode: def __init__(self, left, oper, right): self.oper = oper self.left = left self.right = right def equals(self, node): return (isinstance(node, BinaryNode) and ((self.left.equals(node.left) and self.right.equals...
babeda063ceb9103bb759aa2c020ae8e763cf88d
jubjamie/jamesHelp
/ass3.2.py
529
3.796875
4
import numpy as np import math import matplotlib.pyplot as plt xt = np.linspace(0, 1, 20) n = [1, 2, 3, 5, 10, 30] def fourier(values, order): Sarray = [] print(type(order)) for j in range(order): i = j + 1 S = (1 / ((2 * i)-1)) * np.sin(((2*i)-1)*2*math.pi*values) * 4 /math.pi pr...
3792a04207009f3ea6d040cd0a291ef47f5f7977
riteshelias/UMC
/Sequences/sorting.py
613
3.65625
4
pangram = "The quick brown fox jumps over the lazy dog" letters = sorted(pangram) print(letters) print(pangram) numbers = [4.7, 3.9, 7.7, 9.1, 6.3, 1.2] another_set = sorted(numbers) print(another_set) print(numbers) numbers.sort(reverse=True) print(numbers) print(another_set) print() string1 = sorted("The quick br...
4726f82e7ad0e1194c11e3f98f32243c929cf156
riteshelias/UMC
/HelloWorld/string2.py
1,049
3.9375
4
parrot = 'Norwegian Blue' #STRING INDEX print(parrot) print(parrot[3]) print(parrot[4]) print(parrot[9]) print(parrot[3]) print(parrot[6]) print(parrot[8]) # STRING NEGATIVE INDEX print() print(parrot) print(parrot[-11]) print(parrot[-10]) print(parrot[-5]) print(parrot[-11]) print(parrot[-8]) print(parrot[-6]) pr...
a8cb384dc0440a3f8ae962d3c543af8e179fa9cd
riteshelias/UMC
/ProgramFlow/guessgame.py
1,734
4.125
4
import random answer = random.randint(1, 10) print(answer) tries = 1 print() print("Lets play a guessing game, you can exit by pressing 0") guess = int(input("try count - {}. Please enter a number between 1 and 10: ".format(tries))) while guess != answer: if guess == 0: print("Bye, have a nice day!") ...
182e5c22bbdd561a864d23108e5e8282b0d473bf
riteshelias/UMC
/ProgramFlow/hilogame.py
919
3.828125
4
lower_limit = 1 upper_limit = 1000 print("Please think of a number between {0} and {1}".format(lower_limit, upper_limit)) guesses = 1 input("Please press the 'Enter' key to start: ") while lower_limit != upper_limit: guess = lower_limit + ((upper_limit - lower_limit) // 2) print("My guess is {}".format(guess)) ...
f1aff69414d4ed0d71b51b67bd521a3f8cdbe17e
riteshelias/UMC
/Sequences/buy_computer.py
1,578
3.828125
4
parts_list = ["CPU", "Monitor", "Keyboard", "Mouse", "Printer", "Webcam", "HDMI Cable", "Exit"] selection = "-" selected_parts = [] ind_list = [] for index in range(0, len(parts_list)): ind_list.append(str(index)) # print(ind_list) while selection != "0": if selection in ind_list: part = parts_list[i...
ec8c502c25d83cc456efe7e0c13be7f6a246d7ca
BinYuOnCa/Learning
/lintCode/788TheMazeII/Solution.py
4,832
3.609375
4
from collections import deque class Walker: tx, ty = 0, 0 rows, cols = 0, 0 maze = [] def __init__(self, x, y, dx, dy ): self.x = x self.y = y self.dx = dx self.dy = dy self.steps = 0 def __str__(self): return '({},{})-({},...
4fda562b55868eb8a73eaa9a28501bfdbb9ce5a6
garthk1/Pythonbook
/MIne/battle_game.py
1,227
4.0625
4
# Testing out a RPG sim import random def dice_roller(dice): # generate random number 1 - dice(eg d6, d10, d12) dice = random.randint(1, dice) return dice print("Your lone hero is surrounded by a massive army of trolls.") print("Their decaying green bodies stretch out, melting into the horizon.") print("Yo...
bcb788e167bc890cc5acd7007372f527d3c046e0
pykili/py-204-hw1-polina-malakhova
/task_10/solution_10.py
111
3.625
4
a= input() b="" for i in a: b=str(i)+str(b) if b==a: print ("Nice palindrom!") else: print("I'm depressed")
fed57aa012cc4c0952732abaab4e951b81773dd0
daniel10012/python-onsite
/week_04/intro_apis/03_catch_em_all.py
1,101
3.765625
4
''' Using the PokéAPI https://pokeapi.co/docs/v2.html#pokemon fetch the name and height of all 151 Pokémon of the main series. Create a text document that describes each Pokémon using the information available in the JSON response. NOTE: only using 'height' is enough, but if you want more, go crazy. BONUS: Using your...
ed9d9f13dbaded3e15e357a0e8f9661fd1264799
daniel10012/python-onsite
/week_02/08_dictionaries/09_01_duplicates.py
470
3.96875
4
''' Using a dictionary, write a function called has_duplicates that takes a list and returns True if there is any element that appears more than once. ''' # [a,b,d,s,w,q,a] def has_duplicates(list_): dict = {} for i in list_: dict[i] = list_.count(i) print (dict) for value in dict.values():...
16f595b7e1ff1b8b22ab8ba1221d96448a03d15e
daniel10012/python-onsite
/week_01/03_basics_variables/07_conversion.py
526
4.375
4
''' Celsius to Fahrenheit: Write the necessary code to read a degree in Celsius from the console then convert it to fahrenheit and print it to the console. F = C * 1.8 + 32 Output should read like - "27.4 degrees celsius = 81.32 degrees fahrenheit" NOTE: if you get an error, ...
94cb273f78f1f9b80bb877b7811f5ebf055c23bc
daniel10012/python-onsite
/week_03/01_files/00_long_words.py
507
3.671875
4
''' Write a program that reads in the file words.txt and prints only the words with more than 20 characters (not counting whitespace). Source: http://greenteapress.com/thinkpython2/html/thinkpython2010.html ''' with open("words.txt","r") as fin: # print((fin.read().split())) word_list = (fin.read().split())...
9e6b89661cd68140884634d1a7978e4afc899e98
daniel10012/python-onsite
/week_02/11_inheritance/01_class_attributes.py
910
4.40625
4
''' Flush out the classes below with the following: - Add inheritance so that Class1 is inherited by Class2 and Class2 is inherited by Class3. - Follow the directions in each class to complete the functionality. ''' class Class1: def __init__(self, x): self.x = x # define an __init__() met...
fe26c3fa3494717d2cb65c234594323fae19a5f0
daniel10012/python-onsite
/week_04/intro_apis/01_countries.py
1,117
4.375
4
''' Use the countries API https://restcountries.eu/ to fetch information on your home country and the country you're currently in. In your python program, parse and compare the data of the two responses: * Which country has the larger population? * How much does the are of the two countries differ? * Print the native ...
06774114cb67d9626933f4f3d752b8beb4f9f2b2
daniel10012/python-onsite
/week_03/01_files/04_rename_doc.py
1,156
4.125
4
''' Write a function called sed that takes as arguments a pattern string, a replacement string, and two filenames; it should read the first file and write the contents into the second file (creating it if necessary). If the pattern string appears anywhere in the file, it should be replaced with the replacement string. ...
cd99f695faa50653c2ca9488547a528059c94d62
daniel10012/python-onsite
/week_02/06_tuples/01_make_tuples.py
502
4.34375
4
''' Write a script that takes in a list of numbers and: - sorts the numbers - stores the numbers in tuples of two in a list - prints each tuple Notes: If the user enters an odd numbered list, add the last item to a tuple with the number 0. ''' my_list = [5,3,32,1,3,9,5,3,2,2,5] my_list.sort() if len(...
fca9576e3ebd0e422742c49d083dd68a66a37e6a
daniel10012/python-onsite
/week_04/intro_apis/02_numbers.py
1,584
4.0625
4
''' Write a script that connects to the http://numbersapi.com/ and fetches trivia on all numbers from 0 through 100. Store the responses in a new JSON file called numbers.json BONUS: * fetch information of all the prime numbers from 1-1000 * cycle through the different endpoints the API provides (trivia, math, date, ...
2c3715d17fd38bc5f50eb6b85ac072432cefd2a2
CoderStellaJ/Django-2.2-Python-The-Ultimate-Web-Development-Bootcamp
/Python Refresher/OOP.py
372
3.890625
4
class Dog: dogInfo = "infoinfo" def __init__(self, name="", age=0, color): #constructor self.name = name self.age = age self.color = color def bark(self, str): print("BARK "+str) mydog = Dog("aaa",11,"blue") mydog.bark("meow") mydog.name = "aaa" #evem tho not defined in class mydog.age = 16 print(mydog...
24f52b7bb2549abfe45e0e0a3763b0b42d400f2a
hellocece/100_days_Python_Mastery
/Day_3_PMastery.py
238
3.921875
4
# B_R_R # M_S_A_W # given integral number n, create a dictionary with functions key and value in which value is equal to square of that key. num = int(input("Enter a number: ")) d=dict() for i in range(1, num+1): d[i]=i*i print(d)
aa0dbfd03a4395f8ee870c0cee1ace53da56a426
ByteFun/bemaniutils
/bemani/utils/cardconvert.py
774
3.5
4
import argparse from bemani.common import CardCipher, CardCipherException def main() -> None: parser = argparse.ArgumentParser(description="A utility to convert between card IDs and back-of-card characters.") parser.add_argument( "number", help="card ID or back-of-card characters to convert."...
3d5ec6c45efa5bada199cbd097d2903fd41868b8
piyush-palta/Working-with-PDFs
/mergePdfs.py
602
3.640625
4
# importing required modules import PyPDF2 # pdf files to merge, mention them in exact order you want to merge them pdfFiles = ['pdf1.pdf', 'pdf2.pdf', 'pdf3.pdf'] # output pdf file name mergedFile = 'merged_file.pdf' # creating pdf file merge object pdfMerge = PyPDF2.PdfFileMerger() # appending pdf...
0fbe01f47730577adbc245c9e73b361e8f52fd7f
balaramhub1/Python_Test
/Numbers/Numbers_03.py
1,065
3.859375
4
''' Created on Jul 14, 2014 @author: HOME ''' print("Basic arithmatic-2 operations in Python.") a=2 b=5 c=5.345 d=0.3 e=4 +3j f=-6 print("Value of a =" , a ,"\nValue of b =",b , "\nValue of c =",c,"\nValue of d =",d) #this line is to print multiple lines with their values. print("Value of e =",e) print(...
3087842d19dd04c3db4510b32b21adae5e4620b8
balaramhub1/Python_Test
/Operators/membership_operator.py
388
3.96875
4
''' Created on Jun 6, 2020 Demonstrates the usage of membership operators : in, not in @author: beherb2 ''' l1=[10,20,30,40,50] if(100 in l1): print("Element is Available ") else: print("Element is not available") print(10 in l1) print(11 not in l1) s= "Hello how are you" print("String value is :",s...
fd1561a9a0a9c1cf29c24efbf299c0e3e135fa19
balaramhub1/Python_Test
/Tuple/Tuple_03.py
668
4.125
4
''' Created on Jul 17, 2014 @author: HOME The script is to see the function of T.index[x] and T.count(x) methods of Tuple ''' list1=['hello','balaram'] color = ("red","green","blue",list1) fruit =(5,"lemon",8,"berry",color,"grapes","cherry") numtup=(4,6,3,2,5,23,3,2,4,2,3,5) print("Elements of List1 are : ",...
03c942b5e496d6ffab0b3b0e08230ec1198c09c5
balaramhub1/Python_Test
/MathScripts/reverseString.py
319
3.984375
4
''' Created on Jan 29, 2015 @author: rocky Script to reverse a String ''' st=input("Enter the String : ") ts=[] stlen=len(st) stlen2=stlen print("String length is :",stlen) for i in range(stlen2-1,-1,-1): for j in range(1,stlen): ts.append(st[i]) break ts=''.join(ts) print(ts)
48a7625686c975de87b6b3fe22a3359baf78df38
balaramhub1/Python_Test
/Basic Printing/output_01.py
704
3.75
4
''' Created on Mar 22, 2014 Check for output_01 @author: ROCKSTAR ''' # This script is to check string output and print function. print("hello") str1='hi' print(str1+" "+str1) # shows how string concatenation works print('hello how are you') print("this is python multiline printing \n") # adds a newline after...
195297747cb5f6b1f00adbc5604593717a47f9da
balaramhub1/Python_Test
/Functions/Function_04.py
1,388
4.09375
4
''' Created on Jun 14, 2020 Default parameters in Functions Ex: create a function to generate a password of 8 char length 1 - upper case char 1 - lower case char 1 - special char 5 - digits @author: beherb2 ''' import random # ASCII representations of English characters print(ord("a")) print(ord("z")) print(ord("A"...
9ba5157b7b7ee295f0c367941ddd7de63364d614
balaramhub1/Python_Test
/Lists/List_03.py
500
3.75
4
''' Created on Jul 19, 2014 @author: HOME # Script to see list methods 1) l.append(x), 2) l.count(x), 3) l.extend(m), 4) l+=m, 5) l.index(x,star,end) ''' lista=['a',3,'c','a','tiger'] listb=['inta','charb'] listc=['b','c','e',2,8,'f','h','j','c',(1,2),'c',['d','c','y']] print(lista) lista.append(7) print(l...
cd4a7c75ba7b2c9846f7bca2811e54d03384ec14
balaramhub1/Python_Test
/For_loop/for_02.py
214
4.03125
4
''' Created on Aug 15, 2014 @author: rocky Script to demo "for" loop with range ''' dict1={'x':1,'y':2,'z':3} print("Dictionary dict1 = ",dict1) for key in dict1: print(key," ",dict1[key])
bd2ca872c954096e50e818e402969a3bc9a1ff8b
balaramhub1/Python_Test
/Math/math_03.py
394
4.125
4
''' Created on Jun 14, 2020 Usage of Random module @author: beherb2 ''' import random print(random.random()) # Choose a random number from a list l=[1,2,3,4,5,6] print(random.choice(l)) # generate a random number between a range print(random.randint(10,100)) # end number is not included print(random.randrange(10...
2367490f5dcbbf6e4715f976bb604eca5a209f16
balaramhub1/Python_Test
/Dictionary/dicttest_03.py
470
3.6875
4
''' Created on May 14, 2014 @author: rocky ''' prices={"banana": 4, "apple": 2, "orange": 1.5, "pear": 3} stock={"banana": 6, "apple": 0, "orange": 32, "pear": 15} new_stock={} flist=["banana","apple","orange"] print(prices) print(stock) print(flist) total=0 for k in flist: #for k in stock: ...
ebe13098b0271407fa817d2b77f2b9e2bd85fcca
balaramhub1/Python_Test
/While/while_01.py
269
3.78125
4
''' Created on Jul 23, 2014 @author: HOME ''' x=0 total=0 y=input("Enter the Number : ") print(y.isdigit()) y=int(y) while(x<=y): total+=x print("Value of x is : ",x) print("Value of Sum is : ",total) x=x+1 print("Thank you..!!")
1c15eda3173f904da53c5773f45ae424e68e0c9e
balaramhub1/Python_Test
/Basic Printing/output_03.py
384
3.609375
4
''' Created on May 2, 2014 @author: ROCKSTAR Script to check String operation ''' pyg = 'ay' original = input("Enter a word: ") if len(original) > 0 and original.isalpha(): print(original) else: print ("empty string") word=original.lower() wl=len(word) first=word[0] print(first) print(word[1:le...
4a407d2f3487100a611ee5231ace88cdec2387ec
balaramhub1/Python_Test
/File_Operation/file_operation_03.py
413
3.609375
4
''' Created on Aug 17, 2014 @author: rocky Script to demo "seek()" function while file reading. ''' fopen=open('test1.txt','r') print(fopen.read()) fopen.seek(4) 'seek() takes the control to the specified position in the file.' print(fopen.readline()) fopen.close() print("Reading text file content using Fo...
157b8d0e211a2b44bec4d3e7103dd7c19b6b606a
balaramhub1/Python_Test
/String Formatting/String_Format_03.py
541
3.875
4
''' Created on Jan 23, 2020 @author: beherb2 ''' # demonstration of String formating using sep parameter x=10 y=14 print("{0} + {1} = {2}".format(x,y,x+y)) print("hello","world",sep="hhhh") print("hello","world",sep="---hhhh+++") print("hello","world",sep="") print("hello","world") # String formating using %s,%d.....
56a05e498d6f99db60631e94b398fc2a0927373a
balaramhub1/Python_Test
/System_Tools/directory_01.py
592
3.765625
4
''' Created on Sep 4, 2014 @author: rocky Script to display current directory by using import.os ''' import os '''prints the current working directory''' print(os.getcwd()) '''prints the constant string used by os to refer to current directory''' print(os.curdir) ''' prints the list of files/directories in ...
6a8bd7b8e591172caf5a572d7bbadc30d9aafc97
iamnotaturtle/games
/sloankelly/tictactoe.py
2,039
4.09375
4
#!/usr/bin/python3 board = ['1', '2', '3', '4', '5', '6', '7', '8', '9'] currentToken = 'X' winningToken = '' slotsFilled = 0 print('Tic Tac Toe') print('Match 3 lines vertically, horizontally or diagonally') print('X goes first') def printBoard(board): print("\n") print("%s|%s|%s" % (board[0], board[1], bo...
d31716272844475556d67a0a957f97f4d8703d5c
llllmatinllll/Python_Questions
/فصل1/5-شاخص وزش باد/شاخص وزش باد.py
257
3.828125
4
import math v = float(input("Input wind speed in km/h: ")) t = float(input("Input air temperature in degrees Celsius(C): ")) wci = 13.12 + 0.6215*t - 11.37*math.pow(v, 0.16) + 0.3965*t*math.pow(v, 0.16) print ("The wind chill index is", int(round(wci, 0)))
4bdb920268fc589a7dd7b2b6f6f6bdb95265a4f4
llllmatinllll/Python_Questions
/فصل1/17-ارزش پول/ارزش پول.py
213
3.703125
4
amt = int(input("Enter amount: ")) rate = float(input("Enter rate: ")) years = int(input("Enter years: ")) future = amt * ((1 +(0.01*rate ) ** years)) print("Future_value is %12.0f" %(future))
ac5a8637d71a753eaf34363285b60bc8b4b5136f
markzhang90/General_Al
/mutiply_long_int/mutiply_long.py
504
3.59375
4
__author__ = 'mark' # mutiply big int int_one = [1, 2, 3, 4, 5] int_two = [5, 4, 3, 2, 6] def multiply_long(first, second): first.reverse() second.reverse() z = [0] * (len(first) + len(second)) for i in range(len(first)): for j in range(len(second)): z[i + j] += first[i] * second...
febd9ca05d96ebbfbc854f78f564faa8aa0e35bb
markzhang90/General_Al
/mirror_tree/mirror_tree.py
846
4.03125
4
class node: left = None right = None def __init__(self, value=None): self.value = value def getValue(self): return self.value def swap_node(n): if n is not None: tmp = n.left n.left = n.right n.right = tmp swap_node(n.left) swap_node(n.rig...
be90aefcc14d365e1058f12a56e620941781aed2
markzhang90/General_Al
/substring/substring.py
1,790
3.59375
4
__author__ = 'mark' str1 = "Geeksdas" str2 = ":Geeksdas" class Longest: max_value = 0 def longest_sub_string(self, str1, str2, i, j, temp): str1_len = len(str1) str2_len = len(str2) if i >= str1_len: return 0 if j >= str2_len: return 0 if str1[i...
fc7c9359e3f48af483e839e5df7d1fc4fa140815
nitin-gera/MathFunctions
/math_functions.py
554
3.515625
4
# -*- coding: utf-8 -*- """ Created on Tue Sep 25 09:18:36 2018 @author: nitingera """ import math import random value1 = 100 value2 = 250.5 print(int(value2)) print(float(value1)) diff = value1 - value2 print(diff) absolute_diff = abs(diff) print(absolute_diff) print(math.ceil(diff)) print(math.floor(diff)) pri...
1023042d78dacd2e03d0fae5b1fc63426e9bba9b
cyrmax/VK-Ordnung
/actions/WallCleaner.py
1,287
3.546875
4
from time import sleep def cleanEntireWall(api): answer = input("WARNING!!! This action will delete EVERY post on your VK wall! If you want tto continue, enter 'sure' and press enter. To go back type anything else and press enter.") if answer != "sure": return response = api.wall.get(count=100, offset=0) if...
9b1e5b1a994bc633e8eabe5131f79db0bbfd2c21
jage6277/Portfolio
/Discrete Structures/Unsorted to Sorted List.py
1,559
4.21875
4
# This function takes two sorted lists and merges them into one sorted list # Input: L1,L2 - Two sorted lists # Output: L - One sorted list def merge(L1,L2): L = [] # Array where the sorted list will be stored while len(L1) != 0 and len(L2) != 0: # While L1 and L2 are both nonempty if ...
aa3bbd65e921ceb9c0824643e4fe4d7a7b817f93
SaintClever/ninja_turtling_with_python
/ninja_turtle_flower.py
454
4
4
import turtle # import the module from turtle import Turtle, Screen # from the turtle module import the turtle class # print(turtle, turtle.Turtle()) timmy = Turtle() # create timmy object print(timmy) timmy.shape('turtle') timmy.color('Red') timmy.speed(10) for loop in range(36): timmy.forward(100) timmy....
273260c01459b18a630a5880a8325180cf8dd7ea
newtonis/TuxWorld-3
/main.py
3,844
3.625
4
#Edicion: 1 #Por: Dylan #Cree el sistema para crear la pantalla, junto con el sistema de actualizacion de eventos y puse para que la pantalla sea redimencionable y agregue algunos comandos basicos #Edicion: 2 #Por: Ariel #agrege modificaciones para el cambio cursor #Edicion: 3 #Por: Dylan #Agregue la posibilidad de po...
0d3c9bd9ae5d229c824490453a87f3bac2cdb8ce
GriffinBabe/Hackaton_2021
/resources/teams/hw/my_ai.py
3,087
3.875
4
"""=========================================================================== hackaton best 2021: IA Challenge L°Nakira@Hwtechs ============================================================================""" from src.game.entities import Team, Monkey, Queen from src.game.board import Board from src.game.geo import Vec...
8ce47615351ee85ecc29248260c30bfd3d7d62f9
GriffinBabe/Hackaton_2021
/src/ai/interface.py
3,092
3.875
4
""" Interface files containing the functions necessary to run the AI on the game """ from abc import abstractmethod, ABC from src.game.board import Board from src.game.entities import Team from src.game.command import Command import random class GameInterface(ABC): """ Game Interface base class used to adapt ...
100777015016e6a604c1cf3e3bf996fe55be5f2a
rahosbach/advent-of-code
/my_utils.py
489
3.96875
4
import math import re def get_ints_from_string(string): """Method to grab all integers from a string.""" return list(map(int, re.findall(r"-?\d+", s))) # thanks mcpower! def get_distance_between_points(point1, point2): """Calculates Euclidean distance between two points of any dimension, assuming th...
49b0924501e29a5ae88a370c2d0c30fae60cc1d6
dgander000/notes
/autonomous-drone/Collinearity.py
2,177
4.09375
4
#!/usr/bin/env python # coding: utf-8 # ## Collinearity Check # Collinearity for any three points can be determined easily by taking the determinant of a matrix containing the points. # In[1]: # Define Points (feel free to change these) # By default these will be cast as int64 arrays import numpy as np p1 = np.arra...
cab411617a860c3b0af0297100fd1c7aa9580aac
Harryharries/pythonlearningnote
/Pendulum.py
2,276
3.59375
4
# -*- coding: utf-8 -*- """ Created on Wed Sep 19 18:12:38 2018 @author: js """ # The simple pendulum # Equation of motion: d^2phi/dt^2 = -g/l*sin(phi) import numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation # Define constants g=9.81 # in m/s^2 l=5 # pendulum length in meter phi0...
3c704bb94fd05123b0d5576ce87bbc032cbd4799
k2room/2018-OOP-Python-Soccer
/displayV2.py
4,575
3.5625
4
# -*- coding: utf-8 -*- import pygame WHITE = (255,255,255) dis_width = 754 dis_height = 386 def player_move(x, y): global dis, P1 dis.blit(P1, (x,y)) def ball_move(x, y): global dis, ball dis.blit(ball, (x,y)) def direction(x, y, ball_x, ball_y): if x - ball_x > 0: if y- ...
7fc0098826ecb5e1611f55dccff86d0c7db9fd9a
Silveragent69/Prog_1_beadando
/feladat_41.py
421
3.625
4
list = [] db = 0 while True: str = input() if str == "end": break list.append(str) mgh = "aeiouAEIOU" for i in list: for j in i: if j in mgh: db += 1 avg = db / len(list) print("Átlagos magánhangzószám: ", avg, "\nSzavak:") for i in list: db = 0 for ...
18e4bdd151f34616d3f91dfc1c23295072e13b64
Jyoti-27/Python-7
/Python Session 7.txt
6,568
4.5
4
#!/usr/bin/env python # coding: utf-8 # - Conditional Statement and Loops # In[4]: credentials = {'Rohith':'rohith123', 'Virat':'virat123', 'Sharma':'sharma123', 'Kohli':'kohli123', 'Dhoni':'dhoni123', 'Yuvi':'yuvi123' } pri...
acd02c8b512d4bbd8ba5ac4c3218f78cdae595db
irtyamine/Python_Data_Structures_Algorithms
/Algorithms/merge_sort_exercise.py
1,511
3.84375
4
def merge_sort(arr, key, descending = False): if len(arr) <= 1: return arr mid = len(arr) // 2 left = arr[:mid] right = arr[mid:] left_list = merge_sort(left, key, descending) right_list = merge_sort(right, key, descending) return merge_two_sorted_list(left_list, right_list, key, ...
bd9544a6353c18f0f48e16eaeb0e0118a7cf169f
colinzyj/Cadmin
/utils/pagelist.py
1,831
3.515625
4
# encoding: utf-8 import math import gconf class PageList(object): # 默认分页大小 _default_page_size = gconf.PAGESIZE # 最大页数 _max_page_select = 5 @classmethod def create_pagelist(cls, pagenum, pagesize, totalnum): # 分页大小 _page_size = int(pagesize) if str(pagesize).isdigit() else cl...
6cc4173f190ced84628936cf6e1bd46d888698e1
mareizaa/holberton-system_engineering-devops
/0x16-api_advanced/1-top_ten.py
662
3.578125
4
#!/usr/bin/python3 """ Queries the Reddit API and prints the titles of the first 10 hot posts listed for a given subreddit """ import requests def top_ten(subreddit): """ Prints the titles of the first 10 hot posts """ url = 'https://www.reddit.com/r/{}/hot.json'.format(subreddit) r = requests.get...