blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
55e0c08da639b81fffe62bce0640b46ad5fd4301 | hus0124/Embeded | /Python/28Jan2020/Code06-12.py | 223 | 3.5625 | 4 | i, total = 1, 0
while True :
if i % 3 == 0 :
i += 1
continue
total += i
i += 1
if (i > 100) :
break
print("1에서 %d까지 3의 배수 제외한 합계는 %d" %(i-1, total))
|
f0a4790294f71d75637ce1a1a642b35725d6249d | cpt-nem0/Py-Games | /pong/pong.py | 2,595 | 3.625 | 4 | import turtle
player_a_score = 0
player_b_score = 0
# window
win = turtle.Screen()
win.title("Pong")
win.bgcolor("black")
win.setup(width=1280, height=720)
win.tracer(0)
# player a paddle
paddle_a = turtle.Turtle()
paddle_a.speed(0)
paddle_a.shape("square")
paddle_a.color('white')
paddle_a.shapesize(stretch_len=0.40... |
98c661970c648d03d61ca3bda608b468f3fc949f | danieljbruce/simplealgotrade | /MovingAverageStatistic.py | 847 | 3.796875 | 4 | __author__ = 'Daniel'
import ReadValue
def MovingAverage(pInstrument, pTime = None, pLookback = 1, pLookbackStep = 60, pSkipRecord = False):
# pInstrument is the instrument that we will trade.
# pTime is the effective time we want to calculate the moving average for.
# pLookbackStep is the amount o... |
0a27fd7f00689fdec2344aa394c571206813c931 | Invalid-coder/Data-Structures-and-algorithms | /BinaryTrees/Tasks/eolymp(2314).py | 1,782 | 3.5625 | 4 | #https://www.e-olymp.com/uk/submissions/7563844
class BinaryTree:
def __init__(self, key):
self.key = key
self.leftChild = None
self.rightChild = None
def hasLeft(self):
return not self.leftChild is None
def hasRight(self):
return not self.rightChild is None
d... |
c5766bb07f7c18115f2816d7cac67d8e89fc19c2 | Teemsis/Odyssa | /Model/Model.py | 397 | 3.625 | 4 | #Abstract class
class Model:
def __init__(self):
self.data = None
self.learner = None
self.simulator = None
raise Exception("Abstract class 'Model' can't be instancied")
def simulate(self):
raise Exception("Abstract method must be implemented")
def lear... |
2208ad4de8408a108143b9d38c9d5c7fe167b0db | RiflerRick/foobar | /Level4/Problem1/solutionMethodology.py | 1,919 | 4.03125 | 4 | """
For this final solution we are going to follow a third party solution available online. First we are going to find all possible selections of the number of bunnies possible. For instance if we have a total of 3 bunnies-> [0,1,2] then we first find out all possible combinations of the selection of these bunnies. Thi... |
ed288991e7ce643c6b1c261e7b8fe2e42c30c58f | ZotovPhill/Training_Repo | /alien_invasion/ship.py | 4,578 | 3.59375 | 4 | import pygame
from pygame.sprite import Sprite
class Ship(
Sprite
): # класс инициализирует корабль и задает ему начальную позицию, в дальнейшем будет реализовано поведение объекта
def __init__(
self, game_settings, screen
): # класс получает два параметра, ссылка self и объект surface на которо... |
61bf0d28e537a9179161ead880e83ef5e380629a | Coni63/CG_repo | /training/hard/hanoi-tower.py | 1,668 | 3.625 | 4 | import sys
import math
from queue import LifoQueue
def queue_to_list(q):
res = []
while not q.empty():
res.append(q.get())
res = res[::-1]
while len(res)<n:
res.append(0)
return res
def step(N, beg, aux, end, count):
if N == 1:
print(f"{beg}=>{end}", file=sys.s... |
a5ab30cd35496a610f4645afc4b2ef130d5ed2f3 | abaranguer/wumpus | /wumpusmap.py | 3,061 | 3.53125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import Tkinter as tk
import math
class Room:
xc = 0
yc = 0
x0 = 0
y0 = 0
x1 = 0
y1 = 0
doors = []
if __name__ == "__main__":
# initialize map
rooms = [Room() for i in range(0, 20)]
rooms[ 0].doors = [1, 4, 5]
rooms[ 1].doors = ... |
245bf717db83b6dc341dd562e2d969dedddee517 | cdamiansiesquen/Trabajo07.Damian.Carrillo | /Damian/bucles_iteracion_rango/ejercicio5.py | 254 | 3.671875 | 4 | # Imprimir los numeros que se encuentran entre "a" y "b" dividido entre 2
import os
# input
a = int(os.sys.argv [ 1 ])
b = int(os.sys.argv [ 2 ])
# iterador
for i in range(a, b):
print ((i) / 2 )
# fin_iterador_en_rango
print ( " Fin del bucle " )
|
293aa6bd92892c8706f9bef04dc71b41464c5ea9 | xuefengCrown/Files_01_xuef | /all_xuef/程序员练级+Never/想研究的/类型系统/类型系统学习指导.py | 4,807 | 4.03125 | 4 |
#如果对后者有兴趣,那就学学Haskell喽。
"""
不知道题主目前的知识水平在什么位置,我就先假定你没有学过类型系统的任何知识但有
基本的函数式编程(functional programming)经验,所以先来说静态类型的类型推导,
然后再说动态类型语言。
首先,其实类型推导(Type Inference)只是一种延迟的类型检查(Type Checking)技术而已。
一般的编译原理书都把类型检查放在语义分析这部分来讲,这也就意味着你需要先做语法分析(Parsing)
来得到抽象语法树(AST)。当然如果你可以忍受Lisp 的语法,这步可以先省略。
其次,你最好要会写解释器,不用太复杂,只要给怎样写一个解释器 中的那个l... |
d90ff2c6417da7a878627459e2b7cda221a94abe | santhosh-kumar/AlgorithmsAndDataStructures | /python/problems/backtracking/generate_all_parantheses.py | 1,766 | 4.09375 | 4 | """
Generate All Parantheses
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses of length 2*n.
For example, given n = 3, a solution set is:
"((()))", "(()())", "(())()", "()(())", "()()()"
"""
from common.problem import Problem
class GenerateAllParantheses(Proble... |
2fb3cbdef9ea1b1d508b7584b7ed1ef24276897f | higorsantana-omega/algorithms-and-data-structures | /data_structures/arrays/exercises/merge_sorted_arrays.py | 1,462 | 4.46875 | 4 | """
==== KEY POINTS ====
- Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.
- Input: The number of elements initialized in nums1 and nums2 are m and n respectively.
- nums1 has a size equal to m + n such that it has enough space to hold additional elements from nums2
- It'... |
7cb4717e94eff5d8cae72c6ec5f7067f5f81d26a | anu71195/datastructures-python | /linkedlist.py | 401 | 3.546875 | 4 | class node:
def __init__(self, data,right=None):
self.data=data;
self.right=right;
def createnode(head,data):
temp=node(data);
if head==None :
return temp;
head.right=createnode(head.right,data)
return head;
def printlist(head):
if head==None:
return;
print(head.data);
printlist(head.right)
head=Non... |
b3508f67d2fb55123733400f7fd34e045adb9c0f | ajaymonga20/Projects2016-2017 | /question1.py | 757 | 4.5 | 4 | # Ajay Monga - Algorithm Test - Question #1 - February 14, 2017
# Imports
# Nothing to import
# Functions
def not_string(str):
if (str[0:1] + str[0:2] + str[0:3] == "not"): # Adds the first three letters of the string to see if they equal "not"
return str #If those first three letters equal "not" then the ... |
9d500210341f21e325163547bdd3eade351eb410 | R-Rayburn/PythonCookbook | /01_data_structures_and_algorithms/03_keeping_last_n_items.py | 1,790 | 4.15625 | 4 | # Problem
# Want to keep the last few items during processing
# Solution
# Keeping limited history is prefect fo rcollactions.deque
from collections import deque
# Performs a text match on sequence of lines and yields the matching
# line along with the previous N lines
# This is an example of a generator funct... |
5e66a5bd3570d212606742836fd6a2ee7440f4a7 | EdwaRen/Competitve-Programming | /Code Snippets/random/stonks.py | 313 | 4.3125 | 4 | def interest(rate):
roi = 1
years = 0
while roi < 2:
roi *= (1+rate)
years += 1
return years
interest_rate = float(input("Please enter your interest rate greater than 0\n"))
years = interest(interest_rate)
print("it would take " + str(years) + " years to double your investment") |
2206f6e25f17e9d2886ecb03efa31c4d2daa874b | gokhanamal/algorithms | /ps0.py | 601 | 3.65625 | 4 |
#google interview question
given_array = [9, 9, 9, 9, 9, 9]
def add_one(arr):
result = []
weight = 1
for index in range(len(arr)):
reverse_index = (len(arr) - 1) - index
number = arr[reverse_index] + weight
if number >= 10:
weight = 1
if reverse_index ==... |
480526ec32fec8d755f0fe6b2a85ba2a2c3c9764 | ds257/COEN166_Labs | /Lab1/Part1/Ex3.py | 769 | 3.890625 | 4 | L=[123, 'spam', 1.23] # A list of three different-type objects
len(L) # number of items in the list
L[0]
L[:-1] # Slicing a list returns a new list
L+[4,5,6] # contact/repeat make new lists too
L*2 # repeat
L # we are not changing the original list
M = ['bb', 'aa', 'cc']
M.sort()
M
M.reverse()
M
M = [[1,2,3], [4,5,6], ... |
0fd6eb513e494a26afb94770d7d87d101a448184 | mryingster/ProjectEuler | /problem_099.py | 789 | 3.828125 | 4 | #!/usr/bin/python
import math, re
file = "problem_099.txt"
print("Project Euler - Problem 99")
print("In the textfile, %s, find the line in which the base-exponent pair have the largest computed value.\n" % file)
BaseExpFile = open(file)
LineNumber = 0
MaxLine = 0
MaxValue = 0
debug = False
while 1:
Line = Base... |
49958640651d38fded56182529a2fce0ce0aecfd | jbelo-pro/CoffeeMachine | /Problems/Vowels and consonants/task.py | 230 | 4.15625 | 4 | vowels = 'aeiou'
consonants = 'qwrtypsdfghjklzxcvbnm'
word = input()
for character in word:
if character in vowels:
print('vowel')
elif character in consonants:
print('consonant')
else:
break
|
82942209e0b3beafb45c3b4dd30f2ddf4d2a8ef5 | ranim20-meet/meet2018y1lab4 | /funturtule.py | 445 | 3.625 | 4 | import turtle
turtle.shape('turtle')
finn = turtle.clone()
finn.shape('square')
finn.color('yellow')
finn.goto(100,0)
finn.goto(100,100)
finn.goto(0,100)
finn.goto(0,0)
charlie = turtle.Turtle()
charlie.shape = ('triangle')
charlie.color('blue')
charlie.goto(100,100)
charlie.goto(200,0)
charlie.goto(0,0)
finn.goto(-4... |
7932bbc64243b6290db7c0b9dc988c56575cc946 | guodonghai901901/GitHub | /ex14+.py | 829 | 3.96875 | 4 | from sys import argv
script, user_name, your_husband_name = argv
prompt = '->'
print "Hi %s, I'm the %s script." % (user_name, script)
print "I'd like to ask you a few questions."
print "Do you like me %s?" % user_name
likes = raw_input(prompt)
print "So %s is your husband?" % your_husband_name
facts = raw_input(prompt... |
9b7c55386f7c11b26188a970e8048ae7b560c501 | neyrani/Antonio-Lopez-Neyra-13161075-DISOR | /capicua.py | 1,026 | 3.765625 | 4 |
class capicua():
_capicua = ""
def __init__(self):
self._capicua = ""
def capicua(self, decimal):
if decimal <= 9:
self._capicua = "No capicua"
#return self._capicua
#return "No capicua"
if decimal > 9:
self.calculoCapicua(decim... |
a25de45e901e1279a9acf6d4991e50bfb3badc7d | chinchifou/Scrabble2 | /sources/letters_and_points.py | 3,844 | 3.546875 | 4 | #~~~~~~ GAMES RULES ~~~~~~
#~~~~~~ DICTIONARIES ~~~~~~
#----- English -----
letters_english = [] #total length must be 100
for i in range(12):
letters_english.append('E')
for i in range(9):
letters_english.append('I')
letters_english.append('A')
for i in range(8):
letters_english.append('O')
for i in range(6):
... |
853508f707feba8d4bd5d75a620aeba8f13a0a02 | kypgithub/python | /test_matplotlib/line_01/mpl_squares.py | 501 | 3.734375 | 4 | import matplotlib.pyplot as plt
# 设置默认起点如果不设置的话默认起点为0
default_values = [1, 2, 3, 4, 5]
squares = [1, 4, 9, 16, 25]
# 设置曲线并指定线的宽度
plt.plot(default_values, squares, linewidth=5)
# 设置图标标题, 并给坐标轴加上标签
plt.title("Square Numbers", fontsize=14)
plt.xlabel("Vale", fontsize=14)
plt.ylabel("Square of Value", fontsize=14)
# 设置刻... |
16a8a0bf25f9aa841248a439d8b5ec4fcb50431f | samuelmcmanus819/DIY-RSA-Server | /Encryption.py | 8,492 | 3.609375 | 4 | import MyIO
import base64
import math
import hashlib
class PublicKey:
def __init__(self, e, n):
self.e = e
self.n = n
"""
Name: Encrypt
Purpose: To encrypt a file and write the ciphertext to another file
Param PlainText: The plaintext to be encrypted
Author: Samuel Mc... |
02d808f914071b3bfa70cc49e2c9330a42f9d497 | charlewn/python-learning | /algo-1/MorePourProblem.py | 5,112 | 3.9375 | 4 | # -----------------
# User Instructions
#
# In this problem, you will solve the pouring problem for an arbitrary
# number of glasses. Write a function, more_pour_problem, that takes
# as input capacities, goal, and (optionally) start. This function should
# return a path of states and actions.
#
# Capacities is a tu... |
9790a2646cfe944d2e1008b803ae42e7bf1b7d2f | joy20182018/data_structure_java | /_implement/Trie.py | 2,127 | 4 | 4 |
class TrieNode:
def __init__(self, isWord=None):
if isWord == None:
self.isWord = False
else:
self.isWord = isWord
self.Node = TrieNode
self.next = {} # key: 字符, value:下一个节点
class Trie:
def __init__(self):
self.__root = self._... |
270bb8f00d482a6122195df5a028e7d6acc521ba | Nadirlene/Exercicios-python | /Exerciciospython/Utilizando modulos TEXTOeNUM/e022.py | 521 | 3.90625 | 4 | nome = str(input('Digite seu nome completo: ')).strip()
print('Seu nome em letras maiúsculas é {}'.format(nome.upper()))
print('Seu nome em letras minusculas é {}'.format(nome.lower()))
print('Seu nome ao todo tem {}'.format(len(nome) - nome.count(' ')))
#print('Seu primeiro nome tem {} letras'.format(nome.find(' ')))
... |
4e79ba87b636cd44fb7b5c2a6ce522309dec0167 | mciaccio/Introduction-To-Data-Analysis | /numPyIndexArrays.py | 2,499 | 3.96875 | 4 |
import numpy as np
print()
a = [1, 2, 3, 4, 5]
a_Array = np.array(a)
print("a - {}".format(a))
print("a_Array - {}\n".format(a_Array))
# index Array - identifies elements to keep
# boolean Array
b = [False, False, True, True, True]
b_Array = np.array(b)
print("b - {}".format(b))
print("b_Array - {}\n".format(b_Arra... |
9980e1de2d79df017dec094986d3465216396591 | Yucine/phonebook | /phonebook.py | 1,223 | 3.8125 | 4 | import sqlite3
import argparse
class Phonebook(object):
def __init__(self):
try:
c.execute('CREATE TABLE entries(id INTEGER PRIMARY KEY,name TEXT, phone TEXT)')
except:
pass
print('Welcome to the Phonebook')
def addContact():
name = input("enter ... |
59620cb8aedc5dacd40b4d009d3678f8de20e570 | panvalkar1994/creditcard-system | /task/banking/banking.py | 9,638 | 4.09375 | 4 | # Import necessary modules
# To generate random credits card numbers and pins I will use random module
import random
# For this project i will be using SQLite database which comes with standard python installation
import sqlite3
# connection object which will create and/or connect to sqlite3 database file
connection =... |
1c0a75496dc26abb8212843fd2dac72f93843db0 | here0009/LeetCode | /Python/SpiralMatrixIII.py | 4,126 | 4.15625 | 4 | """
On a 2 dimensional grid with R rows and C columns, we start at (r0, c0) facing east.
Here, the north-west corner of the grid is at the first row and column, and the south-east corner of the grid is at the last row and column.
Now, we walk in a clockwise spiral shape to visit every position in this grid.
Wheneve... |
ae781444863050fbd69cad6334d6780852a8d75e | CarloGauss33/Caesar-and-Vigenere-encrypt-and-decrypt-methods | /caesarcipher.py | 1,553 | 3.65625 | 4 | ### Made by Carlos Paredes for the course IMT1001 HOMEWORK PUC de Chile
### Licenced by MIT LICENSE 2019
import sys
import string
text_to_cipher = open('non_encriptedfile_dir.txt','r') ##First we should open the text to encrypt
global Character_Dict
Character_Dict = string.printable.replace('\t\n\r\x0b\x0c... |
13cac1c8c53e7d570c1550c5c21650fcc858ceec | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/python/beer-song/6927313b7017437db3d61c2ab75d5cb6.py | 686 | 3.671875 | 4 | s1 = "{0} bottle{1} of beer on the wall, {0} bottle{1} of beer.\n"
s2 = "Take one down and pass it around, {0} bottle{1} of beer on the wall.\n"
s_zero = "Go to the store and buy some more, 99 bottles of beer on the wall.\n"
s_one = "Take it down and pass it around, no more bottles of beer on the wall.\n"
class Beer:
... |
69c5654c047ef018d2ca5d5379be2ed776551b80 | daniel-reich/ubiquitous-fiesta | /jyqcRv6giw8an8KB2_14.py | 113 | 4 | 4 |
import re
def invert(s):
return "".join([c.lower() if re.match("[A-Z]", c) else c.upper() for c in s[::-1]])
|
c9d5820643bdd44d81aa60965ce7ae4ae2b8c8f1 | aralyekta/METU | /CENG111/Other/occurr.py | 98 | 3.515625 | 4 | string = raw_input()
substring = raw_input()
N = string.count(substring)
print N
print string * N
|
bf985cdd5afd7de7d8f7d5159fed95d4f9c1a424 | DimitriVictor/Colorizing | /colorization_final/scikit_learn_model.py | 4,311 | 3.515625 | 4 | from sklearn.neural_network import MLPRegressor
from process_image import process_image, grayscale
from PIL import Image
# Generates a neural network model to predict a specific color
def get_sklearn_model(image_name, color_type, learn_rate):
# generate image and grayscale image
image = process_image(imag... |
7ca4ccedd72570a8260c517fcd924e85739c71fc | vuminhdiep/EdX-Python-for-Research | /Book_case_study/lanuage.py | 1,768 | 3.53125 | 4 | text = "This is my test text. We will use this text to test the function."
def count_word(text):
text = text.lower()
skips = [",", ".", ":", ";", "'", '"']
for ch in skips:
text = text.replace(ch, "")
word_counts = {}
for word in text.split(" "):
if word in word_counts:
... |
4e9eb3cea136bf844dde81eef9180b4c8529dd60 | MattyHB/Python | /Prog4/sumcsv.py | 1,793 | 3.75 | 4 | # −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
# File: sumcsv.py
# Author: Matthew Beals User ID: Mbeal872 Class: CPS 110
# Desc: This program makes a filter type option for CSV files.
# It will take two columns and display them.
# −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−... |
d2283b57c4a797bb750d53f71e54163947ec7649 | ymccarter/flashcard_project | /Udemy/Network Automation Tool/basic_kotae.py | 7,937 | 4.15625 | 4 | # 1. assigned the different value to multiple variable
#
# a = 1
# b = 2
# c = 3
#
a, b, c = 1, 2, 3
print(a)
print(b)
print(c)
print ("it shows output of a, b, c : {}, {}, {}".format(a,b,c))
# 2. How to check the memory locations of each variable created above? (a, b, c)
print(id(1))
print(id(a))
# 3 what is the... |
b5337a8a609f23767be1a0716e99d7cbfba862b8 | smartvkodi/learn-python | /6-Python_Flow_Control_Part-2/81-Loops_with_else_block.py | 1,321 | 4.375 | 4 | # 81 - Loops with else block
msg = '81 - Loops with else block'
tn = ' '*5
text = '#'+ tn + msg + tn + '#'
i = len(text)
print('#'*i)
print(text)
print('#'*i)
print('\n')
print('''Other Python specific syntax
# else - can be used in this situations too
- for-else-loop
- while-else-loop
- try - except - else - finall... |
40056aa2ff372e5e70a46761868dca421a923789 | sanketkothiya/python-programe | /excercise/oop.py | 853 | 3.5625 | 4 | class employe:
sk=1
def __init__(self,name,age,profession):
self.name=name
self.age=age
self.profession=profession
def printdetails(self):
return f" the owner name is {self.name} and age is {self.age} and the profession is {self.profession}"
@classmethod
def fro... |
535e500fc654de9aec1a2b10c4358098a7c0c86d | gtoutin/gt6422-coe332 | /homework01/read_animals.py | 553 | 3.84375 | 4 | # Author: Gabrielle Toutin
# Date: 1/27/2021
# Homework 1
import json
import random
with open('animals.json', 'r') as f:
animals = json.load(f)
animal = random.choice(animals['animals']) # choose a random animal
# print out animal body parts
print("Here comes a beast!")
print("It has the head of a " + ani... |
481c69662620ad5a445d2472dcc148d71befe6f6 | love-adela/algorithm-ps | /acmicpc/2490/2490.py | 278 | 3.53125 | 4 | for i in range(3):
yut = list(map(int, input().split()))
if yut.count(0) == 1:
print('A')
elif yut.count(0) == 2:
print('B')
elif yut.count(0) == 3:
print('C')
elif yut.count(0) == 4:
print('D')
else:
print('E')
|
c6b0fd5910562053f23b641a81e034d1111f723b | PalinaUsovich/python_demo | /functions/tupel.py | 433 | 4.09375 | 4 |
# tupel is something very similar to a list, you can store there different data types
# its an immutable (you can not change it
# we usually want to use tupel when we know we wont need to change the value of this variable
# the difference with lists is that in list you can change values or modify them , in tupel - no... |
1ddfd5d54760f5a0d120869e81d05c546530e469 | Anil314/HackerEarth-Solutions | /Implementation/Game of sequence.py | 1,352 | 3.953125 | 4 | '''
Two players P and Q are playing a game of sequence on an array A of size n.
In each move a player will choose two distinct numbers X and Y , both numbers should be present in the array.
Now the player will pick all the positions where the number X is present , and will replace the value there with the number Y.
T... |
6ba53080c2e1f6a4660922562210ac339b388021 | anilized/HackerRank-ProblemSolving | /books.py | 185 | 3.515625 | 4 | def pageCount(n,p):
total = n//2
right = p//2
left = total - right
if (right > left):
return int(left)
else:
return int(right)
print(pageCount(6,5)) |
021c82bda431afe14e6f6e0364fe8fcb9fdc6b6e | kopok2/CodeforcesSolutionsPython | /src/837A/cdf_837A.py | 637 | 3.515625 | 4 | class CodeforcesTask837ASolution:
def __init__(self):
self.result = ''
self.word = ''
def read_input(self):
input()
self.word = input()
def process_task(self):
letters = "abcdefghijklmnoqprstuvwxyz"
for c in letters:
self.word = self.word.replace... |
88c8fae83b5556032843ce56ae61702afd594e72 | ryanfox/doodles | /prime_lengths.py | 346 | 4.0625 | 4 | import sympy
def digits(num):
return len(str(num))
def print_primes(num_digits):
if sympy.isprime(num_digits):
for prime in sympy.primerange(10 ** (num_digits - 1), 10 ** num_digits):
print(prime)
# handle the only even prime
print_primes(2)
i = 3
while True:
pri... |
6e959280ae8d52c2e19a454f1eb61e6282455bfc | dehvCurtis/NSA_Py3_COMP3321 | /Lesson_02/lesson02_sec2_ex3.py | 238 | 3.9375 | 4 | import random
list = {"apples":9.42,"oranges":5.67,"dog food":3.25,"milk":13.40,"bread":7.5}
rand_int = len(list)
number = random.randint(0, rand_int)
print(number)
# print(f'Finding number between 0 and {rand_int}')
print(list[number]) |
2a65ea5d2e7c2bffe28c55a903e7cdfb76b855b6 | jcallahan4/linked_lists | /linked_lists.py | 14,187 | 4.25 | 4 | """
Linked Lists
Jake Callahan
2018/09/27
Basic demonstration of linked list data structures
"""
class Node:
"""A basic node class for storing data."""
def __init__(self, data):
"""Store the data in the value attribute. Only accept int, str, or float."""
if type(data) != str and type(data) != ... |
42a73546752bba5a6979a0adaef74094a7e0f3b1 | murayama333/pg19 | /99_misc/1003/src/05/no50.py | 243 | 3.890625 | 4 | # no50.py
def search(array, target):
for e in array:
if e == target:
return True
return False
names = ["Alice", "Bob", "Carl"]
name = input()
result = search(names, name)
if result:
print("Found")
else:
print("Not Found")
|
f880e7b5f278b45b35280576592c526a706df66f | Arquedy/atom | /fatura.py | 298 | 3.890625 | 4 | nome = input("Nome do cliente: ")
dia = input("Digita o dia de fechamento da fatura: ")
mes = input("Digita o mes do vencimento: ")
fatura = input("Digite o valor da fatura: ")
print("Ola senhor", nome)
print("Sua fatura com vencimento em", dia, "de", mes,"no valor de Rs", fatura, "esta fechada")
|
985a430efc18d8aac66778a0c4bdc39ac1e4d6c9 | guillermo6410/Curso-Phyton | /promedio.py | 466 | 4.09375 | 4 | print("Promedio de calificaciones")
print("Ingresa los resultados de las materias")
matematicas=int(input("Ingresa calificacion matematicas:"))
español=int(input("Ingresa calificacion español:"))
fisica=int(input("Ingresa calificacion fisica:"))
informatica=int(input("Ingresa calificacion informatica:"))
quimica=... |
193bc58044b5007a2c6a39851e9167a5cfc71847 | gokayay/Face-Detection-with-OpenCV | /sharpening.py | 581 | 3.59375 | 4 | import cv2
import numpy as np
# Reading in and displaying our image
def sharpeningf():
image = cv2.imread('image.jpg')
#cv2.imshow('Original', image)
# Create our shapening kernel, it must equal to one eventually
kernel_sharpening = np.array([[-1,-1,-1],
[-1, 9,-1],
... |
f55c990a21adab4367fee9fc56cc5e83c0f08d8a | vasil-panoff/Python_Fundamentals_SoftUni_May_2020 | /PYTHON_FUNDAMENTALS_May_August_2020/Exercise_29_05_2020__Python_Fundamentals_Data_Type_Variables/05. Print Part of the ASCII Table.py | 273 | 3.796875 | 4 | start = int(input())
end = int(input())
result = ''
for i in range (start, end + 1):
result += chr(i) + ' ' #" " поставя спейс след всеки знак
print(result) #print(chr(i), end= " " end - остани на същия ред със спейс |
1d1a11f777a498ee4f788660a5ece2ed3b9884c6 | camilobmoreira/Fatec | /1_Sem/Algoritmos/forca_simples.py | 1,400 | 3.71875 | 4 | listaPalavras = ["satelite", "mustang", "guaxinim", "navio", 'doutor']
from random import randint
var = randint(0, 4)
palavra = str(listaPalavras[var])
palavraList = list(palavra)
palavEmBranco = []
while len(palavEmBranco) < len(palavraList):
palavEmBranco.append("_")
print("A palavra tem %i letras" %len(palav... |
aea511e30008189ca18403bbc0e3a9730c268699 | syedfaisalsaleeem/test_codes_python | /working_with_db.py | 515 | 3.6875 | 4 | import sqlite3
conn = sqlite3.connect('sqlite.db')
c = conn.cursor()
c.execute("CREATE TABLE IF NOT EXISTS faisal(id TEXT,Income INT)")
conn.commit()
c.close()
def alter_table():
# ALTER TABLE Customers
# ADD Email varchar(255);
c = conn.cursor()
# c.execute("Alter TABLE faisal ADD NAME INT ")
c.execute("Alter TAB... |
554a57984fefc14110261aea2021ff64b5b02e2e | arnawldo/Data-Structures-And-Algorithms | /Algorithmic-Toolbox/week2/naiveGCD.py | 248 | 3.859375 | 4 | #python3
# calculate GCD of two numbers
def naiveGCD(a,b):
best = 0
for d in range(1,a+b):
if a%d==0 and b%d==0:
best = d
return best
num1 = int(input())
num2 = int(input())
print('GCD is',naiveGCD(num1,num2))
|
5db89505c50a0a45043f94edf79225b4ed666f5a | gabriellaec/desoft-analise-exercicios | /backup/user_016/ch16_2020_03_09_20_52_09_934243.py | 133 | 3.5625 | 4 | preço=input('Qual o valor da conta do restaurante? ')
preçocomdez=(preço*1.10)
print ('Valor da conta com 10%: R$' + preçocomdez) |
418a20bdf79379a6de9b297684d9846370f34b7d | yumkong/cpp_prac | /leet/0719_pre/leet_628.py | 1,494 | 3.703125 | 4 | #given an integer array, find 3 numbers whose product is maximum and output this maximum product
class Solution(object):
def maximumProduct(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
max_int = 2147483647
min_int = -2147483648
leng = len(nums)
... |
9ef94ead2e28baea85b3afc632378b029efa13ca | Bazouk55555/IDAPI | /Coursework2_a_rendre/IDAPICoursework02.py~ | 11,171 | 3.578125 | 4 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
# Coursework in Python
from IDAPICourseworkLibrary import *
from numpy import *
#
# Coursework 1 begins here
#
# Function to compute the prior distribution of the variable root from the data set
def Prior(theData, root, noStates):
prior = zeros((noStates[root]), float... |
753500a9c6ca714d44cbf540c08bcc6d05223825 | kavinb07/code_war2019 | /diamond/diamond.py | 859 | 3.671875 | 4 | #!/usr/bin/python
with open('diamond.txt') as f:
data = f.readlines()
def make_diamond(size):
matrix = []
for i in range(1, (size / 2) + 1):
string = ''
string += '#' * (size / 2 - i)
string += '/' * i
string += '\\' * i
string += '#' * (size / 2 - i)
matri... |
f184e53ee91cf31856d3c44b859f2652a9d92382 | AndyLiamano/Aprendendo-Python | /1 - elif (comando Caso).py | 671 | 3.9375 | 4 | # elif é semelhante ao comando escolha/caso
print('Segunda-Feira (1)')
print('Terça-Feira (2)')
print('Quarta-Feira(3)')
print('Quinta-Feira(4)')
print('Sexta-Feira(5)')
print('Sábado(6)')
print('Domingo(7)')
semana = int(input('Digite um numero: '))
if semana == 1:
print('Hoje é Segunda-Feira')
elif... |
89a93afc5ffda030bc42e8adde096a2b7fbb2abb | gb-0001/depot-application-python_v1 | /application/src/main.py | 2,472 | 3.515625 | 4 | import crud
import Applications
def print_hi(name):
# Use a breakpoint in the code line below to debug your script.
print(f'{name}') # Press Ctrl+F8 to toggle the breakpoint.
if __name__ == '__main__':
while True:
isNumber = True
print_hi('****Bienvenue sur notre application****')
... |
671a9cd19aa23071cca64f84eb0149564153d008 | bronyamcgrory1998/Variables | /Class Exercises.py | 420 | 3.90625 | 4 | #Bronya McGrory
#17/09/2014
#Write a program that will ask the user for four integer numbers and then add these numbers together before displaying the answer. The input and output should be user friendly.
numberA= int(input("1st number"))
numberB= int(input("2nd number"))
numberC= int(input("3rd number"))
numbe... |
803efbff34965e4a76a4e8d835cfdc1e54d391c0 | danielforero19/taller-30-de-abril | /ejercicio 44.py | 110 | 3.890625 | 4 | n = int(input("ingrese cuantos numeros naturales desea mostrar: "))
c = 0
while c < n:
c += 1
print(c) |
5510bb5c4d4f02db30e558f9a901994dca42de09 | Abinalakalathil/python-lab | /6.py | 128 | 3.65625 | 4 | a=input("Enter 2 Numbers\n")
b=input("")
div=int(a)/int(b)
print("Quotient is ",div)
mod=int(a)%int(b)
print("Reminder is ",mod) |
e7b5a2459439a9a67baab9a0ce142620e4615d4e | jacben13/adventofcode2020 | /day3/part2.py | 1,476 | 3.703125 | 4 | # Day 3 puzzle, part 2
import os
def add_mountain_slice(line, mountain):
line = line.rstrip()
mountain.append(line)
def check_for_tree(slice, x):
return slice[x] == '#'
def toboggan_move(slice, start_x, move):
x = (start_x + move) % len(slice)
return x
mountain = []
with open(... |
08f333f8dbc63d788249b0edb1aa145cc234b197 | codeAligned/Leet-Code | /src/P-110-Balanced-Binary-Tree.py | 1,593 | 3.890625 | 4 | '''
P-110 - Balanced Binary Tree
Given a binary tree, determine if it is height-balanced. For this
problem, a height-balanced binary tree is defined as a binary tree in
which the depth of the two subtrees ofeverynode never differ by more
than 1.
Tags: Tree, Depth-first Search
'''
# Definition for a binary tree node... |
d06de3b6ca32560458eb21cd2f2bc44f65074008 | shenjie1983/Study-Python | /study_1/sj_5/c2.py | 194 | 3.765625 | 4 | # 枚举优势 不可变,防止相同值出现
# 传统方式1:字典
a = {'yellow':1, 'green':2}
a['yellow'] = 3
#传统方式2:类封装
class TypeDiamond():
yellow = 1
green = 2 |
c58c2e55fb2f51bbabcdd4f44003a68ff86266a0 | Punkrockechidna/PythonCourse | /advanced_python/object_oriented_programming/wizard_game.py | 609 | 3.71875 | 4 | # oop
# Classes should be singular
class PlayerCharacter:
# class object attribute (static not dynamic) doesn't change
membership = True
# constructor method/instantiate/init
def __init__(self, name,age):
if (PlayerCharacter.membership):
# self allows you to have a reference to som... |
c19b84fcecbc41598ce504f4311e35ff93ffeabc | BlitzYp/BinarySearchTree-DS | /tree.py | 3,197 | 3.890625 | 4 | def create_tree_node(value):
node = {"value": value, "right": None, "left": None}
return node
class BST:
def __init__(self):
self.root = None
self.current = self.root
def insert(self, value):
node = create_tree_node(value)
if not self.root:
sel... |
780bceb508282a2d0b1168b7de389b71686e4a69 | piedro/Recruiting | /appwill_recruiting.py | 8,526 | 3.921875 | 4 | # -*- coding: utf-8 -*-
"""
移动互联网公司Appwill招聘研发和运维护工程师:
"""
import sys
# Thanks to http://code.activestate.com/recipes/577058/
def query_yes_no(question, default="no"):
"""Ask a yes/no question via raw_input() and return their answer.
"question" is a string that is presented to the user.
"default" is t... |
cd9dad7cbd2b68aaa9cdb73a1ec3d207d062a37f | nsidn98/Residual-Policy-Learning | /controllers/fetchEnvs/pickAndPlaceEnv.py | 15,127 | 3.515625 | 4 | """
Collection of variations in the slide environment
Contains the following:
FetchPickAndPlace:
The vanilla 'FetchPickAndPlace-v1' without any controller
Can be used for learning with RL from scratch
Action taken as:
Pi_theta(s) = f(s)
FetchPickAndPlacePerfect:
... |
5dcbe1c62d2e38a7723ec8c35039bfbe4c3306a8 | Arno98/Python-3-Basics | /Chapter 5 (While conditions)/input_3.py | 603 | 4 | 4 | car = input('Enter a car what do you want to choice ? ')
print("You choice a(an) " + car.title() + '.' + " This a brilliant choice!")
table = int(input('What time do you want table (from 8am to 23pm) ? '))
if table < 8:
print("Sorry, Sir, but this time we are closed. Work time from 8 am to 23.pm")
if table >= 8... |
48ea1651e12ccf3d7aff72692aab96bdc1d29555 | anila-a/CEN-206-Data-Structures | /lab03/ex17.py | 397 | 4 | 4 | '''
Program: ex17.py
Author: Anila Hoxha
Last date modified: 03/13/2020
Write a Python program that inputs a list of words, separated by whitespace, and outputs how
many times each word appears in the list.
'''
def count(list):
f = []
for i in list:
f.append(list.count(i))
return f
... |
6a7d8154cb6a07c18f0af522b318aebea6f1c012 | math-nerd/pfe-sched | /history.py | 11,272 | 3.53125 | 4 | ## fillfab-----------------------------------------------
class fonction:
def fabfill(n,mfab,times):
Fab=[]
for i in range(n):
jfab=[]
for j in range(mfab):
if times[i][j] != 0:
jfab.append(1) #if the product i is processed in the machine... |
2076d1b66af92faf085df640bd5236a461ce6b17 | CourtneyBritney/myCrashCourse-Python | /Chapter8/pg193.TIY.py | 359 | 3.609375 | 4 | #8-1
def display_message():
"""Display a simple message."""
print("Learnt to write functions, which are named blocks of code that are designed to do one specific job.")
display_message()
#8-2
def favorite_books(books):
'''Display a your favorite_book'''
print(f"One of my favorite_books is {books.title()}.")
... |
25dc9396d14b27701b63327f6a10e35f0b554eb9 | Agchai52/Leetcode1 | /0112.py | 1,156 | 3.921875 | 4 | # Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def hasPathSum(self, root, sums):
"""
:type root: TreeNode
:type sum: int
:rtype: bool
... |
8a19aaf520f147c0c1aae48fd54fa017e182fea4 | BigBoyLaboratory/CP3-Nopporn-Tipparawong | /lecture 64.py | 208 | 3.734375 | 4 | myFriends = ["Boy", "Tum", "Yok"]
print(myFriends)
myFriends[2] = "Yoker"
print(myFriends)
myFriends.append("Bank")
print(myFriends)
myFriends.remove("Tum")
print(myFriends)
del myFriends[0]
print(myFriends)
|
9c865acfc74099e074a1d79debaf338dd8febe32 | bipinmsit/Spatial_Information_Technology | /automating_gis_process_intro.py | 2,753 | 3.65625 | 4 | import argparse
def learn_objective(learn_objective):
learn_objective = '''
* Learning Objectives
- Read/write spatial data from/to different formats
- Deal with different projections
- Do diffent geometric operations and geocoding
- Reclassify your data based on different critera
- Do spatial queries
... |
a14d36bda77b096de4e4efa1240b433c96968605 | VladyslavHnatchenko/united | /2018/metanit.py | 1,294 | 4.0625 | 4 | """modules"""
"""scope"""
# def say_hi():
# name = "Sam"
# surname = "Johnson"
# print("Hello", name, surname)
#
#
# def say_bye():
# name = "Tom"
# print("Good bye", name)
#
#
# say_hi()
# say_bye()
# name = "Tom"
#
#
# def say_hi():
# print("Hello", name)
#
#
# def say_bye():
# print("G... |
22245b75bfcdb3d6e993fbbd2d17bd28b5701dbb | hztforever/Student_homework | /liyueran/第五次课/Lesson 5 HW.py | 220 | 3.796875 | 4 | dict1 = {"aiyc": 123, "lilei": 520}
print(dict1.get("aiyc22","aiyc00"))
Set1 = {1, 3, 5, 7, 8}
Set2 = {2, 3, 5, 9,10}
#方法一
print((Set1 - Set2) | (Set2 - Set1))
#方法二
print((Set1 | Set2) - (Set1 & Set2))
|
d7edab620fc55770ff5a60e4212c8e01291cffb7 | archimedessena/pythoncodes | /Cookbook/unpacking1.py | 1,248 | 4.28125 | 4 | #You need to unpack N elements from an iterable, but the iterable may be longer than N elements, causing a "too many values to unpack" exception
#def drop_first_last(grades):
# first, *middle, last = grades
# return avg(middle)
#grades = (3, 4, 5)
#first, *middle, last = grades
#print(drop_first_last(*middl... |
77540f70af8328a0b234c8e7932fe07173f9af18 | technocake/nokon-kjem-til-aa-komme | /billett/utils/settings.py | 1,737 | 4.0625 | 4 | import os
def _env(KEY, DEFAULT=None, TYPE=None):
"""
Shorthand function to just read an environment variable
and provide a default.
Handles parsing of bool/int/list/str values correctly
A couple of conventions exist when designing
environment variables for settings.
... |
1b7c066f6fee3124c11c0c7c632b6cf42dbed43f | vidya3979/luminardjango | /flowcontrols/forloop/powerprint.py | 318 | 3.75 | 4 | #given three input n, min&max find the number of vlues raised to the nth power range.
#eg: num=2
#min=1
#max=40
n=int(input("enter the num"))
min=int(input("enter the minimum"))
max=int(input("enter the maximum"))
for i in range(1,max+1):
if i**n in range(min,(max+1)):
print(i,"," ,i,"^",n,"=",i**n) |
4b556b15e113135b63f539ed725c59a0a12ffaea | rdtr/leetcode_solutions | /python/0077_combination.py | 660 | 3.578125 | 4 | class Solution:
def combine(self, n, k):
"""
:type n: int
:type k: int
:rtype: List[List[int]]
"""
res = []
self.doCombine(n, k, 1, [], res)
return res
def doCombine(self, n, k, curNum, cur, res):
# when we don't have enou... |
13e30d1edfb04d910087645c814f99426875b498 | frclasso/revisao_Python_modulo1 | /ATIVIDADES/imc3.py | 1,744 | 4 | 4 | #!/usr/bin/env python3
# -*-coding:utf-8 -*-
print('*'*70)
print("Bem vinco ao programa de calculo")
print("Do Indice de Massa Corporal IMC")
print('*'*70)
menu = ''
dados_temp = []
while menu != 0:
menu = int(input("""
1 - Para inserir novo cadastro;
2 - Listar cadastro atual;
... |
68fff5af7dedf0e00486842b34ae2d93d9df9064 | kaust-cs249-2020/huawen | /1.8Count_d(ApproximatePatternCount).py | 431 | 3.71875 | 4 | def Count_d(Pattern,Text,d):
'''return the appear times of a pattern with at most d mismatich in a Text'''
L=len(Pattern)
count=0
for i in range(len(Text) - L + 1):
compare_string=Text[i:i+L]
distance=0
for j in range(len(Pattern)):
if Pattern[j] != compare_s... |
3bbff7c65000927f239e97c7779bea87adf96929 | ZoeBin/queues_simulations | /python_files/tutorial_4.py | 6,021 | 3.6875 | 4 | # %%
'''
# Tutorial 4, solutions
This solution is a jupyter notebook which allows you to directly interact with
the code so that you can see the effect of any changes you may like to make.
Author: Nicky van Foreest
'''
# %%
# empty code for numbering
# %%
# empty code for numbering
# %%
# empty code for numbering... |
3880deab87439f25a3d62471556d9037046f9a19 | sobecc/applied-data-science-bootcamp | /ads06_big_data/spark_rdd.py | 6,893 | 3.609375 | 4 | import re
from datetime import datetime as dt
from pyspark import SparkContext
sc = SparkContext.getOrCreate()
def count_elements_in_dataset(dataset):
"""
Given a dataset loaded on Spark, return the
number of elements.
:param dataset: dataset loaded in Spark context
:type dataset: a Spark RDD
... |
a149673c5d4d8be399911cd213281ea1713effa7 | nvyasir/Python-Assignments | /tuple_unpack.py | 563 | 4.53125 | 5 | # Tuple Unpacking
# Tuples can be used to output multiple values from a function.
# You need to make a function called calc(), that will take the side length of a square as its argument and return the perimeter and area using a tuple.
# The perimeter is the sum of all sides, while the area is the square of the side le... |
0134134f53f3058e4928dc96c9c236cad56764a7 | y976362357/PythonLearn | /HeadFirst Ptyhon/ChapterOne/class.py | 2,199 | 3.859375 | 4 |
#格式化距离字符串,将’-‘,’:‘,替换伟'.'并返回
def format_time(time_str):
if '-' in time_str:
split_str='-'
elif ':' in time_str:
split_str=':'
else:
return time_str;
(m, s)=time_str.split(split_str)
return m+'.' + s;
#读取记录文件,并返回一个Biker
def read_record_file(filename,type='list'):
pass
... |
f56c4d11b43c679a619c6b4ba306c189a4c8dc02 | tpotjj/Python | /DataStructuresAndAlgo/LinkedList/InterviewQuestions/RemoveDups.py | 1,057 | 3.578125 | 4 | from BaseLinkedList import LinkedList
def removeDups(ll):
'''
With temporary buffer in the visited set()
'''
if ll.head is None:
return
else:
curNode = ll.head
visited = set([curNode.value])
while curNode.next:
if curNode.next.value in visited:
... |
298c74a063f47fc3de7709bbd33f5e6dd0b5a6f2 | Wendy1127/data_practice | /20171114/while_1.1.py | 301 | 3.765625 | 4 | # coding:utf-8
#三要素
#1.起始值 2.终止值 3.步进值
#输入一个数值,输出从1到这个数的所有奇数。
begin=1
end=input(u'输入一个数:')
step=2
list1=[]
if end%2==0:
end-=1
while begin<=end:
if begin%2 ==1:
list1.append(begin)
begin+=step
print list1 |
59d04e950fceefae72f192229f90bbcf35712068 | zoobot/datastructures | /bstCreate.py | 6,132 | 4.03125 | 4 | # based off this https://github.com/charulagrl/data-structures-and-algorithms/blob/master/data_structures/binary_search_tree.py
class Node(object):
def __init__(self, data):
self.data = data
self.left = None
self.right = None
self.contains_target = False
class BinarySearchTree(obje... |
8cbc429d2d04bf9aca56e1e2e097fb831015111e | tamasbrandstadter/python-learning | /week2/day2/classes.py | 2,379 | 3.609375 | 4 | class Animal(object):
def __init__(self):
self.hunger = 50
self.thirst = 50
def eat(self):
self.hunger -= 1
def drink(self):
self.thirst -= 1
def play(self):
self.hunger += 1
self.thirst += 1
class Farm(object):
def __init__(self):
self.an... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.