blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
4fe74ca36df016555745231db7d44f4cafd45615 | dohmart/python_challenge | /PyBank/main.py | 4,870 | 3.546875 | 4 | # This function outputs results. If no second argument passed, then it goes to stdout
# Otherwise, it expects a file name that it can successfully open. No error checking done for write access.
def OutputResults(fin_ana, file_name=None):
import sys
if file_name is None:
fd = sys.stdout
else:
... |
d3b78a7422d3d96c3c5f22b6b12331584bfa5193 | Alan-Menchaca-M/AlgoritmosSistemas | /ago-dic-2020/Fco. Alan Menchaca Merino/algoritmos_ordenamiento/heap_sort.py | 1,618 | 3.640625 | 4 | class HeapSort:
@staticmethod
def heapify(array, n, i):
largest = i
# Definiendo nodo izquierdo y derecho
idx_left = (2 * i) + 1
idx_right = (2 * i) + 2
if idx_left < n and array[i] < array[idx_left]:
largest = idx_left
if idx_right < n and array[la... |
914ca8b6c0748fcf61c0e158e2972bd41c384049 | NikilReddyM/python-codes | /set_symmetricdifference.py | 192 | 3.71875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Nov 13 20:09:10 2017
@author: HP
"""
n = input()
eng = set(input().split())
m = input()
fre = set(input().split())
print(len(eng^fre))
|
5cdfb9f36ca69e8ff5fabc7944ba6a1bbc3b4b56 | GilBaggio/python-project | /scen9.py | 1,268 | 3.734375 | 4 | #Highest percentage in all india level
def high_percentage():
try:
#opening and reading the standerdised file
stdfile = open('Standardiseddata.csv','r')
firstline = stdfile.readline()
heading = firstline.split(',')
percentage_index = heading.index('mathpcor')
... |
414c74c25ddb02effc6269b528cf76770e65fe44 | KChen1317/cpl | /Tokenizer.py | 6,250 | 3.84375 | 4 | def main():
print("Lexer part 1 (Tokenizer no parse)")
file_name=get_file_name()
file=open(str(file_name)+".txtcpl")
proceed(3,"Getting lines\ny or proceed","Getting lines\ny or proceed")
lines=get_lines(file)
print(lines)
proceed(3,"Seperating lines\ny or proceed","Seperating lines\n... |
04b2af12de3a01b2787516b3c1fff07866e10151 | SARAOGIAMAN/PYTHON-PROGRAMS | /factorial.py | 114 | 3.640625 | 4 | def fact(n):
f=1
for i in range(n,0,-1):
f*=i
return f
n=int(input())
res=fact(n)
print(res)
|
9bf1bd64c1a038e9acae2278f3468d3a4b99cd1f | Byliguel/python1-exo7 | /aleatoire/tkinter_mouvement.py | 1,257 | 3.578125 | 4 |
##############################
# Tkinter - Mouvement
##############################
from tkinter import *
Largeur = 400
Hauteur = 200
root = Tk()
canvas = Canvas(root, width=Largeur, height=Hauteur, background="white")
canvas.pack(fill="both", expand=True)
# Les coordonnées et la vitesse
x0, y0 = 100,100
dx =... |
380f239db3efdfc38625e67693886274bab9e339 | lilyli007/AE597 | /lasso.py | 4,210 | 4 | 4 | from sklearn.linear_model import Lasso
import mglearn
from sklearn.model_selection import train_test_split
import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import Ridge
from sklearn.linear_model import LinearRegression
# let's use the boston housing dataset again
X, y = mglearn.datasets.loa... |
a7e0a9667234e20445e5737629e88babb05a3447 | Adrianozk/exercicios_python | /resolucoes/ex027.py | 323 | 4.0625 | 4 | # Faça um programa que leia o nome completo de uma pessoa,
# mostrando em seguida o primeiro e o último nome separadamente.
# Ex: Ana Maria de Souza
# Primeiro = Ana
# Último = Souza
nome = input('Nome completo: ')
print(f'Primeiro nome: {nome.split()[0]}')
print(f'Último nome: {nome.split()[len(nome.split... |
a10e03d18abbb7543bfe98599dd9e565d435343a | PanagiotisV/ESETU | /ergasia 1.py | 1,398 | 4.03125 | 4 | #hello professor this is my first excercise on python i hope you like it :D
#Now at the beginning may i say that python is really great and that i find making programms with python really easy and entertaining thanks for the 6-months of lessons (more like 2 months too bad huh?)
#so this is the first input it's a raw... |
22588c91290d989f2e365dc5cb5172af9db57435 | swity001/Matematika | /module/VolumeBalok.py | 135 | 3.65625 | 4 | x = input('Masukan panjang:')
y = input('Masukan lebar:')
z = input('Masukan tinggi:')
print('V= panjang x lebar x tinggi =', x*y*z,)
|
82a9154f1725aeed37ff54249aaba4fa5ca1fc3d | BMClab/detecta | /detecta/detect_seq.py | 4,661 | 3.625 | 4 | #!/usr/bin/env python
"""Detect indices in x of sequential data identical to value."""
import numpy as np
__author__ = 'Marcos Duarte, https://github.com/demotu'
__version__ = 'detect_seq.py v.1.0.1 2019/03/17'
def detect_seq(x, value=np.nan, index=False, min_seq=1, max_alert=0,
show=False, ax=None)... |
2a1d43bdc1255441b35ee518c9c11d667130266d | yuli5/python3.1 | /actividad3/ejer2.py | 251 | 3.90625 | 4 | #ejercicio2
#ingresar un valor y mostrar los numeros desde el -10 hasta el nuemro ingresado.
print("bienvedios".center(50,"*"))
numero= int(input("ingrese el valor"))
contador = -10
while contador <= numero:
print (contador)
contador+=1
|
b4103ae2d670d76c60fd609ec57846a56fb228ff | xerifeazeitona/PWS | /rework_wordlist.py | 456 | 3.875 | 4 | #!/usr/bin/env python
"""
This simple module removes all the words that have less than 2 or more
than 7 characters, since they can't be used in the game.
"""
input_file = 'words.txt'
output_file = 'valid_words.txt'
with open(input_file) as file_obj:
words = file_obj.read()
words = [x.lower() for x in words.split... |
b782f9c069ccd156fbf1b3cec914fa03133bd66b | andkoc001/mypylearn | /sum_large_ints_as_strings.py | 1,399 | 3.515625 | 4 | str1 = '112314342545645757'
str2 = '131234455'
print('Check:', int(str1) + int(str2))
# print('Last digit:', (int(str1) % 10))
def add2str(s1, s2):
res = 0
carry_over = 0
result = ''
tmp1 = s1
tmp2 = s2
if len(s2) < len(s1):
for k in range(len(s1)-len(s2)):
tmp2 = "0" +... |
986569f5f87f78ad7338466ed786c4396c7aadce | baradhwajpc/Learning | /Self Learning/Numpy/100puzles.py | 6,221 | 3.515625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Oct 18 18:41:17 2017
@author: baradhwaj
"""
# Q1.
import numpy as np
import sys as s
import calendar
# Q2.
print(np.version.version)
print(np.show_config())
#Q3. Null vector of size 10
zeros = np.zeros((10))
print(zeros)
# Q4. find the memory size of any array
Z = np.zeros... |
b3b357051dc89ef0bfd57fa9ec500515164233f6 | mykelson/rearrange | /main.py | 1,346 | 3.875 | 4 | def main():
""" Main function """
nums = []
# Get an integer
i = int(input("Enter a number: "), 10)
# Populate the list
print(f"Enter {i} numbers: ")
for c in range(i):
nums.append(int(input(), 10))
# Sort the list
rearrange(nums, i)
#Print out the list one at a ... |
65932283a6dcc6eadc7f91a9cdbe7c93f6c8b16c | cbosss/domain-search | /api/trie.py | 939 | 3.75 | 4 | from collections import defaultdict
class Node:
__slots__ = ['children', 'is_leaf']
def __init__(self):
self.children = defaultdict(Node)
self.is_leaf = False
def insert(self, word):
node = self
for character in word:
node = node.children[character]
no... |
ba72651cab6feea49a8b4bc157a3be2e769992f2 | WillSchick/CS111-Coursework | /Z) Exercises/Week3/7 - oldEnough.py | 279 | 3.953125 | 4 | #oldEnough
#Will Schick
#3/5/2018
ageInput = int(input("How old are you?: "))
print(ageInput)
if age <15:
print("You are too young!")
print("Apply again in", 15 - age, "years.")
else:
if age < 18:
print("You can work part-time")
|
64de516b8f24c4bc13547c387511c617dcae78c8 | TripleChoco/ubb | /sem1/fop/Lab5-7/Book Rental/appstart.py | 2,755 | 4.125 | 4 | """
A customer has a unique number (id), a name, a CNP, and an address.
A rental has: <customer>, <book>, <date>, <#days>.
The application allows:
* CRUD Operation (Create, Read, Update, Delete) for books, customers
* Search (books, customers)
* Rental / response
* 2 Sort (eg sorted by name / price / title, ...)... |
ab6d67949ccad8149d4c74c67a4dc91373e6d1d3 | HatsuneMikuV/PythonLearning | /52.py | 591 | 3.546875 | 4 | # -*- coding: utf-8 -*-
"""
-------------------------------------------------
File Name: 52
Author : anglemiku
Eamil : anglemiku.v@gmail.com
date: 2020/1/7
-------------------------------------------------
Change Activity: 2020/1/7:
---------------------------------... |
e3e5b9e6026a3dafc16cd58f0c8c28921dbd3be9 | yinyajun/Sundries | /python_web_framework/web/util.py | 4,847 | 3.765625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2019/12/22 9:25
# @Author : Yajun Yin
# @Note :
"""
python2: type `str` save as [bytes]
python3: type `str` save as [unicode]
encode func: [unicode] ---> [bytes]
decode func: [bytes] ---> [unicode]
python2:
s = 'hello' # s is [bytes]
s.e... |
c4f09a2d42725a428622ca5b1b01b4f24e50bd58 | blemay360/CS-UY-1114 | /Homework/hw1/bl2448_hw1_q4.py | 216 | 3.859375 | 4 | years=int(input("Input number of years: "))
seconds=years*365*24*60*60
population=307357870
population=population+int((1/7)*seconds)+int((1/35)*seconds)-int((1/13)*seconds)
print("Estimated population:", population)
|
18f406cf7c4d6b9d9705f739ad6a6d5f3283a265 | cnebher/imw | /ut2/a4/program4.py | 234 | 3.84375 | 4 | import sys
numbers = sys.argv[1:]
number = len(numbers)
count_number = 0
for seccion in numbers:
seccion = float(seccion)
count_number += seccion
result = count_number / number
print(f"La media de los valores es: {result}")
|
556d69cf1bf78e1f5015af83ab415ecb978c8deb | vicwuht/pl-hd | /learning/compare.py | 549 | 3.953125 | 4 | """函数conpare用来比较xy的大小"""
def compare(x, y):
"""
compare函数比较xy大小
:param x:
:param y:
:return: 1,0,-1
"""
if x > y:
return 1
elif x == y:
return 0
else:
return -1
# x = input('请输入X值:\n')
# y = input('请输入Y值:\n')
# print(compare(x, y))
def is_between(x, y, z):... |
9751406d4baad53c38fe6c9eba6d7be44237b4d9 | keepgoing2021/lieklion-seoul-6th | /week3/function.py | 2,805 | 4.09375 | 4 | ### 함수(function) 실습
def add(num1, num2):
result = num1 + num2
return result
result = add(2, 5)
print(result)
### 내장 함수
# 숫자의 절댓값을 돌려줍니다.
num1 = 100
num2 = -40
print('num1 =', abs(num1))
print('num2 =', abs(num2))
# 객체의 《아이덴티티》를 돌려준다
var = 'str'
var1 = 'str'
var2 = 4
print('var = ', id(var))
print('var1 = ... |
59ac70df8fb040943b8b98e995f53ece2682bc1d | igorleshchuk/algorithms-leetcode-python-scha-poreshaem | /episode48-2021-06-13/q1603-design-parking-system.py | 395 | 3.828125 | 4 | class ParkingSystem:
def __init__(self, big: int, medium: int, small: int):
self.car_places = {1: big, 2: medium, 3: small}
def addCar(self, carType: int) -> bool:
self.car_places[carType] -= 1
return self.car_places[carType] >= 0
if __name__ == '__main__':
ps = ParkingSystem(1, ... |
8b5cbd57f17b15aeb366b38f4f66edb6d66ba4f9 | MaksymMinko/PythonLessons | /HomeWork1/Task2.py | 597 | 4.03125 | 4 | a1 = input('Enter the first side of the first rectangle: ')
b1 = input('Enter the second side of the first rectangle: ')
a2 = input('Enter the first side of the second rectangle: ')
b2 = input('Enter the second side of the second rectangle: ')
s1 = float(a1) * float(b1)
s2 = float(a2) * float(b2)
print('Area of t... |
6b5d57e88506504d7d6258cca72cc00b9987cb99 | mholimncube/Python | /Tutorial 9 Python Number Systems/DecimalToIEEE754v1.py | 3,153 | 4.15625 | 4 | def DecimalToIEEE754Single():
print('Conversion to IEE754 Single Program Format')
exp=-1
exp1=0
num=''
sig=''
b=''
d=''
f=''
biased_expb=''
n=input('Enter decimal number: ') #this is where you enter decimal number to be converted
if n[0]=='-':
j='1'
elif n[0]=='0... |
767623eadd2fe8ff18afe4d8756d7cc3574d3f1e | jam193/datacamp-projects | /Analyze International Debt Statistics/notebook.py.html | 9,087 | 3.734375 | 4 | #!/usr/bin/env python
# coding: utf-8
# ## 1. The World Bank's international debt data
# <p>It's not that we humans only take debts to manage our necessities. A country may also take debt to manage its economy. For example, infrastructure spending is one costly ingredient required for a country's citizens to lead comf... |
970501885f27a0005b980b12baf9256fcaa8b3aa | deer95/Prog_Sparrow | /Term_2/Syms-2.py | 533 | 3.796875 | 4 | s = input('Your string: ')
eng = [list('ABCDEFGHIJKLMNOPQRSTUVWZYZ'), list('abcdefghijklmopqrstuvwxyz')]
rus = [list('АБВГДЕЁЖЗИКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ'), list('абвгдеёжзиклмнопрстуфхцчшщъыьэюя')]
while s != '':
for sym in s:
if sym in eng[0]:
print(eng[1][eng[0].index(sym)], end='')
eli... |
d81458661bf4afc28cbcd0459b1b9aa315bfd37e | Miyayx/device-mapping | /models.py | 1,091 | 3.6875 | 4 | # -*- coding:utf-8 -*-
class DeviceNode:
def __init__(self, string):
self.name = string
self.type = "d"
self.visited = False
def __str__(self):
return str(self.name + "#" + self.type)
def __hash__(self):
return hash(str(self))
def __eq__(self, other):
... |
a5c7a0acd13b59c9fe2ccab7c1ae2305ee11dd66 | anneharris4/Hackbright-Intro-to-Programming-Assignments | /Lesson_7/Functions_Exercises_2.py | 1,133 | 4.09375 | 4 | def add (num1, num2):
return num1+num2
num1 =int(raw_input("what is your first number?"))
num2 =int(raw_input("what is your second number?"))
print add(num1, num2)
def subtract(num1,num2):
return num1-num2
num1 =int(raw_input("what is your first number?"))
num2 =int(raw_input("what is your second number?"))
print su... |
e799b4cd115d46a5cc11a25c0e6a37c21a0d141b | koltpython/python-exercises-spring2020 | /section1/solution/fizzbuzz.py | 970 | 4.59375 | 5 | """
FizzBuzz is a classical interview question.
We will implement a modified version of it, however, you can also find the original version on the web if you are interested.
Write a program that takes a number from the user.
If this number is negative, print an error message
if this number is a multiple of 3, print '... |
ceb4a20b5b477f03aa069b367e4f50b434d94695 | barnybug/aoc2020 | /day22.py | 1,432 | 3.609375 | 4 | #!/usr/bin/env python
import re
def parse_player(data):
return list(map(int, re.findall(r'\d+', data)))[1:]
def part1(data):
player1, player2 = map(parse_player, data.split('\n\n'))
while player1 and player2:
p1 = player1.pop(0)
p2 = player2.pop(0)
if p1 > p2:
player1.... |
10d2319025b4d9cdfdf6293a4147bf764ad729fa | BigObasheer/holbertonschool-higher_level_programming | /0x03-python-data_structures/1-element_at.py | 187 | 3.53125 | 4 | #!/usr/bin/python3
def element_at(my_list, i):
if i < 0:
return None
elementcount = len(my_list) - 1
if i > elementcount:
return None
return my_list[i]
|
15fe0e93bd865664c61abe9df6c4d176579cc704 | cohaolain/ryanair-py | /ryanair/airport_utils.py | 1,929 | 3.734375 | 4 | import os
from dataclasses import dataclass
from math import radians, sin, cos, asin, sqrt
import csv
from typing import Any
from ryanair.types import Flight
AIRPORTS = None
@dataclass
class Airport:
IATA_code: str
lat: float
lng: float
location: str
def load_airports():
global AIRPORTS
i... |
3cf303370304028ce8acace3d30982436d64ce5e | wurrzag/sudoku | /sudoku/data.py | 9,577 | 3.6875 | 4 | # *** creates 9x9 board (valid input for _main_file.solve()) from some of data below (below the getch() method)
def create_sudoku(inp):
row = 0; col = 0; outp = [[0] * 9 for _ in range(9)]
for letter in inp.replace('.', '0'):
a = ord(letter)
if a >= 48 and a <= 57: # if letter is in between '0' ... |
6c679d36f2a8b427c26861917d197154a297219c | pfcperez/DevF_Ram | /Clases/Clase9.py | 3,351 | 3.828125 | 4 | """
Paradigma de programacion para resolver un problema
Pensar que todo es un objeto
Abstraer cosas del mundo real en objetos y propiedades
Instancia o Objecto
Nombres de clases se esriben con convencion Camel Case
"""
class Empleado(object):
#variable de clase
#Constante para todoas las instancias
monto... |
00fc1d55ed9354a8c02d1190336e92f709cbb608 | natTP/2110101-comp-prog | /04_Loop/0406-Triangle.py | 361 | 4 | 4 | h = int(input())
w = 2*h - 1
for i in range(h-1):
line = ""
for space in range(h-1-i):
line += " "
line += "*"
for space in range(2*i-1):
line += " "
if i != 0:
line += "*"
for space in range(h-1-i):
line += " "
print(line)
line = ""
for i in ... |
ce294d5833d50433314fb6c87a23417cbf760b18 | akira2nd/CODES | /Algoritmos e Lógica de Programação/lista 2 akira/questao02.py | 501 | 4 | 4 | '''
2. Determine se um ano é bissexto. Verifique no Google como fazer isso...
'''
print('Verificar se o ano é bissexto')
print()
ano = int(input('Digite o ano: '))
if len(str(ano)) == 4:
if ano%4 == 0 and int(str(ano)[3:4]) != 00:
bis = 'Foi bissexto'
elif ano%4 == 0 and int(str(ano)[3:4]) == 00 and an... |
e229fe3ebca39e5beb99a0a9e8af1d16cb04e580 | carlosmertens/Learning-Training | /Deep-Learning/Python-Scripts/keras_XOR.py | 1,393 | 3.765625 | 4 | # PROJECT: Solve XOR Problem
# PROGRAMMER: Carlos Mertens - Udacity Student
# Udacity Instructors (Machine Learning Engineer Nanodegree)
# DATE CREATED: (DD/MM/YY) 11/01/2019
# REVISED DATE: (DD/MM/YY)
# PURPOSE: Create a Neural Network model with Keras Framework to solve XOR
# USAGE: ...
import numpy as np
import... |
a6b2f4eb46d96c75152cbec322cd99b1413031d9 | TomaszKolodziejczak/code_snippets | /simple_game_while_loop.py | 2,655 | 3.890625 | 4 | """
This is a simple example of using data structures and loops.
Code reformatting needed
"""
import random
from enum import Enum
from time import sleep
def find_approx_value(value, percent_range):
lowest_value = value - (percent_range / 100) * value
highest_value = value + (percent_range / 100) * value
... |
762dcf0edf7688c9f2d114c009a68121eca68c6a | me6edi/Python_Practice | /F.Anisul Islam/12.program_if_else..py | 889 | 4.03125 | 4 | # #Innner if statement
# if 7 > 3:
# if 7 > 3:
# print("Hi")
# num1 = 30
# num2 = -80
# num3 = -40
# if num1 > num2: # 30 > 20
# if num1 > num3: # 30 > 40
# print(num1)
# else:
# print(num3)
# if num2 > num1: # 20 > 30
# if num2 > num3: # 20 > 40
# print(num2)
# ... |
09e8038fb00bb16eca4887b0eb00750d94235d90 | StepaMin/SecondPythonProject | /Vowels.py | 592 | 3.65625 | 4 | print("Программа подсчитывает кол-во гласных в строке")
Vowels = ["a", "A", "o", "O", "u", "U", "i", "I", "e", "E", "y", "Y"]
Counter = [0, 0, 0, 0, 0, 0]
def FindVowels():
inputValues = input("Введите любой текст латиницей: ")
for i in range(len(Vowels)):
for j in range(len(inputValues)):
... |
d7c427d2507018847d62873eb78753a31d6dda77 | tentacion098/e-olymp-solutions | /8001 - 9000/8521 Şərt operatoru - 2 | Python.py | 75 | 3.8125 | 4 | x=int(input())
if x>=10:
y=x**3+5*x
else:
y=x**2-2*x+4
print(y)
|
2f275b803f348cc858383be38eeb4f4bb87943d8 | nicolovendramin/Perfect-Hash-Generator | /Code/PythonCode/version0.1/dictionaryGenerator.py | 2,939 | 3.6875 | 4 | #This module is meant to generate a dictionary (in Python style) in which the keys are lists of ints (the right hand sides) and the values are the corresponding left hand sides.
#Done this the module generates another dictionary of test cases (a subset of the initial dictionary) in C style to be used in a C program as ... |
81cf97687750b166ce77f841efbd27c398997de7 | thenixan/CourseraPythonStarter | /src/week2/task9.py | 162 | 3.796875 | 4 | n = int(input())
if 10 < n % 100 < 20 or n % 10 == 0 or n % 10 >= 5:
print(n, "korov")
elif n % 10 == 1:
print(n, "korova")
else:
print(n, "korovy")
|
94bb0ccbc5c82507c31563e148e4d60d9b827c31 | a3910/aid1807-1 | /aid1807a/练习题/python练习题/python基础习题/04/jiujiu.py | 157 | 3.75 | 4 |
for left in range(1,10):
#打印每一行
for col in range(1, left + 1):
print("%dX%d=%d" % (col, left, col * left), end = ' ')
print() |
fbd7df9500d98be6eec070aa9783b14ea4f8c1dd | shizzeer/CTF | /PicoCTF2018/crypto/vignere_cipher_cracker_V2.py | 327 | 3.671875 | 4 | import string
cipher_text = "llkjmlmpadkkc"
key = "thisisalilkey"
alphabet = string.ascii_lowercase
plain_text = []
i = 0
for letter in cipher_text:
index_of_the_plain_letter = (alphabet.index(letter) - alphabet.index(key[i])) % 26
plain_text.append(alphabet[index_of_the_plain_letter])
i += 1
print "".join(plain... |
3eeb42ea9a25c7dcba4308dd067bb86d784ab45d | khushi-developer/PythonPrograms | /Healthyprogrammer.py | 1,217 | 3.5 | 4 | from pygame import mixer
import datetime
from time import time
def musiconloop(file,stopper):
mixer.init()
mixer.music.load(file)
mixer.music.play()
while True:
a=input()
if a == stopper:
mixer.music.stop()
break
def log_now(msg):
with open("mylog.txt","a") ... |
7f1696ab437f2edaee45f71ef95409b478fb3d17 | riyafernando/dicegames | /DiceGamesTkinter.py | 30,950 | 3.90625 | 4 | # Python Class 2344
# Lesson 8 Problem 1 Part (b)
# Author: violet_baudelaire (479380)
from tkinter import *
import random
class GUIDie(Canvas):
'''6-sided Die class for GUI'''
def __init__(self,master,valueList=[1,2,3,4,5,6],colorList=['black']*6):
'''GUIDie(master,[valueList,colorList]) -> GUIDie
... |
cd4fe844d2cf7c6fd6c7d5ff9f856b95bb369e2e | xpessoles/Informatique_PSI | /Fiches/P_03_01_Integration_TD/programmes/imprimeRangee.py | 202 | 3.84375 | 4 | def imprimeRangee(rangee):
'''rangee est une liste de 2 et de 3'''
c=''
for element in rangee:
if element==2:
c+='01'
else:
c+='001'
return c[:-1] |
752601878d095b28b1687f64e02282e816499da2 | 6chelo6/python-dev-fund | /030_square.py | 93 | 3.5625 | 4 | #!/usr/bin/env python
def square(value):
return value * value
age = 5
print (square(age))
|
6da6c77c52b03a1d66f93c0237b98605ff12f043 | Anaid-Garcia/Python-Programs | /ArtificialIntelligenceHw0/mustard_analytics.py | 12,313 | 3.96875 | 4 | # Anaid Garcia
# COMPSCI 383 Homework 0
# Version: 2/6/2021
# Fill in the bodies of the missing functions as specified by the comments and docstrings.
import sys
import csv
import datetime
from datetime import timedelta
import pandas as pd
import numpy as np
# Exercise 0. (8 points)
#
def read_data(file_name):
... |
5ceb08df8516fb4b5e5ef8f0f0119e88750bd0a4 | bssrdf/pyleet | /E/EvaluateReversePolishNotation.py | 1,880 | 4.03125 | 4 | '''
-Medium-
Evaluate the value of an arithmetic expression in Reverse Polish Notation.
Valid operators are +, -, *, and /. Each operand may be an integer or another
expression.
Note that division between two integers should truncate toward zero.
It is guaranteed that the given RPN expression is always valid. That... |
465eadd79452698271d0a5bf9041e71ca5d5755d | sanchit0496/Python_Practice | /scratch_41.py | 301 | 3.671875 | 4 | class point:
def __init__(self, x=0, y=0):
self.x,self.y = x,y
def __str__(self):
string = "("+str(self.x)+","+str(self.y)+")"
return string
def __del__(self):
print("Delete")
pt1 = point(3,4)
pt2 = point(8,9)
pt3 = pt2
print(pt1)
print(pt2)
print(pt3)
|
a811fabce2cc66fc9b7c645e4990748303b11bc8 | trevorbillwaite/Week-Eleven-Assignment | /part1.py | 950 | 3.671875 | 4 | # Trevor Waite
# Week 11 Assignment
# Collaboration with Nicole Ignasiak and Devin Simoneaux
from BowlingGame import Game
# Open textscores.txt for reading
inFile = open("testscores.txt", "r")
for line in inFile:
line = line.strip() # take out punctuation from text file
scoreList = line.split(",") # split t... |
08fc1842d57bd4cfa214da0c5ceb2cc3fa07c4a7 | thenickforero/holbertonschool-machine_learning | /math/0x00-linear_algebra/12-bracin_the_elements.py | 709 | 4.1875 | 4 | #!/usr/bin/env python3
"""Module to compute element-wise addition, subtraction,
multiplication, and division on a NumPy ndarray.
"""
def np_elementwise(mat1, mat2):
"""Performs element-wise addition, subtraction, multiplication,
and division.
Arguments:
mat1 (numpy.ndarray): a NumPy array that ... |
a7623a4688883e64efc8680435eaabdd0bfeec4e | xingetouzi/Bigfish | /Bigfish/test/testcode3.py | 3,206 | 3.546875 | 4 | # -*- coding:utf-8 -*-
def init(): # init函数将在策略被加载时执行,进行一些初始化的工作
pass
# 每一个不以init为名的函数都将别视为一个信号,信号在每根K线的数据到来时都会被执行
def handle(slowlength=20, fastlength=10, lots=1): # 函数签名的中只支持带默认值的参数(即关键字参数),可以对此处的参数使用我们平台的参数优化功能
def highest(price, len, offset=0): # 计算从当前K线向前偏移offset根K线开始起,之前n根K线的price序列数组中的最低价
m... |
433a9f86638159f7d7840ec7b6aef1a6374f60e3 | AFLgains/Advent_2017_2 | /day17.py | 836 | 3.796875 | 4 | """
Spinlock
"""
from typing import List, Tuple
def step_forward(list_: List[int], n: int,current_position: int) -> Tuple[int,int]:
final_position = (current_position + n) % len(list_)
return final_position, list_[final_position]
assert step_forward([1,2,3,4,5],3,0) == (3,4)
assert step_forward([1,2,3,4,5],3,3) =... |
cb8df301f45aae001e7cc95576288c7f0253521b | ChandraKanthV/CodilityExercise | /src/main/Python/test_max.py | 839 | 3.59375 | 4 | def test_max_slice(A):
maxVal=1
begin=0
end=0
arrLength = len(A)
for i in range(arrLength):
begin = i
end = begin
while( end+1 < arrLength ):
if( A[end] * A[end+1] < 0 ):
end += 1
elif((end == 0) and (A[end] * A[end+1]) == 0):
... |
56ef76c22bf2f3ddc899fcaa7bb973f2b147c9d8 | mutdmour/projecteuler | /projecteuler-2015/p5.py | 638 | 3.6875 | 4 | def sumvalues(n):
s = str(n)
total = 0
for i in range(len(s)):
total = total + int(s[i])
return total
def main():
z = False
j = 20
while z == False:
# if sumvalues(j)%3 == 0: #this does not make it faster
for i in [7,11,13,16,17,18,19,20]:
... |
1c5603c493a7468814275e72c1e607f488e64cb7 | Ze1598/Python_stuff | /examples/matplotlib/matplotlib_pyplot_line_plots.py | 7,341 | 4.25 | 4 | from matplotlib import pyplot as plt
import numpy as np
#y-values to be plotted in the graph
#The x-values will be the index of each value, i.e. (0,1), (1,3), (2,8) and (3,4)
y = [1, 3, 8, 4]
#Plot a graph with the y-values contained in the 'y' list, using black dashed lines
plt.plot(y, 'k--', linewidth=3)
#Name the y... |
62cea469f2bf3bd0e6bf7193f42f2d43811ef3f3 | okvarsh/Hackerrank-Codes | /Problem Solving/Python/BeautifulDayAtTheMovies.py | 1,980 | 4.3125 | 4 | #Lily likes to play games with integers. She has created a new game where she determines the difference between a number and its reverse. For instance, given the number 12, its reverse is 21. Their difference is 9. The number 120 reversed is 21, and their difference is 99.
#She decides to apply her game to decision ma... |
0279c663a756cdf845347114db25c6596e64e4b8 | josbp0107/data-structures-python | /matrix.py | 1,143 | 3.890625 | 4 | from arrays import Array
"""
Grid type class
Methods:
1. Initialize
2. Get height
3. Get width
4. Access item
5. String representation
"""
class ArrayTwoDimension:
"""
Args:
rows(int): numbers of rows in the matrix.
columns(int): numbers of columns in the matrix.
fi... |
128fc318d9e9e1c2bb653ef2c89a1b934042eefb | bigeast/ProjectEuler | /(#88)MinSets.py | 695 | 3.65625 | 4 | from operator import mul
def mulArray(a):
return reduce(mul,(x for x in a),1)
def findMin(k):
array=[1]*(k-1)
array.insert(-1,2)
index=-1
m=10**10
final=[]
while index!=int(.5*len(array))*-1:
while sum(array)!=mulArray(array):
array[index]+=1
if array[index]>1... |
01f12db5fa6b3118adc420a642e38b1b1896e5d3 | JonathanBallard/Coding_Dojo_Python_OOP_And_ORM_Math_Dojo | /mathdojo.py | 757 | 3.609375 | 4 |
class MathDojo:
def __init__(self):
self.result = 0
def add(self, num, *nums):
# your code here
self.result += num
if len(nums) > 0:
for i in range(len(nums)):
self.result += nums[i]
return self
def subtract(self, num, *nums):
s... |
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... |
a4258469225e4b17cff0e5aceda6d774446ab509 | mrtroian/telegram_parser | /telegram-parser/parser.py | 1,396 | 3.5625 | 4 | from sys import argv
from parsing import Parsing
from datetime import datetime
from config import keys
def main():
try:
if len(argv) < 3:
print('''Options:\nparse_messages [group name]
\rparse_participants [group name]\nget_statistics [group name | date from | date until]''')
return 1
parse = Parsing(ar... |
b91715a69b83d017d0242259ee1171dbaa960dd1 | khlee12/python-leetcode | /medium/186.Reverse_Words_in_a_String_II.py | 628 | 3.828125 | 4 | # 186. Reverse Words in a String II
# https://leetcode.com/problems/reverse-words-in-a-string-ii/
# http://www.voidcn.com/article/p-dpxpifak-qp.html
class Solution:
def reverseWords(self, str: List[str]) -> None:
"""
Do not return anything, modify str in-place instead.
"""
# reverse... |
30bf594e2ce32a72e24d3fe19cfce44ff8b77e45 | silvanaoliveira/Exercicios_Python_TrainingCenter | /Ex07.py | 733 | 3.8125 | 4 | #!/usr/bin/python3
import random, string
caracteres = string.ascii_lowercase + string.ascii_uppercase + string.digits + string.punctuation
tamanho = 0
password = ""
file = open("passwords_geradas.txt","a")
while tamanho < 8 or tamanho > 32:
tamanho = int(input("Entre 8 e 32 caracteres, introduza o número d... |
f432b160be863f284adcc1cf13e95d3327036c02 | cosmos1030/CLK | /recursion/(2)10870_K.py | 135 | 3.625 | 4 | n = int(input())
def Pibo(i):
if i==0: return 0
if i==1: return 1
else:
return Pibo(i-1)+Pibo(i-2)
print(Pibo(n)) |
c37abdb8c64361e01fd784de2cc7efb85ba34f6e | lucaslattari/manim-palestra | /exemplo1.py | 479 | 3.796875 | 4 | #importamos a manim
from manim import *
#toda animação na manim deve ser uma classe que herda de Scene
class SquareToCircle(Scene):
#as ações passo a passo a serem realizadas na animação devem estar inseridas
#dentro de um método construct()
def construct(self):
circle = Circle() #cria um novo obj... |
344f0f963e06d546948bc800a075be8bc654c585 | juliovt-07/Exercicios-Python | /Condicional 17.py | 488 | 3.890625 | 4 | #programa que calcule e mostre a área de um trapézio. Sabe-se que:
#A = (basemaior + basemenor) ∗ altura / 2
#Lembre-se a base maior e a base menor devem ser números maiores que zero.
altura = float(input("Altura do trapézio: "))
basemaior = float(input("Base maior: "))
basemenor = float(input("Base menor: "))
if basem... |
e155028a8e81bbf060efdef85a3bd5e0dd1c84f6 | slconrad/ATBSWP | /guess_num.py | 1,363 | 4.09375 | 4 | # Guess the number game!
import random
import time
print('Hi and Welcome to the Number Guessing Game.')
time.sleep(2)
print('You have 6 chances to guess a number between 1 and 20.')
time.sleep(2)
print('But first, what shall I call you?')
name = input() # Wait for the user's imput
time.sleep(1)
print('Ok, ' + name +... |
4718149656c92729a3bd26c6a6f30ac0cdd9b84b | Dushyanttara/Competitive-Programing | /happy_number.py | 2,451 | 3.984375 | 4 | def isHappy(n):
words_digits = list(str(n))
new_num = 0
for digit in words_digits:
new_num += int(digit)*int(digit)
if new_num == 1:
print("Happy Number")
else:
try:
isHappy(new_num)
except RecursionError:
print("unhappy number")
... |
23fca0aee9e74ad2ec33b23545b24dea38bb8130 | haohao2021/The-Complete-Python-Pro-Bootcamp-for-2021 | /d27-mile_to_kilo_converter/main.py | 1,305 | 3.671875 | 4 | # Mile to Kilometers Converter
import tkinter as tk
FONT = ("Arial", 12)
CONV_FACTOR = 1.60934
def calculate():
mil_str = entry_box.get()
try:
mil = float(mil_str)
kms_str = str(round(mil * CONV_FACTOR, 2))
# change the color in case the previous entry was invalid
converted.c... |
ec901d367dd1dcaeb2f8f26a378ed7ce787695fd | dahuzi0/PycharmProjectsLearn | /pyTestList/week_02/day_06/shopping.py | 735 | 3.515625 | 4 | #_author: earl
#_data: 18/02/08
# -*- coding: utf-8 -*
#购物车
goodsList = ['pengguo','pad','android','apple']
priceList = ['100','2000','1000','3000']
selectGoodsList = []
priceTotal = 10000
selectGoodsPriceTotal = 0
for index,val in enumerate(goodsList):
msg = '''
'---------- 货物 (%s) 价格 ------------'
name... |
328514e675f0bbffdf4e5c4035e8d3201445d619 | gawmanarnar/c-eval | /sum-primes/sum-primes.py | 636 | 3.671875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# sum-primes.py
#
import cmath
def main():
print sum(seive(10000)[:1000])
return 0
def seive(n):
if n < 2:
return []
elif n == 2:
return [2]
primelist = []
booleanlist = []
for x in range(n-2):
booleanlist.append(True)
checks = int(abs(cmath.s... |
51a0544ec9ea3769104759e23b84d489182e451d | zrsoo/a1-915-Neamtiu-Zaris | /p3.py | 927 | 3.96875 | 4 | #
# Implement the program to solve the problem statement from the third set here
#
# Generate the largest perfect number smaller than a given natural number n.
# If such a number does not exist, a message should be displayed.
# A number is perfect if it is equal to the
# sum of its divisors, except itself. (e.g. 6 is a... |
6724eb0bbdf21066b4406a588f9df058f291a8a0 | 30-something-programmer/Python-Noob | /While-loop.py | 673 | 3.90625 | 4 | #Includes continue and break
#Executes code so long as the expression evaluates to true
x = 10
while x > 0:
print('{}'.format(x))
x -= 1
print("Happy New Solstice!")
questions = ['Tell me your name: ', 'People like colour, what\'s yours? ','Lightsaber or Master Sword. Pick: ']
i = 0
#Break
while True:
pri... |
548e69dc0327d0cf5394dedb52ac9406faec8092 | AphroditesChild/Codewars-Katas | /digital root.py | 233 | 3.53125 | 4 | def digital_root(x):
root = x
while root > 9 :
sum = 0
for i in range(len(str(root))) :
sum += (root // 10**i) % 10
root = sum
return root
print(digital_root(5468))
input()
|
d27fdc798ebabe89ebd4365b2795ca3ed96fdeac | simtb/coding-puzzles | /leetcode-july-challenge/reverse_words_string.py | 435 | 3.9375 | 4 | """
Given an input string, reverse the string word by word.
"""
class Solution:
def reverseWords(self, s: str) -> str:
tmp: List[str] = s.split(" ")
tmp: List[str] = list(filter(lambda x: x != "", tmp))
l: int = 0
r: int = len(tmp) - 1
while (l < r):
... |
061a1da679aad89be770544f54f00681543167b8 | lukaswangbk/Python-for-Everybody-Specialization | /2-Python-Data-Structure/Assignment/Assignment 9.4.py | 966 | 3.984375 | 4 | """9.4 Write a program to read through the mbox-short.txt and figure out who has the sent the greatest number of mail messages. The program looks for 'From ' lines and takes the second word of those lines as the person who sent the mail. The program creates a Python dictionary that maps the sender's mail address to a c... |
dcb6ab461851953872ccbbfeb2471ef015a8d1f8 | Aasthaengg/IBMdataset | /Python_codes/p02267/s192837412.py | 549 | 3.640625 | 4 | # encoding: utf-8
class Solution:
@staticmethod
def linear_search():
array_length_1 = int(input())
array_1 = [int(x) for x in input().split()]
array_length_2 = int(input())
array_2 = [int(x) for x in input().split()]
# print(len(set(array_1).intersection(set(array_2)))... |
17bc96011a442943b291c8e77a15b32c73b5a436 | choi-tak-bong/Coding-Test-My-Algorithms-That-Hurt-Your-Eyes-But-Managed-To-Get-Through | /q10866_덱.py | 895 | 3.5 | 4 | """
https://www.acmicpc.net/problem/10866
"""
from collections import deque
import sys
input = sys.stdin.readline
n = int(input())
answer = []
answer_append = answer.append
q = deque([])
for _ in range(n):
s = input().split()
order = s[0]
if order == "push_front":
q.appendlef... |
4b5080a0649ce6110aee6e8bd3fd873d52db3b3c | DragomirCristian/ai-chess-framework | /ChessFramework/Strategies.py | 7,300 | 3.5625 | 4 | import random
from Board import Board
from Piece import Piece
class Minimax_Base:
def __init__(self, AI, human):
self.ai_player = AI
self.human_player = human
def get_piece_value(self, piece: Piece):
piece_values = {"Rook": 50, "Horse": 30, "Bishop": 30, "King": 900, "Queen": 800, "... |
0afc058eccdcb8fb7fb901c0a603cf8723d26b09 | HomePagess/Python-basic-practice | /NO.4/2.py | 395 | 4 | 4 | print('hello')
temp=input("不妨猜下我想的是那个数字:")
guess=int(temp)
while guess!=8:
temp=input("猜错了,重新输入吧:")
guess=int(temp)
if guess==8:
print("我靠这都猜到了")
print("但是没奖励")
else :
if guess>8:
print("大了大了")
else:
print("小了小了")
print("游戏结束")
|
884f68b9295ebc523bc4ce24bf5c367514d5bbd0 | Gloria0618/semantic_analysis | /example_01.py | 148 | 3.546875 | 4 | class Student(object):
def __init__(self,name,score):
self.name = name
self.score = score
bart = Student('Bart Simpsion',59)
print() |
b3df72354711060c18c9e94523ff98b6d0033043 | Scorpioeric-dev/Python_UVU | /lesson_5.py | 1,913 | 4.5 | 4 | # def print_test():
# """This will print a test of 2 separate text"""
# print("This is a test")
# print("My first function in python")
#
# # --We have to invoke the function in the bottom of the file
#
# print_test()
# def print_value(value):
# """This function prints the value passed in"""
# print ... |
be952d31a928fc4ff8e5455f8eeae55b466d937f | Dramoun/DoDgame | /dod_cmd.py | 25,501 | 3.640625 | 4 | from random import randrange
class gameSystem:
def __init__(self):
self.stageTimer = 1
self.stageRand = 1
self.restRand = 1
self.diffF = 1
self.diffP = 1
self.diffC = 1
self.diffM = 1
self.diffB = (self.diffF+self.diffP+self.diffC+self.diffM)/4
def sRandGen(self):
... |
24a7df8738bec58cbf02391e6467702a96a37c19 | koshelev-dmitry/Elements_of_codding_interviews_in_python | /chap_9_bin_trees/_9.1_height_balbanced_check.py | 809 | 3.6875 | 4 | import collections
def is_balanced_binary_tree(tree):
BalancedStatusWithHeight = collections.namedtuple(
'BalancedStatusWithHeight', ('balanced', 'height'))
def check_balance(tree):
if not tree:
return BalancedStatusWithHeight(True, -1)
left_result = check_bala... |
2bb1c2e622934594bb779b6c3fc6da93c697e467 | Andros415/BlackJack | /deck.py | 617 | 3.765625 | 4 | from random import shuffle
class Deck:
suits = ["Hearts","Diamonds", "Spades", "Clubs"]
cardsinsuit = {"2":2,"3":3,"4":4,"5":5,"6":6,"7":7,"8":8,"9":9,"10":10,"Jack":10,"Queen":10,"King":10,"Ace":11}
def __init__(self):
self.deck = []
for suit in Deck.suits:
for card... |
ab8508b0238652c288bc95df4a742d2fd2f65c15 | ahenshaw/aoc2020 | /aoc03/day3.py | 470 | 3.640625 | 4 | def trees(data, right, down):
count = row = col = 0
while row < len(data):
line = data[row].strip()
count += line[col % len(line)] == '#'
col += right
row += down
return count
data = list(open('input.txt'))
##### Part 1 #####
print('Part 1:', trees(data, 3, 1))
##### Part ... |
43e795a8c32e322570b33612309ef6edc5502af9 | nihathalici/Break-The-Ice-With-Python | /Python-Files/Day-21/Question-85-alternative-solution-1.py | 388 | 3.890625 | 4 | """
Question 85
Question
By using list comprehension, please write a program to print the list
after removing the 0th,4th,5th numbers in [12,24,35,70,88,120,155].
Hints
Use list comprehension to delete a bunch of element from a list.
Use enumerate() to get (index, value) tuple.
"""
li = [12,24,35,70,88,120,155]
li =... |
fb2f46b03583879adb3a65f6a12a1c11d376254a | leandromt/python3-curso-em-video | /scripts/ex019.py | 347 | 3.734375 | 4 | #sortear lista de alunos
import random
a1 = input('Primeiro aluno: ')
a2 = input('Primeiro segundo: ')
a3 = input('Primeiro terceiro: ')
a4 = input('Primeiro quarto: ')
lista = [a1, a2, a3, a4]
escolhido = random.choice(lista)
#print('O aluno sorteado foi {}'.format(lista[random.randint(0,3)]))
print('O aluno sorteado ... |
fbc91889d8d81daa0ed60289560bbe0639c3ee42 | LiudaShevliuk/python | /lab3_2.py | 192 | 4 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
print('Enter the temperature in Fahrenheit: ')
temper_celsius = (int(input()) - 32) * 5 / 9.0
print('Temperature in Celsius: ', temper_celsius)
|
56fe7b36c2f21a5b337fd9ee8a6e317bfb15ca81 | mercurium/proj_euler | /prob173.py | 338 | 3.515625 | 4 | import math
import time
start = time.time()
n = 10**6
count = 0
i = 2
while (n - i**2)/(2*i) > 0:
count = count + (n - i**2)/(2*i)
#print (n - i**2)/(2*i)
i = i +2
print count
print "Time Taken:", time.time() - start
"""
22:38 ~/Desktop/python_projects/proj_euler $ python prob173.py
1572729
Time Taken: 0.00... |
c97a6e9ee1941129a1c810152615b0dec607661e | vesche/ctfs | /2020-04-DawgCTF/Man these spot the difference games are getting hard/affine.py | 1,032 | 3.546875 | 4 | WIDTH = 26
ASC_A = ord('A')
def encrypt(key, words):
return ''.join([shift(key, ch) for ch in words.upper()])
def decrypt(key, words):
a, b = modInverse(key[0], WIDTH), -key[1]
d = str()
for ch in words.upper():
if ch == '{':
d += '{'
continue
elif ch == '}':
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.