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 |
|---|---|---|---|---|---|---|
d481a60cd5eecf140841967d1ebcdd744a45f89d | connorjohnson85/CLIFF | /backend/ScienceSimulators/physics/main.py | 642 | 3.609375 | 4 | # import onedimensionalsimulator.main.run as onedimensionalsimulator
# import rocketsimulations.main.run as rocketsimulations
# import twodimensionalsimulator.main.run as twodimensionalsimulator
# def run():
# print('What would you like to simulate today? ')
# print('one dimensions kinematics(o)')
# print(... |
bfd960dd91674a66a91d4402c1b498fe332a239b | connorjohnson85/CLIFF | /backend/ScienceSimulators/physics/equations.py | 1,537 | 3.75 | 4 | import math
def equation1(finalVelocity, initialVelocity, acceleration, time):
if acceleration == False:
acceleration = (finalVelocity - initialVelocity)/time
return acceleration
if finalVelocity == False:
finalVelocity = initialVelocity + acceleration*time
return finalVelocity
... |
825b4222911020af48e4aac79d9a3cdd219ee97a | diksha12p/Data-Structures-ALgorithms---Spring-19 | /Assignment_1/Q4/farthestPair_Revised.py | 1,006 | 3.84375 | 4 | import time as t
def farthestPair(arr): # Function defined to calculate the farthest pair
if len(arr) == 0: # Ensuring that the array isn't empty
print('Operation can\'t be performed on NULL ARRAY!')
else:
current_min = current_max = 0
for i in range(0, len(arr)):
if arr[i] <= ... |
0117cff350242ebc57af8f04f05dcb8b68c17ac0 | AnamIslam/PatternRecognitionLab | /Assignment 02/Lab 2.1/TwoDList.py | 1,106 | 3.515625 | 4 | import os
import re
print(os.getcwd())
#---------------------------------corpus text read------------------------------------
with open("corpus1.txt") as f1:
lines = f1.read()
#--------------------------------- spliting by paragraph---------------------------------
person = lines.split("\n\n")
pri... |
34be53844678ba0b0830987db774c66d25e8b72e | sandipgole/BasicPython | /21_2dlist.py | 258 | 3.96875 | 4 | matrix=[
[1,2,3],
[4,5,6],
[7,8,9]
]
'''matrix[0][1]=20
print(matrix[0][1])'''
for row in matrix:
for item in row:
print(item)
matrixA=[
[1,2],
[3,4]
]
for row in matrixA:
for num in row:
print(num) |
021ea54e8baa3e15cb9f02d3447264e368b702a6 | sandipgole/BasicPython | /07_Arithmetic.py | 139 | 3.71875 | 4 | print(1+2)
print(2-1)
print(5/2)
print(5//2)
print(5%2)
print(5*2)
print(5**3)
x=10
x=10+3
print(x)
y=20
y+=3
print(y)
z=10
z*=10
print(z)
|
1d65e4f105dde9639c59e211d1463fc0823dced4 | sandipgole/BasicPython | /16_Guessinggame.py | 226 | 3.796875 | 4 | secret_num=9
guess_count=0
guess_limit=3
while guess_count<guess_limit:
guess=int(input("guess: "))
guess_count+=1
if guess==secret_num:
print("you won")
break
else:
print("you loose") |
63d20821cc349256ae4929da0ef0a2691713a831 | gchristofferson/credit.py | /credit.py | 2,681 | 4.15625 | 4 | from cs50 import get_int
import math
# prompt user for credit card
# validate that we have a positive integer between 13 and 16 digits
while True:
ccNum = get_int('Enter Credit Card Number: ')
if ccNum >= 0:
break
# reset value of ccNum
copyCCNum = ccNum
count = 0
# count the number of digits in the ... |
d919fffb4b021e402e665f5e10dc4978640f1b53 | ohnoitsjmo/CSC365-Lab1 | /schoolsearch.py | 16,150 | 3.5625 | 4 | import re
class Student:
def __init__(self, StLastName, StFirstName, Grade, Classroom, Bus, GPA, TLastName, TFirstName):
self.StLastName = StLastName
self.StFirstName = StFirstName
self.Grade = Grade
self.Classroom = Classroom
self.Bus = Bus
self.GPA = GPA
se... |
2b8dd7f2e26e9e1d2ea426d93ce432d9711d3cae | naveenk4545/Practice-set | /single_list.py | 509 | 4.03125 | 4 | class Node:
def __init__(self,data):
self.data=data
self.next=None
class Linkedlist:
def __init__(self):
self.head=None
def print_list(self):
if self.head is None:
print("LL is Empty")
else:
N = self.head
while(N is not None):
... |
a8b8a9bba84f6d45aba52a792ddd4f1d6581ed1b | Janis90/snlp | /Project/implementation/ChangingRule.py | 20,644 | 4.25 | 4 | from implementation.Inflection import Inflection
class ChangingRule():
"""A general ChaningRule describes the process of changing an input word with a certain strategy to an output. The
ChangingRule base class refers to replacing a certain part of an input. PrefixRule or SuffixRule are applied for changes at ... |
434691b9d60b6179be17ec5ef41d59daceebf441 | ericbgarnick/AoC2017 | /2017day02/min_max.py | 1,638 | 4.0625 | 4 | from sys import argv
from typing import List, Callable
def total_differences_by_function(number_rows: List[str],
aggregation_function: Callable) -> int:
total = 0
for row in number_rows:
number_row = [int(number) for number in row.split()]
total += aggregation... |
352d2df0ac4e2560cdcdfec367a3f07aeab8937f | someMadCoder/mpt | /18.py | 387 | 3.78125 | 4 | words = ["hallo", "klempner", "das", "ist", "fantastisch", "fluggegecheimen"]
variants = {}
varCount = 0
for var in range(97, 123):
variants[chr(var)] = 0
for word in words:
for var in word:
variants[var] += 1
varCount += 1
word = input("Введите стоп слово: ")
chance = 1
for var in word:
... |
7ca653797e58e6f5710430753c2e6cc46c5cbec8 | someMadCoder/mpt | /11.py | 390 | 3.921875 | 4 | def getNum(num):
while type:
num = input('Введите ' + num + ': ')
try:
int(num)
except ValueError:
print('"' + num + '"' + ' - не является числом')
else:
break
return int(num)
a = getNum("основание")
b = getNum("степень")
num = a
for i in ra... |
42822dab2a362422b5fd9c50db2920c3ee7c254e | amanda103/Cracking-the-Coding-Interview | /zero_matrix.py | 967 | 3.59375 | 4 | # write a function that given an MxN matirix finds the zeros
# and sets rows and columns to zeros
import unittest
def zeros(mat):
col_to_z = set()
row_to_z = set()
for i, r in enumerate(mat):
for j, c in enumerate(r):
if c == 0:
col_to_z.add(j)
row_to_z.... |
52979760d9e1c9ba2049e86de84af98b99a744b8 | iHoHyeon/BOJ | /BASIC1/%11729.py | 394 | 3.65625 | 4 | N = int(input())
def HN(i,a,b,c):
if i==1:
print(a,c)
else:
HN(i-1,a,c,b)
#i-1 개를 1에서 2로 이동
print(a,c)
#1에 남은 1개를 3으로 이동
HN(i-1,b,a,c)
#2에 올려있는 i-1개를 3으로 이동
cnt = 1
for i in range(N-1):
cnt = cnt*2 +1
# N번째는 N-1개를 두번 이동하고 1개를 한번 이동시킨다
print(cnt)
HN(N,1,2,3) |
23fa1760ea7b4fcefcbb11fee9144460659dfc39 | iHoHyeon/BOJ | /CLASS3/1260.py | 742 | 3.5 | 4 | ##DFS and BFS
N, M, V = map(int,input().split())
matrix = [[0]*(N+1) for _ in range(N+1)]
## 행렬의 (a,b) = 1이면 a,b는 연결되어있다
for _ in range(M):
x,y = map(int,input().split())
matrix[x][y] = 1
matrix[y][x] = 1
def DFS(visit, start_node):
visit += [start_node]
for i in range(len(matrix[start_node])):
if matrix... |
f13bd2436840d8a4a85ae12b6e64b19de38622e9 | YsabelDuart/App-BOMTCHAU- | /tela.py | 3,886 | 3.609375 | 4 | from tkinter import *
#----------------------TELA 2-----------------------
class Tela2(Toplevel): #Pagina do cadastro
def __init__(self, original): #Inserindo inicialização
self.frame_original = original
Toplevel.__init__(self)
self.title('CADASTRO') # Inserindo nome da janela
... |
0c060b1df0de850f8b40b2cc66ccafe2b50f8e5e | dcnbruce/pbd_dnb | /dbs_car_rental/dbs_car_rental.py | 7,100 | 3.671875 | 4 | # CA03
# Student ID: 10365675
# DBS Car Rental - Object Oriented Programming
from car import Car, ElectricCar, PetrolCar, DieselCar, HybridCar, CarFleet
# Assumptions: There are only four types of cars: each class type has the same specifications, colour and mileage. For example there are 20 green Toyota Yaris cars ... |
6cada93ecd50aa4fba100bb5c35c6d62d4f936ff | jhg-eps/Intro_to_Unix_Systems_Programs | /ECE_331_HW14.py | 2,497 | 3.71875 | 4 | # Joseph Garcia
# ECE 331 Sheaff
# Homework 14
# May 6, 2015
#Request: Write a PYGTK application that grabs data from the temperature sensor and prints it to the terminal when you press the "Temp" button.
#Program is run using $ python ECE_331_HW14.py
#Note: Code is adapted from http://www.pygtk.org/pygtk2tutorial/se... |
8060affa584b2960c87b0b5b73372fc40f819fda | hsianghai/demo | /game1.py | 1,397 | 3.9375 | 4 | human = int(input('请输入您的等级:'));
angel = int(input('请输入天使的等级:'));
devil = int(input('请输入恶魔的等级:'));
humanlife = human * 100;
angellife = angel * 200;
devillife = devil * 250;
while(humanlife > 0 and devillife > 0):
print('你砍了恶魔一刀,伤害20生命');
devillife -= 20;
print('恶魔砍了你一刀,伤害30生命');
humanlife -= 30;
while... |
8a7bbba9c703e95fcf5c37a65956ca57338b4d33 | yassu/polynomial-ga | /polynomial_ga/main.py | 282 | 3.546875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from random import random
from entities import Wave
DEGREE_OF_WAVE = 100
def main():
coefs = [(random(), random()) for _ in range(DEGREE_OF_WAVE + 1)]
wave = Wave(coefs)
wave.plot()
if __name__ == '__main__':
main()
|
33a59e90274ccecfdc7bb6ee031ddecf57a40e89 | jamesbyrnes/recep-test | /graph.py | 13,540 | 4.1875 | 4 | from queues import PriorityQueue
class StationGraph:
"""
A class representing a graph of train stations and their connections.
The private dictionary _nodes contains:
keys - The names of each station (node) in the network.
values - Another dict containing the name of each station (node) th... |
804d49cc16147143b795633905cd5c77d74057ca | Monula21/Pyladies | /cisar.py | 329 | 3.578125 | 4 | "Tento program Vám zašifruje vložený text!"
k = int(input("Jaký je klíč?"))
text = input("Text k zašifrování?")
rozkouskovani = list(text)
i = len(text)
for opakovani in range(i):
prevod = ord(rozkouskovani[opakovani]) + k
novy = chr(prevod)
print(novy, end="")
#pi =
ord("a")
chr(97)
#ci = (pi + k) % 26
|
7e064e82fc46f10a506c93ffcada00f67b4ae947 | nevil-patel7/Dijkstra-Algorithm | /dijkstra_rigid.py | 6,901 | 3.921875 | 4 | #Importing required libraries
import heapq
import numpy as np
import math
import time
import matplotlib.pyplot as plt
#Initializing the variables
start_time = time.time()
plotx = []
ploty = []
ox =[]
oy =[]
obstacle_space =[]
obs =[]
open_list = []
closed_list = []
#Takes the Start and Goal Node fro... |
6e5b1518779ae223c51e892212a575538ff04aec | YellowOfTheEgg/ddss | /ddx-website/app/autocomplete/autocompleter.py | 485 | 3.921875 | 4 | from typing import List
class Autocompleter:
"""Implements a simple auto complete functionality based on the provided data.
"""
def __init__(self, options: List[str]):
self.options = options
def complete(self, term):
"""Returns a list of strings that contain the provided term from da... |
ab1ae89b29b7e47e543e9cdd703f1a6971974d4b | riopes/MP_Prob3-Python- | /Problem3.py | 676 | 3.875 | 4 | import numpy as np
print(' ')
# Can read nx2 matrix form
xi = int(input("Enter number of rows: "))
yi = 2
print("Enter values in the matrix: ")
# Must be exact values (e.g. twice number of row values)
R = list(map(int, input().split()))
e = np.array(R).reshape(xi, yi)
print(e)
print(' ')
def Python3(e):
... |
abb6ba83646ff851bf040335c71eac59697ae67d | jamoemills/misc | /utopian_tree.py | 656 | 3.984375 | 4 | #!\usr\env\python
# -*- coding: utf-8 -*-
import sys
def tree_height(cycle, cycles, height):
while cycle != cycles:
if cycle % 2 == 0: # Checks if summer cycle
height = height * 2
elif cycle % 2 == 1: # Checks if spring cycle
height = height + 1
cycle += 1
tree_height(cycle, cycles, height)
... |
dcb7085f360547f5cf4fe1b3f324dedd937b8e02 | rylee-boop7/booga_booga_123 | /celsius.py | 480 | 4.125 | 4 | temp = input ("Imput the tempurture you like to convert? (e.g., 45f, 102c etc.) : ")
degree = int(temp[: _1])
i_convention = temp[-1]
if i_convention.upper() == "C":
result = int(round((9 * degree) / 5 + 32))
o_convention = "Fahrenheit"
elif i_convention.upper() =="F":
result = int(round((degree - 32) * 5... |
72b76b4fdadfd01b0139c323b6412008fd70e90d | omi-akif/My_Codes | /Python/DataAnalysis/MIS401/Class Resource/1st Class/MIS401-Class 1.py | 1,402 | 4.125 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[12]:
# In[17]:
Name ='Kazi' #Assigning String Variable
# In[56]:
Age=28 #assigning variable
# In[15]:
Name #Printing varibale without using Print
# In[16]:
Age #Printing varibale without using Print
# In[18]:
Name
# In[19]:
print(Name)
# In[21... |
95116edab456123336900efa3f548562c6e66a05 | omi-akif/My_Codes | /Python/test_python/test_class2.py | 673 | 3.515625 | 4 | class Car(object):
def __init__(self, model, color, company, speed_limit):
self.color = color
self.company = company
self.model = model
self.speed_limit = speed_limit
def start(self):
print("started")
def stop(self):
print("stopped")
de... |
9ccd5d505534bbd966bb69748205e3369febd847 | Martystan/weekend-hw-rps | /tests/game_test.py | 378 | 3.5625 | 4 | import unittest
from models.game import Game
from models.player import Player
class TestGame(unittest.TestCase):
def setUp(self):
self.player1 = Player("player1", "rock")
self.player2 = Player("player2", "scissors")
def test_if_rock_beats_scissors(self):
result = Game.who_wi... |
fca2e4ec97be17bf43acfecd5d79d2501aa41b35 | fettucheeny/mini-pancakes | /calc.py | 510 | 3.984375 | 4 | print('1. add')
print('2. subtract')
print('3. multiply')
print('4. divide')
choice = int(input('Enter number of choice: '))
while choice > 4:
print('pick a number from 1 to 4 only')
choice = int(input('Enter number of choice: '))
else:
x = float(input('enter first number: '))
y = float(input('enter seco... |
513281329712151ce5776db93f5366c300911603 | fettucheeny/mini-pancakes | /power.py | 108 | 4.03125 | 4 | n = int(input('enter an integer number: '))
p = float(input('enter power: '))
result = n**p
print(result) |
878be9ed1842922b3298d7368466c870829252ac | CougNinja24/PY4E | /10-Tuples/ex10_4FreqAnalysis.py | 692 | 3.546875 | 4 |
#Freq Analysis, need to add def in this file for stringcleaning
import string
from stringcleaning import str_cleaner as SC
#fname = input('Enter file for analysis')
try:
fh = open(fname,'r')
except:
fh = open('../mbox-short.txt','r')
freq, cln_strngs = {}, []
for ls in fh:
cln_strngs.append(SC(ls))
... |
3013270ca21512345d62165312d4c205be658a25 | vassax/study | /block3_8.py | 2,686 | 4.0625 | 4 | # Блок 3. Задача 8. Калькулятор функции в классе
import math
import random
class Calc:
def plus(self, number1, number2):
print("Сумма = ", float(number1 + number2))
def minus(self, number1, number2):
print("Разность = ", float(number1 - number2))
def multi(self, number1, number2):
... |
0923d3f96524c4cd7f0a542c158feb6f67c30717 | ARCTraining/swd6_hpp | /previous_material/codes/profiling_pi.py | 926 | 3.59375 | 4 | # Profiling pi methods
# mw 20150916
import math
import random
import decimal
def montecarlo(maxIt):
ctr = 0
variance = 3.141
for i in range(maxIt):
if math.pow(random.random(), 2.0) + math.pow(random.random(), 2.0) <= 1.0:
ctr += 1
result = (4.0 * ctr / maxIt)
if abs(math.pi - result) <= variance:
... |
b29d9b5c12703fccbc47c3e817aba530acf9448a | ArmanSh7/SnakeGame | /Include/snake.py | 1,625 | 3.796875 | 4 | from turtle import Turtle, Screen
COORDINATES = [(0, 0), (-20, 0), (-40, 0)]
UP = 90
DOWN = 270
RIGHT = 0
LEFT = 180
class Snake:
def __init__(self):
self.segments = []
self.createSnake()
self.head = self.segments[0]
def snakeMove(self):
for segment in range(l... |
3617f55a8d77da3fcdf8720dc9787f89a40ce2ea | CalPlug/Numpy-TensorFlow_Examples | /GettingStarted/neural_decision_boundary.py | 1,062 | 4.0625 | 4 | #Neural Network Boundary Plot Example
#Adapted From: https://stats.stackexchange.com/questions/253217/neural-network-decision-boundary/254325
#Note:
#Each neuron splits the input into one of 2 classes (see: http://hagan.okstate.edu/NNDesign.pdf, Chapter 11)
#The first neuron splits the upper left blue input from... |
eda01e2851344fd421d7f46b3ab7ba5758d88bf4 | endherestaba/mis_programas_python | /manejo_excepciones.py | 262 | 3.65625 | 4 | def divide_elementos_de_lista(lista, divisor):
return [i / divisor for i in lista]
lista = list(range(10))
divisor = 2
def main():
print(divide_elementos_de_lista(lista, divisor)
if__name__ == '__main__':
if__name__ == '__main__':
main() |
7dd68dae22931a47b08678c07189a1322c8220ca | popcorncolonel/TrafficSim | /graphics.py | 3,288 | 3.765625 | 4 | """ Handles graphics via pygame.
Provides a Window class, for opening a window for the graphics display,
and a Sprite class, for images to be drawn on that display.
"""
import os, sys
import pygame
from pygame.locals import *
import threading
pygame.init()
def load_image(name, colorkey=None):
#fullname =... |
208f3676d2ce57c06ac2d79d9d5505d1f08d2648 | hadadnad/Python-projects | /Stack_Calculator.py | 1,285 | 4 | 4 | def StackCalc(inp):
"""
This function gets a string (e.g. "9 4 2 + 7 -") and does the calculations
as if it was a stack calculater (for the ex above: 7-(2+4)=1.)
This function returns the top of the stack (for the ex above: 1 because the stack is [9 1]).
"""
inp = inp.split()
leng = l... |
3658e1ee0217d92ff423052a5a44f347a591b73b | joeblack24/ordermark | /get_order.py | 1,886 | 3.640625 | 4 | def get_times(times, directions):
# People entering, exiting and results, setting default status to exiting
# because exiting people have priority in clash.
# Also getting initial time
entering = []
exiting = []
order = []
status = 1
time = times[0]
# Split to people entering and exi... |
20f875587c629d341bd7cf8b13ac7025b899117e | AntonyYan0715/ComputationalPhysicsHomework | /homework5/5_2_17307110134.py | 995 | 3.53125 | 4 | import numpy as np
import sympy as sp
from sympy.abc import t
def Simpson(x1, x2, n):
# Simpson's rule to calculate integration of f(x)
# x1: lower bound of integration
# x2: upper bound of integration
# n: number of intervals, which must be even
interval = np.linspace(x1, x2, num=n+1)
step = (x2-x1)... |
c4d00a89c39e443b68d7b27f521dce0a8d6c74f9 | AntonyYan0715/ComputationalPhysicsHomework | /homework4/最小二乘法.py | 920 | 3.515625 | 4 | import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import leastsq
def Fun(p,x): # 定义拟合函数形式
a1,a2,a3 = p
return a1*x**2+a2*x+a3
def error (p,x,y): # 拟合残差
return Fun(p,x)-y
def main():
x = np.linspace(-10,10,100) # 创建时间序列
pri... |
3fd5e293677113854d2f5d4a33bef3c9b91fe4f9 | KBabic/MY-PROJECTS | /Find_Pi_To_Nth_Digit.py | 185 | 3.859375 | 4 | import math
while True:
try:
print(round(math.pi,int(input("How many decimals for PI do you need? Please enter an integer: "))))
break
except:
continue |
dd5772edef98e367dd1b134d04f08652c6fb5459 | KBabic/MY-PROJECTS | /Python on Coursera/Mail_Senders.py | 717 | 3.703125 | 4 | name = input("Enter file:")
if len(name) < 1 : name = "mbox-short.txt"
handle = open(name)
senders = list()
ddd = dict()
for line in handle:
# take only lines that start with the word 'From '
if line.startswith('From '):
senders.append(line.split()[1])
# create a dictionary with either incrementing exis... |
a730cc5c9d85141825a60df5b9de4aa26b9755ca | KBabic/MY-PROJECTS | /Change_Return_Program.py | 1,767 | 4 | 4 | while True:
try:
cost = float(input("Please enter the cost in dollars: "))
break
except:
print("Please enter the cost as number with '.' as separator for decimals!")
while True:
while True:
try:
payment = float(input("\nEnter your payment in dollars: "))
... |
a390437a991d4054376f97283da012b3d082d5b3 | KBabic/MY-PROJECTS | /Spy_Game.py | 353 | 3.578125 | 4 | # moj nacin:
def spy_game(nums):
for i in range(0,len(nums)-1):
if nums[i] == 0:
for n in range(i+1,len(nums)-1):
if nums[n] == 0:
for x in range(i+2,len(nums)-1):
if nums[x] == 7:
... |
e08f2b54e7e43af7ed00a4fc3f3ce2378941b21e | KBabic/MY-PROJECTS | /Q files/Q15.py | 421 | 3.984375 | 4 | # Write a program that computes the value of a+aa+aaa+aaaa with a given digit as the value of a.
d = input('Enter a digit: ')
x = d + '+' + d*2 + '+' + d*3 + '+' + d*4
print(x)
y = x.split('+')
sum = 0
for num in y:
sum += int(num)
print(sum)
# another way:
# a = input()
# n1 = int( "%s" % a )
# n2 = int( "%s%s" %... |
9eb989e34bbc29dcfa7e3c2b48e3e5bc62be8f07 | xzlukeholo/guess_number | /guess_number.py | 1,059 | 3.9375 | 4 | import random
print('歡迎來到~終極密碼~請先決定最大的數字與最小的數字')
min_number = input('請輸入最「小」值:')
max_number = input('請輸入最「大」值:')
min_number = int(min_number)
max_number = int(max_number)
game_round = 0
answer = random.randint(min_number, max_number)
while True:
num = input('請猜數字:')
num = int(num)
game_round = game_round + 1
if n... |
becf8dbae35653aded756a0afc0baf9de31d1cf1 | pois2000/project | /game/spaceship/shooting_game.py | 6,511 | 3.609375 | 4 | # -*- coding: utf-8 -*-
import pygame
import random
import sys
# Define some colors
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
RED = (255, 0, 0)
BLUE = (0, 0, 255)
GREEN = (0, 255, 0)
screen_width = 700
screen_height = 400
background_position = [0, 0]
# --- Classes
class Block(pygame.sprite.Sprite):
""" This cl... |
4c7e69575e94494b766bc93490e318e1041fef43 | RareRaj25/Python_Program | /Reverse_No.py | 109 | 3.90625 | 4 | i=int(input("Enter a num "))
rev=0
while(i>0):
rev=(rev*10)+i%10
i=i//10
print("Reverse=",rev)
|
4237780ac438f7b8493478369bbfbecad6c9c5d5 | gonchi282/factory | /catfile.py | 655 | 3.5625 | 4 | # coding: utf-8
# パッケージインポート
import csv
import re
import glob
# ファイルオープン
machinefile = open("MAC_machine_list.csv", "r")
# CSVを読み込む
machinecsv = csv.reader(machinefile)
# マシン名をリストに入れる
machinelist = [i[2] for i in machinecsv]
# マシンのジョブをリストに入れる
machinejob = [i[1] for i in machinecsv]
# ファイルクローズ
machinefile.close()
# ... |
4de58601460d7ea1e5590131574bdc92c8952b54 | Ahnseungwan/Phython_practice | /2021.01/1.13/1.13 람다.py | 728 | 3.8125 | 4 | # def call_10_times(func):
# for i in range(10):
# func()
# def print_hello():
# print("안녕하세요")
# call_10_times(print_hello)
# map , filter
# def power(item):
# return item * item
# def under_3(item):
# return item < 3
# list_input_a = [1, 2, 3, 4, 5]
# output_a = map(power, list_input_a)
#... |
6f6ed37d86fa84fe8061f1c2c0cce4fae0689e2b | Ahnseungwan/Phython_practice | /2020.12/12.31/Quiz2.py | 832 | 3.59375 | 4 | # 퀴즈 - 사이트별로 비밀번호를 만들어 주는 프로그램을 작성하시오
#예) http://naver.com
# 규칙1 : http:// 부분은 제외
# 규칙2 : 처음 만나는 점(.) 이후 부분은 제외 => naver
# 규칙3 : 남은 글자중 처음 세자리 + 글자 갯수 + 글자 내 'e' 갯수 + "!" 로 구성
# 예) 생성된 비밀번호 : nave 51!
#내가 푼 답
# name = "http://naver.com"
# print("생성된 비밀번호 :"+ name[7:10]+ str(len(name[7:-4]))+str(name[7:-4].count("e")... |
b4b33fcb2a566d1bee64ea3e0af972e37bcf9d77 | Ahnseungwan/Phython_practice | /2021.01/1.7/1.7 파일 입출력.py | 1,315 | 3.59375 | 4 | # score_file = open("score.txt","w", encoding="utf8")
# print("수학 : 0", file=score_file)
# print("영어 : 50", file=score_file)
# score_file.close()
# score_file = open("score.txt","a", encoding="utf8") # 뒤에더 추가할때는 w가 아니라 a 를쓴다
# score_file.write("과학 : 80")
# score_file.write("\n코딩 : 100") # print 와는 다르게 줄바꿈이 없어서 \n을 통해서... |
e1a2d8b3884e8d27d1b2abb85cc59490e34bdfe3 | rlongocode/Portfolio | /Python/Independent Practice/Problem 1_3.py | 143 | 3.625 | 4 | #Ricardo Longo
def problem1_3(n):
my_sum = 0
i = 1
while i <= n:
my_sum = my_sum + i
i = i+1
print(my_sum) |
693ea8a9af5de02bf275efb087d181f687e45917 | rlongocode/Portfolio | /Python/Computer Graphics Design/GengarPokemonDraw in Python/pokemonshadeRicardo.py | 3,125 | 3.5625 | 4 | from graphics import *
import math
import random
def main():
win = GraphWin("My Window",500,500)
win.setCoords(0,200,200,0)
# win.setBackground( 'blue' )
i=int(input("enter color, 0 for red, 1 for green"))
if( i==0):
win.setBackground( color_rgb(255,0,0 ))
else:
win.set... |
5f0dd287d8f815acb97ee0fdf9a02d02edce17b9 | bbhunter/blip | /blip/blip.py | 2,247 | 3.890625 | 4 | import argparse
parser = argparse.ArgumentParser(description='B(itf)lip a string to all its variants, for science.')
parser.add_argument('-s', required=True, type=str, help='String you want to blip')
parser.add_argument('--ascii', action='store_true', help='Print ASCII strings only')
parser.add_argument('--no-caps', a... |
6ab711498820b8d6f553b2a30fabf35495b57aef | tiago-falves/FPRO-Python | /FproPlay/Tuples/add_item.py | 201 | 3.609375 | 4 | def add_item(tup,idx,item):
tup=list(tup)
if idx==0:
tup[0]=item
elif idx==len(tup)-1:
tup[len(tup)-1]=item
else:
tup.insert(idx,item)
return tuple(tup)
|
186977482ed84bdc14b3d36c15a0b7619ba06e1b | tiago-falves/FPRO-Python | /Testes/Miniteste 2/R12/sort_by_field.py | 930 | 3.625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Dec 20 12:16:59 2018
@author: Xavier Pisco
"""
def sort_by_field(filename, field):
result = ''
with open(filename, 'r') as f:
content = f.read()
content = content.split('\n')
a = content[0].split(',')
content.... |
d147438641fa96e35b069323c24c8a93401fd015 | tiago-falves/FPRO-Python | /Testes/Miniteste 2/R08/anagrams.py | 945 | 3.625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Nov 22 18:28:44 2018
@author: Gustavo
"""
def anagrams(alist):
result=[]
m=0
for i in alist:
result.append([])
result[m].append(i)
result1=[]
for j in alist:
if i!=j:
f= list(i.lower().replace(" ",""))
... |
206b0fc299ebc10df7b51e709141df6220dc48ec | tiago-falves/FPRO-Python | /Testes/Miniteste 2/Estudo/R07/triplet.py | 361 | 3.71875 | 4 | def triplet(atuple):
a=()
s=(len(atuple),len(atuple),len(atuple))
for i in range(len(atuple)-2):
for j in range(i+1,len(atuple)-1):
for k in range(j+1,len(atuple)):
if atuple[i]+atuple[j]+atuple[k]==0 and (i,j,k)<s:
s=(i,j,k)
a=(atu... |
3f0ceb4b91deed31d3b4d69f610f32e02efdecd5 | tiago-falves/FPRO-Python | /Testes/PE3_1/recursive_dot.py | 415 | 3.734375 | 4 | def recursive_dot(l1,l2):
soma=0
def extra(l1,l2,soma):
for i in range(len(l1)):
if type(l1[i]).__name__=="list":
return extra(l1[i],l2[i],soma)
else:
soma+=l1[i]*l2[i]
return soma
return extra(l1,l2,so... |
c65ea24a7fdc6bd885839ee86eb5979cd8a05d70 | tiago-falves/FPRO-Python | /RE/Exceptions/raise_exception.py | 257 | 3.625 | 4 | def raise_exception(alist, value):
l=[]
for i in alist:
try:
if i<=value:
raise ValueError('{} is not greater than {}'.format(i,value))
except ValueError as error:
l.append(error)
return l
|
ca9cd2c388955ab46bfca746792502b82f8aa1b2 | tiago-falves/FPRO-Python | /FproPlay/Strings/ragnoli.py | 954 | 3.546875 | 4 | def ragnoli(N):
if N==1:
return "a"
else:
traços="-"
s=""
ntraços=N-2
k=0
abc="abcdefghijklmnopqrstuvwxyz"
for i in range(N-1):
k=0
ntraços=(N-(i+1))*2
s+=traços*ntraços
for j in range(i+1):
... |
6399909e638f5691dfc846ccb7e14f4a3df03d47 | tiago-falves/FPRO-Python | /Testes/PE1.py | 758 | 3.6875 | 4 | def question1(num):
soma=0
num=str(num)
for i in num:
soma+=int(i)**3
if soma==int(num):
return True
return False
def question2(d,num):
soma=0
num=str(num)
for i in num:
if int(i)>d:
soma+=2*int(i)
return soma
def question3(names,ages):
s=""
... |
954959ab38ebc709a8f81657b636fcf5f6d3ede3 | tiago-falves/FPRO-Python | /RE/Outros/min_path.py | 1,790 | 4.15625 | 4 | """
5. Minimum path
Write a function min_path(matrix, a, b, visited=[]) that discovers the minimum path
between a and b inside the matrix maze without going through visited twice. Positions a
and b are tuples (line, column), matrix is a matrix of booleans with False indicating no
obstacle and True indicating an obstacl... |
4a3562cc1920d873d7fa7b0cd1174374cbd2c974 | tiago-falves/FPRO-Python | /RE/Outros/grades.py | 416 | 3.75 | 4 | def ordem(records):
soma=0
for i in records[2]:
soma+=i
avg=soma/len(records[2])
return (-avg,records[0],records[0])
def grades(records):
new=sorted(records,key=ordem)
return new
records=(('João', 'up20186042', (90, 87)),('Ana', 'up20186040', (90, 90)),('José', 'up20186063', (70, 90)),(... |
a6d8eba4f2f2da65220dcab0fd1023a95b7d50ac | tiago-falves/FPRO-Python | /FproPlay/Tuples/counting elements.py | 136 | 3.65625 | 4 | def count_until(tup):
for i in range(len(tup)-1):
if type(tup[i+1]).__name__=="tuple":
return i+1
return -1
|
68ff1cd921793bbf8cac71fd1cba12b096c26731 | tiago-falves/FPRO-Python | /Testes/Miniteste 2/up201706156/RE10/flatten.py | 235 | 3.625 | 4 | #1. Flatten
def flatten(alist):
if isinstance(alist, list):
if len(alist) == 0:
return []
first, rest = alist[0], alist[1:]
return flatten(first) + flatten(rest)
else:
return [alist] |
b471d81e9575815f73eced1a58b3323a1d982889 | NikSWE/warnsdorff-algorithm-visualizer | /utils/cursor.py | 617 | 3.828125 | 4 | class Cursor(object):
x: int
y: int
max_x: int
max_y: int
def __init__(self, max_x: int, max_y: int) -> None:
self.max_x = max_x
self.max_y = max_y
self.x = self.max_x // 2 - 15
self.y = self.max_y // 2 - 8
def get_x(self) -> int:
return self.x
def ... |
d6563425ec8706dc3b2dee7024637d36a36a2266 | mdziuban/Python-HTML-and-CSS | /Python_Labs/Extra_Labs/Connect4_v2_mark.py | 4,573 | 3.671875 | 4 | class Player:
def __init__(self, name, color):
self.name = name
self.color = color
class Game:
def __init__(self, moves=0):
self.board = [
[' ',' ',' ',' ',' ',' ',' '],
[' ',' ',' ',' ',' ',' ',' '],
[' ',' ',' ',' ',' ',' ',' '],
[' ',' ... |
e6d923a36ecd16e5207fc29a4a54f0ff37282cab | mdziuban/Python-HTML-and-CSS | /Python_Labs/Required_Labs/Lab12_v1_mark.py | 684 | 3.609375 | 4 | file_name = "contacts.csv"
def open_and_read(file_name):
with open(file_name, "r") as file:
lines = file.read().split('\n')
for i in range(len(lines)):
lines[i] = lines[i].split(',')
file.close
return lines
def create_contacts_list(lines, contacts):
for i in range(1,len(li... |
9ef92d83f95f0469d875fdd9a95780a5db27bf46 | mdziuban/Python-HTML-and-CSS | /Python_Labs/Required_Labs/Lab09_v2_mark.py | 419 | 3.78125 | 4 |
data = [1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 5, 6, 7, 8, 9, 8, 7, 6, 7, 8, 9]
def draw_graph(data):
top_of_graph = max(data)
for i in range(top_of_graph,0, -1):
row_list = []
for item in data:
if item >= i:
row_list.append(" X ")
else:
row_list.... |
77b75b5e83619fc1cbe06aeab7f5b56fcb424c95 | jacky-hello-cck/helloworld | /Ex2.py | 200 | 3.625 | 4 | def func(x):
if x == 1:
def rv():
print("x is equal to 1")
else:
def rv():
print("x is not 1")
return rv
new_func = func(2)
new_func()
|
17d8451dd01292304e8262dbc51e8ca9fb174080 | Sunilnain/Bill-Generator | /Recipt(Tkinter).py | 2,345 | 4.0625 | 4 | # import Tkinter and make interface of size(300x180)
import tkinter as tk
from tkinter import *
root = tk.Tk()
root.geometry("300x180")
root.configure(bg='#856ff8')
item_name=tk.StringVar()
item_price=tk.IntVar()
item_quant=tk.IntVar()
# add() method is use for operatimg add button
def add():
global... |
15ba4f68f198cf8cc6002824bdadb0f6e2275b69 | JanaanL/neural_net | /neural_net.py | 11,273 | 4.28125 | 4 |
# coding: utf-8
# Three-layer Neural Network classifier
# In[69]:
import numpy as np
import matplotlib.pyplot as plt
# In[70]:
def sigmoid(Z):
return 1/(1+np.exp(-Z))
# In[71]:
class ThreeLayerNet(object):
"""
A three-layer fully-connected neural network. The net has an input dimension of
N, two-... |
b8bc37e2eb5d2676feebd21cd6b08e83af86fa01 | da8865892q/learn_python_code | /6kyu/calculate_damage.py | 1,288 | 3.609375 | 4 | # Pokemon Damage Calculator
# https://www.codewars.com/kata/536e9a7973130a06eb000e9f
# My code
def calculate_damage(your_type, opponent_type, attack, defense):
effectiveness = type_check(your_type, opponent_type)
return (50 * (attack / defense) * effectiveness)
def type_check(your_type, opponent_type):
if ... |
178dac3434f5e8c0947e9bca9be816bed0ecddb0 | kaizokufox/Python | /python/exercFuncao.py | 666 | 4.03125 | 4 | '''1)Faça um programa que recebe um número inteiro e através de um módulo
função calcula e mostra se o número é primo ou não.'''
'''
def primo(num):
cont = 0
for i in range(2, num):
if num % i == 0 :
cont = cont +1
break
if cont == 0:
return True
else:
... |
9b2f498eb5a9866cf6feb8f99303d850812b6fb5 | kaizokufox/Python | /ExercRepetição.py | 2,458 | 4.125 | 4 | #1) calcular a soma dos numeros digitados e a media
'''
soma = 0
media = 0
numero = 1
qdt = 0
while numero != 0 :
numero = int(input("Digite um numero: "))
if numero != 0:
soma = soma + numero
qdt = qdt + 1
media = soma / qdt
print("A soma dos números é: %d " % soma)
print("A medi... |
8180da315e37a3b95d2b2a5bb98f70040a5951cb | kaizokufox/Python | /Exerc2.py | 1,214 | 4.53125 | 5 | #print("flavia e te amo")
#Operadores aritméticos auxiliares em python
''' ** potenciação Exemplo -> 2**3 = 8
math.sqr Radiciação exemplo -> math.sqrt(4) = 2
% Resto de Divisão Exempl -> 4%3 = 1'''
#Prioridades
'''Pareneses mais internos
pot rad
* / mod
+ -'''
#Exemplo/Exemplo de operação arimética
# A... |
1bc8f525da47f764d2d3ce4396d488b964a6ceb3 | Ankit1dubey/Hacktoberfest-Accepted | /Python/binarysearch.py | 341 | 4 | 4 | def binarysearch(arr, target):
n=len(arr)
arr=sorted(arr)
l=0
r=n-1
while (l<=r):
half=int((l+r)/2)
check=arr[half]
if target == check:
return half
elif target > check:
l=half+1
elif target < check:
r=half-1
return "No... |
f1bc2cbde2a268c020ebee9cb6adcdadcc1626f2 | Ankit1dubey/Hacktoberfest-Accepted | /Python/The next palindrome.py | 474 | 3.78125 | 4 | def rev_item(p):
rem=0
num=0
while p>0:
rem=(rem*10)+(p%10)
num=rem
p=p//10
return(num)
n=int(input("Number of test cases you want: "))
for i in range(n):
t=int(input("Enter a number:"))
if t==rev_item(t):
print(f"{t} itself is a palindrome")
else:
fo... |
c0896304188088cb6bfa4644741f6ac469b07a28 | absupriya/Applied-Algorithms | /1. Bubble sort/bubble_sort.py | 2,273 | 4.375 | 4 | #Reading the entire input file
orig_file=open('input.txt','r').readlines()
#Convert the input data from strings to integer data type
orig_file = list(map(int, orig_file))
#Create an empty list to hold the average elapsed time and the number of inputs
avg_elap_time_list=[]
num_of_inputs_to_sort=[]
#Setting up the arr... |
053ce7f44b55e85e90693b995bc07f3a5f8d2ac3 | debrosky/python | /Exercises/ex24.py | 1,273 | 3.953125 | 4 | print "Let's practice everything."
print 'You\'d need to know \'bout escapes with \\ that do \n newlines and \t tabs.'
poem = """
\tThe lovely world
with logic so firmly planted
cannot discern \n the needs of love
nor comprehend passion from intuition
and requires an explanation
\n\t\twhere there is none.
"""
print "... |
660ac78e3c7c71a1633f2b919e167a1cd08a6627 | nalie-linda/Cali_predictions | /first-cali-prediction.py | 2,845 | 3.515625 | 4 | #!/usr/bin/env python
# coding: utf-8
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import os
os.getcwd()
data = pd.read_csv("./Cali Hosuing Predict_files/housing.csv")
#exploring the dataset
data.info()
# In[10]:
#statistics about our dataset
#data.... |
04e124cc6ccfb31d1e12a2492ea6fb579874f180 | daimainardi/curso-python | /exercicios/ex035.py | 421 | 3.9375 | 4 | r1 = int(input('Qual é o comprimento da primeira reta: '))
r2 = int(input('Qual é o comprimento da segunda reta: '))
r3 = int(input('Qual é o comprimento da terceira reta: '))
lista = [r1, r2, r3]
if ((r1 + r2) > r3 and r3==max(lista)) or ((r1 + r3) > r2 and r2==max(lista)) or ((r2 + r3) > r1 and r1==max(lista)):
p... |
71d45bf0d5426446382fbeccddab95fc5b571f97 | daimainardi/curso-python | /exercicios/ex031.py | 249 | 3.734375 | 4 | distancia = float(input('Qual a distância em Km da viagem que quer fazer? '))
if distancia <= 200:
print('O preço da passagem é R$ {:.2f}'.format(distancia * 0.50))
else:
print('O preço da passagem é R$ {:.2f}'.format(distancia * 0.45)) |
28b4d283ae0bb546aa994f788af1f60cfb41ac28 | daimainardi/curso-python | /pythonteste/aula06a.py | 421 | 4.03125 | 4 | # n1 = input('Digite um valor: ')
# print(type(n1))
# se deixar assim ele entende que é uma string
# n1 = int(input('Digite um valor: '))
# print(type(n1))
# converteu para numero inteiro
n1 = int(input('Digite um número: '))
n2 = int(input('Digite outro número: '))
soma = n1 + n2
# print('A soma dos números', n1, 'e'... |
adb047b71f44ce538781db813692d2f5f32f89aa | daimainardi/curso-python | /exercicios/ex024.py | 289 | 3.90625 | 4 | #cid = str(input('Em qual cidade você mora? ')).strip()
#print(cid [:5].upper() == 'SANTO')
#true
cidade = str(input('Em qual cidade você mora? ')).strip()
if cidade.upper().startswith('SANTO'):
print('A cidade começa com Santo')
else:
print('A cidade não começa com Santo')
|
3b5b8813dc4716fab95c24de2551d7d41ccd52d4 | mmichalke1/MIS3640-01 | /Text_analysis.py | 1,071 | 3.671875 | 4 | import string
# print(string.punctuation)
sherlock = (open('sherlock_holmes.txt'))
def skip_gutenberg_header(book):
header = 1000000
for i, line in enumerate(book):
if line.startswith('Produced'):
header = i
if i > header:
print(line)
def total_words(book):
wordc... |
09d673c4010596cbf98102227ecec155ffef5e90 | cotengineer/Python-Codes | /missing_integer_finder.py | 686 | 3.53125 | 4 | def solution(A):
Asorter = A
#sort least to largest
Asorter.sort()
#initiate empty array to store unique values (sorted)
Asort = []
#loop through values for unique values
for i in Asorter:
if i not in Asort:
Asort.append(i)
#all negative integers
if ... |
db5d8a4248eb525151c4cb389dd98ff1e055a130 | denisefavila/python-playground | /src/linked_list/remove_duplicates.py | 1,247 | 4 | 4 | from typing import Optional
from src.linked_list.node import Node
def remove_duplicates(head: Optional[Node]) -> Optional[Node]:
"""
Remove duplicates from an sorted linked list,
such that each element appears only once.
https://leetcode.com/problems/remove-duplicates-from-sorted-list/
"""
c... |
77eeda8905113f1cbd1d2fe1e13685c814ebe662 | denisefavila/python-playground | /src/linked_list/swap_nodes_in_pair.py | 720 | 4.125 | 4 | from typing import Optional
from src.linked_list.node import Node
def swap_pairs(head: Optional[Node]) -> Optional[Node]:
"""
Given a linked list, swap every two adjacent nodes and return its head.
You must solve the problem without modifying the values in the list's nodes
(i.e., only nodes themselv... |
84153183e0a39b01ff864ec034bcfa734c730462 | fsakura/leetcode-py | /sol1.py | 2,352 | 3.71875 | 4 | #!/usr/bin/python
# Given an array of integers, find two numbers such that they add up to a specific
# target number.
# The function twoSum should return indices of the two numbers such that they add
# up to the target, where index1 must be less than index2. Please note that your
# returned answers (both index1 and ind... |
e70fb0aa3e1d79e98dcd5eca46ae3c83829f76c2 | antatianka/Machine_Learning_Regression | /RSS.py | 2,138 | 3.71875 | 4 |
import pandas as pd
from sklearn import linear_model
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import math
train_data = pd.read_csv("wk3_kc_house_train_data.csv", dtype=dict)
test_data = pd.read_csv("wk3_kc_house_test_data.csv", dtype=dict)
valid_data = pd.read_csv("wk3_kc_house_valid_d... |
15addcdd1118225f4cdb6b6e90a461a2564f43fb | FawnAardvark/1_1 | /1_1/Hello World.py | 193 | 3.671875 | 4 | import turtle as trtl
t = trtl.Turtle()
t.penup()
t.goto(-200, -200)
t.pendown()
x = 3
while x < 3:
t.forward(100)
t.left(90)
t.forward(200)
t.right(90)
x = x + 1 |
4abe3499dda109510e4504da973652e71024d54b | FawnAardvark/1_1 | /1_2/1_2_1.py | 1,619 | 3.53125 | 4 | # a121_catch_a_turtle.py
#-----import statements-----
import random as rand
import turtle as trtl
import turtle as score_writer
import turtle as counter
#-----game configuration----
score = 0
spot_color = "cyan"
spot_size = 2
spot_shape = "circle"
font_setup = ("Arial", 20, "normal")
timer = 30
counter_int... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.