blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
ab044d0514af5a1d52cc9dcd6352f40b41d3aa85 | jonolss/AdventOfCode2020 | /adventOfCode/day1/day1.py | 1,890 | 3.65625 | 4 | def main():
print("HEJ")
path = "inputDay1.csv"
list = getDynamicList(path)
sortedList = sortList(list)
print("Part1 start")
part1(sortedList)
print("Part1 end")
print("Part2 start")
part2(list)
print("Part2 end")
def part2(list):
list.sort()
ind1 = 0
ind2 = 1
... |
4cf6e40a2ebd7adf55407950789ceab66362fdfa | roy-van-dijk/iscrip | /assignments_2/driepluseen.py | 2,826 | 3.765625 | 4 | # Main class
def main():
# Intial list with prices of items to be bought
prijzen = [3.23, 5.32, 8.23, 2.23, 9.98, 7.43, 6.43, 8.23, 4.23]
# Print total price of all items together minus the 2 cheapest items
print(samen(prijzen))
# Print prices array grouped in 4's
print(groeperen(prijzen))
... |
412ab69dcfa60737c083dd59347d3ecb2160a0da | vinayshashank/Python | /coding interview.py | 1,304 | 3.9375 | 4 | # Enter your code here. Read input from STDIN. Print output to STDOUT
import math
a,b = map(int,raw_input().strip().split(" "))
fact = math.factorial
print fact(a)/fact(b)/fact(a-b)
#--------------------------------------------------------------------------
# Enter your code here. Read input from STDIN. Print output to... |
2b088ac251f180d37b330d7f12609e1ade9be3c0 | OkJoe/JoesRSA | /RSAbaseTransformer.py | 210 | 3.734375 | 4 | #! /usr/bin/env python
def base10to2(var):
s = 23
temp = ''
while s >= 0:
temp = temp + str (var / (2 ** s))
var = var % (2 ** s)
s = s - 1
return temp
def base2to10(temp):
return int (temp, 2) |
e818d6d6e154ea341cf6e3a90010d9c5c16cd7df | carlosgallardo21/SY402 | /csv_parser.py | 274 | 3.59375 | 4 | import csv
def main():
list = ["filename","/tmp/","hash_here","datetime"]
csv_parser(list)
def csv_parser(list):
with open("hash.csv", 'a+') as csv_file:
csvwriter = csv.writer(csv_file)
csvwriter.writerow(list)
csv_file.close()
return
main()
|
e1ecb3509114bad95fb9bcadcbebec372f000d8c | Nagammam/python-lab | /3b.py | 168 | 3.65625 | 4 | import string
from random import randint
str1=string.printable
print(str1)
print(len(str1))
print("password")
for i in range(6):
print(str1[randint(0,100)],end="")
|
d736f32e5b20aaa40e388686d229e20e7a9656bd | marianatudo/Exercise01-Result | /exercise01-result.py | 1,494 | 4.0625 | 4 | """
cliente:
mira esta buenisimo peeeerroooooo, fijate que mi clientela a aumentado a veces tengo
3 a veces 5 a veces 10 osea ya no se cuantos clientes tendre en un dia, podrias
agregarle alguna forma de que yo le diga cuando quiero que se detenga y que me muestre
el reporte de lo que llevo en cos... |
82907992857d00f09fe51ba9eb7be582af1546b0 | CauanKMS/Exercises_20170913 | /exercicio5.py | 421 | 3.515625 | 4 | #Exercicio5
#Cauan K, 09/13/17
#Kill me please
c = input("Digite o valor de C: \n")
n_String = input("Digite o valor de N: \n")
n = int(n_String)
if(n > 50):
n2 = 50
salario = 10 * n2
ne = n - 50
e = ne * 20
else:
salario = 10 * n
e = 0
salarioTotal = salario + e
pri... |
78693cd1f53b663061337bace998e54622728e8a | bhanu-pappala/Random | /Python/paranthesis_generator.py | 776 | 3.5 | 4 | from collections import deque
class Parantheses:
def __init__(self, string, open, close):
self.string = string
self.open = open
self.close = close
def parantheses_gen(num):
result = []
queue = deque()
queue.append(Parantheses("", 0, 0))
while queue:
present = que... |
af12e5efcd68abd0f2cff2966019e693d680c414 | bhanu-pappala/Random | /Python/heap_sort.py | 714 | 4.125 | 4 | #/usr/bin/python3
def heapify(arr, heap_size, index):
largest = index
left, right = 2 * index + 1, 2 * index + 2
if left < heap_size and arr[left] > arr[largest]:
largest = left
if right < heap_size and arr[right] > arr[largest]:
largest = right
if largest != index:
arr[lar... |
3879e12d3923bfb016149b2877623c5a7aa5a63f | Biblicalhuman/Lab_18S103156 | /src/Game_start.py | 1,987 | 3.609375 | 4 | import numpy as np
import os
from chess import *
if __name__=="__main__":
#主函数
GameType=input("Game:chess or go:")
pl1,pl2=input("player1 and player's name:").split(' ')
if GameType=="chess":
myGame=Chess(pl1,pl2)
elif GameType=="go":
myGame=Go(pl1,pl2)
i=0
print('本游戏需输入正确的指... |
e7a9e817a7d389b6a653ddd8bd7e42f22844e1c7 | yourbasic/grudat18 | /ovn0/uppg3.py | 781 | 3.984375 | 4 | # Nisse Nilsson, grudat18 uppg 0.3
class Stack:
"""This class implements a stack of objects."""
def __init__(self):
"""Construct an empty stack."""
# _data[] holds the stack items.
self._data = []
def push(self, item):
"""Add x to the top of the stack."""
self._data += [item]
def pop(self):
"""Remov... |
c354040f0e6c79879d59a0c20b6aebb99ebe9827 | mprac/knights | /puzzle.py | 3,016 | 4 | 4 | from logic import *
AKnight = Symbol("A is a Knight")
AKnave = Symbol("A is a Knave")
BKnight = Symbol("B is a Knight")
BKnave = Symbol("B is a Knave")
CKnight = Symbol("C is a Knight")
CKnave = Symbol("C is a Knave")
# Puzzle 0
# A says "I am both a knight and a knave."
knowledge0 = And(
# if A were a knight, ... |
2871388e49c2daeb3ef0d7771433c4d3d734b5f2 | User135v20/Python | /task1/SRC/task1.py | 1,660 | 3.65625 | 4 | import re
import sys
def converter_from_10(number, number_system):
bit_depth = len(number_system)
result = []
if number > 0:
while number > 0:
remains = number % bit_depth
number = number // bit_depth
result.append(number_system[remains])
elif number == 0:
... |
bcd48174d81fe6da70e31c4450625f625257b037 | Syix-Stevens/bagorenkeepfiles | /BGK_Source.py | 129,358 | 4.0625 | 4 | #start of game
def start(first = False):
if first == True:
print "There are doors to your left and right and a long hallway in front of you."
print "The hallway is brightly lit by rows of torches on the wall that don't seem like"
print "they'll go out any time soon. Where would you like to go?"
while Tr... |
b7d4b52134a589d296b11e2da25d6145d07c5f4b | austinsanchez45/Robots-vs-Dinosaurs | /robot.py | 777 | 3.9375 | 4 | from weapon import Weapon
class Robot:
def __init__(self):
self.name = ""
self.health = 100
self.weapon = Weapon()
self.alive = True
def attack(self, dinosaur):
print(f"\n{self.name} blasts the {dinosaur.name} with their {self.weapon}!")
dinosaur.health -= self.... |
9ddb1d790590d19493c18788bc35ba847adf7788 | hemafeifei/python_projects | /multi-threading/threading101/aaa.py | 671 | 3.578125 | 4 | import time
import threading
def doWaiting():
n = 0
while n < 10:
print('t1 start waiting {}:'.format(n), time.strftime('%H:%M:%S'))
time.sleep(2)
print('t1 stop waiting {}'.format(n), time.strftime('%H:%M:%S'))
n += 1
def doWaiting2():
n = 0
while n < 5:
print(... |
807324a3cf7ee4b7740ea5612fbceec6cb8b9b4a | irinaignatenok/Dev-Inst | /Week7/Day1/Exe_Gold/ExeGold.py | 3,382 | 3.671875 | 4 | def main():
d_ages = {
"yael": 27,
"dani": 31,
"Julie": 30,
"Shmecht": 19
}
print(d_ages)
d_exe2 = {0: 10, 1: 20}
d_exe2[2] = 30
print(d_exe2)
mx = 0
for x in d_ages:
if d_ages[x] > mx:
mx = d_ages[x]
print(mx)
products = {"SMA... |
b13bdfba738c47e0b740d542de1bd38b5c150a32 | irinaignatenok/Dev-Inst | /Week7/Day1/daily_challange/perfect number.py | 551 | 3.84375 | 4 | def main():
try:
user_input = int(input("enter a positive number to be checked as perfect\n>>"))
except:
print("not a number, goodbye")
return
if user_input < 1:
print("not a positive number, goodbye")
return
divisors = []
for x in range(1,user_input):
... |
5fd0828c86ce2f0989b2d27d09551291935f2bf6 | irinaignatenok/Dev-Inst | /Week9/Day 1/Daily Challange.py | 600 | 4.1875 | 4 | class Palindrom():
def __init__(self,word_input):
self.word = word_input
def is_palindrome(self):
for i, letter in enumerate(self.word):
if letter != self.word[-i-1]:
return False
return True
def main():
while True:
user_input = input("en... |
2b75f322d7f19feb1ab881087fdb9288197f507c | irinaignatenok/Dev-Inst | /Week10/Day1/exeXP.py | 324 | 3.828125 | 4 | import random
import string
def randomize(number):
if number == random.randint(1,100):
print("wow, success")
def main():
user_input = int(input("enter a number 1 to 100: "))
randomize(user_input)
print("".join((random.choices(string.ascii_letters, k=5))))
if __name__ == "__main__":
ma... |
8001e900e88d9da75a5f19bfb9adf1c27f515d6b | irinaignatenok/Dev-Inst | /Week7/Day 5/Daily Challenge/Daily_challenge.py | 837 | 3.5625 | 4 | import random
def main():
user_input = input("enter a number: ")
#check input
for x in user_input:
if x.isdigit() != True:
print("not good input")
return;
user_input=int(user_input)
converted = []
output=0
# convert to bit
print(user_input)
while u... |
cd204377dfa918d4570cfdf7f7f9a2f4848bfefa | irinaignatenok/Dev-Inst | /Week8/Day1/Exe_XP/exe_xp.py | 2,592 | 3.90625 | 4 | class Cat:
species = 'mammal'
def __init__(self, name, age):
self.name = name
self.age = age
class Dog:
species = "mammal"
def __init__(self, nameDog, heigtDog):
self.name = nameDog
self.height = heigtDog
def talk(self):
print("Wouaf")
def jump(self)... |
ff3144e3243f9892ad07c1715b987bb3bc7e784d | irinaignatenok/Dev-Inst | /Week6/Day1/Exe_Ninja2/exe_ninja2.py | 2,725 | 3.59375 | 4 | import re
def main():
# exe1
num_of_drivers = 30
num_of_passangers = 90
avaialble_cars = 100
print("the number of available cars is: {}".format(avaialble_cars))
print("the number of registered drivers is: {}".format(num_of_drivers))
print("The number of empty cars today: ", avaialble_cars ... |
f4db42b671f3852bde590f98a36608653e884264 | irinaignatenok/Dev-Inst | /Week8/Day1/daily_challange/daily_challenge.py | 1,541 | 3.890625 | 4 | class Unique:
def __init__(self, l):
self.list_of_numbers = l
def subset(self):
subsets = []
for x in self.list_of_numbers: #outer loop for number of items in list
subsets.append([x])
subsets_temp = subsets.copy()
for y in subsets_temp: #inner loop... |
3184445f6474c8f5ce58f04b544fc6188924fddf | username-JM/coding_test | /programmers/heap/heap2.py | 851 | 3.59375 | 4 | from queue import PriorityQueue
def solution(jobs):
answer = 0
time = 0
ps_list = sorted(jobs, key=lambda x : (x[0], x[1]))
waiting_ps = PriorityQueue()
while len(ps_list) > 0 or not waiting_ps.empty():
if waiting_ps.empty():
ps = ps_list.pop(0)
time = ps[0] + ps[1]
... |
c47682592ca862d01d76246824987b8107ad93f0 | ijassiem/project_tests | /my_employee/MyEmpl.py | 1,491 | 4.25 | 4 |
class Employee:
"""A sample Employee class"""
raise_amt = 1.05
def __init__(self, first, last, telno):
self.first = first
self.last = last
self.telno = telno
self.email = self.first + '.' + self.last + '@gmail.com'
def set_firstname(self, name):
self.first = ... |
6e0d48324e90b84e5712eca9118649e886f26daa | Emily-Garcia/CursoDjango_While | /diccionarios.py | 408 | 4.09375 | 4 | nombre = input('Ingresa el nombre: ')
apellidos = input('Ingresa los apellidos: ')
edad = int(input('Ingresa la edad: '))
correo = input('Ingresa el correo: ')
datos = {
'nombre' : nombre,
'apellidos' : apellidos,
'edad' : edad,
'correo' : correo
}
print(f'Hola! Mi nombre es {datos["nombre"]} {datos["... |
dc6eda1d6265defdecdde5438724765aa66b9219 | Emily-Garcia/CursoDjango_While | /salario.py | 392 | 3.8125 | 4 | selection = 'S'
while selection == 'S':
nombre = input('Ingresa el nombre del trabajador: ')
salario = float(input('Ingresa el salario del trabajador: '))
sal_bruto = salario - (salario * 0.16)
print('El salario bruto de', nombre ,' es:', sal_bruto)
selection = input('¿Desea colcer a calcular... |
3c2fa876efb3ccdd7514f138dbf6955e8420d362 | tclax/PyBattleship | /Board.py | 14,630 | 3.625 | 4 | from Tile import Tile
import functionalComponents
import random, copy
#Represents a collection of Nodes that will act as the Battleship board
class Board:
def __init__(self, size):
self.tileList = {}
self.initalTileListState = {}
self.emptyTileCode = '*'
self.hitTileCode = 'X'
... |
71672da06bfaba1695b32452d181439176c34da7 | josepdecid/LP-FIB | /Python/Jutge/P84591.py | 475 | 3.53125 | 4 | def absValue(x):
return x if x >= 0 else x*-1
def power(x, p):
return x ** p if p < 10 else power(x * x, p - 1)
def isPrime(x):
return (x > 1) and not [isPrime(p) for p in range(2, x+1)
if p * p <= x and x % p == 0]
def slowFib(n):
return n if n <= 1 else slowFib(n - 1)... |
df38e028bd7fc55f2bdca917bfd20af0bc568635 | Passionate-coder997/Python | /lesser_of_two_evens.py | 475 | 4.125 | 4 | def lesser_of_two_evens(a,b):
if a%2==0 and b%2==0:
if a<b:
print(a)
else:
print(b)
elif a%2==0 and b%2!=0:
if a>b:
print(a)
else:
print(b)
elif a%2!=0 and b%2==0:
if a>b:
print(a)
else:... |
a5e4165a5ba9d3e2d61750018980e24d3facdbea | Passionate-coder997/Python | /for10X10.py | 596 | 3.703125 | 4 | for i in range(1,11):
print('{:<3}|'.format(i),end="")
for j in range(1,11):
print('{:>4}'.format(i * j),end="")
if i==1:
print('\n',end="")
print(" ")
if i==2:
print('\n',end="")
print(" ")
if i==3:
print('\n',end="")
print(" ")
if i==4:
print('\n',end="")
print(" ")
if i==5:
... |
97c412e93a51faf546115c2c3c9895638892d232 | Passionate-coder997/Python | /halfdiamondshape.py | 260 | 3.921875 | 4 | def recursion(S):
for i in range(S):
for j in range(0,i+1):
print('*',end=" ")
print()
for i in range(1,S):
for j in range(i,S):
print('*',end=" ")
print()
#driver code
S=5
recursion(S) |
4deedde1775f9857d34fdbab071a49f4df4ce5fe | econkli/sample | /Python Coursework/fastaParse.py | 1,617 | 3.9375 | 4 | #-------------------------------
#Emily Conklin
#5/4/2015
#This program takes a list of protein sequences
#And splits up the sequences into seperate files by species
#-------------------------------
def writeFiles(nameList, file):
'''
creates file for each species
and writes corresponding sequences to the... |
10f20738d07d74a0b2c75d2fe37e619e6a7c5eda | smallgaint/Small-Projects | /rule.py | 447 | 3.59375 | 4 | def rule(*args):
if args[0] == args[1]:
print ('draw')
else:
if 'rock' in args:
if 'scissor' in args:
win = 'rock'
print (win)
elif 'paper' in args:
win = 'paper'
print (win)
else:
... |
d78fecde89eeea0030cfb385a1e3bc696d555685 | sidizawi/ExeProgrammation | /Chapitre3/test3_5.py | 561 | 3.5625 | 4 | import unittest
import math
import sol3_5 as sol
class RacineTest(unittest.TestCase):
def test_1_racine(self):
# x² + 2x + 1 = (x + 1)²
alpha = 1
beta = 2
gamma = 1
self.assertEqual([-1], sol.rac_eq_2nd_deg(alpha, beta, gamma))
def test_2_racine(self):
# x² + 3x + 2
alpha = 1
beta = 3
gamma = ... |
70b4c909922bbbb48173009df2056939eb4b3d15 | momentum-cohort-2019-05/w2d1-house-hunting-phankerson4 | /house_hunting_hard_mode.py | 703 | 4.28125 | 4 | annual_salary = int(input("What is your annual salary? "))
portion_saved = float(input("What percent of salary will you save? "))
r = float(input("What is the rate of return?"))
total_cost = int(input("What is the total cost of your dream home? "))
portion_down_payment = float(input("What is down payment percent?"))
do... |
4c70695889fbe4693b2ecd212ecd5338334aabda | justNeto/VisualCodeHaven | /Projects/CSIA-Coding/TillNow/DijstrakAlgorithmFinal.py | 12,124 | 3.640625 | 4 | from copy import copy
import math
import numpy as np
class Vertex: # class vertex for creating objects with x, y values
def __init__(self, vertexName, x_cor, y_cor):
self.name = vertexName # name of the Node, also could be considered as a label :)
self.location = [x_cor, y_cor] # x and y coordinat... |
87dfc66c9c9d59f4224e98f56ea7f586e5023fac | justNeto/VisualCodeHaven | /Projects/MIT_CLASSES/BWSI_Students/Alonso Flores Romero/name_and_age.py | 242 | 3.65625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Feb 28 06:52:22 2020
@author: Alonso
"""
name = str(raw_input("What's your name? "));
age = str(raw_input("What's your age? "));
print "My name is ", name, "and I am ", age, "years old."
|
0ba31eec233b03147a679ec30204fb1481e4c8e6 | justNeto/VisualCodeHaven | /Projects/MIT_CLASSES/BWSI_Students/Jorge Gabriel Barragán Jiménez/Grade Sort | 343 | 3.953125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 25 16:57:42 2020
@author: jorge
"""
a= int (input("Put your grade:"))
if a<70:
print ("You failed:(")
elif a>=70 and a<=75:
print ("That was close")
elif a>= 76 and a<=85:
print ("Good")
elif a>=86 and a<=95:
print ("Incredible")
els... |
c50993bef8630cd653bcc0dc9ebff428c1f5f5a1 | justNeto/VisualCodeHaven | /Projects/MIT_CLASSES/BWSI_Students/Andrés Eugenio Martínez Sánchez/Palindromos.py | 425 | 3.96875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Mar 1 12:57:42 2020
@author: andres
"""
"""Crea un programa que acepte un String del usuario e
imprima true si es un palíndromo o false si no lo es"""
print ("Is your word a palindrome?")
x = input("Enter a word: ")
y = x.replace(" ", "")
z = y.cas... |
5f8b090077832b4a220d581d3ca86e851e71cb03 | angioletti/heisenchain | /main.py | 3,777 | 3.5625 | 4 | # This program simulates a mock blockchain for a proof of concept only.
# To run this program, use your terminal (cmd on Windows)
#
# Here, we create transactions, validate blocks and construct a mock
# blockchain. We also start a server that will allow us to query the
# blockchain after it is populated.
#
# This softw... |
c6701009aded5e34897388bb1eeca8119705c8fc | dankalish/Training-a-quadcopter-to-fly | /task.py | 4,825 | 3.515625 | 4 | import numpy as np
import math
from physics_sim import PhysicsSim
class Custom_Task():
"""Task (environment) that defines the goal and provides feedback to the agent.
This task will be a straightforward takeoff task: the quadcopter begins
the task at rest on the ground at the center of the... |
ed51456eed8f4dccf04265bf177ac49545fe31a7 | 01Flame10/BMSTU | /eduSem_1/pythonCoding/confirmationOfLaboratoryWorks/Защита лабораторной работы №3.py | 1,527 | 3.78125 | 4 | from math import *
X1, Y1 = list(map(int,input("Введите целочисленные значения координат вершины треугольника X1, Y1 через пробел: ").split()))
X2, Y2 = list(map(int,input("Введите целочисленные значения координат вершины треугольника X2, Y2 через пробел: ").split()))
X3, Y3 = list(map(int,input("Введите целочисленные... |
5bd4d0f838bbd7fad54ea0e6367caecd747c3ead | 01Flame10/BMSTU | /eduSem_2/pythonCoding/py_lab_02/test.py | 15,715 | 3.703125 | 4 | from tkinter import *
from decimal import *
from math import *
from tkinter import messagebox
root = Tk()
root.title('Калькулятор перевода из четверичной в десятичную и обратно системы счисления')
buttons = (('7', '8', '9', '/', '('),
('4', '5', '6', '*', ')'),
('1', '2', '3', '-', 'decimal to ... |
14161093f2ff76ce1497ad5d0425a92c05c27c86 | 01Flame10/BMSTU | /eduSem_1/pythonCoding/laboratoryWorks/laboratoryWork_23.09.2019/Задача №3 (Система).py | 512 | 3.921875 | 4 | #Решение задачи №3 на нахождение значения S при заданных параметрах a,c
from math import sqrt
a,c,x = list(map(float, input("Введите значения a,c,x через пробел: ").split()));
if a * x * x < c:
s = 2 * (c ** (0.85 * a));
elif a * x * x >= c:
s = sqrt(a * x * x - c);
print("Вычисленное начение переменной S =... |
5232f1a5b6cced21577d17ba5bbeda80484e5915 | 01Flame10/BMSTU | /eduSem_1/pythonCoding/confirmationOfLaboratoryWorks/Защита лабораторной работы №5.py | 607 | 4 | 4 | # Андреев Александр ИУ7-14Б
# Защита лабораторной работы №5
x = float(input("Введите значение x: "))
eps = float(input("Введите точность eps: "))
n = 1; ans = 0
prev_num = ((-1) ** n) * ((2 * x)** 2) / 2;
ans = prev_num;
#print(ans, prev_num)
while abs(prev_num) >= eps:
prev_num = ((-1) ** (n + 1)) * abs(prev_n... |
6ae63a79321619fc377cd17d0819ae3a9bc7ef97 | wmemorgan/intro-python-ii-guided-project | /function.py | 2,119 | 4.46875 | 4 | # define a doubling function that passes args by value
def double_num(x):
x = x * 2
print(double_num(5))
# # define a doubling function that passes args by reference
# # define a double function, that doubles every item in a list
def double_list(li):
for i in range(0, len(li)):
li[i] = li[i] * 2 #the... |
ec273e7b14c501ab1d8d9feba700df1b7be37f7d | amruth0007/repository01 | /array1.py | 360 | 4.0625 | 4 | import array as arr
newarr=arr.array('i',[])
n=int(input("Enter the number of values you want : "))
for i in range(n):
val=int(input("Enter the next value : "))
newarr.append(val)
for a in newarr:
print(a)
search=int(input("Enter the value to search from array : "))
for e in newarr:
if search==e:
... |
7439e4ce43fd32a88d438d73e6a5ab746a00e15f | chiao3bb33/Python | /start9-def_exercise.py | 796 | 4.28125 | 4 | # 定義函式
""" 函式內部的程式碼,若是沒有做函式呼叫,就不會執行 """
# 不含回傳值
""" # def multiply(n1, n2):
# print(n1*n2)
# # 呼叫函式
# multiply(3, 4)
# multiply(10, 8) """
# 含回傳值
""" def multiply(n1, n2):
print(n1*n2)
return n1*n2
# 呼叫函式
value = multiply(3, 4)
print(value) """
# eg
# def multiply(n1, n2):
# ret... |
7987b2967ac858e7d02995380b777f586576a7e4 | chiao3bb33/Python | /start5.py | 1,133 | 4.09375 | 4 | """#if判斷式 基本語法"""
# TYPE A
# if 布林值:
# 若布林值為trun,執行命令
# else:
# 若布林值為False,執行命令
# TYPE B
# if 布林值一:
# 若布林值一為trun,執行命令
# elif 布林值二:
# 若布林值二為trun,執行命令
# else:
# 若布林值一和二為False,執行命令
# 程式範例
"""x=input('請輸入數字:') #基本輸入為字串型態
x=int(x) #轉換為整數型態
if x>200:
print('大於200')
elif x>100:
print('大於100, 小於2... |
9fb776a244d44278ba1e0d7329df84cdb3cf74a6 | mattpap/bokeh | /bokeh/ggplot.py | 9,196 | 3.5 | 4 | """
An implementation of GGPlot in Python.
The functions try to mimic the R interface, for better or for worse, but
there is an underlying object model for the actual graphics pipeline that
is constructed.
"""
from __future__ import absolute_import, print_function
#from traits import api as traits
#from traits.api ... |
6345998ba3020aa573c2726ae52acd044a6cb943 | kmbabu/mahesh | /pos.py | 125 | 4 | 4 | ch=int(raw_input("enter the num"))
if(ch>0):
print("positive")
elif(ch<0):
print("negative")
else:
print("zero")
|
400a9ecb8e77a53285a010f9c2746e29278d8a31 | cjchoi97/Tetris-project | /Tetris.py | 2,415 | 3.765625 | 4 | import pygame, sys
from Board import *
from random import *
SPEED = 25 #Controls how fast the pieces come down
#making this number bigger slows down the speed
class Tetris:
def __init__(self):
pygame.init() #initiate pygame
pygame.mixer.music.load('tetrisb.mid')
... |
100c38498b2246e9be0df8f6e9edc8c178531859 | alexako/ProjectEuler | /14.py | 655 | 3.984375 | 4 | #!/bin/python
def Collatz_sequence(number):
if not number % 2:
return number / 2
else:
return 3 * number + 1
def find_longest_chain():
longest_chain = 1
term_count = 1
for num in xrange(410011, 1000000):
index = num
while num > 1:
num = sequence(num... |
1c8c508256df5ae9639bea185f67afa9e98d5081 | alexako/ProjectEuler | /06.py | 258 | 3.828125 | 4 | #!/bin/python
def sum_of_squares(num):
return sum([i*i for i in range(num+1)])
def square_of_sum(num):
total = sum([i for i in range(num+1)])
return total * total
if __name__ == '__main__':
print square_of_sum(100) - sum_of_squares(100)
|
50a36765e75517c5102770ba7275c1c40cdd9b37 | alexako/ProjectEuler | /09.py | 459 | 4.25 | 4 | #!/bin/python
# Conditions:
# a < b < c
# a^2 + b^2 = c^2
# Goal: a + b + c = 1000; Find product of abc
# Example: 3^2 + 4^2 = 9 + 16 = 25 = 5^2
def find_pythagorean_triplet(num):
for n in range(2, num):
for m in range(1, n):
a, b, c = (n**2 - m**2), (2 * n * m), (n**2 + m**2)
if... |
48402a4af99716af140b2f605b28c4eb61c527d4 | Lie-huo/Data_Structure_with_Python | /5.4快速排序.py | 1,867 | 4.0625 | 4 | # _*_ coding: UTF-8 _*_
"""快速排序(Quick-Sort)
1.从数列中挑出一个元素,称为"基准"(pivot),
2.重新排序数列,所有元素比基准值小的摆放在基准前面,所有元素比基准值大的摆在基准的后面(相同的数可以到任一边)。
在这个分区结束之后,该基准就处于数列的中间位置。这个称为分区(partition)操作。
3.递归地(recursive)把小于基准值元素的子数列和大于基准值元素的子数列排序。
"""
def quick_sort(alist, start, end):
"""快速排序"""
# 递归的退出条件
if start >= end:
r... |
60792bb632fd34cab2c3eba8e996c80fc960a0c4 | KathiW/python_foundations | /labs/src/E.0.FizzBuzzTexty/startingpoint/main.py | 315 | 3.84375 | 4 |
def toText(n):
"""Transforms this number to a fizbuzz message
Args:
n (int): number
Returns:
str: either a number, 'fizz', 'buzz', or 'fizzbuzz'
"""
return str(n)
def main():
for i in [1,2,3,4,5,6,8,9,10]:
print(toText(i))
if __name__ == "__main__":
main()
|
7d10d6d53387d5bd9ec9c6e86d19495c59dc2431 | Anurag-Code-Hub/python | /Day-5/csvRead.py | 386 | 3.765625 | 4 | import csv
row_list = [["SN", "Name", "Experience"],
[1, "Souvik", "1year"],
[2, "Sonal", "2year"],
[3, "Avik", "3year"]]
with open('students.csv', 'w', newline='') as file:
writer = csv.writer(file)
writer.writerows(row_list)
with open('students.csv', 'r') as file:
r... |
40016ad7ee24ae89ca569bc728b4c96cf6a1b35c | Anurag-Code-Hub/python | /Day-4/decs.py | 545 | 3.859375 | 4 | withdraw = int (input("enter the withdrawl amount:"))
def balance(func):
def securebalance(intialamount):
if withdraw > intialamount:
print(f"you dont have sufficent balance in your account ")
elif withdraw < 0:
print(f"the withdraw ammount should be greater than the 0") ... |
cc234614b4a23e4711519abc44c845d624f5025c | Anurag-Code-Hub/python | /Day-4/iter.py | 450 | 3.921875 | 4 | class Iteration:
def __init__(self,data):
self.data = data
self.index = len(data)
def _iter_(self):
return self
def __next__(self):
if self.index == 0:
raise StopIteration
self.index = self.index - 1
return self.data[self.index]
... |
00e6d9519700d9f97e245fe2f7ff014bdbf09779 | samhain13/just-scripts | /batch-copier.py | 2,268 | 3.625 | 4 | #! /usr/bin/env python
"""
Typically used for copying "season episodes" from the download folder to
another directory. Requires:
1. file extension filter, a condition for os.listdir(os.getcwd())
2. target directory, must already exist
3. separator, a character with which to split the filenames
... |
0b0b10970cdb374b8d324676b3d2c6afbc3d697f | flaviorbianchi/CodeSignal | /almostIncreasingSequence.py | 412 | 3.546875 | 4 | def almostIncreasingSequence(sequence):
for value in sequence:
#create copy of sequence and remove current value
sequenceCopy = sequence.copy()
sequenceCopy.remove(value)
counter = 0
while (counter < len(sequence)-1):
if (sequenceCopy[counter] <= sequence... |
11d3e88ecd4c284f9cef3d9d741356c7314dd734 | jasonjiexin/Python_Basic | /python0-1/basic.py | 933 | 3.734375 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
a
# In[4]:
a=1
print(a)
# In[5]:
one=two=three=10
# In[8]:
print(id(one),id(two),id(three))
# In[16]:
var01,var02=2,1
print(id(var01),id(var02))
# In[2]:
name='''jason'''
name1="zhang"
name2='tom'
print(name,name1,name2,'<<me is me>>')
# In[21]:
... |
ce79fa5a0eea00b32d18a6b53a46e9cc9c97cbfb | jasonjiexin/Python_Basic | /python_grammer/day2_continue_break.py | 1,472 | 3.578125 | 4 | #-*- coding:utf-8 -*-
#continue跳出
for f in range(10):
if f%2==0:
continue
print(f)
print("--------------1--------------")
#break,1000以内能被7整除的前20个数
count = 0
for i in range(0, 1000, 7):
print(i)
count += 1
if count >= 20:
break
print("--------------2--------------")
#改为while语句
coun... |
441fee3d607d7da47cba0c8d588e33c28192111c | jasonjiexin/Python_Basic | /magedu/basic_syntax/matrixexchange.py | 1,060 | 3.875 | 4 | '''
M=N(方阵)矩阵元素转换
'''
# 写法1
matrix = [[1,2,3],[4,5,6],[7,8,9]]
print(matrix)
count = 0
for i, row in enumerate(matrix):
for j, col in enumerate(row):
if i < j:
temp = matrix[i][j]
matrix[i][j] = matrix[j][i]
matrix[j][i] = temp
count += 1
print(matrix)
print(c... |
bf57b05c7ecb9e804ad8e3d2aa5a434bb03a8016 | jasonjiexin/Python_Basic | /magedu/string/zifuchuandaxiaoxie.py | 296 | 4.21875 | 4 | '''
字符串功能性的方法()
'''
#字符串大小写切换
s1 = "i 'm a Super Student"
# 字符串全部转换为大写
print(s1.upper())
# 字符串全部转换为小写
print(s1.lower())
# 字符串中大写字母转小写字母,小写字母转大写字母
print(s1.swapcase()) |
836143b82751f9bdbf688c4efe12e081cc517515 | jasonjiexin/Python_Basic | /magedu/string/zifuchuanjoin.py | 320 | 3.671875 | 4 | # join 将可迭代对象连接起来,.join(lst)
lst = ['1', '2', '3']
print(lst)
print("\"".join(lst))
print(" ".join(lst))
print("\n".join(lst))
lst = ['1',['a','b'],'3']
# "+" 把不同的字符串连接起来形成新的字符串
lst1 = "i"
lst2 = "am"
lst3 = "jason"
print(lst1 + " " + lst2 + " " + lst3) |
dac7878d2acaa719139581c8bea6b7b52948ce34 | jasonjiexin/Python_Basic | /magedu/basic_syntax/jiujiu.py | 2,397 | 3.671875 | 4 | #i为行,j为列
for i in range(1, 10):
for j in range(1, i+1):
print(str(j) + 'x' + str(i) + '=' + str(i * j), end=' ') #end=' ' 打印的时候不换行
print(' ') #打印后空格换行
print("1------"*20)
#用制表符\t解决对不齐的问题
for i in range(1, 10):
for j in range(1, i+1):
print(str(j) + 'x' + str(i) + '=' + str(i * j) + '\... |
fbf1322d0125d0468b640398e653a2d4f1ff9009 | jasonjiexin/Python_Basic | /python_grammer/day3_exercises.py | 1,871 | 3.703125 | 4 | #-*- coding:utf-8-*-#
print("----------------1----------------")
#打印一个正方形
while True:
for i in range(1, 11):
if i == 1:
print('*' * 21)
elif i == 10:
print('*' * 21)
else:
print('*' + ' ' * 19 + '*')
break
print("---------------------------------")
... |
56c0644c24fb8f5d148dfd84c19ca6885fecfc73 | sheeba23/pythonprograms | /14_find_aggregates_from_existing_list.py | 1,556 | 4.4375 | 4 | """W.A.P to find different aggregates(min, max, average/mean and median) value in existing list of numbers.
[5, 10, 15, 12, 500, 950, 0, 0.5, 6.75, 840, 1500, 7, 84, 15000]
Note:- Program should have implementation of function and
don't use inbuilt function to calculate specific aggregates."""
static_list = [5, 1... |
61292eac144cc291fa75c541eb3acfc62b207f14 | sheeba23/pythonprograms | /12_duplicate_words_count.py | 1,312 | 4.125 | 4 | """W.A.P to find number of duplicate words in string with count and also removed it from string. output should have unique words in string.
Input:-
Please enter string to find duplicate words and remove it:- Hi My Name is Musikaar Hi Kashyap How are you all we are working as a team You are working in tenable Hi Kruna... |
1bf931f12f86d542ad37db1b77e307ea91895f13 | adriellison/MyCodes | /Introdução à programação com Python/teste.py | 60 | 3.578125 | 4 | a = 5
print(a)
b = 2
a = b - b
print(a)
a = b - b
print('a') |
7273188b4bba225e32262d4870416398035f1186 | keisuke-isobe/Magic8Ball | /wordform.py | 406 | 3.765625 | 4 | """
Function that returns a dictionary that contains a keyword and it's part
of speech.
"""
def wordForm(sorted_keywords):
document = language_client.document_from_text(sorted_keywords)
annotations = document.annotate_text().tokens
wordForm = {}
for token in annotations:
word = token.text_conten... |
87a4ee34c18c2fb243aa3a88d789f6f465a4348d | kotano/brain-games | /brain_games/games/calc.py | 411 | 3.84375 | 4 | import random
from operator import add, mul, sub
RULE = 'What is the result of the expression? '
OPERATORS = [(mul, '*'), (add, '+'), (sub, '-')]
def generate():
num1 = random.randint(1, 10)
num2 = random.randint(1, 10)
operation, sign = random.choice(OPERATORS)
correct_answer = operation(num1, num2... |
adf465b1be682f8de06d88ec521c95c8efb82d84 | 3bp3/code | /python/COMP9021/quiz/quiz6/quiz_6.py | 4,816 | 3.71875 | 4 | # Creates a class to represent a permutation of 1, 2, ..., n for some n >= 0.
#
# An object is created by passing as argument to the class name:
# - either no argument, in which case the empty permutation is created, or
# - "length = n" for some n >= 0, in which case the identity over 1, ..., n is created, or
# - the n... |
410ae3c8820c44d6c323a6f9c15c1c774b38f88c | HappDen/HW3 | /kek1.py | 85 | 3.578125 | 4 | a = int(input())
b = int(input())
i = 0
for i in range(a,b):
b += i
print(b) |
cb761f8842dbe565579a5b9fe4a0e75d4c1b29a2 | barreto-juan/python-GUI | /src/006.py | 576 | 3.65625 | 4 | '''
foi aplicado o gerenc. de layout pack - fill - o qual faz com que o componente estenda ao tamanho da janela/disponivel, podendo
ser no sentido vertical ou horizontal
'''
from tkinter import*
root = Tk()
lb1 = Label(root, text="escrito 1", bg="purple")
lb1.pack(side=TOP, fill=X)
lb2 = Label(root, text="escrito... |
8493e97f16dd7cb342c2847d01f959ba37272ce3 | ecresp1el/PFB_problemsets | /PythonSet2/PythonDay1PBS2.py | 581 | 3.96875 | 4 | #!/usr/bin/env python3
import math
#assign a value to a variable
one = '0'
# logic cotnrol statment
if '1' in one:
print ("You maybe can code now")
else:
print ("You are fake")
#pos vs neg
# because one = '1' is a string and NOT an int, you need to convert the string into a int using the int(x) func... |
7c7c3d72e7792773b70372771bc5b8ebb64475bd | FelpsThePru/trabalho1.1 | /Exercicio5.py | 2,421 | 3.59375 | 4 | #Um posto está vendendo combustíveis com a seguinte tabela de descontos:
#Álcool:
#até 20 litros, desconto de 3% por litro
#acima de 20 litros, desconto de 5% por litro
#Gasolina:
#até 20 litros, desconto de 4% por litro
#acima de 20 litros, desconto de 6% por litro Escreva um algoritmo que leia o número de litros vend... |
7e4e2717e31529324813a2ab39788c7ffd117531 | ShennyO/MakeSchool-CS2 | /dictionary_words.py | 821 | 3.75 | 4 | import random
import sys
def generate_random_sentence(input_number):
with open('/usr/share/dict/words', 'r') as f:
number_of_words = input_number
# sentence = []
all_words = f.readlines()
all_words_array = list(all_words)
output = []
for index in all_words_array:
... |
c166274ac277ff6daa2553f169f6d002f300fe16 | juanchax/MagaPython | /Week 3/08. Calculate Mileage.py | 828 | 3.578125 | 4 | # 08 ------------
#
# Crear una función que calcule cuántos litros de nafta gasta un auto que consume
# 2 litros x 100km, en un viaje ida y vuelta MdP-Bue si la distancia es de 400km.
# Luego crear una función que, a partir de esos datos, devuelva cuánto significa
# eso en pesos si el litro de nafta está 60$
def total... |
38881ffd65b49a0e3af66250b119b6fa309e1b7d | juanchax/MagaPython | /Week 2/05. Change Dict Keys.py | 1,499 | 4.15625 | 4 | # 05 -----------
#
# Crear un diccionario con los meses del año de la forma { 1: "enero"}.
# Desafío: lograr cambiar las claves. Pista: si imprimen ítems del diccionario
# les crea una lista. Una vez que lo logren, imprimir el diccionario modificado.
import random
months_of_year = \
{1: "enero", 2: "febrero", 3: "... |
9d9e6de7028bfeb94f817d1f50f2b2331a3539d4 | juanchax/MagaPython | /Week 1/08. Get List by Index.py | 406 | 4.71875 | 5 | # 08 -----
# Create a program that stores the following subjects in a list:
# History, Maths, English and Geography.
# Print out the last subject stored
#
# Crear un programa que almacene en una lista las siguientes materias:
# Historia, Matemática, Lengua y Geografía.
# Luego devolver por pantalla la última materia al... |
1a86db561d3659cd6a605da364daa7316fd47515 | juanchax/MagaPython | /Week 2/10. Iterate Over Range.py | 187 | 3.953125 | 4 | # 10 ------------
#
# Utilizar el método range() para recorrer el iterable e imprimir
# solo los números impartes entre 1 y 40 inclusive.
for number in range(1, 41):
print(number)
|
a8544376e69f1d4edbb9e95fdd56513f61941cc6 | JasperKirton/MajorProj-Local | /LikertAnalysis.py | 1,185 | 3.640625 | 4 | import pandas as pd
from pandas.api.types import CategoricalDtype
# Pre-study Qs
df = pd.read_csv('Pre-study Survey (Responses) - study corresponding.csv', sep=',', header=None)
# define column names for dataframe
df.columns = ['time', 'noneed', 'name', 'gender', 'age', 'Musical experience', 'Musical importance', 'A... |
7187e74fa5358d58941eba251de52a29e4b8c9cc | sanaturies/pyflakes | /temp/leetcode/wordindex.py | 1,197 | 3.828125 | 4 |
sentence='you are very very smart'
words='you are very handsome'
sensplit=sentence.split()
wordsplit=words.split()
for i in range(len(wordsplit)):
result=sentence.find(wordsplit[i])
if result != -1:
print('sentence contains the the following string:', wordsplit[i],result)
else:
p... |
1d93078fe5707d01119095ae390eb679be4feb05 | sanaturies/pyflakes | /temp/leetcode/dice.py | 2,178 | 3.953125 | 4 |
import random
def roll():
num=random.randint(1,6)
return num
def count(days,integer):
total=0
for i in range(days):
for j in range(i):
if roll()==integer:
total+=1
return total
print(count(365,3))
#20 of my friends love rolling dice.
# They are... |
509aada00bba67adc25efbb8372927b5b17d1c6b | sanaturies/pyflakes | /temp/leetcode/candy.py | 1,452 | 3.796875 | 4 |
#Given the array candies and the integer extraCandies, where candies[i] represents the number of candies that the ith kid has.
#For each kid check if there is a way to distribute extraCandies among the kids such that he or she can have the greatest number of candies among them. Notice that multiple kids can have the... |
7c8777274124446dd02bcf3fc19e4f1e9c40f64d | sanaturies/pyflakes | /temp/leetcode/ugw.py | 171 | 3.734375 | 4 |
ugw=int(input('num?'))
count=0
while ugw > 0:
if ugw%2==0:
ugw/=2
count+=1
else:
ugw-=1
count+=1
print('%s steps'%count) |
0ffa38bf0459e91586fa1dece914052ada7e1409 | sanaturies/pyflakes | /temp/algorithm_practise/tree/return_root.py | 163 | 3.703125 | 4 |
lst=[8,6,4,7,10,9,11]
order='preorder'
if order=='inorder':
print(lst[len(lst)//2])
elif order=='preorder':
print(lst[0])
else:
print(lst[-1]) |
1554844377463ae502975932f22f7184bc3a8d29 | sanaturies/pyflakes | /temp/leetcode/transpose_matrix.py | 248 | 3.6875 | 4 |
#get a grid and flip it clockwise
grid=[
[6,8,9,1],
[7,9,1,4]
]
grid2=[]
lst=[]
count=0
for i in range(len(grid[0])):
for j in range(len(grid)):
lst.append(grid[j][i])
grid2.append(lst)
lst=[]
print(grid2) |
20ac7663773e4469770facd02990960004898c85 | ekinoguz/hiding | /experiments/distances_test.py | 2,369 | 3.53125 | 4 | import unittest
import os
import distances
from distances import Distances
class DistancesTests(unittest.TestCase):
def testChiSquare(self):
r1 = {'value1':5}
r2 = {'value1':5}
distanceCalculator = Distances()
distanceCalculator.set_type(Distances.CHI_SQUARE)
distance = distanceCalculator.calcul... |
43615273bb5476c8db7212cb4c34dda680428728 | NishkarshRaj/Programming-in-Python | /Practise Problems/sumlenlist.py | 324 | 3.78125 | 4 | # len and sum functions of list!!!!
list1 = [31,52,425,642]
print(len(list1))
print(sum(list1))
list2 = ['Finn','Seth','Styles','Bryan']
print(len(list2))
#print(sum(list2)) #Sum function of list only works for integers!!!!
list3 = [14.24,25.23]
print(len(list3))
print(sum(list3)) #Sum function also works for float!... |
27467b77394c0ff99573494b43d35b841ac381da | NishkarshRaj/Programming-in-Python | /Module 1 Assignments/test_module.py | 299 | 4.0625 | 4 | import number_checker
num=int(input("Enter a number for checking: "))
print("")
print("Let's check whether number is prime or not")
print("Is prime?:",number_checker.is_prime(num))
print("")
print("")
print("Let's check whether number is even or not")
print("Is even?:",number_checker.is_even(num))
|
3963c47b3501e6f63eed1adb8c59a947f06c2afb | NishkarshRaj/Programming-in-Python | /Module 1 Assignments/assignment27_1.py | 371 | 4.5625 | 5 | print("Printing Fibonacci series till nth term")
def print_fibonacci(num):
a,b=0,1
print(a,end=" ")
print(b,end=" ")
for k in range(1,num-1):
c=a+b
print(c,end=" ")
a=b
b=c
print("")
return
n=int(input("Enter a number of terms until which you want to generate Fibo... |
5de46b11c04abf9785ef0def0044ad72bdd8a862 | NishkarshRaj/Programming-in-Python | /FinalProject/updated_finale.py | 5,458 | 3.75 | 4 | ''' Importing necessary modules and packages '''
import sqlite3
from random import randint
from os import system,name
from time import sleep
''' Creation of Connection Object in sqllite for Ubuntu '''
con = sqlite3.connect("pro.db") #Connection IP
cur = con.cursor()
''' Function to generate Student Chapter ID '''
de... |
804426bcdc4a901cdced6d46b8f269b0c3742ffb | NishkarshRaj/Programming-in-Python | /Module 4 Assignments/Assignment17.py | 1,000 | 3.671875 | 4 | #Assignment 17
''' Parent Class 1: Employee '''
class Employee:
def __init__(self,salary):
self._salary = salary #Protected Data Member
def getSalary(payday,lop):
pass
''' Parent Class 2: Faculty '''
class Faculty:
def __init__(self,rem):
self._remuneration = rem #Protected Data Me... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.