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
34f84a9883b3d57911b30aea2ab4470efa57e482
AsharGit/Python-ICP
/Source/ICP-3/Employee.py
1,137
4.28125
4
class Employee: num_employees = 0 total_salary = 0 def __init__(self, name, family, salary, department): self.emp_name = name self.emp_family = family self.emp_salary = salary self.emp_dept = department self.increment(salary) # Increment num_employees and total_...
b102bff33fd3153179fd6ea7bf0cb996de31ec87
moodymood536/geekbrains-python-level1
/03/02-normal.py
2,780
4.0625
4
# Задание-1: # Напишите функцию, возвращающую ряд Фибоначчи с n-элемента до m-элемента. # Первыми элементами ряда считать цифры 1 1 def fibonacci(n, m): current, next_item = 1, 1 numbers = [] for x in range(1, m + 1): if x >= n: numbers.append(current) current, next_item = nex...
e50d45dda524f0471a01371f202cb2f7384ca07f
stompingBubble/Asteroids
/shape.py
2,492
4.15625
4
# -*- coding: utf-8 -*- """ Gruppuppgift: Asteroids - Objektorienterad Programmering Nackademin IOT 17 Medverkande: Isa Sand Felix Edenborgh Christopher Bryant Stomme källkod: Mark Dixon """ from abc import ABC, abstractmethod import math from point import Point class Shape(ABC): def __init__( self, x=0, y=0,...
8ad5a5358ab38d99de5f6c86770dd965ae963181
MrHeadQ/SSF
/random_.py
142
3.6875
4
import random str_=input() if str_=="GET": for i in range(0,6): print(random.randint(0,9),end="") else: print("input error!")
ffd1c6706c107f8fa4ca74bf33d36650046d0608
thechemist54/PYth0n-and-JaVa
/Area calculation.py
1,663
4.4375
4
#printing the options print("Options:") print("-"*8) print("1. Area of Rectangle") print("2. Area of Triangle") print("3. Area of Circle") print("4. Quit") #assigning a value to flag flag = False #analyzing responses and displaying the respective information #looping statement while f...
7d2c07bb4e07718c1d198a1d39adc49a03bb688d
thechemist54/PYth0n-and-JaVa
/Fuun with files/funwithfiles.py
1,760
4.09375
4
#defining main function def main(): inFile = open("numbers.txt",'r') #reading a file and asigning variable inFile #to that file smallest = 1000 largest = 1 for line in inFile: #looping to determine the largest and smallest value n = int(lin...
a36a9537394771c996ac82a615c089486b5a4473
caa2020projects/FirstCaaProject
/diamondwithasterisks.py
368
4
4
size = int(input("Enter the size >> ")) count = size for i in range(size): print(" " * count, end="") for j in range(i + 1): print("{0:2}".format("*"), end="") print() count -= 1 count = 2 for i in range(size-1, -1, -1): print(" " * count, end="") for j in range(i): print("{0:2}"...
b116a4dad9540ecd3ca827cc96f1748ddb2ad20a
kasapenkonata/python
/13_09/task9.py
384
4.21875
4
import turtle import math #осталось центрировать turtle.shape('turtle') def draw(n): R = 10*n a = 2 * R * math.sin(2 * math.pi / n) turtle.penup() turtle.goto(-a/2, R) turtle.pendown() for i in range(n): turtle.forward(a) turtle.right(360/n) return(0) for ...
7265e6cd3c017f7a64810e88f6a532df43549864
kasapenkonata/python
/13_09/task5.py
307
3.796875
4
import turtle turtle.shape('turtle') a = 0 for j in range(10): a = a + 10 for i in range(4): turtle.forward(a) turtle.right(90) turtle.penup() turtle.backward(5) turtle.left(90) turtle.forward(5) turtle.right(90) turtle.pendown() x = input()
a0b5031929b31082264bde325ef3d8ed1c496abd
AndrejLehmann/my_pfn_2019
/Vorlesung/src/Basic/parse_atoms.py
343
3.515625
4
#!/usr/bin/env python3 import re atoms = ['Hydrogen gas 1.00794', 'Lithium alkaline metal 6.941', 'Beryllium alkaline earth metal9.012182'] for atom in atoms: m = re.search(r'(\w+)\s+([\w\s]+)\s?(\d+\.\d+)', atom) if m: print('{:<9s} {:<20s} {:>.3f}' .format(m.group(1),m.group(...
461a54fb3c246ba90879c6ca2ce8e18f48996a53
AndrejLehmann/my_pfn_2019
/Uebungen/Blatt08.Harkov.Lehmann.Music/Aufgabe1/Splitnumber/splitnumber.py
3,126
3.75
4
#!/usr/bin/env python3 # Bearbeitungszeit: 4.0h import math import sys testArray = [2,3,3,3,3] def quality_function(intArray): mean = sum(intArray)/len(intArray) quality = 0. for n in intArray: quality += (n - mean)**2 quality = math.sqrt(quality) return quality #print(quality_function(t...
a948e2106b7150b3a41ae7486415a8dc17842292
AndrejLehmann/my_pfn_2019
/Vorlesung/src/Basic/example4_2.py
769
4.65625
5
#!/usr/bin/env python3 # Example 4-2 Concatenating DNA # store two DNA sequences into two variables called dna1 and dna2 dna1 = 'ACGGGAGGACGGGAAAATTACTACGGCATTAGC' dna2 = 'ATAGTGCCGTGAGAGTGATGTAGTA' # print the DNA onto the screen print('Here are the original two DNA sequences:') print(dna1) print(dna2) # concaten...
16e407549a250ee05b197e1857c772c9ae722409
AndrejLehmann/my_pfn_2019
/Vorlesung/src/Basic/example5_2.py
673
4
4
#!/usr/bin/env python3 # Example 5-2 Reading protein sequence data from a file, take 4 import sys # The filename of the file containing the protein sequence data proteinfilename = 'NM_021964fragment.pep' try: proteinfile = open(proteinfilename,'r') except IOError as err: sys.stderr.write('{}: {}\n'.format(sys....
e43a80096be86723bd60a82c0d4cb7a92ea8992c
AndrejLehmann/my_pfn_2019
/Vorlesung/src/Basic/button.py
173
3.75
4
#!/usr/bin/env python3 from tkinter import * def out(): print('hello') # the button calls this function Button(root, text='Hello!', font='Times 16', command=out).pack()
25c6a9ddda03186aaed84f4eed8c5c31cbd63d4f
AndrejLehmann/my_pfn_2019
/FragenKatalog/Aufgabe35/reverse_complement.py
442
3.734375
4
import sys def reverse_complement(string): new_string = '' for c in string: if c == 'A': new_string += T elif c == 'C': new_string += G elif c == 'G': new_string += C elif c == 'T': new_string += 'A' else: sys.s...
4bc1402118ed4b23bbb6bac3afa1fe7dc140687a
AndrejLehmann/my_pfn_2019
/Vorlesung/src/Basic/score2grade.py
473
3.84375
4
#!/usr/bin/env python3 score = 39 if score >= 85: print('sehr gut') else: if score >= 70: print('gut') else: if score >= 55: print('befriedigend') else: if score >= 40: print('ausreichend') else: print('nicht bestanden') score = 40 if score >= 85: print('sehr gu...
dfef8d83019b9cfb8a7fd3f80fbf33ff2631fa05
AndrejLehmann/my_pfn_2019
/Vorlesung/src/Basic/pur_pyr.py
298
3.8125
4
#!/usr/bin/env python3 dna = 'acgactactcgaccatcatcagcca' count_purine = count_pyrimidine = 0 for base in dna: if base == 'a' or base == 'g': count_purine += 1 elif base == 'c' or base == 't': count_pyrimidine += 1 print('purine={},pyrimidine={}'.format(count_purine,count_pyrimidine))
1046536ce2164edcc2e353d4d2cc9a074ce36b44
AndrejLehmann/my_pfn_2019
/Vorlesung/src/Math/listcomp.py
5,127
4.3125
4
#!/usr/bin/env python3 from math import sqrt ''' http://python-history.blogspot.com/2010/06/from-list-comprehensions-to-generator.html [f(x) for x in S if P(x)] This produces a list containing the values of the sequence S selected by the predicate P and mapped by the function f. The if-clause is optional, and multip...
cada55884f3f2d0631c5fc5a9756d89c2113b643
AndrejLehmann/my_pfn_2019
/Vorlesung/src/Math/iplot_linear.py
626
3.734375
4
#!/usr/bin/env python3 ''' Present an interactive function explorer with slider widgets. Scrub the sliders to change the properties of the ``linear function`` Use the ``bokeh serve`` command to run the example by executing: bokeh serve iplot_linear.py at your command prompt. Then navigate to the URL http://...
d2596f06baec082086375cfced185c22524a27a9
AndrejLehmann/my_pfn_2019
/Vorlesung/src/Basic/errors.py
354
3.71875
4
a = 6 if a == 5 print('Hello world') If a == 3: print('hello world') if a == 4: print 'hello world' countr = 0 if counter < 5: counter = counter + 1 i = 0 if 2 * (i+1) / (3 * i < 5: print('i={}'.format(i)) arr = [1, 2, 3 4] s = 'abc' print('Here is a string {}'format(s)) print('Here is a string {}'.for...
43df1857d471bf9b0a03878ed8428f04fc8e894e
AndrejLehmann/my_pfn_2019
/Vorlesung/src/Basic/hex2int.py
470
3.78125
4
#!/usr/bin/env python3 import sys def hextoint(cc): if cc >= 48 and cc <= 57: # a digit return cc - 48 elif cc >= 65 and cc <= 70: return 10 + cc - 65 else: sys.stderr.write('{}: illegal character in hex-number'.format(sys.argv[0])) exit(1) def hex2toint(s): if len(s) != 2: sys.stderr.wri...
f50453629c50ce59ae503a9eb71784aa918324e7
AndrejLehmann/my_pfn_2019
/Vorlesung/src/Basic/scanmotif.py
1,275
4.09375
4
#!/usr/bin/env python3 import sys # for error message import re # for regular expressions # ask the user for the filename of the file containing # the sequence data, and collect it from the keyboard filename = input('type filename of the sequence: ') # remove trailing newline from the read filename filename = file...
909aa514974aba40587f8d610a5175c5b61da3a5
paulinastal/course-MITx-6.00.1x
/week2/minMonthlyPaymentBis.py
1,187
3.59375
4
# -*- coding: utf-8 -*- """ Created on Wed Sep 16 21:39:58 2020 @author: Paulina """ balance = 320000 annualInterestRate = 0.2 monthlyInterestRate = (annualInterestRate) / 12.0 monthlyPaymentLowerBound = balance / 12 monthlyPaymentUpperBound = (balance * (1 + monthlyInterestRate)**12) / 12.0 updatedBa...
e7ce4cf3de577b28d63feb55f1da3445a03a2e06
ectuser/StateExam-27.Solutions
/17-var.Digest(20-variants).py
1,406
3.59375
4
N = int(input()) ''' Найти максимальную возможную четную сумму элементов и вывести индексы этих элементов -------------------------------------- Сумма будет максималльно возможной и четной, если количество нечетных элементов будет четным. Короче, считаем количество нечетным элементов и ищем минимальный вреди них, ег...
23d3166c12adb10d2e279a0fa5ccc072b13640f6
hjlynch2/440assignment4
/part1/pong.py
16,305
3.5
4
''' NOTES ------ - Use pygame.image.save() to save the image of the gamestate, http://www.pygame.org/docs/ref/image.html - source of pong code -> https://trevorappleton.blogspot.com/2014/04/writing-pong-using-python-and-pygame.html - assignment 4 link -> http://slazebni.cs.illinois.edu/fall16/assignment4.html ''' ...
65159cab413936916e8cb8deb56aaa01b088aae1
aadi1998/Text-Adventure-Game
/game_data.py
13,486
3.921875
4
class Location: def __init__(self, num, x, y, brief_desc, long_desc, action, items): """Creates a new location. Data that could be associated with each Location object: a position in the world map, a brief description, a long description, a list of available commands...
8f65cf1741e525ea4ac462b9e70d315990a24b56
romqrq/SelfStorageApp
/tests/test_models.py
1,056
3.546875
4
from src.models import Booking, Unit def test_new_unit(): """ GIVEN a Unit model WHEN creating a new unit THEN check key/values are defined correctly """ unit = Unit(unit_name="test unit", unit_size="20", unit_price=20.20) assert unit.unit_name == "test unit" assert unit.unit_size == "...
3c795fee0e645d91ec739e2d09bd7b4eb0aa92da
mijaz18/Smart-ICU
/Worst_Score_Functions.py
3,669
3.546875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jun 25 17:32:52 2018 @author: muhammadusamaijaz """ def Age(x): if x<=44: score=0; elif x>=45 and x<=54: score=2 elif x>=55 and x<=64: score=3 elif x>=65 and x<=74: score=5 elif x>=75: score=6...
dc784b84a2311a167a6df82e6603fca92186581d
Zoe187419/omar_lak
/resample_workflow.py
1,395
3.546875
4
def distinguish_sample(population): """ Distinguishes the sample that received the treatment from the potential matching population, discarding all others. :param population: A list of subjects :return: (sample,potential_matches) """ assert (isinstance(population, list)) pass def pairw...
3b742e5de9330d323816d5d384cc6d18f6f2d392
copasta/NLP100knock2020
/chap01/prob05.py
866
3.546875
4
def n_gram(text, n, mode="word", do_lower=False): if mode not in ["char", "word"]: raise(ValueError("this mode is not define.")) if do_lower: text = text.lower() text = text.replace(",", " ,").replace(".", " .") if mode == "char": text = "".join(text.split()) t...
41732a270bad918edab4ba677fd9d8521add053a
aidan-coward/python
/learn-python/text-game/rooms.py
508
3.90625
4
class Room(object): def __init__(self): pass class Entrance(Room): def enter(self): print("""You approach the temple entrance. A large door stands before you. What would you like to do?""") action = input('> ') if action == "open door": print("You entered...
977214148d5e4d52ce3ab40d254a3c37af0c0e27
aidan-coward/python
/learn-python/text-game/combat.py
3,066
4.125
4
from random import randint import sys test_enemies = {"Skeleton" : 15, "Ghost" : 12, "Slime" : 0, "Red Slime" : -3} #for i in enemies: # print(i+":", enemies[i]) def combat(player_health, potions, enemies): """Runs through the combat sequence while player and total enemy health is greater than 0""" """Ite...
35bfd73b22e37fab79de7b8cccf83574e44b19e6
Greccu/OtherProjects
/Maze Generator/main.py
4,145
3.84375
4
from random import randint # working on bits, for example 10001 means the cell has been visited and has a path to north :) north = 1 east = 2 south = 4 west = 8 visited = 16 def maze(width=10, height=10, display = False): Stack = [] Maze = [] for _ in range(height): Maze.append([0] ...
5ab7e54618b304e06665656d5d9f712a2bb94607
Nilesh-kodag/statistics
/math.py
537
3.734375
4
import math #a mathematical function that is the inverse of the cosine function. print (math.acos(0.55)) print (math.acos(-0.55)) print (math.acos(0)) print (math.acos(1)) print (math.acos(-1)) print('the value of Euler e') print (math.e) print ("the value of tau") print (math.tau) # Initialize the number of item...
b5be2dba6bef062deb838c0212693fba6b6c689e
loucq123/toys
/treeCommand.py
3,850
4.34375
4
import os class TreeCommand(): ''' The TreeCommand just like the tree command in windows. It Graphically displays the directory structure of a path or of the disk in a drive. ''' def __init__(self, path='', depth=0, currentPosition=0): ''' :param path: the path you want t...
ea9d9b9d465e3ec4a94ec9b83b98f6601e8d6eb4
Qtzi/useless-program
/C4LCUC4T0R.py
1,241
3.65625
4
ye = 9 while ye == 9: print("Select operation.") print("1. Aritmetic") print("2. Geometric") choice = input("your choice: ") if choice == '1': print(input("Press Enter to start ...")) a1 = float(input('a:')) an = float(input('n:')) dif = float(input('dif:')) ...
32a3a2404676323009aa52ace6c1d5b135b3150b
sthe-eduarda/Curso-de-python
/Desafios/desafio016.py
126
3.609375
4
from math import trunc n = float(input('Digite um número: ')) i = trunc(n) print(f'O número {n} tem a parte inteira {i}.')
4d9a76ec2a42ccfe96ce5e8750360e50ebf7aa95
sthe-eduarda/Curso-de-python
/Exercicies/ex0016.py
237
3.921875
4
from math import trunc num = float(input('Digit um valor: ')) print(f'O calor digita foi {num} e sua porção inteira é {trunc(num)}') print(20 * '=') print('Ou podemmos usar o int() para extrair apenas o valor inteiro') print(int(num))
5dc857219e22b61002ec09442fafd014325922a0
sthe-eduarda/Curso-de-python
/Exercicies/ex008.py
268
3.921875
4
m = float(input('Digite uma distância em metros: ')) print('A medida de {:.1f}m correspode a :') print('{:.3f}km'.format((m / 1000))) print('{:.2f}hm'.format((m / 100))) print('{:.1f}dm'.format((m / 10))) print('{}cm'.format((m * 10))) print('{}mm'.format((m * 100)))
d6f3a5ed5874db0f61c96c5df4382af3b2f3adf4
Seedsiz/FYS4150-Project4
/code-and-results/plothist.py
3,152
3.640625
4
# Code to read text files and make histogram # with distribution of energies for a steady state # for one particular temperature # PS: need to make textfile for wanted temperature before running #, only handles one temperature # - If you want to plot energies or exp values, # change arrays (comment out) in isingmodel ...
772b0177b02e7755d542fde4e9cf749df6865da2
Surendra58/Suri
/JSON files in Python.py
1,899
3.609375
4
#!/usr/bin/env python # coding: utf-8 # In[1]: # Saving JSON Data import json # example dictionary to save as JSON data = { "first_name":"John", "last_name":"Doe", "email":"john@doe.com", "salary":1499.9, # just to demonstrate we can use floats as well "age":17, "is_real":False, # also boolea...
dee7d2ac0cb1cfbad241507c713987013a145cdf
amogh2794/Selenium_Python_Implementation
/Python Basics/read.py
551
3.921875
4
#file = open("test.txt") #print(file.read()) # read all content of file #rint(file.read(2)) # read n no. of characters #print(file.readline()) # will print first line #print(file.readline()) # will print 2nd line #file.close() # print all lines using readline method #file = open("test.txt") #line = file.read...
74350f7ddd540749007be99373d7b05e94d11806
amogh2794/Selenium_Python_Implementation
/Python Basics/FirstDemo.py
273
3.828125
4
print("Hello Chutya") # comment aisa karte hai a = 3 # variable aisa declare karte hai. data type automatically lega python runtime pe print(a) Str = "hello lodu" print(str) b, c, d = 5, 6.4, "great" print(b,c,d) print(type(c)) print(Str+" concatenated with "+d)
1bac52b4323de5e6849d35cda1c122a62322d8fe
Rhysoshea/maths
/expected_value.py
2,985
3.84375
4
''' G-Research trading game Expected value of product is determined by probability density y=2/(1+x)^3 Rules: - each time step a new price will be exposed according to the probability distribution - this value is captured according to an algorithm you have to write - if you decide to take a value as profit then it bl...
221e3f16dc28d8447f978ef69c12e27b44cb5251
FranciscoRiosJesus/ParaboloideTangente
/paraboloideConTangenteFunc.py
482
3.703125
4
from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np fig = plt.figure() ax = fig.add_subplot(111, projection='3d') # Make data u = np.linspace(0, 2 * np.pi, 100) v = np.linspace(0, np.pi, 100) x = 10 * np.outer(np.cos(u), np.sin(v)) y = 10 * np.outer(np.sin(u), np.sin(v)) z = x...
3c0172711df5cbcccef35b8f727b57183f81a831
caijiahao/machineLearning
/src/linearRegression/doubleLinearRegression.py
2,137
3.796875
4
# -*- coding: gbk -*- das as pd import pandas as pd import seaborn as sns import matplotlib.pyplot as plt from sklearn.cross_validation import train_test_split from sklearn.linear_model import LinearRegression data = pd.read_csv('Advertising.csv') print data # visualize the relationship between the features and...
6a2eda2ee7724f175259aa34780115b8a324e24d
gopalbala/codingninjas
/pythondatastructures/PrintLevelWiseGeneticTrees.py
1,512
3.875
4
import queue class treeNode: def __init__(self, data): self.data = data self.children = [] def __str__(self): return str(self.data) def printLevelWiseTree(tree): ############################# # PLEASE ADD YOUR CODE HERE # ############################# if tree is None: ...
aad2262c707eed0260c511dcdd0c9047320014f3
gopalbala/codingninjas
/pythondatastructures/NodeWithMAximumChildSum.py
1,351
3.625
4
import queue class treeNode: def __init__(self, data): self.data = data self.children = [] def maxSumNode(tree): # Return the node and its sum ############################# # PLEASE ADD YOUR CODE HERE # ############################# if tree is None: return None q = q...
804a9027faf67d751ec7f1665ebd8cfd8d8e3460
gopalbala/codingninjas
/pythondatastructures/GrpahBfs.py
1,379
3.5625
4
import queue class Graph: def __init__(self,nVert): self.nVert = nVert self.adjMatrix = [[0 for i in range(nVert)] for j in range(nVert)] def addEdge(self, v1, v2): self.adjMatrix[v1][v2] = 1 self.adjMatrix[v2][v1] = 1 def removeEdge(self, v1, v2): if contai...
1e5a5e26989f7d5d544b3ad9e24bfff418449b1b
gopalbala/codingninjas
/pythondatastructures/GraphHasPath.py
1,600
3.671875
4
import queue class Graph: def __init__(self,nVert): self.nVert = nVert self.adjMatrix = [[0 for i in range(nVert)] for j in range(nVert)] self.found = False def addEdge(self, v1, v2): self.adjMatrix[v1][v2] = 1 self.adjMatrix[v2][v1] = 1 def removeEdge(self, v1, ...
3f51a69ce6cea3a0794ea56bc0bfb8ed0ecdfe24
gopalbala/codingninjas
/pythondatastructures/AppendLastNNodesToFrontLL.py
1,853
3.9375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Sep 8 22:50:40 2019 @author: balasubramanian """ class Node: def __init__(self, data): self.data = data self.next = None def append_LinkedList(head,n) : # Given a linked list and an integer n, append the last n elements of th...
202a8c7e66fd2d375867a2525460ae1f469b09f0
gopalbala/codingninjas
/pythondatastructures/NodesKDistanceFromNode.py
3,813
3.984375
4
# Read input as specified in the question. # Print output as specified in the question. import queue class BinaryTreeNode: def __init__(self, data): self.data = data self.left = None self.right = None def kdistance(root, n, k): level = 0 if root is None: return q = qu...
2c0d5d254b66b0b3d19f302b9e3e1a59b73313d6
LeiYangGH/pylinux
/win/readwords.py
197
3.734375
4
#!/usr/bin/env python # coding: UTF-8 import csv my_file = r'C:\test\test.csv' with open(my_file) as f: reader = csv.reader(f) row1 = next(reader) print(row1) print(row1[0]) print('hello')
32acfc20dff3d5b6491d5578dc0aa4e36e5f63ec
cabaude/helloword
/indexe.py
158
3.890625
4
def isIndex(t, n): t2 = [] for i in range(0, len(t)): if n == t[i]: t2.append(i) print(t2) isIndex([3, 5, 0, 4, 4, 7], 5)
cba058c0369a103387eaaf484eca9177d4beaaca
ChristianRojas09/beginning-python
/rental_car.py
2,070
3.859375
4
import sys #Request Rental code: rentalCode = input("(B)udget, (D)aily, or (W)eekly rental?\n").upper() #Request time period the car was rented. if rentalCode == 'B' or rentalCode == 'D': rentalPeriod = int(input("Number of days rented:\n")) else: rentalPeriod = int(input("Number of weeks rented:\n")) #print(r...
e0e7dfc887697ef76b1a8e2f3005a240d01de405
arijit-muk02/Guess_it
/guess.py
1,079
4.09375
4
import random #to get input from user def get_guess(): return list(input("What is your guess?Guess a 3 digit number ")) #to generate the random code def generate_code(): digits= [str(num) for num in range(10)] #to shuffle the digits from 0 to 9 random.shuffle(digits) #to get the first...
93b80038ce3dd97ecece977ae9d5c19baa639f03
LakshayMahajan2006/Prime-number
/Code.py
317
4
4
# Prime-number n = int(input("Enter a starting number : "))#it takes starting number u = int(input("Enter a ending number : "))#it takes endinging number for num in range(n, u+1): if num > 1: for i in range(2, num): if (num%i) == 0: break else: print(num)
d6d8216aa075669078b6db78c2d7c4dae7a29916
kangyan0902/aiops-sentiment
/clean_data.py
2,033
3.6875
4
""" This py script is use for preprocess tweets """ import re import csv import pandas as pd from nltk import tokenize class Preprocess(): """ class """ def __init__(self, input_str, filename, max_length_dictionary=30000, max_length_tweet=20): """ initiate instance """ self.filenam...
e2bcf65cac30ca1009a015861d6bae5b31684948
paula96m/Ping-Pong-Game
/ping/ping-pong.py
2,607
3.5625
4
import turtle window = turtle.Screen() window.title("Ping-Pong") window.bgcolor("black") window.bgpic('imag.gif') window.setup(width=800, height=600) window.tracer(0) #Paddle_1 paddle_1 = turtle.Turtle() paddle_1.speed(0) paddle_1.shape("square") paddle_1.color("white") paddle_1.shapesize(stretch_wid=5,...
aac1f3ea12bcbd7e4267eb63ce4507dbb3f9ff3f
Bonnet1/py4e
/ch9/ex_9_4.py
560
3.53125
4
name = input("Enter file:") if len(name) < 1 : name = "mbox-short.txt" handle = open(name) emails = [] counts = dict() for line in handle: words = line.split() if len(words) == 0 : continue if words[0] == 'From' : emails.append(words[1]) continue for email in emails: if email not in count...
06feae0dad0ef12a06b047e703b517e697ee547a
Flo1000/Python
/FizzBuzz.py
477
3.96875
4
print "Welcome to the FizzBuzz game!" exit_number = raw_input("Enter a number between 1-100 to define end point of game: ") print exit_number print for i in range(int(exit_number) + 1): fizz = i % 3 buzz = i % 5 if i == 0: print "Start" elif fizz == 0 and buzz != 0: print...
e2802f46eeb773f497cab112e4a74fe96b763f8f
pravalikavis/Python-Mrnd-Exercises
/finaltest_problem3.py
2,052
4.34375
4
__author__ = 'Kalyan' max_marks = 25 problem_notes = ''' For this problem you have to implement a staircase jumble as described below. 1. You have n stairs numbered 1 to n. You are given some text to jumble. 2. You repeatedly climb down and up the stairs and on each step k you add/append starting k chars fr...
78e22f56c3bea84b4fada3110f17ab81a8da934f
pravalikavis/Python-Mrnd-Exercises
/unit5_assignment_03.py
1,805
4.0625
4
__author__ = 'Kalyan' notes = ''' Now we move on to writing both the function and the tests yourself. In this assignment you have to write both the tests and the code. We will verify your code against our own tests after you submit. ''' # fill up this routine to test if the 2 given words given are anagrams ...
f1e3335cbe9ab3dd4813b081355665a10b5eaf46
antoneliasson/skript
/pagesplitter.py
720
3.625
4
#!/usr/bin/env python # # Splits pages in a PDF. Useful when one has scanned A5 pages in an A4 scanner # and every PDF page contains two sheets. # # Adapted from https://unix.stackexchange.com/questions/12482/split-pages-in-pdf from __future__ import print_function import copy, sys from pyPdf import PdfFileWriter, Pdf...
e65cf485bb2103ee8dfebbd246458e87494db37b
CristianAlm/grado-python
/ejercicios_python/clase03/tabla_informe.py
1,986
3.640625
4
import csv headers = ('Nombre', 'Cajones', 'Precio', 'Cambio') espacios = ('-----', '-----', '-----', '-----') def leer_precios(nombre_archivo): with open(nombre_archivo, 'rt') as archivo: rows = csv.reader(archivo) preciosLocales = [] for row in rows: try: dat...
bf3f73d7692eb7708ca06827bc6e22b872439939
reachtomrinal/PythonCoding
/app/Tuples.py
415
3.71875
4
# hold multiple information into a single entity # It is immutable in nature Cordinates = (4, 6) print(Cordinates[0]) # Cordinates[1] = 9 print(Cordinates[1]) # We can have a list containing cordinates friend = [(3, 4), (6, 7)] print(friend[1]) friend[1] = (4, 9) # this is valid print(friend[1]) try: friend[1][1...
5cd003029c8cbd8e6c6209650d9690981555815a
reachtomrinal/PythonCoding
/app/calc.py
150
3.8125
4
def add(x, y): """ addition of numbers """ if str(x).isnumeric() and str(y).isnumeric(): return x + y else: return False
62d237675cc7e27380bab83205ea4b12e0962ea7
reachtomrinal/PythonCoding
/app/Dictionaries.py
249
3.90625
4
from collections import defaultdict dictionaries = { "name": "Mrinal", "age": 29, "gender": "male" } print(dictionaries.get("name")) d = defaultdict(lambda: "Purulia") d["a"] = 1 d["b"] = 2 print(d["a"]) print(d["b"]) print(d["c"])
539ebe092890f27ab4014456779809282e10390e
patu0/rob599
/rob599_basic/src/breadcrumbs.py
3,121
3.6875
4
#!/usr/bin/env python # An example of using markers and tf to drop a set of breadcrumbs. # # breadcrubs.py # # Bill Smart # # This example shows how we might build a simple breadcrumb system for the Fetch robot. It shows # how we can autmatically publish a set of breadcrumbs showing where the robot has been. The cod...
6b75d853175d8e30074a5486cae7f36f2a580e03
patu0/rob599
/rob599_basic/src/subscriber.py
1,279
3.65625
4
#!/usr/bin/env python3 # Basic topic subscriber example. # # subscriber.py # # Bill Smart # # This example shows the basic code for subscribing to a topic. # Import ROS Python basic API and sys import rospy import sys # We're going to subscribe to 64-bit integers, so we need to import the defintion # for them. fro...
bb5ecdcc4660bc3153db44d0f0d445d3dc502816
jesus1612/CursoIntermedioPython
/assert_statements.py
569
4.03125
4
def divisors(num): assert num < 0, "ingresa un número positvo" divisors = [i for i in range(1, num + 1) if num % i == 0] return divisors def main(): # Solución propuesta por mi con assert statements # num = int(input("ingresa un número: ")) # print(divisors(num)) # assert ValueError, "Ingresa solo val...
e4ad1ae6cda807445e08a64a564596ffa3785e69
Zhou3983/ECE654-A1
/tests/samples/true_negative_2.py
248
3.578125
4
for i in range(5): for j in range(10): for k in range(15): for l in range(20): for m in range(25): this_equal_13 = 1 abcdefghijklm = 2 print('test')
604a61fa472352b1b28ce8258d99abf6efcc54e8
hermanstehouwer/adventofcode2020
/core/boating.py
2,296
3.53125
4
from typing import Iterable, Tuple def get_new_direction(d: str, action: str)-> str: rotate = int(action[1:]) directions = {"N":0, "S": 180, "E": 90, "W": 270} reverse_lookup = {0:"N", 180:"S", 90:"E", 270:"W"} if action[0] == "L": rotate = 360 - rotate direction = directions[d] direct...
113cb9d409734ce57b54d741431c565cd459cfb4
hermanstehouwer/adventofcode2020
/core/crabcups.py
2,138
3.71875
4
from typing import List, Dict class CrabCups: cups: Dict[int, int] current_cup: int min_val: int max_val: int def __init__(self, cups: List[int], expand=False): self.cups = dict(zip(cups, cups[1:] + cups[:1])) self.current_cup = cups[0] self.min_val = min(cups) sel...
cfddf9e9f39f5e78ae81bf03ed2fd58a84ee410c
FireeBurn/Points
/points.py
553
3.90625
4
class Point: def __init__(self, x, y, z): self.x = input() self.y = y self.z = z class Triangle(Point): def __init__(self, a, b, c ): self.a = a self.b = b self.c = c def sides(self): A = Point(5, 7, 5) B = Point(input(), input(), input...
392b7fdc5fbd5a320aa9373d60b79f5172fd0378
dhanushm3/pythonwork
/PythonStringDouble.py
548
3.921875
4
#doubling of the number s = "12345" for char in s: if(char.isnumeric()): print((int(char) * 2 ), end=",") print(" ") #squaring of number s = "12345" for char in s: if(char.isnumeric()): print((int(char) * int(char) ), end=",") #reverse print (" ") for i in range(1, len(s) + 1)...
10c3249b2ea9fceaef21af48113f7a3a37a78d70
dani117m/demo-flask-001
/run.py
1,461
3.609375
4
""" Introducción a Flask https://parzibyte.me/blog """ from flask import Flask app = Flask(__name__) @app.route('/') def inicio(): return "<h1>Hola mundo con Flask levantado desde heroku</h1>" return "<h1>dani117m</h1>" @app.route('/suma') def suma(): resultado = 10 + 10 return "<h3>10 + 10 = %d</h3...
45a9eb78158a8fcc4e4a2d395c3dd10dbec82c84
Isaac1989/DAT8
/code/03_file_reading.py
3,101
3.96875
4
''' Lesson on file reading using Airline Safety Data https://github.com/fivethirtyeight/data/tree/master/airline-safety ''' # read the whole file at once, return a single string (including newlines) # 'rU' mode (read universal) converts different line endings into '\n' f = open('airlines.csv', mode='rU') file_...
41df54fcccc79f23b843c0cd4c46b1ab5b56a42d
amerca/itp-w1-list-of-prime-numbers
/list_of_prime_numbers/main.py
348
3.96875
4
"""This is the entry point of the program.""" def _is_prime(x): for i in range(2,x): if x%i==0: return False else: return True def list_of_prime_numbers(x): a=[] for i in range(2,x+1): if _is_prime(i): a.append(i) return a if __name__ == '__main__...
0eace7e53b6a7729e7f9fe6152c29c954203ff15
pankajdahilkar/python_codes
/even.py
400
3.625
4
a=["Rock","Scissor","Paper"] while True: i =input("Enter s to start game ") p1=input("Player 1 input ") p2=input("player 2 input") V1=a.index(p1) V2=a.index(p2) k=V1-V2 if k == 0 : print("Same input Try again") elif k== -1 or k== 2: print("Congratulations !!!! Player 1 wi...
4985176efcf51c70d2c1dec19603857bb63babcd
pankajdahilkar/python_codes
/fibo.py
240
3.84375
4
def fibo(x): if x == 1 or x == 2: return 1 return (fibo(x-1)+fibo(x-2)) def userinput(y): i=1 while(i <= y): print(fibo(i),end=" ") i=i+1 z=int(input("enter the number of sequence :")) userinput(z)
2873efc5e996028da3dbe1d1a3a70e8046511c65
pankajdahilkar/python_codes
/prime.py
268
4.1875
4
def isPrime(a=0): i=2 if a==0 : return 0 while(i<a): if a%i==0: return 0 i=i+1 return 1 x=int(input("Enter The number : ")) if(isPrime(x)): print(x, "is Prime number ") else : print(x," is not Prime number")
b87ef01cecfa2e6d4b86866f75cfd256b24bac5f
SMKxx1/Very-Very-Very-Basic-1-Plus-1-1-Plus-0-Program
/Very Very Very Basic 2.py
2,798
4.21875
4
def student1(eng_marks1, acc_marks1, ip_marks1): dic_std_name1 = {'eng':eng_marks1,'accounts':acc_marks1,'ip':ip_marks1} av1 = (eng_mark1 + ip_mark1 + acc_mark1) / 3 return av1 #Return command is explained in line 43 def student2(eng_marks2, acc_marks2, ip_marks2): dic_std_name2 = {'eng':eng_marks2,'ac...
5e4b87a0e9d8682c4854da5e321c4bad99f70eed
Camilo1318/EjerciciosPython
/TiposDeDatosSimples/ejercicio11.py
1,776
3.921875
4
#Imagina que acabas de abrir una nueva cuenta de ahorros que te ofrece el 4% de interés al año. Estos ahorros debido a intereses, que no se cobran hasta finales de año, se te añaden al balance final de tu cuenta de ahorros. Escribir un programa que comience leyendo la cantidad de dinero depositada en la cuenta de ahorr...
8d74006f1fc16e468dce3aa668ca39aae7e697f2
Camilo1318/EjerciciosPython
/Listas/ejer12.py
1,393
4.0625
4
#Escriba un programa que permita crear una lista de palabras y que, a continuación, pida dos palabras y sustituya la primera por la segunda en la lista. #Cristian Pérez numero = int(input("Ingrese un numero: ")) palabras = [] for i in range(numero): if numero>0: palabras.append(input(f"Ingrese la palabra {i+1}: ...
1dae7e9c2b12c1996158a26d4a4b2cbeab5456d2
Camilo1318/EjerciciosPython
/Condicionales/Ejercicio2.py
656
3.828125
4
#Escribir un programa que almacene la cadena de caracteres contraseña en una variable, pregunte al usuario por la contraseña e imprima por pantalla si la contraseña introducida por el usuario coincide con la guardada en la variable sin tener en cuenta mayúsculas y minúsculas. password = input("Ingresa tu contraseña: "...
6ec568987a0315308f70ea53a710a341e15a5a2a
Camilo1318/EjerciciosPython
/Cadenas/ejercicio3.py
645
4.625
5
#Escribir un programa que pregunte el nombre del usuario en la consola y después de que el usuario lo introduzca muestre por pantalla <NOMBRE> tiene <n> letras, donde <NOMBRE> es el nombre de usuario en mayúsculas y <n> es el número de letras que tienen el nombre. #Cristian Pérez nombre = input("Ingrese su nombre: ")...
d52d9afdde8c92bd665a17015463d796ae1c8b32
Camilo1318/EjerciciosPython
/Listas/ejer7.py
380
4.0625
4
#Defina una funcion max() que tome como argumento dos numeros y devuelva el mayor de ellos #Cristian Pérez def max(n1,n2): if n1>n2: return n1 else: return n2 x = max(2,10) print("Numero mayor:",x) #Juan Diego print("Juan Diego".center(50, "*")) def max(a, b): if a<b: return b els...
1904cf28781ab4add0b0309e4e09554a76001db9
Camilo1318/EjerciciosPython
/Listas/ejer9.py
684
3.921875
4
#Escriba un programa que permita crear una lista de palabras. Para ello, el programa tiene que pedir un número y luego solicitar ese número de palabras para crear la lista. Por último, el programa tiene que escribir la lista. #Cristian Pérez numero = int(input("Ingrese un numero: ")) palabras = [] for i in range(numer...
4050578c94d6c46b4069c5556e615a5d2ea3c456
heisenberg1804/competitive-programming
/spiral_matrix.py
715
4.09375
4
def spiral_matrix(m,n,a): k=0 l=0 while (k<m and l<n): for i in range(l, n): print(a[k][i], end=" ") k += 1 for i in range(k,m): print(a[i][n-1], end= " ") n -= 1 if (k<m): #is this condition necessary??? ...
8f716555328dc413477ed5cd08bfd2d8a565414a
ewajs/advent-of-code-2020
/Day 7/first_half.py
2,106
3.78125
4
from raw_data import RAW_DATA test_data = """ light red bags contain 1 bright white bag, 2 muted yellow bags. dark orange bags contain 3 bright white bags, 4 muted yellow bags. bright white bags contain 1 shiny gold bag. muted yellow bags contain 2 shiny gold bags, 9 faded blue bags. shiny gold bags contain 1 dark oli...
ed63a1dd4509f6c8fdfd89f10f02331781d2b730
cristan563/practicas
/madlibs.py
559
4.03125
4
print("madlibs") x = input("escoge una profesion") y = input("escoge un lugar con agua ") z = input("escoge un elemento ") a = input("escoge planeta") b = input("escoge un ecosistema") print("------------------------------------------") print(f"seremos {x} que surcan el {y}") print(f"el {z} se enciende y crea...
53b60a9854edad544278cafe7c750259cbe27bc3
AdriaSalvado/M03
/ejercicio-mayor_menor.py
200
3.890625
4
# coding: utf8 # Adrià Salvadó A=input ("introduce un número") B=input ("introduce un número") C=input ("introduce un número") if (A==B) and (A==C) print "los tres numeros son iguales" else: if (B==C
7e299e2163ff7db1657349f61195e3130fd48417
AdriaSalvado/M03
/ejercicio-bucle-vuelta_derecha.py
533
3.765625
4
# coding: utf8 # Adrià Salvadó # Inicializaciones salir = "N" inicio=1 maximo=8 while ( salir=="N" ): # Hago cosas if(inicio%8==1) or (inicio%8==2): print inicio, "-> Arriba" if(inicio%8==3) or (inicio%8==4): print inicio, "-> Derecha" if(inicio%8==5) or (inicio%8==6): print inicio,"-> Abajo" ...
017dd7ccf801098cc9cca36a55d28e1ebbd7e883
rajatkulkarni95/python-algorithms
/credit-card-validate.py
861
4.09375
4
# Validate whether a Credit Card is a valid one based on the Luhn Check cred_arr = [] total = 0 credit_card = input('Enter the credit card to be validated :') def CreditCardValidate(reversed_string): sum_odd = 0 sum_even = 0 # Reverse the String and add into an array reversed_string = credit_card[::-1...
739015e184e7695b8625ee0302f389c01273580f
endridani/python-oop
/company_manager.py
4,868
4.0625
4
__author__ = 'Endri Dani' #################################################################################################### # Abstract class Employee and subclasses HourlyEmployee, SalariedEmployee, Manager and Executive. # # Every one's pay is calculated differently. Company class that allows you to manage the e...
a42fc87ffe6f06fa260d662e670f30131d9e83c5
pravishbajpai06/Projects
/12.py
942
4.0625
4
#12-Happy Numbers - A happy number is defined by the following process. Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for whic...
44894e050247f38dc88e2184ed65b8e7fc3e868e
pravishbajpai06/Projects
/6.py
1,483
4.1875
4
#6-Change Return Program - The user enters a cost and then the amount of money given. The program will figure out the change and the number of quarters, dimes, nickels, pennies needed for the change. import math cent=0.01 penny=0.01 nickel=0.05 dime=0.1 quarter=0.25 do=1 cost=float(input("Enter the costt")) amount=flo...
23fd9407cf11230da14866b75496cda1f502c27f
lqchien/CS231n
/assignment1/cs231n/classifiers/softmax.py
3,693
3.71875
4
import numpy as np from math import log, exp from random import shuffle from past.builtins import xrange def softmax_loss_naive(W, X, y, reg): """ Softmax loss function, naive implementation (with loops) Inputs have dimension D, there are C classes, and we operate on minibatches of N examples. Inputs: - ...
f9b9e99152bebcc8ae96cfd2ef2fa2727b0fc39e
danielrees97/Iteration
/Currency Problem.py
637
3.84375
4
#Daniel Rees #16/9/13 #Currency problem firstnumber = int(input("please enter an integer: ")) twenties = firstnumber//20 remainder = firstnumber%20 print ("You can have {0} twenty pound note(s), ".format(twenties)) tens = remainder//10 remainder = remainder%10 print ("and {0} ten pound note(s), ".format(tens)) fi...