blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
af082c2e8d59422370246cec0abb3308698fbd1b | omer19-meet/yl1201718 | /lab3.py | 324 | 3.5625 | 4 | import turtle
# turtle.addshape("redmeat.gif")
# turtle.shape("redmeat.gif")
# turtle.mainloop()
turtle.speed(1000)
for a in range(360):
turtle.pendown()
turtle.right(a+1)
turtle.forward(100)
turtle.right(50)
turtle.forward(40)
turtle.right(90)
turtle.forward(20)
turtle.penup()
turtle.home()
turtle.mainloop... |
ffa1b4044bd58e1f5f12d98dfd6446397c8b18ab | jensenloke/python3-python-basics | /final_chpt_9.py | 1,989 | 3.671875 | 4 | # Question 1
# scores = "67 80 90 78 93 20 79 89 96 97 92 88 79 68 58 90 98 100 79 74 83 88 80 86 85 70 90 100"
# score = scores.split(" ")
# score_list = list()
# for i in range(len(score)):
# score[i] = int(score[i])
# if score[i] >= 90:
# score_list.append(score[i])
# a_scores = len(score_list)
# pri... |
e6c06440fa7baf555f57d4530c6d62136c6053a6 | PeterDziuba/Codeguild | /Sudoku/suds.py | 9,557 | 3.625 | 4 | #Testing my sudoku board:
import os
board = []
my_looper = True
board_set_1 = {1, 2, 3, 4, 5, 6, 7, 8, 9}
board_set_2 = {1, 2, 3, 4, 5, 6, 7, 8, 9}
board_set_3 = {1, 2, 3, 4, 5, 6, 7, 8, 9}
board_set_4 = {1, 2, 3, 4, 5, 6, 7, 8, 9}
board_set_5 = {1, 2, 3, 4, 5, 6, 7, 8, 9}
board_set_6 = {1, 2, 3, 4, 5, 6, 7, 8, 9}
boar... |
c5f7eafa125403c2ce3eadf40d2823458637ef3a | DvorahC/Numpy---exercices | /numpy6.py | 306 | 4.125 | 4 | import numpy as np
'''
Build an array of 100 randomly chosen integers (any number from 1 to 100)
and find the five largest numbers.
'''
x = np.random.randint(1, 101, size=100)
print(x)
#use the sort() to order all the numbers of tha array
x_in_order = np.sort(x)
print(x_in_order)
print(x_in_order[-5:])
|
aa55bf9b78f627cab12acc7072606a575d658670 | seydouxxx/data_structure | /linked_list/doubly_linked_list.py | 1,092 | 4.09375 | 4 | ## Doubly Linked List
## by seydouxxx (risc@kakao.com || seydoux.tistory.com)
## 2019. 12. 28.
class LinkedList:
def __init__(self):
self.head = None
self.tail = None
# print all elements by lines
def show(self):
point = self.head
while (point is not None):
... |
99ad4e73b66f51dcf8805fc27b34f579241e03c3 | AliAdam-77/Smoothstack | /smoothstack/week1/day4/codingexercise8.py | 3,756 | 4.5 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
#1.Create a function func() which prints a text ‘Hello World’
def func():
print("Hello World")
func()
print("\n")
# In[2]:
#2.Create a function which func1(name) which takes a value name and prints the output “Hi My name is Google’
def func1(name):
print("Hi... |
f5be35bf15951480dbe08fa73fa96e864ac89e2b | DEskinazi/Python_Coursework | /hello_world.py | 219 | 3.578125 | 4 | # various ways of printing in Python
#print command
#print("Hello Python world!")
#adding a variable message
message = "Hello Python world!"
print(message)
message = "Hello Python Crash Course world!"
print(message)
|
3102c90cc40c929a2b19c3cfc0c0570100e3c07b | pragatij17/General-Coding | /Day 1/largest_element_in_an_array.py | 334 | 4.03125 | 4 | # Largest Element in An Array
def largest_num(array:list)->int:
largest_no=-99999
largest_index=0
for index in range(0,len(array)):
if(largest_no<array[index]):
largest_no=array[index]
largest_index=index
return largest_no
array=list(map(int,input().split()))
print(large... |
9cdbcdb4d9ff74efc3fccf58c7827b9e9d2a89d8 | MikeOcc/MyProjectEulerFiles | /Euler_1_34.py | 1,378 | 3.640625 | 4 | #Problem 34
#03 January 2003
#
#145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.
#
#Find the sum of all numbers which are equal to the sum of the #factorial of their digits.
#
#Note: as 1! = 1 and 2! = 2 are not sums they are not included.
#
from time import time
from math import factorial
starttime=time(... |
4edc1f80495ddd46b55515f50e0a8182b5ccab6f | Emmano97/python-base | /corrections/exo_surgery.py | 1,042 | 3.8125 | 4 |
from nbautoeval import Args, ExerciseFunction
####################
# @BEG@ name=surgery
def surgery(liste):
"""
Prend en argument une liste, et retourne la liste modifiée:
* taille paire: on intervertit les deux premiers éléments
* taille impaire >= 3: on fait tourner les 3 premiers éléments
"""
... |
b0d1032e9682fb1be6ef32ded5cbc48731dc5a0b | ShreyasShray/project-105 | /standardDaviation.py | 729 | 3.921875 | 4 | # import all modules
import csv
import math
# opening the file and getting the list of data
with open("standard_deviation_for_project.csv", newline = "") as f:
reader = csv.reader(f)
file_data = list(reader)
file_data = file_data[0]
# getting the mean of data
total = 0
for x in file_data:
tot... |
553f6b3c6cc172192dd935e4322ab478d01c34fd | quano2/MATLAB-to-Python-Translator | /node.py | 6,376 | 3.59375 | 4 | from functions import *
def printVar(var):
'''
Will return the printed version of var if it is a Node,
otherwise will return var.
:param var:
:return:
'''
if isinstance(var,Node):
var = var.print()
return var
class Node:
type = "NODE"
def __init__(self,m ... |
db07e58e18de8b09d59de523920bce8eaf520fe9 | ayertay/Meme-Generator | /MemeEngine/MemeEngine.py | 1,426 | 3.546875 | 4 | """Meme Generator."""
import os
from PIL import Image, ImageDraw, ImageFont
class MemeEngine:
"""Combine texts and pictures to make a meme."""
def __init__(self, output_dir):
"""Save and create the output directory path."""
self.output_dir = output_dir
self.count = 1
if not... |
d74116c4e7a19272e86c34ed920acc8e8b91c6a1 | kamyu104/LeetCode-Solutions | /Python/check-if-word-is-valid-after-substitutions.py | 448 | 3.609375 | 4 | # Time: O(n)
# Space: O(n)
class Solution(object):
def isValid(self, S):
"""
:type S: str
:rtype: bool
"""
stack = []
for i in S:
if i == 'c':
if stack[-2:] == ['a', 'b']:
stack.pop()
stack.pop()
... |
fc709171b4973ee98d57de1a87d95930853c46d7 | us-upal/modern-python3-bootcamp | /Basic/screaming.py | 271 | 4.0625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue May 5 10:40:54 2020
@author: ASUS
"""
a=input('how many times do I have to tell you?')
# input() takes string and I have to convert into int/float
aa=int(a)
for i in range(0,aa+1):
print('clean up your room!') |
bd6d550dad1cd5939440e30774c299d11d2b6c57 | Camaz993/AI_Example | /randomPlayer.py | 1,529 | 3.5 | 4 | import numpy as np
playerName = "randomPlayer"
nPercepts = 75
nActions = 7
class MyCreature:
def __init__(self):
# This agent doesn't evolve, and it doesn't have a chromosome.
# The pass statement is for no-op (replace it with your chromosome initialisation)
pass
def AgentFunction(se... |
eb98a6aca33b55bdc0327c7d17abc0811457ef4a | devon6686/python3 | /exercise/tree/heap_sort1.py | 3,531 | 3.78125 | 4 | #!/usr/bin/env python3
"""
堆排序:
为了和树编码对应,增加一个无用的0在首位。
"""
import math
def print_tree2(array):
"""
前空格 元素间隔
1 7 0
2 3 7
3 1 3
4 0 1
"""
index = 1
depth = math.ceil(math.log2(len(array)))
sep = " "
for i in range(depth):
offset = 2 ** i
print(sep * ... |
53570e817f81630f7b8c97254a17f034b5529b9e | kollaa/day9task | /newxl.py | 814 | 3.640625 | 4 | import xlsxwriter
import sqlite3
conn = sqlite3.connect('customer.db', check_same_thread=False)
cu = conn.cursor()
cu.execute("SELECT * FROM student")
# Create a workbook and add a worksheet.
workbook = xlsxwriter.Workbook('stud.xlsx')
worksheet = workbook.add_worksheet()
# Some data we want to write to the... |
a13c47c3fb2c4f0e34749bfad9ae4da308596090 | mhsNSnair/My-Work | /ICS3U/Unit 5/Lists p 5.py | 166 | 3.921875 | 4 |
print('Please input a list of numbers')
sum = 0
list = input().split()
for s in range (len (list)):
sum+=int (list[s])
print ("The sum is",sum)
|
17a7b9b7e4348fba72bc25ef7dff321ca2c61136 | ekinkaradag/HackerRank-Solutions | /Python/Strings/Designer Door Mat/designer-door-mat.py | 246 | 3.5625 | 4 | # Enter your code here. Read input from STDIN. Print output to STDOUT
n, m = map(int, input().split())
pattern = [('.|.' * (2 * i + 1)).center(m, '-') for i in range(n // 2)]
print('\n'.join(pattern + ['WELCOME'.center(m, '-')] + pattern[::-1])) |
d911799543d91310ead09c647e36ca3ce725e5fa | ArroyoBernilla/T08_Arroyo.Aguilar.. | /Aguilar/iteracion_cadena.py | 4,647 | 4.03125 | 4 | print("="*50)
#EJERCICIO 1 - ITERACION
#dar el total de vocales
alumno="AGUILAR VERONA MIGUEL"
vocalA=0
vocalE=0
vocalI=0
vocalO=0
vocalU=0
#iteracion
for letra in alumno:
if(letra=="A"):
vocalA+=1
if(letra=="E"):
vocalE+=1
if(letra=="I"):
vocalI+=1
if(letra=="O"):
vocalO... |
341e8c057ea09f71a3177a3861776deab7695ee6 | EunSe-o/Python | /practice 3/string_handling_function_1.py | 1,021 | 4.1875 | 4 | python = "Python is Amazing"
# lower() 전부 소문자 출력
print(python.lower())
# upper() 전부 대문자 출력
print(python.upper())
# isupper() 해당 문자가 대문자인지 출력
print(python[0].isupper())
# len(변수) 해당 변수 전체 문자열의 길이 출력
print(len(python))
# replace("찾고 싶은 문자", "바꿀 문자")
print(python.replace("Python", "Java"))
# index("문자") 해당 문자가 몇 번째에... |
a7edf8a14eb3f0eeb1dd3090f8bb8a4b4a302490 | jiucaneg/hungman | /hungman.py | 1,360 | 3.859375 | 4 | import random
from string import ascii_lowercase
print('H A N G M A N')
print('Type "play" to play the game, "exit" to quit: ', end='')
x = input()
word = random.choice(['python', 'java', 'kotlin', 'javascript'])
# word = random.choice(['java'])
s = set()
w = set()
lives = 8
while x != 'play':
if x == 'exit... |
7b44744477c624b95e75a273cb2640f997c518d5 | duddk226/Python_SUD_Game | /Unit Test/test_monster.py | 770 | 3.75 | 4 | from unittest import TestCase
import Monster
class TestMonster(TestCase):
def setUp(self):
self.test_monster = Monster.Monster()
def test_get_hp_default(self):
expected = 5
actual = self.test_monster.get_hp()
self.assertEqual(expected, actual)
def test_set_hp_monster(self... |
29bc23496173ecaef7fa6f78e14823cf7386f58d | szatakia/Zappos-Internship-2017 | /BermudaTriangle.py | 776 | 3.515625 | 4 | import math
def is_inside(x1, y1, x2, y2, x3, y3, ax, ay):
a= abs((x1*(y2-y3) + x2*(y3-y1)+ x3*(y1-y2))/2.0)
a1= abs((x1*(y2-ay) + x2*(ay-y1)+ ax*(y1-y2))/2.0)
a2= abs((x2*(y3-ay) + x3*(ay-y2)+ ax*(y2-y3))/2.0)
a3= abs((x1*(y3-ay) + x3*(ay-y1)+ ax*(y1-y3))/2.0)
return a==(a1+a2+a3)
def found(x1, y1, x2, y2, x3, y... |
40e2f4f8193aee061848bf8425491428b7b0ed38 | peinbill/leetcode_learning_card | /array/Solution26.py | 528 | 3.859375 | 4 | from typing import List
class Solution26:
def removeDuplicates(self, nums:List[int]) -> int:
if len(nums) == 0 or len(nums) == 1:
return len(nums)
i = 0
while True:
if i + 1 >= len(nums):
break
if nums[i] == nums[i + 1]:
num... |
81f4439f7dd066da0626fcfd25188fab9fe8da5f | Arj4ns/addBinary | /addBinary.py | 852 | 3.640625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Jul 28 15:33:51 2019
@author: Arjan
"""
def addBinary(a, b):
result = ""
carry = 0
while len(b) > len(a):
a = "0" + a
while len(a) > len(b):
b = "0" + b
for j in range(len(a) - 1, -1, -1):
i... |
0f94e7e039d40c717d420f3e52e928cb810703d4 | JacobN1003/CSUSM-CS-111-Labs-Python | /Lab 24 - Bubble Sort.py | 483 | 4.03125 | 4 | #Bubble Sort
#Jacob Norenberg
#July 3, 2019
n = int(input("Enter size of number list: "))
numList = []
for i in range(n):
numbers = int(input("Enter number (" + str(i+1) + " of " + str(n) + "): "))
numList.append(numbers)
print("Original list: ",numList)
for i in range(n):
for j in range(n-1... |
0e42eb2700d77c46f3d7baede8175f33207ca18e | alexcomu/python-decorators | /scripts/3.py | 488 | 3.78125 | 4 | from termcolor import colored
print colored("\n*** Lesson 3", "yellow")
print colored("## Introduction to Decorators!\n", "green")
def outer(some_func):
def inner():
print "before some_func"
ret = some_func() # 1
return ret + 1
return inner
def foo():
return 1
decorated = outer(fo... |
f12c165be6b51907c13b8048a80b432e8bfb29dc | samanmalee/mini-games | /sum_of_10_user_input_int.py | 178 | 3.8125 | 4 | a_list = []
print("Please enter 10 numbers without decimals\n")
for num in range(10):
list_num = int(input("Enter a number:"))
a_list.append(list_num)
print(sum(a_list)) |
cc4ead416202d3d598660778fbe23e30b13d4bd0 | svetlana-strokova/GB_BigData_1055_Python | /3/3 les 4page.py | 643 | 3.984375 | 4 | # 4 Задание
#Программа принимает действительное положительное число x
#и целое отрицательное число y. Необходимо выполнить возведение
#числа x в степень y. Задание необходимо реализовать в виде функции
#my_func(x, y). При решении задания необходимо обойтись без встроенной
#функции возведения числа в степень
def my_fun... |
cc0f930cb10ebfb8cd2dff0c2433a39cf96e9f91 | KuboBahyl/coding-interviews | /Algo topics/Interview real problems/RocketPath.py | 1,626 | 3.65625 | 4 | # Input: M x N grid of positive integers
grid = [
[3, 6, 4],
[8, 4, 9],
[9, 1, 1],
[5, 0, 5],
[1, 2, 3]
]
"""
rocket starts in the first row
every cell of the grid contains a positive integer
every step it can go straight up, up-left, up-right
can’t leave the grid
Output: What’s the maximum total su... |
64833009d38b89e855c40cb5be018f26adc85d9c | Fedjmike/taipan | /lexer.py | 5,474 | 3.515625 | 4 | from enum import Enum
class TokenType(Enum):
Unknown = 0
Keyword = 1
Ident = 2
Op = 3
NumLit = 4
StrLit = 5
StartOfBlock = 6
EndOfBlock = 7
EndOfLine = 8
EndOfFile = 9
class Token:
def __init__(self, _type):
self.str = ""
self.type = _type
d... |
a07f9fb1116aa9f6b443063d8ab0d77f0b05f7a2 | ArmandoCarrillo91/Platzi | /Cursos/basic_python/diccionarios.py | 681 | 3.96875 | 4 | def run():
mi_diccionario = {
'llave1': 1,
'llave2': 2,
'llave3': 3,
}
# print(mi_diccionario['llave1'])
# print(mi_diccionario['llave2'])
# print(mi_diccionario['llave3'])
poblacion_paises = {
'Argentina': 44938712,
'Brasil': 210147125,
'Colombi... |
56ff49baa3eec2f663783d933a51755172538817 | girishneni/python | /ConditionalOperators.py | 496 | 3.6875 | 4 |
# coding: utf-8
# In[1]:
2 == 2
# In[2]:
1 == 0
# In[3]:
# not equal
2 != 1
# In[4]:
2 != 2
# In[6]:
2<>1
# In[7]:
2 > 1
# In[8]:
1 > 2
# In[9]:
1 < 2
# In[10]:
2 < 1
# In[11]:
2 >= 2
# In[12]:
2 <= 2
# In[13]:
2 > 2
# In[14]:
2 <= 2
# In[15]:
2 < 2
# 2 < 2
# In[18]:
name... |
91428f0257b9e83f7ed3b6b41cdb5a0d678ad2d6 | Yatin-Singla/InterviewPrep | /Leetcode/isBadVersion.py | 596 | 3.625 | 4 | class Solution:
x = [False,False,False,True,True]
def isBadVersion(self, n):
return self.x[n-1]
def firstBadVersion(self, n):
lower = 1
upper = n
while lower < upper:
middle = int((upper+lower)/2)
if isBadVersion(middle):
if middle-1 ... |
fbf9d2c7b5d036aecdd423695e81e30b5b0ea61d | yxtay/how-to-think-like-a-computer-scientist | /Recursion/palindrome.py | 585 | 3.71875 | 4 | import string
def removeWhite(s):
outs = ''
for ch in s.lower():
if ch in string.ascii_lowercase:
outs += ch
return outs
def isPal(s):
if len(s) <= 1:
return True
else:
return s[0] == s[-1] and isPal(s[1:-1])
print isPal(removeWhite("hello"))
# testEqual(i... |
0dd813e070db98ddabbd5b6b8abe575726a30fdc | rubiyadav18/list_questions | /count_6 and3.py | 281 | 3.71875 | 4 | list1=[2, 3, 4, 5,6, 3, 3, 3, 5,3, 3, 3, ]
list2=[4, 5, 6, 6, 6, 3,6, 7, 7, 6, 7, 6,]
i=0
empty1=[]
empty2=[]
# count=0
while i<len(list1):
if list1[i]==3:
empty1.append(list1[i])
if list2[i]==6:
empty2.append(list2[i])
i=i+1
print(empty1)
print(empty2) |
40ba4e240104dd30dff48e7715c284183422357f | sungminoh/algorithms | /exercise/tree.py | 7,326 | 3.8125 | 4 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2018 sungmin <smoh2044@gmail.com>
#
# Distributed under terms of the MIT license.
"""
"""
from collections import deque
from typing import Optional
from typing import Callable
from typing import List, Union
class Tree(object):
def _... |
80b0cd9fd5fa3364cb58da9f85bd2a11c9f35a3c | learning-Kong/python-concurrent | /线程/python-queue.py | 903 | 3.625 | 4 | # -*- coding:utf-8 -*-
# author: "XiangLei Kong"
#-----------------------------------先进先出为队列------------------------------------
import queue
q = queue.Queue(3)
q.put('123')
q.put('ab')
q.put('dd')
print(q.get())
print(q.get())
print(q.get())
#-----------------------------------先进后出为堆栈------------------------------... |
985096c4db4aeb17c879aa502fa3aaae93c466f2 | kanybek740/Chapter1_Part2_Task4 | /task4.py | 230 | 3.671875 | 4 | num_hours1 = int(input())
num_min1 = int(input())
num_sec1 = int(input())
num_hours2 = int(input())
num_min2 = int(input())
num_sec2 = int(input())
print(((num_hours2-num_hours1)*3600)+((num_min2-num_min1)*60)+(num_sec2-num_sec1)) |
6cd20b52a7248890aa6de2bcb65b2a0274a2a996 | Uaena25/GoGoNewEpisodes | /anime_list.py | 1,525 | 3.703125 | 4 | from pathlib import Path
def add_anime():
add = input("Add anime to watch list (enter 'y' or 'n')? ")
while add != "y" and add != "n":
add = input("Add anime to watch list (enter 'y' or 'n')? ")
if add == "y":
while True:
anime = input("Enter name of anime to add (or e... |
37047c588eb7af5a0b2e205898c36650a3b49f68 | Nikunj-Gupta/Networking | /Program1(TCP)/tcp_server.py | 674 | 3.65625 | 4 | import socket # Using the socket library
def capitalizer():
host = "127.0.0.1" # stating the host
port = 5000 # stating the port number
s = socket.socket() # creating a new socket object
s.bind((host,port)) # binding the tuple of (host,port) to the socket object s
s.listen(1) # Now the socket starts listening... |
f0c8617037f9ddb29f76bc26e40b0738e7c7861f | sidhanshu2003/LetsUpgrade-Python-Batch7 | /Batch 7 Python Day 2.py | 2,771 | 3.59375 | 4 | #!/usr/bin/env python
# coding: utf-8
# # List and its default fuctions
# In[3]:
Lst = [1,'a',1.5,"sud",[1,2,3]]
# In[4]:
Lst[0]
# In[13]:
Lst[0:]
# In[21]:
Lst[4]
# In[22]:
Lst[4][0]
# In[23]:
Lst[-1:]
# In[31]:
Lst[-2:]
# In[30]:
Lst[:-4]
# In[26]:
Lst[-5:]
# In[27]:
Lst[-6:]
... |
859f66fae2d646a8d6942123118f47b2ec060d2d | Leo-Mun/CS | /Python/숫자.py | 408 | 4.03125 | 4 | ##k=int(input("number : "))
##num=1
##
##
##for i in range(k):
## for j in range(i+1):
## print(num,'',end='')
## num+=1
## print()
##k=int(input("odd number : "))
##
##center=k//2
##
##for i in range(k):
## n_plus = (i*2)+1
## if i >center:
## n_plus=k-((i-center)*2)
## n_star=(k-n... |
bd74082c4a68ba0cd36899424955a593c48e9583 | Jasffertp/phonebook | /phone directory.py | 5,972 | 4.09375 | 4 | #Author: Jasffer T. Padigdig
#Date: October 14, 2020
#Assignment: Phonebook code
#Description: The code is executes the CRUD using hashing
#References:
def linearprobing(A, location):
counter = 0
#if the counter is greater than the length of the list then it means the phone book is already full
w... |
88a37157997cbd8f3ccd5ad7fd7284f52d396c5c | xiaohuoche302/django2 | /d4/xpath.py | 1,349 | 3.8125 | 4 | import lxml
from lxml import etree
html = '''
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div>
<ul class="ul">
<li class="li">1</li>
<li id="li2">2</li>
<li class="li">3</li>
<li class="li">1</li>
<li id="li5">... |
7bddaf635da1441719d37efe68c6e2970eb98585 | Kori3a/M-PT1-38-21 | /Tasks/Tsikhan Bukraba/Home work 1.py | 450 | 3.515625 | 4 | from decimal import Decimal
# Условия задачи Депозит:
# начальная сумма - 20000 BYN
# срок - 5 лет
# процент - 15%
# ежемесячная капитализация
# Вычислить сумму на счету в конце указанного срока.
from decimal import Decimal
s = 20000 * (1 + 1.25/100)**60
sum = Decimal('42143.62693902471')
print(sum.quantize(Decimal('... |
5489895450210e6e798949840f8d58d5114e4138 | fejese/advent-of-code-2020 | /day-24/solv-2.py | 2,818 | 3.59375 | 4 | #!/usr/bin/env python3
from enum import Enum, auto
from typing import List, Set, Tuple
# INPUT_FILE_NAME: str = "test-input"
INPUT_FILE_NAME: str = "input"
Coord = Tuple[int, int]
class D(Enum):
# e, se, sw, w, nw, and ne
E = auto()
SE = auto()
SW = auto()
W = auto()
NW = auto()
NE = au... |
f658ca319bdd45b2902464888add58767d73b4a2 | JoyChudasama/Python_Labs | /Lab-8/insertion.py | 475 | 4.0625 | 4 | def insertion_Sort(aList):
for index in range(1,len(aList)):
currentvalue=aList[index]
position=index
# finding the position of the number to insert!
while position >0 and aList[position-1]>currentvalue:
aList[position]=aList[position-1]
position-=1 # positi... |
d910f3f8926bed6d5d702dc3379cea8f50cdb9cc | tywenrick3/Schools_Data_Search_And_Latin_Decoder | /latin.py | 2,379 | 4.1875 | 4 | def format_latin_text(unformatted_latin_text):
"""
Accepts a string of Latin text and upper-cases all of its alphabetic characters, replacing all 'U' characters with
'V'.
:param unformatted_latin_text: A string containing Latin text
:return: A string containing properly formatted Latin
"""
n... |
6235fbfdb656a723fa1f176471448162972156ec | Sarodus/tests | /auto_call_dict.py | 1,091 | 3.75 | 4 | import inspect
class AutoCallStruct(dict):
"""
Dictionary, also accesible with attributes, that automatically calls
the value if it's a function without arguments.
AutoCallStruct(
param1=lambda: 'called!',
).param1
"""
def get(self, key, default=None):
try:
retur... |
dd2df734244c12ae2a48460bf2a6a7a77788e6a0 | sudheer-sanagala/intro-python-coursera | /WK-04-Lists,Tuples/dictionary.py | 3,248 | 4.5 | 4 | """
x = {key1:value1, key2:value2}
Operations
len(dictionary) - Returns the number of items in the dictionary
for key in dictionary - Iterates over each key in the dictionary
for key, value in dictionary.items() - Iterates over each key,value pair in the dictionary
if key in dictionary - Checks whether the key is in... |
db77097c987b28f9cdd338f8cd018999ff27b800 | daaniel3232/dio-introducao-ao-python | /aula07_calculadora1.py | 834 | 4.15625 | 4 | # função é tudo que retorna um valor
# método é tudo que não retorna, no python método é chamado definição(def)
# por convenção Classe começa com letra maiúscula e métodos e funçẽos com letra minúscula
class Calculadora:
def __init__(self, num1, num2):
self.valor_a = num1
self.valor_b = num2
d... |
f9d96bd16445542ccc53535ba965b25f505ab012 | leaclaire/flaskIP1-Password-Locker | /account_test.py | 1,476 | 4.28125 | 4 | import unittest
from account import Account
class TestAccount(unittest.TestCase):
"""
Test class that defines test cases for the account class behaviours.
Args:
unittest.TestCase: TestCase class that helps in creating test cases
"""
def setUp(self):
"""
setUp... |
cfa4ff975d6e7f27f8a3bada3f37ac6bc2720090 | xiaguangxuan/PAT-PTA | /PTA-B/1034-1.py | 194 | 3.609375 | 4 | #!/usr/bin/env python
# -*- coding:utf-8 -*-
s1, s2 = raw_input().split()
for s in s1, s2:
if round(int(s[0])/int(s[2])) == int(s[0])*1.0/int(s[2]):
s = int(s[0])/int(s[2])
if
|
f38d5d28ba385bb52e379efc99b502618fd33fa5 | PdxCodeGuild/20170724-FullStack-Night | /Code/sam/python/lab08.5-comp_guess_the_number.py | 768 | 4.09375 | 4 | import random
user_choice = int(input('Choose a number between 1 and 10. '))
# create a list of previous guesses
previous_guesses = []
i = 0
while i < 10:
while True:
comp_guess = random.randint(1, 10)
# if comp_guess not in previous guesses, continue guessing.
if comp_guess not in previou... |
73e5478b8f446e53f27136360781dd1134aa3484 | Monukushwaha/Python_Practice- | /first.py | 186 | 4.0625 | 4 |
#check the number odd or even
number = int(input("enter the number "))
if number%4==0:
print"number is 4even "
elif number%2==0:
print"number is even"
else:
print("even nhi he ")
|
f968bea0f02391a8fc42b45e3ef460147b5af220 | lilirass/integrals | /integral3.py | 1,348 | 4.125 | 4 | def integral(a,b,npoints):
#Simpson rule integral=(dx/3)[f(a)+2f(i=even)+4f(i=odd)+f(b)]
dx=(b-a)/(npoints)
#define the function f(x), it can be any function
def f(x):
return 2*x
#B=sumf(i=odd) and C=sumf(i=even)
B=0
C=0
i=1
while i < npoints:
if i%2 !=0 :
... |
f04322776f394b3824bb3f0e0004b8b2b979bd04 | vsrandom/Machine_Learning | /LinReg/tut.py | 13,062 | 4.03125 | 4 | ####..........................................PRACTICAL MACHINE LEARNING BY SENTDEX in Python ..................................................
'''
Regression- Take continous data and figoure out best regression line for that
Features and Labels
feastures are like attributes
Now in our data set,each column is a feat... |
e3c2dafb190fdcfe6621c792f48de8aa69f14db8 | Satily/leetcode_python_solution | /solutions/solution500.py | 438 | 3.78125 | 4 | class Solution:
def findWords(self, words):
"""
:type words: List[str]
:rtype: List[str]
"""
lines = list(map(lambda x: set(x), ["qwertyuiop", "asdfghjkl", "zxcvbnm"]))
return [word for word in words if sum([sum([ch in line for ch in word.lower()]) == len(word) for li... |
0d19ce08ecb3e83e13526f9d84dacc6a6d054cc7 | SHETU-GUHA/leetcode | /sortedarraytoBST.PY | 588 | 3.53125 | 4 | class TreeNode:
def __init__(self, x):
self.data = x
self.left = None
self.right = None
class Solution:
def sortedarraytoBST(self, nums):
if len(nums) == 0:
return None
centerIndex = len(nums)/2
center = TreeNode(nums[centerIndex])
center.left = self.sortedarraytoBST(nums[:centerIndex])
center.r... |
bf4df1d72aaaba0002322cd29c86ed1f1243e07f | gabriellaec/desoft-analise-exercicios | /backup/user_348/ch64_2020_04_21_20_38_59_317035.py | 210 | 3.65625 | 4 | def acha_bigramas (string):
lista = []
for i in range(len(string)-1):
bigrama = string[i] + string[i + 1]
if not bigrama in lista:
lista.append(bigrama)
return lista
|
97910c9c8657777e22c7c23516caa8dc376ba38f | sidv/Assignments | /Pooja_SR/Aug19/circle.py | 445 | 4.09375 | 4 | #parent class
import math
class Circle:
def __init__(self,radius):
self.radius= radius
def area(self):
print("computing area")
a=math.pow(radius,radius)
c=a*math.pi
print(c)
def __add__(self,b):
return self.radius + b.radius
def __str__(self):
return 'The radius is'+str(self.radius)
radius=in... |
f59c11d0da110961e4c70b62ed8328168fe1466e | mridho/hello-world | /uniquify_list.py | 1,128 | 3.71875 | 4 | ####################################################################
## FUNCTION FOR DIFFERENTIATING CASES OF DUPLICATE COLUMN
## add _(incremental_integer) at the tail of the duplicated column
###################################################################
## sub_function for getting the list of the duplicated... |
ffa8fa6a8b5aab02e3be14d02985bce37f02180d | icenamor/wekaDomains | /IPC-2018-Files/Result.py | 2,652 | 3.59375 | 4 | #! /usr/bin/env python
__author__ = "Isabel Cenamor"
__copyright__ = "Copyright 2013, Portfolio Project Features"
__email__ = "icenamor@inf.uc3m.es"
import string
import sys
class Result:
"store the result"
def __init__(self, a, b, c, d):
self.planner = a
self.domain = b
self.problem = c
self.time =... |
f844ead2d3a5076baa5fcd5d32c67e378255a59c | doroshroman/EulerProject | /010.py | 493 | 3.59375 | 4 | # https://projecteuler.net/problem=10
import math
def sum_prime_numbers(limit=2*10**6):
# using eratosthenes sieve
prime = [True] * limit
for i in range(2, int(math.ceil(math.sqrt(limit)))):
if prime[i]:
j = i * i
while j < limit:
prime[j] = False
... |
972b6688a1526e3c568a81e24a6bcc333ffd13f4 | yuanhongjian/Python_small_cases | /6_Real_Name_Survey.py | 847 | 3.8125 | 4 | class RealNameSurvey():
def __init__(self, question):
self.question = question
self.response = {}
self.show_question()
self.store_response()
# show the question
def show_question(self):
print(self.question)
# store the responses
def store_response(self):
... |
3c2dd10ce98f15d5dfcbf7c54a243cd045100edd | CodecoolKRK20173/erp-mvc-ziemotrykmichantek | /view/terminal_view.py | 6,281 | 3.65625 | 4 | from view import getch_module
getch = getch_module.instant_input()
""" Terminal view module """
def print_table(table, title_list):
"""
Prints table with data.
Example:
/-----------------------------------\
| id | title | type |
|--------|----------------|--------... |
9d697299b61be9a6bdc01fbf3a30a8563f0c0308 | bitepy/learn-python | /input.py | 79 | 3.609375 | 4 | name=input('What\'s your name ?')
input('Hi,'+" "+name+', How are you today?')
|
5ec0f94e0ebc377df6c4e5c7d0fde2c0afe83bdc | JoaoFiorelli/ExerciciosCV | /Ex013.py | 154 | 3.703125 | 4 | sal = float(input('Qual o valor do seu salário? R$'))
novosal = 1.15 * sal
print('O valor do seu novo salário será de {:.2f} reais!'.format(novosal)) |
5972e7c1383da32699eb6a8739fe212107de2d41 | kyousuke-s/PythonTraining | /day0209/EX7_6.py | 1,534 | 3.703125 | 4 | import random
print('数当てゲームを始めます3桁の数を当ててください!')
#答え作成
answer = list()
for _ in range(3):
answer.append(random.randint(0,9))
print(answer)
while True:
#解答入力
prediction = list()
for i in range(3):
prediction.append(int(input(f'{i+1}桁目の予想を入力(0~9)>>')))
print(prediction)
#答え合わせ
hit ... |
b83941d67caf97c3233a6de11525cd4415e481e9 | anjanibhat/ShowAway | /data_base.py | 1,148 | 3.734375 | 4 | #
# Author : Anjani Suresh Bhat
# Date : August 2016
#
# This file is to create a class which maps to a database
#
#
import os
import sys
from sqlalchemy import Column, ForeignKey, Integer, String
from sqlalchemy.orm import sessionmaker
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative i... |
a853cb66d379aa7ad12af36afabbaf87ecef47bd | kzmorales92/Level-2 | /mod2-1.py | 225 | 4.25 | 4 | # Karen Morales
#04/16/19
# program will iterate over a dictionary using a for loop and print each
# key value and value entry.
autoDict = { 'a': 5, 'b': 10, 'c': 15}
for x, y in autoDict.items():
print (x,y)
|
a226ae2a0877767da41c8c0ece96f35bdcfe1e34 | RoshanSun/PythonProjects | /Pygame Testing/firstGame.py | 879 | 3.90625 | 4 | import pygame
# always need this - initializes game
pygame.init()
# (width, height) of game
size = (width, height) = (500, 500)
window = pygame.display.set_mode(size)
pygame.display.set_caption("First Game")
x = 250
y = 250
width = 10
height = 10
velocity = 5
run = True
while run:
# in ms (1000 = 1s)
pygame.ti... |
07b8c957a7515731b658874762701cdf4dbd6b9b | rimijoker/Coding-Interview-Practice | /Python/Deepest Node in a Binary Tree.py | 940 | 3.984375 | 4 | class Node(object) :
def __init__(self, val) :
self.val = val
self.right = None
self.left = None
def __repr__(self) :
return self.val
def deepest(node):
if node and not node.left and not node.right:
return (node, 1) # Leaf and its depth
if not node.left: # Then the dee... |
229831454712b6ffe41c925a6d3043bac2d27955 | 531621028/python | /函数式编程/匿名函数.py | 298 | 4.1875 | 4 | #匿名函数lambda x: x * x实际上就是:
#def f(x):
# return x * x
#关键字lambda表示匿名函数,冒号前面的x表示函数参数。
#匿名函数有个限制,就是只能有一个表达式,不用写return,返回值就是该表达式的结果。
f = lambda x : x * x
print(f) |
ad5f458a164a284c6d58c47ddca66a7d9dcd08eb | mangalagb/Leetcode | /Medium/ReorganizeString.py | 2,218 | 3.75 | 4 | # Given a string S, check if the letters can be rearranged so that two characters that
# are adjacent to each other are not the same.
# If possible, output any possible result. If not possible, return the empty string.
from heapq import heappush, heappop
class Solution(object):
def reorganizeString(self, S):
... |
3b86f1f3c6a834c8de52968c20481fffb9eda388 | standrewscollege2018/2020-year-12-python-code-2020-year-12-classwork-mmc8158 | /Bookstore.py | 728 | 4.1875 | 4 |
print ("hi welcome to my bookshop!")
print ("/n")
running=True
while running==True:
print ("1 add a book title.")
print ("2 edit an existing book title.")
print ("3 delete a book title.")
print ("4 end the programme.")
command=input ("please enter 1, 2, 3, or bye" ,)
if command==("1"):
... |
ba4fa8d1c2fd8b0a84cae12cd6207e9437533fae | Khundzaka/khundzaka | /works/classes.py | 552 | 3.703125 | 4 | class Radio():
def __init__(self, name, channel, now_playing, priceofmin):
""" """
self.name = name
self.channel = channel
self.now_playing = nowplaying
self.priceofmin = priceofmin
def rekl_calculator(self, days, mins):
answer = self.priceofmin * days * mins
... |
e602d6a9c778f1e3b15087c6db7b85b8b9419d54 | HsiangHung/Code-Challenges | /leetcode_solution/graph/#332.Reconstruct_Itinerary.py | 1,343 | 3.890625 | 4 | # 332. Reconstruct Itinerary (medium)
# https://leetcode.com/problems/reconstruct-itinerary/
#
class Solution:
'''
https://www.youtube.com/watch?v=WYqsg5dziaQ
using dict[depart] = [arrival1, arrival2, ...] as data structure
if ticket (depart, arrrival2) is used, update dict[depart][2] = 0 t... |
ac79ee7bec32d739ede3575c1cece44a1bc05772 | aliabbasrizvi/CodeEval | /compare_points.py | 582 | 3.53125 | 4 | import sys
def get_direction(test_case):
x1, y1, x2, y2 = test_case.split()
direction = 'N' if y1 < y2 else 'S'
direction = direction + ('E' if x1 < x2 else 'W')
if x1 == x2:
direction = direction.replace('E', '')
direction = direction.replace('W', '')
if y1 == y2:
direction = direction.replace(... |
41aee54f7f8cda75f28ccaa4dc2f6eb82c4b41ed | Araym51/DZ_Algoritm | /Ostroumov_DZ_3/Ostroumov_DZ_3-7.py | 902 | 4.0625 | 4 | """
7. В одномерном массиве целых чисел определить два наименьших элемента.
Они могут быть как равны между собой (оба являться минимальными), так и различаться.
"""
import random
min_1 = 101
min_2 = 101
array = [0] * 20
for i in range(20):
array[i] = int(random.randint(1, 100))
for item in array: # ищем первое ... |
efc41376c867288d199791a5d3d6f1fcdfe678fa | AlexanderZ3/Python3-Exercise | /0_lpthw/lpthw_01/ex04.py | 485 | 4.375 | 4 | my_name = 'Zezhong'
print(f'Hello, my name is {my_name}')
print(f"helo, let's try one more again about my name is {my_name}")
#the following is a program to convert inches and pounds to centimeters and kilograms
num_inches = 23
num_pounds = 34
num_centimeters = num_inches * 2.54
num_kilograms = num_pounds * 0.454
... |
160e5af47ad17b6bc1fd8fdaec3949c0b17ff303 | Kantslerr/laba1-python- | /lab1.py | 286 | 4 | 4 | x = int(input("Введите первое число: "))
y = int(input("Введите второе число: "))
if y % x == 0:
print('Число',x, 'делится на число',y,'без остатка')
else: print('Число', x, 'не кратно числу',y)
|
5cd957d5b4434f4ba4803592ba677bb196e90d47 | ConsultAtlas/digital_crafts | /practice/python/files/solutions/wordhist2.py | 909 | 3.953125 | 4 | def isWhiteSpace(character):
return character == ' ' or character == '\n'
def slice(sentence):
words = []
beginningOfWord = 0
currentCharacter = 0
for character in sentence:
if isWhiteSpace(character):
word = sentence[beginningOfWord:currentCharacter]
words.append(wo... |
5f6a8083a916d12ce88040826d747c12c0eb4267 | Elsword24/Python-Objet-B1 | /main.py | 4,883 | 3.703125 | 4 | <<<<<<< Updated upstream
#####################################################
# Le code est écrit en anglais pour l"opensource #
# Merci de continuer ainsi #
# Jason #
#####################################################
def printGameBoard(gameBoard): # Display the game... |
4015be7b73d880f1f121a541bdca4f4da18938f2 | sabur234567/COSC2316- | /rotate.py | 846 | 4.34375 | 4 | # Name: Sabur Khan
# Date: 9/17/19
# Course: COSC 2316 Fall 2019 (Dr. Shebaro)
# Program Description: To rotate a string ex: roate by 2 the string "hello" = "llohe"
######### Algorithm/Psuedocode ########
#1. receive the line by an input text file
#2. read each line
#3. have a function that splits each word b... |
d535a21cbe47f525b4359a592489173ed1b871e6 | Clebom/exercicios-livro-introd-prog-python-3ed | /capitulo-06/ex09.py | 887 | 3.546875 | 4 | # Modifique o exemplo para pesquisar dois valores
# Em vez de apenas p, leia outro valor v que também será procurado
# Na impressão, indique qual dos dois valores foi achado primeiro
L = [15, 7, 27, 39]
p = int(input('\nDigite o primeiro valor a procurar: '))
v = int(input('Digite o segundo valor a procurar: '))
foun... |
14efadb69e3ce4478ffcc78d26c40a1b623f678d | python-hydro/pyro2 | /pyro/util/runparams.py | 9,890 | 4.03125 | 4 | """basic syntax of the parameter file is::
# simple parameter file
[driver]
nsteps = 100 ; comment
max_time = 0.25
[riemann]
tol = 1.e-10
max_iter = 10
[io]
basename = myfile_
The recommended way to use this is for the code to have a master list
of parameters and their defaults ... |
941ea126e8b97f9b65aa8a1226012ca11793f6b8 | prpratheek/Interview-Problem-Statements-HacktoberFest2020 | /generators.py | 1,016 | 3.796875 | 4 | #Normal Approach
import memory_profiler
import time
def check_even(numbers):
even = []
for num in numbers:
if num % 2 == 0:
even.append(num*num)
return even
if __name__ == '__main__':
m1 = memory_profiler.memory_usage()
t1 = time.clock()
cubes = check_even(range... |
1d182891e84c9c75a4a37013441b72ec15b3ce5b | neiltyagi/tcpTROJAN | /tcpserver.py | 2,058 | 3.5625 | 4 | import socket
import os
def transfergrab(conn,command):
conn.send(command)
grab,filename=command.split('*')
path="//root//Desktop//"
path += filename
bits=conn.recv(1024)
if "The File Doesn't Exist" in bits:
print("[-]The File Doesn't Exist")
else:
f=open(path,'wb+... |
d3bca0e39d51d4eab4aa8deadd29e170980c7afa | ForSign/Leetcode-1 | /Difficulty/Medium/[36] Valid Sudoku/solution.py | 733 | 3.609375 | 4 | #
# @lc app=leetcode id=36 lang=python3
#
# [36] Valid Sudoku
#
class Solution:
def isValidSudoku(self, board: List[List[str]]) -> bool:
_dict = dict()
for i in range(9):
for j in range(9):
if board[i][j] != '.':
b = '(' + board[i][j] + ')'
... |
eed78cc2a41f4977a661c2960e4bbb0604fe7ae9 | AlexandreBarde/TraitementsImages | /unnoise/medianV2.py | 4,647 | 3.609375 | 4 | # -*- encoding: utf-8 -*-
from copy import deepcopy
from numpy import *
"""
Débruitabe par filtrage médian
<image> l'image à débruiter
retourne l'image débruitée
"""
def median(image):
nombrePixel = 0
newimg = deepcopy(image)
# Parcours des lignes de pixels
for x in range(newimg.shape[0]):
... |
4da112e9cd9ac7bf3260a4c6b33290cbe8c69a58 | MalgorzataBala/repo_python | /week2/day3/przelicznik.py | 630 | 3.671875 | 4 | """
Przelicznik C => F i C <= F a. C = (F - 32) * 5/9 b. F = C * (9/5) + 32
"""
input_data= input("Podaj temperature do przeliczenia :" )
input_data_value= input_data[0:len(input_data)-1]
if input_data_value.isdigit() == True :
if input_data.endswith("C"):
c_to_f = int(input_data_value)*(9/5) +32
... |
5ba5a32deb983f0e93e13c122cbd13ea5143f15e | zhoufengzd/python | /_exercise/_basics/_algorithm/list/candy.py | 832 | 3.734375 | 4 | # There are matrix_size children standing in a line with some rating value. You want to distribute a minimum number of candies to these children such that:
# Each child must have at least one candy.
# The children with higher ratings will have more candies than their neighbours.
def iterate(numbers):
res = [1 for ... |
25eb84a143a1abf067094a8169a7257c9b22fd28 | DyogoBendo/URI-Python | /iniciante/1010.py | 279 | 3.640625 | 4 | if __name__ == '__main__':
valor = 0
for i in range(2):
linha = input().split()
codigo = linha[0]
numero_pecas = int(linha[1])
preco = float(linha[2])
valor += (numero_pecas * preco)
print(f"VALOR A PAGAR: R$ {valor:.2f}")
|
1734777d889ab6e6a2f236e8240b9767be17651a | dean-weez/anagramarama | /anagrams.py | 3,242 | 3.703125 | 4 | import sys
import bisect
from collections import Counter
# Words list taken from https://users.cs.duke.edu/~ola/ap/linuxwords
# and post-processed to lowcase and exclude non-letter characters
with open('linuxwords.txt') as f:
words = [line.rstrip() for line in f]
def search_words(s, soft):
"""Checks whether ... |
9658db2a33a0d2d36f58a86514bda3c8f2bd435c | mskl/fit-bi-zns-homeworks | /ulohy/04/Fuzzy/Function/trap_mf.py | 640 | 3.546875 | 4 | class TrapMF:
""" Trapezoidal membership function """
def __init__(self, a, b, c, d):
""" Initialise the __/‾‾\__ function with 4 points: __a/b‾‾c\d__ """
self.a = a
self.b = b
self.c = c
self.d = d
def __getitem__(self, x) -> float:
""" Get the function val... |
6ee150f59fda38902205370ab450402e4582d4c8 | rspineda/Ronald | /python/funciones.py | 314 | 3.5625 | 4 |
def mensajero():
message="Hola Mundo, arrancando con phyton"
print(message)
mensajero()
def suma():
num1=2
num2=3
print(num1+num2)
suma()
def suma2(num1,num2):
print(num1+num2)
suma2(5,7)
def suma3(num1,num2):
resultado = num1*num2
return resultado
print(suma3(10,6)) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.