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
29240ab6e69652738d220283183acb439879ada0
utsav-195/python-assignment
/problem1.py
1,003
3.875
4
def validate(password): condition = [0, 0, 0, 0, 1] # for testing all the four criterias for i in password: if ord(i) >= ord('A') and ord(i) <= ord('Z'): # checking for capital alphabet condition[0] = 1 elif ord(i) >= ord('a') and ord(i) <= ord('z'): # charcking for small alp...
f1c745b6786930254c938f7be7afbab341253872
roguishmountain/dailyprogrammer
/challenge228.py
536
3.75
4
lwords = ['billowy', 'biopsy', 'chinos', 'defaced', 'chintz', 'sponged', 'bijoux', 'abhors', 'fiddle', 'begins', 'chimps', 'wronged'] for word in range(len(lwords)): bInOrder = True bRInOrder = True for char in range(len(lwords[word])-1): if lwords[word][char] > lwords[word][char+1]: bInOrder = False elif ...
6e39b7628ea2e62d8a0da616c94ccb8195d73cc6
MalachiBlackburn/CSC121new
/functions.py
1,597
4.0625
4
def addition(): first=int(input("Enter your first number: ")) second=int(input("Enter your second number: ")) add=first+second print(first, "+", second, "=", add) def subtraction(): first=int(input("Enter your first number: ")) second=int(input("Enter your second number: ")) sub=fi...
ed0df19d54dd286b6996146454fa108b3d73adf3
tinayating/Leetcode
/Python/121. Best Time to Buy and Sell Stock.py
465
3.53125
4
import math class Solution: def maxProfit(self, prices): """ :type prices: List[int] :rtype: int """ if len(prices) == 0: return 0 minPrice, maxProfit = prices[0], -math.inf for p in prices: minPrice = min(p, minPrice)...
195d83bbefa65c664cbbbc9446984ba007e3d81c
valerio-oliveira/edx_cd50_python_javascript
/03_python/loops.py
78
3.734375
4
# a basic loop #for i in [0,1,2,3,4,5]: for i in range(10,15): print (i)
46af2af08a021f4a646df6debfe9a6fd28843d0d
awstown/PHYS200
/Chapter12/Chapter12.py
1,983
4.0625
4
# -*- coding: utf-8 -*- # Chapter 12 Exercises: 12.1, 12.2, 12.3 # Dwight Townsend # Phys 400 - Spring 2012 - Cal Poly Physics # imports import random # Exerise 12.1 def sumall(*args): return sum(args) print sumall(1, 3, 5, 7, 9) # Exercise 12.2 def sort_by_length(words): t = [] for word in words: ...
537ddca25824fd995727cbb026fecefa5bdcaf8b
wkomari/Lab_Python_04
/data_structures.py
1,383
4.40625
4
#lab 04 # example 1a groceries = ['bananas','strawberries','apples','bread'] groceries.append('champagne') print groceries # example1b groceries = ['bananas','strawberries','apples','bread'] groceries.append('champagne') # add champagne to the list of groceries groceries.remove('bread') # remove bread from the lis...
39c80f04366d2381fa04b4b851cca2ba58a1cb26
Only8Bytes/Python-Programs
/Final Project.py
1,837
3.703125
4
import operator def palindrome(a): if str(a) == str(a)[::-1]: return "yes" return "no" def nearPrime(a): val = 0 for i in range(2, int(a) - 1): if (int(a)/i) % 1 == 0 and int(a)/i != i: val += 1 if val > 2: return "no" return "y...
566a189b7b5fff577335764813be64f9dabfaaee
jayson-s/csci1030u
/Test1_Question4.py
278
3.546875
4
# -*- coding: utf-8 -*- """ Created on Thu Oct 19 11:12:52 2017 @author: Jayson """ def drawParallelogram(numRows, numCols): for rows in range(numRows, 0, -1): print(' ' * (numRows - rows) + '*' * (numRows)) drawParallelogram(10, 8)
3c4f2f635ffb56ddec52a1ea4b0fb59fc9dafad5
jayson-s/csci1030u
/Test2_Question1a.py
769
3.796875
4
#Name: Jayson Sandhu #Student ID: 100659589 #Question 1a import math class Rectangle: def __init__(self, width, length): self.width = width self.length = length def getLength(self): return self.length def getWidth(self): return self.width def getArea(self)...
fcd2821ec8109d3270d9c73e4c06ace969bb7782
jayson-s/csci1030u
/Jayson_Lab6.py
5,276
3.921875
4
#Jayson Sandhu, 100659589 #Declare Variables and Initialize with values partyNames = ['Krogg', 'Glinda', 'Geoffrey'] partyHP = [180, 120, 150] partyAttack = [20, 5, 15] partyDefense = [20, 20, 15] partyDead = [False, False, False] bossAttack = 25 bossDefense = 25 bossHP = 500 round = 1 class Charact...
fcbe70e27eaba61f35abb918ffcb7cc55bd11066
nhan1361992/python
/helloworld.py
137
3.671875
4
print ("begin") arrs = [] for i in range(20,35) : if ((i%7 == 0) and (i%5 != 0)) : arrs.append(str(i)) print(','.join(arrs))
84e31e9c440bdcc0b6e101ee8739a721f388ce07
GurmanBhullar/hactoberfest-Projects-2020
/Hackerrank-Python/designerdoormat.py
512
3.890625
4
# Mr. Vincent works in a door mat manufacturing company. One day, he designed a new door mat with the following specifications: # Mat size must be X. ( is an odd natural number, and is times .) # The design should have 'WELCOME' written in the center. # The design pattern should only use |, . and - characters. n, ...
555913911bc903f7d407f39009ac136e3e281f72
GurmanBhullar/hactoberfest-Projects-2020
/Hackerrank-Python/Find angle MBC.py
210
3.96875
4
from math import acos, degrees, sqrt AB = int(input()) BC = int(input()) AC = sqrt(AB*AB + BC*BC) BM = AC / 2 angel = round(degrees(acos((BC * BC + BM * BM - BM * BM) / (2.0 * BM * BC)))) print(str(angel)+'°')
075c6e5733adf3dec09c3337f42806a51ed524ad
mohamed-minawi/KNN-LLS
/KNN.py
1,310
3.84375
4
import numpy as np class KNN(object): def __init__(self): pass def train(self, Data, Label): """ X is N x D where each row is an example. Y is 1-dimension of size N """ # the nearest neighbor classifier simply remembers all the training data self.train_data = Data self....
db7b6be5a8c25fff421436696ad1d332fa367a66
CamiloSaboA-csv/problemas_HackerRank
/Strings_Making_Anagrams.py
352
3.609375
4
def makeAnagram(a, b): # Write your code here from collections import Counter a,b=list(sorted(a)),list(sorted(b)) a_count=Counter(a) b_count=Counter(b) x=((b_count-a_count)+(a_count-b_count)).values() x=sum(x) return x a,b= 'faacrxzwscanmligyxyvym','jaaxwtrhvujlmrpdoqbisbwhmgpm...
262ec8a9fc2241422d79720605e903e873c25d4e
BLOODMAGEBURT/exercise100
/data-structure/sort-search/5.9.插入排序.py
1,522
3.96875
4
# -*- coding: utf-8 -*- """ ------------------------------------------------- File Name: 5.9.插入排序 Description : Author : Administrator date: 2019/10/12 0012 ------------------------------------------------- Change Activity: 2019/10/12 0012: --------------------------...
b1ab6571086c0867dabdfee9970348aee716dbe5
BLOODMAGEBURT/exercise100
/exercise/exercise5.py
532
3.9375
4
# -*- coding: utf-8 -*- def sort_method(alist): """ 给一个list排序,从小到大 :param alist: :return: """ assert isinstance(alist, list) new_list = sorted(alist) return new_list if __name__ == '__main__': print(sort_method([2, 7, 5, 10, 4])) """ 按学生年龄大小排队,从小到大 """ students =...
3fb4a522861fca51b2f54d48c9cc9c28120280aa
BLOODMAGEBURT/exercise100
/exercise/exercise12.py
988
3.921875
4
# -*- coding: utf-8 -*- """ ------------------------------------------------- File Name: exercise12 Description : Author : burt date: 2018/11/7 ------------------------------------------------- Change Activity: 2018/11/7: ---------------------------------------------...
4712a8abf07cb2927fbb8695e3764f0590e87dd9
BLOODMAGEBURT/exercise100
/exercise/exercise7.py
583
3.75
4
# -*- coding: utf-8 -*- """ ------------------------------------------------- File Name: exercise7 Description : Author : burt date: 2018/11/6 ------------------------------------------------- Change Activity: 2018/11/6: ----------------------------------------------...
2539e1965cf3e3df19acc8c1e7a9f65c734a4c12
gelisa/sandbox
/working-with-spark/run_spark.py
2,129
3.8125
4
# run_spark.py """ a sandbox to test spark and learn how it works to run it: put some (at least a couple) text files to the data folder type in command line: python run_spark.py or <path to spark home folder>/bin/spark-submit run_spark.py to understand very basics of spark read: http://mlwhiz.com/blog/2015/09/07/Spark...
30850c4f1d5a5d986941cd04d8e17178e15a835d
johnabfaria/bambus.py
/main.py
771
3.8125
4
import pic_it import tweet_it import txt_it import drop_it import pin import time """ This is the main program that will use pin to id inputer from raspberry pi using RPi.GPIO If input from IR motion sensor is positive, camera will be activated, photo snapped and saved locally Photo will be tweeted and then uploaded ...
fe957545e1dc512e5d3a2a28defc654281ae82ee
YunYouJun/python-learn
/primer/first_program.py
437
3.984375
4
def isEqual(num1, num2): if num1 < num2: print(str(num1) + ' is too small!') return False elif num1 > num2: print(str(num1) + ' is too big!') return False else: print('Bingo!') return True from random import randint num = randint(1, 100) print('Guess what I...
87de1f7da5274947664161b3e54d2913720b59e9
Om-Jaiswal/Python
/Python_Programs/FizzBuzz.py
643
4.03125
4
# for number in range(1,101): # if number % 3 == 0 and number % 5 == 0: # print("FizzBuzz") # elif number % 3 == 0: # print("Fizz") # elif number % 5 == 0: # print("Buzz") # else: # print(number) print("Welcome to FizzBuzz!") Fizz = int(input("Enter a number for fizz :\n")) Buzz...
c0549fa722759a574c69585d0e0767c47d8d1be1
Om-Jaiswal/Python
/Python_Programs_OPP/Dash_Square.py
326
3.5
4
import turtle as t from turtle import Screen tim = t.Turtle() tim.shape("turtle") def dash_line(): for _ in range(15): tim.forward(10) tim.penup() tim.forward(10) tim.pendown() for _ in range(4): dash_line() tim.right(90) screen = Screen() screen.exitonc...
5f168aeaf97ebb2100fafcbaef59928522f86d70
sha-naya/Programming_exercises
/reverse_string_or_sentence.py
484
4.15625
4
test_string_sentence = 'how the **** do you reverse a string, innit?' def string_reverser(string): reversed_string = string[::-1] return reversed_string def sentence_reverser(sentence): words_list = sentence.split() reversed_list = words_list[::-1] reversed_sentence = " ".join(reversed_list) ...
4196ac75509c5eff3227c1e8bff9ad00cc83ddd0
frfanizz/PressureChess
/pressurechess.py
5,374
3.75
4
import sys from pieces import * ''' Considerations: allow buring pieces ''' class tile: """ (Board) tile objects """ def __init__(self, piece, hp = 6): """ Tile classs constructor :param self tile: the current object :param piece piece: the current object :param hp int: the current obj...
2e61bac1d6b08105532a2c34e96b98e5e6886b0f
rabahbedirina/HackerRankContests
/CatsandaMouse.py
207
3.65625
4
def catAndMouse(x, y, z): X = abs(x - z) Y = abs(y-z) if X < Y: cat = "Cat A" elif X > Y: cat = "Cat B" else: cat = "Mouse C" return cat catAndMouse(x, y, z)
0e599494c99b1d05d0162c5cf66b98f0b0301be1
rabahbedirina/HackerRankContests
/Big Sorting.py
526
3.625
4
def bigSorting(unsorted): for i in range(n): unsorted[i] = int(unsorted[i]) print(unsorted) list_sorted = sort(unsorted) print(list_sorted) for j in range(n-1): print(str(list_sorted[j])) return str(list_sorted[-1]) n = 6 unsorted = ['31415926535897932384626433832795', '1', '3...
a336bb76c0bce019135ea4a775ab09f434a5b01d
skyrusai/code_training
/others/FizzBuzz.py
327
3.96875
4
# -*- coding: utf-8 -*- """ Created on Tue Nov 13 09:44:32 2018 @author: shenliang-006 """ for l in range(101): if l==0: continue if l%3==0: if l%5==0: print("FizzBuzz") else: print("Fizz") elif l%5==0: print("Buzz") else: print(l) ...
e2584e9dda14afad7ca6aa5eebf4f23d56ac01f9
ardieorden/electrical_circuits
/circuit_initial.py
6,626
3.671875
4
import cmath import numpy as np import matplotlib.pyplot as plt from sympy import Symbol, simplify, Abs from sympy.solvers import solve from scipy.signal import sawtooth # We set our unknowns: vo, vr, ir, ic and il vo = Symbol("V_O") vr = Symbol("V_R") ir = Symbol("I_R") ic = Symbol("I_C") il = Symbol("I_L") r = Sy...
18fae6895c6be30f0a3a87531a2fafe965a3c89f
pkdoshinji/miscellaneous-algorithms
/baser.py
1,873
4.15625
4
#!/usr/bin/env python3 ''' A module for converting a (positive) decimal number to its (base N) equivalent, where extensions to bases eleven and greater are represented with the capital letters of the Roman alphabet in the obvious way, i.e., A=10, B=11, C=12, etc. (Compare the usual notation for the hexadecimal numbers....
60a99e1a6a1a8ab2c8a5827d36b891fdafb5035f
DimitrisParris/Bootcamp-AFDE
/Exercises in Python/ex.8(part2).py
290
3.703125
4
num = input("Give sequence of numbers:") sum = 0 for i in range(len(num)): if i%2 == 0 and i<(len(num)-1): a = int(num[i])*int(num[i+1]) sum+=a if len(num)%2 !=0 and i==(len(num)-1): sum += int(num[-1]) print("This is the sum of the sequence:", sum)
653e3c2184e36a5a05ea9e77d7f8214e4be9d770
DimitrisParris/Bootcamp-AFDE
/Exercises in Python/ex.2(part 2).py
410
3.703125
4
number=input('Give 8-bit number:') num=str(number) if len(num)!=8: print('Not an 8-digit number. False. Check again.') else: neo=num[:7] print(neo) sum=0 for i in neo : if int(i)==1: sum+=1 if sum%2==0 : print('sum even') else : print('sum odd') if (int...
5d9d9ee735c83028145dda4bbc9a615cab916d6c
DSJ-23/DS_Algorithms
/valid_parenthesis.py
1,039
3.890625
4
from stack import Stack class Solution: def isValid(self, s): valid = Stack() for p in s: if p == "(" or p == "[" or p =="{": valid.add(p) # elif p == ")" or p == "]" or p == "}": print(valid.get_stack()) return True a= Solu...
7c53f978351f9de8b446810c5fbd0d87160806cf
DSJ-23/DS_Algorithms
/DS/queue.py
316
3.5
4
class Queue: def __init__(self): self.data = [] def push(self, x: int) -> None: self.data.append(x) def pop(self): return self.data.pop(0) def peek(self): return self.data[0] def empty(self): return bool(self.data == [])
28b99002de36b734fe2f53b72ac863075f594ebc
DSJ-23/DS_Algorithms
/all_duplicates.py
549
3.578125
4
class Solution: def findDuplicates(self, nums): for i in range(1, len(nums) +1): if i in nums and nums.count(i) == 1: nums.remove(i) elif i in nums and nums.count(i) > 1: self.remove_nums(nums, i) else: continue retu...
d7cae30b5df626903234bce52cde315a602603cb
DSJ-23/DS_Algorithms
/binary_search.py
495
3.671875
4
a = list(range(1001)) def binary_search(nums, num): lower = 0 upper = len(nums) - 1 mid = 0 while lower <= upper: mid = (lower + upper)//2 # print(nums[mid]) if nums[mid] > num: upper = mid -1 elif nums[mid] < num: lower = mid + 1 ...
becb9a7d85b964a23e2a9e416b3654a2a4e8b7d5
tomchor/scivis
/plots/ex0/ex0.py
665
3.9375
4
import numpy as np from matplotlib import pyplot as plt # Create some made up simple data y1=[1,4,6,8] y2=[1,2,3,4] # Create a new figure with pre-defined sizes and plot everything plt.figure(figsize=(3,4)) plt.plot(y1) plt.plot(y2) plt.savefig('bad_ex.pdf') plt.close('all') # Create another figure with defined size...
c901957b592edc23c8b162ab5483e8f005bf3de2
cbrandao18/python-practice
/math-practice.py
564
4.0625
4
import math numbers = [5, 8, 27, 34, 71, 6] n = len(numbers) def getSum(numbers): summation = 0 for num in numbers: summation = summation + num return summation def getSD(numbers): avg = getSum(numbers)/n numerator = 0 for num in numbers: numerator = numerator + (num - avg)**2...
fe03952ad6982e0e51a9218b01dc9231df641b41
cbrandao18/python-practice
/celsius-to-f.py
226
4.1875
4
def celsiusToFahrenheit(degree): fahrenheit = degree*1.8 + 32 print fahrenheit celsiusToFahrenheit(0) celsiusToFahrenheit(25) n = input("Enter Celsius you would like converted to Fahrenheit: ") celsiusToFahrenheit(n)
edeff33f8b00a449bab826aa2b05a50108ea335f
luciengaitskell/csci-aerie
/csci0160/3-data/athome3_sorting_algos.py
6,579
4.15625
4
""" Sorting Algos Handout Due: October 7th, 2020 NOTES: - Reference class notes here: https://docs.google.com/document/d/1AWM3nnLc-d-4nYobBRuBTMuCjYWhJMAUx2ipdQ5E77g/edit?usp=sharing - Do NOT use online resources. - If you are stuck or want help on any of them, come to office hours! Completed by Lucien Gaitsk...
a07ada7c787f741ef1884b2a455b69fdab98f28c
Nawod/Hactoberfest2021-1
/Python/Guess_Number_Game.py
1,416
4.03125
4
import random import sys print('GUESS THE NUMBER') #function for genarate random numbers according to the levels def level(lvl): global randNo if lvl == 'E': randNo = random.randint(1,10) print('Guess a number between 1 & 10..') elif lvl == 'N': randNo = random.randint(1,20) ...
8040f07a2775078bcdc058cd58e49ef3c9fc2f96
lydxlx1/icpc
/src/codeforces/_1131F.py
883
3.5625
4
"""Codeforces 1131F Somehow, recursive implementation of Union-Find Algorithm will hit stack overflow... """ from sys import * n = int(stdin.readline()) parent, L, R, left, right = {}, {}, {}, {}, {} for i in range(1, n + 1): parent[i] = i L[i] = R[i] = i left[i] = right[i] = None def find(i): root...
c49b8274518bd59b4ba0fdfc75e6370afaec562b
lydxlx1/icpc
/src/adventofcode/2021_04.py
2,430
3.53125
4
import sys import math def readln_str(): return input().split(" ") def readln_int(): return [int(i) for i in readln_str()] class Board: def __init__(self, A): self.A = A self.visited = [ [False for _ in range(len(A[0]))] for _ in range(len(A))] def place(self, num): A = sel...
36f9546b9a292d58f205ff22c9895fa65b0a70d9
Meldanen/kcl
/scientific_programming/algorithm_optimisation/pathing.py
10,269
3.578125
4
from itertools import chain import math from algorithmType import AlgorithmType import numpy as np def getAdjustedImageArray(image, algorithmType, size=None): """ Returns an image with the best path based on the selected method :param image: The image from which we'll look for the best path :param siz...
4b01cbf0895f080bfee152a52c3bcceed8b2df6e
nicoleta23-bot/instructiunea-if-while-for
/prb2.py
151
3.921875
4
import math n=int(input("dati numarul natural nenegativ n=")) s=0 for i in range (1,n+1): s+=(math.factorial(i)) print("suma 1!+2!+...n!= ",s)
1a7fcc21c19fe743f7517e5221b4de3fe871cf7c
tbgdwjgit/python3
/baseTest/first.py
6,425
4.15625
4
__author__ = 'Test-YLL' # -*- coding:utf-8 -*- import os print("Hello Python interpreter!") print("中文也没问题!") print('翻倍'*3) print('45+55') print(45+55) #注释 ''' 多行 print("Hello World") print('What is your name?') # ask for their name myName = input() print('It is good to meet you, ' + myName) print('The length of you...
ebc8d4374db54e557755d67cfe9d39631575fb3e
chm7374/linera_algebra_final
/linear_algebra_final/main.py
3,078
3.625
4
import numpy as np import fractions def create_matrix(): print("2x2 matrix:\n[ m11 m12 ]") print("[ m21 m22 ]") m11 = float(input("Enter the value of m11: ")) m12 = float(input("Enter the value of m12: ")) m21 = float(input("Enter the value of m21: ")) m22 = float(input("Enter the ...
5c9d24c0cc24a7f0346fe7cee3239a467c51dd6d
zainiftikhar52422/Perceptron-learning-gates-given-theta
/perceptron learning And gate.py
1,127
3.71875
4
import random def andGate(): # Or gate Learning # in and gate you can increase decimal points as much as you want weight1=round(random.uniform(-0.5,0.5), 1) # to round the out to 1 decimal point weight2=round(random.uniform(-0.5,0.5), 1) # to round the out to 1 decimal point print("Weighte...
3009d64a201ffd4616985588111ec747f510925c
m-blue/prg105-Ex-16.1-Time
/Time.py
331
4.09375
4
class Time(): """ This will hold an object of time attributes: hours, minutes, seconds """ def print_time(hour, minute, sec): print '%.2d:%.2d:%.2d' % (hour, minute, sec) time = Time() time.hours = 4 time.minutes = 30 time.seconds = 45 print_time(time.hours, time.minutes, time...
2cee626ca8bbdd1c78751e9df019279d323d1e06
Philngtn/pythonDataStructureAlgorithms
/Arrays/ArrayClass.py
1,291
4.15625
4
# # # # # # # # # # # # # # # # # # # # # # # # # Python 3 data structure practice # Chap 1: Implementing Class # Author : Phuc Nguyen (Philngtn) # # # # # # # # # # # # # # # # # # # # # # # # class MyArray: def __init__(self): self.length = 0 # Declare as dictionary self.data = {}...
e96d19e436a77fcca9e16e143a81ea58eee15997
Philngtn/pythonDataStructureAlgorithms
/String.py
3,163
4
4
# # # # # # # # # # # # # # # # # # # # # # # # # Python 3 data structure practice # Chap 0: String # Author : Phuc Nguyen (Philngtn) # # # # # # # # # # # # # # # # # # # # # # # # # Strings in python are surrounded by either single quotation marks, or double quotation marks. print("Hello World") print('Hello Worl...
9fb22d73c2c5983d48283c648ab5ef1527cb4c1e
Philngtn/pythonDataStructureAlgorithms
/LinkedList/LinkedListClass.py
3,734
4.03125
4
# # # # # # # # # # # # # # # # # # # # # # # # # Python 3 data structure practice # Chap 3: Linked List # Author : Phuc Nguyen (Philngtn) # # # # # # # # # # # # # # # # # # # # # # # # from typing import NoReturn class Node: def __init__(self, data): self.value = data self.next = None ...
280fbe40b133e0b47f101f5855014fdb1fcb8815
Philngtn/pythonDataStructureAlgorithms
/Algorithm/Sorting/BubbleSort.py
338
4.0625
4
def bubble_sort(array): count = len(array) while(count): for i in range(len(array) - 1) : if(array[i] < array[i+1]): temp = array[i] array[i] = array[i + 1] array[i + 1] = temp count -= 1 a = [1,2,4,61,1,2,3] bubble...
875635c71286360aef3af5b485e87d195974fa32
sepej/162P
/Lab6/main.py
478
3.859375
4
# Joseph Sepe CS162P Lab 6B from helper import * def main(): employees = [] # get number of employees to enter print("How many employees work at the company?") num_employees = get_integer(5, 10) # create an employee and add it to the list for num_employees for i in range(num_employees): ...
bc1fb8b5ec979d6031e2dfaf934defff52e6d45b
sepej/162P
/Lab1/functions.py
4,197
4.03125
4
# Display instructions def display_instructions(): print('\nWelcome to Tic-Tac-Toe\nTry to get 3 in a row!') # Reset board, rewrites the board list with '' def init_board(board): for idx, value in enumerate(board): board[idx] = '' # Get the player name, Returns X or O # Adds the possibility of letting...
8557893e7488d2eb1993bbaf96b4e87a88a91bc4
sepej/162P
/Lab6/Sepe_Lab6A/employee.py
460
3.671875
4
from person import * class Employee: # init employee class composition def __init__(self, first_name = "", last_name = "", age = None): self.__person = Person(first_name, last_name, age) # return employee name def get_employee_name(self): return self.__person.get_first_name() + " "...
6470b470180117635b5e5515ee39d08951ca1118
Spencer-Weston/DatatoTable
/datatotable/typecheck.py
4,509
4.125
4
""" Contains type checks and type conversion functions """ from datetime import datetime, date from enum import Enum def set_type(values, new_type): """Convert string values to integers or floats if applicable. Otherwise, return strings. If the string value has zero length, none is returned Args: ...
f371d7904f943099dd17d251df171b63592d8c9c
hhost-madsen/prg105-drawingObject
/House.py
633
3.515625
4
import turtle bob = turtle.Turtle() alice = turtle.Turtle() def square(t): for i in range(4): t.fd(100) t.lt(90) square(bob) square(alice) def square(t, length): for i in range(4): t.fd(length) t.lt(90) square(bob, 100) def polygon(t, n, leng...
d3c36626dce89bafc3df9b8e63adaab05bdd4c30
etx77/protostar-write-up
/alpha.py
170
4.0625
4
#!/usr/bin/env python import string # this program is generate string to calculate return address text = "" for c in string.ascii_uppercase: text += c*4 print text
9d7b65b56e55b02b6ff598018da15c9ce16ac4e2
yitu257/pythondemo
/filterSquareInteger.py
902
3.765625
4
#过滤出1~100中平方根是整数的数: import math def is_sqr(x): return math.sqrt(x)%1==0 templist=filter(is_sqr,range(1,101)) newlist=list(templist) print(newlist) # 通过字典设置参数 site = {"name": "菜鸟教程", "url": "www.runoob.com"} print("网站名:{name}, 地址 {url}".format(**site)) print(globals()) #a=input("input:") #print(a...
ba97831c540e5109dd1cfe338c885f4004b191b8
avshrudai1/recommedation_engine_chrome
/main.py
1,044
3.625
4
# importing the module import pandas as pd import csv import numpy from googlesearch import search # taking input from user val = input("Enter your command: ") #splitting the command to subparts K = val.split() T = len(K) def queryreform(): search_name = 'Brooks' with open('tmdb_5000_movies.csv', 'r')...
b9bdcf609dd73187034012475399c0eda465fb79
yarlagaddalakshmi97/python-solutions
/python_set1_solutions/set1-4a.py
173
3.5
4
''' a) The volume of a sphere with radius r is 4/3pr3. What is the volume of a sphere with radius 5? Hint: 392.7 is wrong! ''' r=5 volume=(4/3)*3.142*(r*r*r); print(volume)
5ab66decbeb7f56a685d621d6eb7695d6021ac47
yarlagaddalakshmi97/python-solutions
/python_practice/cmd-args1.py
470
4.0625
4
from sys import argv if(len(argv)<3): print("insufficient arguments..can't proceed..please try again..") elif argv[1]>argv[2] and argv[1]>argv[3]: print("argument 1 is largest..") elif argv[1]>argv[2] and argv[1]<argv[3]: print("argument 3 is largest..") elif argv[2]>argv[1] and argv[2]>argv[3]: print("...
1b2b5047eaa337f94083a7b09e7b8103cc8170ca
yarlagaddalakshmi97/python-solutions
/python_practice/nested for loop.py
792
4.0625
4
''' for i in range(1,10): for j in range(1,i+1): print(i,end=" ") print("\n") for i in range(1,10): for j in range(1,i): print(j,end=" ") print("\n") for i in range(1,10): for j in range(1,i): print("*",end=" ") print("\n") for i in range(1,5): for j in range(1,5)...
9c3f2d4f7813d13d83db9c1b19108ac1dc2260ed
yarlagaddalakshmi97/python-solutions
/python_set3_solutions/set3-8.py
617
4.0625
4
''' 8.Write a function called is_abecedarian that returns True if the letters in a word appear in alphabetical order (double letters are ok). How many abecedarian words are there? (i.e) "Abhor" or "Aux" or "Aadil" should return "True" Banana should return "False" ''' def abecedarian(words): for i in words: ...
0606f08dfe5a4f9f41b38c60330ed5de7852c64e
yarlagaddalakshmi97/python-solutions
/python_practice/factorial.py
101
3.578125
4
def fact(n): if n>0: return 1 else: return n*fact(n-1) res=fact(7) print(res)
e3814888ad456dbcd5e9fc3ae048ff8395dfad80
yarlagaddalakshmi97/python-solutions
/python_set2_solutions/set2-6.py
790
4
4
''' 6.Implement a function that satisfies the specification. Use a try-except block. def findAnEven(l): """Assumes l is a list of integers Returns the first even number in l Raises ValueError if l does not contain an even number""" ''' ''' try: list1 = list(input("enter list of integers..:\n")) num = 0 ...
94c4554eea473193dff5415d66e7fe3253fd7d36
yarlagaddalakshmi97/python-solutions
/python_set2_solutions/set2-4.py
229
4.03125
4
''' 4.Write a program that computes the decimal equivalent of the binary number 10011? ''' string1='10011' count=len(string1)-1 number=0 for char in string1: number=number+(int(char)*(2**count)) count-=1 print(number)
7842f4fb35ab747fba9c8207b7eb4f1ec7a20a92
MDLR29/python_class
/entrenamiento.py
243
3.828125
4
np=int(input(" usuarios a evaluar: ")) lm=1 sumed=0 while lm<=np : genero=input(" cual es tu genero: ") edad=int(input("escriba su edad: ")) lm = lm + 1 sumed=sumed+edad promedio=sumed/np print("el promedioes: ",promedio)
b515031a176de8d788207e9a53fafa3ae2e86559
wnsdud4206/stockauto
/test2.py
809
3.5625
4
# from datetime import datetime # t_now = datetime.now() # t_9 = t_now.replace(hour=9, minute=0, second=0, microsecond=0) # t_start = t_now.replace(hour=9, minute=5, second=0, microsecond=0) # t_sell = t_now.replace(hour=15, minute=15, second=0, microsecond=0) # t_exit = t_now.replace(hour=15, minute=20, second=0,micr...
8e17ae60197afe42c01addf2cf79aafcae6cd01e
Abhra-Debroy/Udacity-ML-Capstone
/utilties.py
6,889
3.6875
4
## Disclaimer : Reuse of utility library from Term 1 course example ########################################### # Suppress matplotlib user warnings # Necessary for newer version of matplotlib import warnings warnings.filterwarnings("ignore", category = UserWarning, module = "matplotlib") # # Display inline matplotlib ...
358c68067412029677c59023d1f4b35af58c54ff
yuniktmr/String-Manipulation-Basic
/stringOperations_ytamraka.py
1,473
4.34375
4
#CSCI 450 Section 1 #Student Name: Yunik Tamrakar #Student ID: 10602304 #Homework #7 #Program that uses oython function to perform word count, frequency and string replacement operation #In keeping with the Honor Code of UM, I have neither given nor received assistance #from anyone other than the instructor. #--...
189da51101c163022df6d8b417da004cba11c649
annamunhoz/learningpython
/exercise01.py
476
4
4
# Exercise 01: create a python program that takes 2 values # and then select between sum and sub. Show the result. print("Submit your first number") first_number = float(input()) print("Submit your second number") second_number = float(input()) print("Choose the basic arithmetic: type SUM for sum or SUB for...
904398e1e75159b8047dc94757e5a7ac0dfb16e8
wxb-gh/py_test
/demo3.py
363
3.796875
4
# coding:gbk colours = ['red', 'green', 'blue'] names = ['a', 'b', 'c'] for colour in colours: print colour for i, colour in enumerate(colours): print i, ' -> ', colour for colour in reversed(colours): print colour for colour in sorted(colours, reverse=True): print colour for name, colour in zip(na...
7345117ef887ad5049d57e2688e1ce8d5601f001
AndrewsDutraDev/Algoritmos_2
/Tabelas/Teste.py
886
3.53125
4
from Tabelas import Table tamanho_tabela = 5 tabela = Table(tamanho_tabela) # Inicializa a tabela com tamanho 3 tabela.insert("xyz", "abc") #Insere um valor e uma key tabela.insert("dfg","dfb") #Insere um valor e uma key tabela.insert("ffg","dfb") #Insere um valor e uma key tabela.insert("hfg","dfb") #Insere um valor...
5ccf9390ee5678a3c21acbd019df5673c7ff08a5
AndrewsDutraDev/Algoritmos_2
/Recursão/recursao2.py
1,623
3.734375
4
# Busca Encadeada Recursiva def busca_encadeada(): if (len(lista) == 0): return else: if (lista[0] == produto): return cont else: cont = cont + 1 return busca_encadeada(lista[1:], produto, cont) # Busca Linear Recursiva def busca_linear_recursiva(list...
3b2a0f4b8f0a7c1f9e480ded60b1a2aaf2c75603
taniarebollohernandez/progAvanzada
/ejercicio7.py
85
3.6875
4
n = float(input('Inserta un numero positivo: ')) print('suma',int(((n*(n+1)/2))))
124e7250acd99e2668d71cf4717f0b54db63f7ab
taniarebollohernandez/progAvanzada
/ejercicio5.py
792
4.03125
4
#In many jurisdictions a small deposit is added to drink containers to encourage peopleto recycle them. In one particular jurisdiction, drink containers holding one liter or less have a $0.10 deposit, and drink containers holding more than one liter have a $0.25 deposit. Write a program that reads the number of contain...
de52a7dc06b7dcd402a07e8d76a00f487f5e84b8
kazimuth/python-mode-processing
/examples/misc/triflower/triflower.pde
999
3.65625
4
""" Adapted from the TriFlower sketch of Ira Greenberg """ # # Triangle Flower # by Ira Greenberg. # # Using rotate() and triangle() functions generate a pretty # flower. Uncomment the line "# rotate(rot+=radians(spin))" # in the triBlur() function for a nice variation. # p = [None]*3 shift = 1.0 fade = 0 fillCol...
f6a909d7e0d878aaf314109c6b594bc80964da83
LucasFerreira06/ExercicioProva4Dupla
/Questao2.py
1,306
3.921875
4
def adicionarSorteado(sorteados): numAdd = random.randint(0, 100) sorteados.append(numAdd) print(sorteados) def adicionarAluno(alunos, matricula, nome): alunos[matricula] = nome def exibirAlunos(alunos): for chave, valor in alunos.items(): print("Matricula:", chave, "Aluno:", val...
48c6bbe599a6444304766b3f23a51a43adb8103a
PrashantMittal54/Data-Structures-and-Algorithms
/String/Look-and-Say Sequence String.py
927
4.09375
4
# Look-and-Say Sequence # To generate a member of the sequence from the previous member, read off the digits of the previous member # and record the count of the number of digits in groups of the same digit. # # For example, 1 is read off as one 1 which implies that the count of 1 is one. As 1 is read off as “one ...
5e1c85a492b786dcb674a436f3bb7fb9ad6f8559
PrashantMittal54/Data-Structures-and-Algorithms
/LinkList/Deletion.py
1,778
3.796875
4
# Deletion by Value and Position class Node: def __init__(self, data): self.data = data self.next = None class Linklist: def __init__(self): self.head = None def delete_node_at_pos(self, pos): cur = self.head if pos == 0: self.head = c...
19013fbbb00b4c43c334ccf48a52b13c278932ee
PrashantMittal54/Data-Structures-and-Algorithms
/LinkList/Move Tail to Head.py
1,023
3.859375
4
class Node: def __init__(self, data): self.data = data self.next = None class Linklist: def __init__(self): self.head = None def append(self, data): new_node = Node(data) curr = self.head if curr is None: self.head = new_node ...
db4df4d10e3392349cb74bb36f5614c794e59eff
PrashantMittal54/Data-Structures-and-Algorithms
/Array/Arbitrary Precision Increment Array.py
353
3.65625
4
def plus_one(A): A[-1] += 1 carry = 0 for x in range(1,len(A)+1): if (A[-x] + carry) == 10: carry = 1 A[-x] = 0 else: A[-x] += carry break if A[0] == 0: A[0] = 1 A.append(0) return A print(plus_one([2,9...
5ee72868552ba9c802f653357564b241c00ca020
bsspirit/mytool
/src/md5_rdict.py
282
3.875
4
# -*- coding: utf-8 -*- #读字典文件 def dict_read(file): lines = [] f = open(file,"r") line = str(f.readline()) lines.append(line.split(',')) while line: line = f.readline() lines.append(line.split(',')) f.close() return lines
e5098b5399a500afcf7d5c140b2a5aed46d613f7
hdjewel/Markov-Chains
/lw_markov.py
3,792
3.765625
4
#!/usr/bin/env python from sys import argv import random, string def make_chains(corpus): """Takes an input text as a string and returns a dictionary of markov chains.""" # read lines --- we don't need to read the lines. We are reading it as one long string # strip newlines, punctuation, tabs and mak...
5649dabbf39457cb906368ebc3591f964108713c
ijoshi90/Python
/Python/hacker_rank_staricase.py
460
4.3125
4
""" Author : Akshay Joshi GitHub : https://github.com/ijoshi90 Created on 30-Oct-19 at 08:06 """ # Complete the staircase function below. """def staircase(n): for stairs in range(1, n + 1): print(('#' * stairs).rjust(n)) """ def staircase(n): for i in range(n-1,-1,-1): for j in range(i): ...
cc0dbeccd0b265b09bf10f8aa12881d5e245acae
ijoshi90/Python
/Python/loop_while.py
534
3.78125
4
# -*- coding: utf-8 -*- """ Created on Tue Aug 20 20:47:00 2019 @author: akjoshi """ import time # While Loop x = 5 y = 1 print (time.timezone) while x >=1: print (time.localtime()) time.sleep (1) print ("X is "+ str (x)) x-=1 while y <= 5: time.sleep(1) print ("Y is "+str(y)) ...
035e8af4d681ae42fa9ce31a9a22f2430aaa1531
ijoshi90/Python
/Python/array_operations.py
579
3.765625
4
# -*- coding: utf-8 -*- """ Created on Sun Aug 25 18:21:20 2019 @author: akjoshi """ from array import * arr = array('i', []) l = int (input ("Enter the length : ")) print ("Enter elements") for i in range (l): x = int (input("Enter the " + str (i) + " value : ")) arr.append(x) key = int (input ("Enter v...
e3b10157dafc23d144d1a2db892f055a8f2d608f
ijoshi90/Python
/Python/prime_or_not.py
391
4.09375
4
# -*- coding: utf-8 -*- """ Created on Sat Aug 24 16:40:46 2019 @author: akjoshi """ # Prime or not number = int (input ("Enter a number to print prime numbers between 0 and number : ")) for num in range(2,number + 1): # prime numbers are greater than 1 if num > 1: for i in range(2,num): if ...
4c951106721a49a06d1e6a95f6461e5d8da18c44
ijoshi90/Python
/Python/dictionary.py
1,448
3.875
4
# -*- coding: utf-8 -*- """ Created on Wed Aug 7 18:05:09 2019 @author: akjoshi """ #dictionary dictionary_car = { "Brand" : "BMW", "Model" : "X1", "Year" : "2020", "Owner" : "Sanaksh" } print (dictionary_car) # Accessing this_dictionary = dictionary_car["Model"] print (thi...
75aabcea6f84ac4f13a725080c9858954074472c
ijoshi90/Python
/Python/maps_example.py
1,385
4.15625
4
""" Author : Akshay Joshi GitHub : https://github.com/ijoshi90 Created on 19-12-2019 at 11:07 """ def to_upper_case(s): return str(s).upper() def print_iterator(it): for x in it: print(x, end=' ') print('') # for new line #print(to_upper_case("akshay")) #print_iterator("joshi") # map() with st...
00e0422cf41f40f287b9d72f42881b3afcb93ce1
ijoshi90/Python
/Python/bubble_sort_trial.py
364
3.984375
4
""" Author : Akshay Joshi GitHub : https://github.com/ijoshi90 Created on 09-01-2020 at 10:15 """ list = [1, 3, 8, 9, 2, 5, 2, 3, 6, 5, 8, 10, 19, 12, 14, 7, 20] def bubble (list): for i in range(len(list)): for j in range(i+1, len(list)): if list [i] > list [j]: list [i], list...
6fc2d2631238c25c2d2e30ed887c4abbe8a0083c
ijoshi90/Python
/Python/set.py
851
4.03125
4
# -*- coding: utf-8 -*- """ Created on Tue Aug 6 20:40:20 2019 @author: akjoshi """ # Set Example thisset = {"1 apple", "2 banana", "3 cherry","4 kiwi"} print(thisset) for i in thisset: print (i) print ("5 banana" in thisset) print ("2 banana" in thisset) thisset.add("5 Strawberry") print (thisset) thiss...
3f28a1970aa458cfde8700646e1adecf1bb63634
ijoshi90/Python
/Python/string_operations.py
421
4
4
""" Author : Akshay Joshi GitHub : https://github.com/ijoshi90 Created on 17-12-2019 at 14:43 """ string = "Hello, World!" # Strings as array print (string[2]) # Slicing print (string[2:5]) # Negative indexing - counts from the end print (string[-5:-2]) # Replace print (string.replace("!","#")) print((string.replac...
2733ce9698980790023690e311fd8ab37e46fb8f
ijoshi90/Python
/Python/iterator.py
383
3.859375
4
""" Author : Akshay Joshi GitHub : https://github.com/ijoshi90 Created on 18-12-2019 at 15:18 """ # Iter in tuple mytuple = ("apple", "banana", "cherry") myit = iter(mytuple) print(next(myit)) print(next(myit)) print(next(myit)) # Iter in strings string = "Akshay" myit1 = iter(string) print(next(myit1)) print(next(...
bbcdeafd4fdc92f756f93a1a4f990418d295c643
ijoshi90/Python
/Python/variables_examples.py
602
4.375
4
""" Author : Akshay Joshi GitHub : https://github.com/ijoshi90 Created on 26-Sep-19 at 19:24 """ class Car: # Class variable wheels = 2 def __init__(self): # Instance Variable self.mileage = 20 self.company = "BMW" car1 = Car() car2 = Car() print ("Wheels : {}".format(Car.wheels)...
d17f55a72be36d93dd6c5dc553d312e5c26beda4
romilpatel-developer/CIS2348_projects
/Homework 4/pythonProject24/main.py
1,398
3.671875
4
# Romilkumar Patel # 1765483 # Homework 4 (Zybooks 14.13) # Global variable num_calls = 0 # TODO: Write the partitioning algorithm - pick the middle element as the # pivot, compare the values using two index variables l and h (low and high), # initialized to the left and right sides of the current elements being sort...