blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
1e43f325984f4ea0103d924c733d1e012b8dc215 | abhidya/ml-c-vsSnek | /sol.py | 408 | 3.6875 | 4 | import sys
def selfDividingNumbers(test):
average = 0
count = 0
def self_dividing(n):
for d in str(n):
if d == '0' or n % int(d) > 0:
return False
return True
for n in range(test+1):
if self_dividing(n):
count = count +1
aver... |
a41b44ba1aba2a1d66ae12332756ef1eff4529b4 | taurenshaman/Birds-of-a-Feather | /Generative_Birds.pyde | 6,543 | 3.5 | 4 | w, h = 1400, 1400
# Number of birds
grid_x = 5
grid_y = 5
# The birds will draw inside this rectangle
grid_x_pixels = .8 * w
grid_y_pixels = .8 * h
# Distance between the birds
sep_x = grid_x_pixels / (grid_x - 1)
sep_y = grid_y_pixels / (grid_y - 1)
# Background Color
bc = (255, 255, 255)
# Global bird variables
... |
04697024e7cbb64c7ec475243991ac1918b160c9 | georgesrebel/Python-Fundamentals | /7. Handling External Files/Quiz Application/quiz.py | 1,070 | 3.71875 | 4 | import json
import random
import os
import time
def read_data():
with open("quiz.json", "r") as file:
data = json.load(file)
return data
def question(data):
print("Question " + str(data["id"]))
print(data["question"])
random.shuffle(data["choices"])
options = ["A", "B", "C", "D"]
... |
c7d644e028bd0c46aebaffcf3a57e7a8aa033546 | jayaramjayam/DineshJaya | /positiveandnegative.py | 151 | 3.796875 | 4 | num = int(input("Enter a number: "))
if (1<= num <= 100000):
print("Positive number")
elif num==0:
print("zero")
else:
print("Negative numbers")
|
37c49d2d5f9a1080b79ff18dcb8d92dbd1859072 | vgtstptlk/siaod_labs | /lab1/main.py | 3,688 | 3.859375 | 4 | from tkinter import *
from tkinter import scrolledtext
class Graph:
def __init__(self):
self.nodes = set()
self.edges = {}
self.distances = {}
def add_node(self, value: str) -> None:
self.nodes.add(value)
def add_edge(self, from_node, to_node, cost):
self._add_edg... |
8d3801cf147b3715f97eceff8618e35e6d4b56b1 | dauanaana/desafionaval | /batalhaNaval/navio.py | 1,744 | 3.6875 | 4 | """
:mod:'Jogador'
==============
module:: jogador
:plataform: All
:synopsisi: Esté modulo implementa a classe navio
moduleauthor:: Ríad Mattos Nassiffe
"""
class Navio:
"""
A classe navio é assim...
"""
def __init__(self, coordIX, coordIY, coordFX, coordFY):
"""
... |
d7443835d6b3d681a554b92c2845783f6c00a246 | CCarissimo/ProjectEuler | /3.py | 1,084 | 3.65625 | 4 | # -*- coding: UTF-8 -*-
# Fing the largest prime factor of the number n.
# First I need import the necessary packages. In this case I need the squareroot, which
# I fing in the math package. I also want to work with arrays, so I import the numpy
# package.
import math
import numpy as np
#Setup of the problem
n... |
c4b8179eb631f212d81cd63c778a1e305b201b90 | hizkiawilliam/praktikum-dasar-dasar-pemrograman | /UTS/UTS nmr 3.py | 287 | 3.953125 | 4 | def max_cap(text):
maks = ""
for char in text:
if ((ord("A") <= ord(char) <= ord("Z"))and char > maks):
maks = char
if(maks!=""):
return maks
print(max_cap("belAjaR PyThon DengaN geMBira"))
print(max_cap("belajar python dengan gembira"))
|
b49b55fdcc9a533f43c5e08cf82f2cbf7563ba14 | Kwabs7991/PYHTON | /TechWithTim_OOP_for_Beginners Part 6.py | 2,127 | 4.15625 | 4 | #Object Oriented Programming in Python:
##Looking at Static and Class methods and attributes:-
# Minute stopped = ... into the video.
#Class Attributes are Attributes that are specifc to the class not to an instance where an object of that class.
class Person:
number_of_people = 0
##This attribute/variable above ... |
75325c430759d3f53a3e224591e4818dda7519ae | zoomjuice/CodeCademy_Learn_Python_3 | /Unit 11 - Function Arguments/11_01_06-KeywordArgs.py | 1,980 | 4.96875 | 5 | """
When we call a function in Python, we need to list the arguments to that function to match the order of the
parameters in the function definition. We don’t necessarily need to do this if we pass keyword arguments.
We use keyword arguments by passing arguments to a function with a special syntax that uses the names... |
e02f138109bf1e903fcca8d5ac659e133c838b2f | Aasthaengg/IBMdataset | /Python_codes/p02552/s402701313.py | 60 | 3.640625 | 4 | t=int(input())
if t==0:
print("1")
elif t==1:
print("0") |
826f69dcbd337027cf9dfaa192821e22572aa073 | HsinTingHo/CodeTime | /week10_binary_trees_1/insertion.py | 1,447 | 4.34375 | 4 | # Problem 2: Insert into a Binary Search Tree
# Given the root node of a binary search tree (BST) and a value to be inserted into the tree, insert the value into the BST.
#Plan:
#1. if root node is empty, set root node data to value
#2. comapare value with node data and traverse down to the tree until find suitable po... |
6e02367a562caeafc3daeede6971b1de086dae89 | stellakaniaru/practice_solutions | /3rd_person_singular_function.py | 999 | 4.09375 | 4 | '''
The third persom singular verb form in English can be
distinguished using the following rules:
1. If the verb ends with y, remove it and add ies.
2. If the verb ends in o, ch, s, sh, x or z, add es.
3. By default just add s.
Create a function make_3sg_form() that given a verb in
infinitive form returns its third... |
1bdd89d7bc270fca699ac76dc43789c9a548e323 | AnnapurnaThakur/python_code | /While_loop/while_loop6.py | 231 | 4.0625 | 4 | for i in range(0,6):
for j in range(0,i):
print("1" ,end="")
print("")
# for i in range(0,20,3):
# print(i+3)
# i=1
# while i<5:
# j=1
# while j<5:
# print(j)
# j=j+1
# i=i+1
|
5637cd1ea05722ef8a05f89733d71b0042f15db6 | Saadkhanhere/Assignment | /Assignment_2/Q_4.py | 368 | 3.984375 | 4 | '''
Online Python Compiler.
Code, Compile, Run and Debug python program online.
Write your code in this editor and press "Run" button to execute it.
'''
# Initializing list
list = [ 1, 4, 5, 7, 8 ]
# Printing test_list
print ("The list is : " + str(list))
print("... |
0ddbef325988a6f0201051c24cab35aa1c8663fc | Samuel2402/python-demo | /Practice/conditionals.py | 1,306 | 4.03125 | 4 | # is_dev_cool = False
# if is_dev_cool:
# print("Dev is cool")
# else:
# print("Dev isn't cool")
## is_Sam_drunk = False
## if is_Sam_drunk:
## print("Sam is drunk")
## else:
## print("Sam is NOT drunk")
#age = int(input("Enter your age: "))
#if age >= 85:
# print("You are above 85")
#elif age >= 50:... |
4b26eb9d34003c6e3133658838d5365de56f1938 | HyunupKang/StepJaeKJoon | /0707_2_2750_수 정렬하기.py | 789 | 3.734375 | 4 | # 파이썬 라이브러리 이용
x = int(input())
num_list = []
for i in range(x):
num_list.append(int(input()))
num_list1 = sorted(num_list)
for i in range(len(num_list)):
print(num_list1[i])
# 버블 정렬
N = int(input())
numbers = []
for _ in range(N):
numbers.append(int(input()))
# Bubble Sort
for i in range(len(numbers)):
... |
1c876ba55fe399cf877c79cb4890eca18b9916fc | choroba/perlweeklychallenge-club | /challenge-115/lubos-kolouch/python/ch-2.py | 265 | 4.15625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
def largest_multiple(arr):
arr = sorted([str(x) for x in arr if x % 2 == 0], key=lambda x: x * 3, reverse=True)
return int("".join(arr))
# Test
print(largest_multiple([1, 0, 2, 6, 9, 4, 5])) # Output: 6420
|
6a6d86555160cf24377f80e1f2b37898bccf5bf8 | Cozoob/Algorithms_and_data_structures | /BIT ALGO/SORTOWANIA cz2/zad3.py | 1,175 | 3.53125 | 4 | # Dana jest tablica liczb rzeczywistych wielkosci n reprezentujaca
# kopiec minimum (array-based heap). Majac dana liczbe rzeczywista
# x sprawdz, czy k-ty najmniejszy element jest wiekszy lub rowny x.
# moj pomysl O(klogn)
# k razy budujemy kopiec minimum i zdejmujemy z samej gory ten
# najmniejszy element i sp... |
7fc6daf27feb30ed92fc3d39c074d5d2673a50cf | atkabyss/1G_python | /定期テスト/K019C1068_石井恭輔_Exam07.py | 105 | 3.5 | 4 | a = float(input("半径を入力してください>"))
b = a*a*3.14
print("円の面積:" + str(b)) |
50a0764ec66de83afaf948637930d4a6086f1a9d | NastkaKorpak/Kurs-01 | /PLiki_moduly.py | 551 | 3.5625 | 4 | # # Otwórz plik
# fo = open("text.txt", "r")
# print("Nazwa pliku: ", fo.name)
#
# line = fo.readline()
# print("Czytaj linię: >" + line + "<")
#
# # Ponownie ustaw wskaźnik na początek
# fo.seek(0, 1)
# line = fo.readline()
# print("Czytaj linię: >" + line + "<")
#
# # Zamknij otwarty plik
# fo.close(
#
#
# import os
... |
b6acb2cc1957579db2be7a26d4be60ad17b11718 | IvanYangYangXi/PythonStudy | /Day006/Class.py | 1,055 | 3.96875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Class.py
# @Author : Ivan-杨杨兮 (523166477@qq.com)
# @Link : www.cgartech.com
# @Date : 10/28/2018, 11:48:13 AM
# class people: # 经典类写法
class people(object): # 新式类写法
def __init__(self,name,age,lifevalue=100): # 初始化类(必须包含self)
self.name = name
sel... |
9bec5c629a4805e4d077bcbd83707479f7cf3628 | Bipul-Harsh/Code-Chef-Solutions | /ATTENDU.py | 164 | 3.71875 | 4 | # cook your dish here
for _ in range(int(input())):
_ = int(input())
b = input()
if(b.count('0')>30):
print('NO')
else:
print('YES') |
f4a1d1c5e2f02c3f609fd77879652449ee625f59 | Alegraph/PyHackerRang | /Strings/merge-the-tools.py | 792 | 3.734375 | 4 | def merge_the_tools(string, k):
# your code goes here
string=list(string)
print(len(string))
print(k)
if len(string)>k:
for i in range(0,len(string),len(string)//k):
result=[]
for j in range(len(string)//k):
if string[i] not in result:
... |
adf057a8adfcac52611f99dfd165155932dddea5 | shiikharrr/Hangman-Game | /Hangman_player.py | 528 | 3.859375 | 4 | import Hangman
hangman = Hangman.Hangman('c:\\wordlist.txt')
hangman.choose_the_word()
hangman.fill_the_word_status()
while True:
hangman.get_word_status()
hangman.guess_the_letter()
if(hangman.lives == 0):
print("Out of attempts. \n |||GAME OVER||| \n The word was: ",format(hangman.ch... |
2b5597a801f25916415cc6c3058b9c4f521ac27e | krishnausjs/learn_python_hardway | /ex15_read_files.py | 621 | 4.25 | 4 | #Importing argv from sys
from sys import argv
#Read script and filename through argv
script, filename = argv
#Open the file with filename
txt = open(filename)
#Print your file name and then contents of the file
print "Here's your file %r:" % filename
#Use the file object and read function to read the file
print txt.... |
b2222ad46e061342f7d794c399fcbfd3ec0a916a | lanhaixuan/Data-Structure | /剑指offer/6.旋转数组的最小数字.py | 2,132 | 3.765625 | 4 | # -*- coding: utf-8 -*-
# @Time : 2018/12/2 9:08
# @Author : lanhaixuan
# @Email : jpf199727@gmail.com
# @File : 6. 旋转数组的最小数字.py
# @Software: PyCharm
'''
把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转。
输入一个递增排序的数组的一个旋转,输出旋转数组的最小元素。
例如数组{3,4,5,1,2}为{1,2,3,4,5}的一个旋转,该数组的最小值为1。
NOTE:给出的所有元素都大于0,若数组大小为0,请返回0。
'''
'''
二分查找的变形,... |
9f9ec153323a6aaa69af993747f1d5959e753d5f | santanavictor/trabalho_final | /buscarAluno.py | 226 | 3.890625 | 4 | import pandas as pd
filename = input ("Nome do arquivo onde estão as matrículas: ")
data = pd.read_csv (filename)
name = input ("Nome do Aluno que deseja achar?: ")
busca = data[["Nome"] == name]
print (busca) |
10a4a0a5fb05a53ce73be74f861327e93372d000 | VCloser/CodingInterviewChinese2-python | /20_NumericStrings.py | 1,393 | 3.859375 | 4 | def scan_unsigned_int(str, index):
# start_index == index 用来标注是否有数位
start_index = index
while index<len(str) and str[index] in "0123456789":
index+=1
# 当str中存在若干0-9的数字时,返回true
return index != start_index,index
def scan_int(str, index):
if index<len(str) and str[index] in ['-','+']:
... |
a0f889e6946629ff1ab89242751390b93c64ff3c | yordan-marinov/fundamentals_python | /mid_exams/memory_game.py | 1,264 | 3.8125 | 4 | def indexes_validated(lst, i, ii):
return (
(i != ii) and
(i in range(len(lst)) and ii in range(len(lst)))
)
def adding_elements(lst, moves, twins):
print(
"Invalid input! "
"Adding additional elements to the board"
)
middle = len(lst) // 2
return (
... |
cd2b579f920cc2ff1fe577f08f0a586ba7b6a606 | DimitrisVervitis/Calculator- | /Calculator.py | 1,100 | 4.15625 | 4 |
import os
import math
print (30 * '-')
print(' C A L C U L A T O R')
print (30 * '-')
print (" M A I N - M E N U")
print (30 * '-')
print ("1. Addition +")
print ("2. Subtraction -")
print ("3. Proliferation *")
print ("4. Division /")
print ("5. Square ")
print (30 * '-')
choice=int(input(' Enter your choice... |
7d1d3b123264680a6e3837ff199d85aea8207984 | shubhamoli/solutions | /ctic/2.4.py | 1,191 | 3.609375 | 4 | """
2.4 - Write a function to partiion a LL around "x" such that values
less than x comes nefore it and values greater than it comes after "x"
"""
# Definition of a list node
class ListNode:
def __init__(self, val):
self.val = val
self.next = None
def partition(head: ListNode, x:i... |
7d7602eb3415854c5b6a5b6bcf3a277dbf5680b6 | misladkova/python_exercises | /zvacsi.py | 177 | 3.59375 | 4 | n = int(input())
x = int(input())
for i in range(n):
y = int(input())
z = y+x
if i < (n-1):
print(z, end = ' ')
else:
print(z, end = '')
print()
|
dbd7c97d2b51d1e48259c0ac828fafccdb02ce42 | benkeanna/pyladies | /04/ukol22faktorial.py | 128 | 3.578125 | 4 | cislo = int(input('Zadej číslo: '))
faktorial = 1
for i in range(1,cislo):
faktorial = faktorial * i
print(faktorial)
|
f3b665cfb4a2fc27c88de5c64fd9aa394ae7bc9d | joekreatera/python_basic_va_course | /8_08_2020/distance.py | 472 | 4.1875 | 4 | # distance between points and
from math import *
def distance(xa,ya,xb,yb):
dx = xa - xb
dy = ya - yb
d = sqrt(dx**2 + dy**2)
return d
x1 = int(input('X1:'))
y1 = int(input('Y1:'))
x2 = int(input('X2:'))
y2 = int(input('Y2:'))
x3 = int(input('X3:'))
y3 = int(input('Y3:'))
d = distance(x1, y1, x2, y2)
pr... |
a215af5c0c36cd9fe83f9e1d350197d63b34b1ed | MiKueen/Data-Structures-and-Algorithms | /Leetcode/0201-0250/0230-kth-smallest-element-in-a-bst.py | 1,239 | 3.828125 | 4 | '''
Author : MiKueen
Level : Medium
Problem Statement : Kth Smallest Element in a BST
Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.
Note:
You may assume k is always valid, 1 ≤ k ≤ BST's total elements.
Example 1:
Input: root = [3,1,4,null,2], k = 1
3
/ \
1 4
... |
f28eaaffd0da60e627248ceedfdd0c9899b1348e | epasseto/pyprog | /NetBeansPython/Statistics/src/H3_IncrementalMean.py | 685 | 3.59375 | 4 | #! /usr/bin/python
# To change this template, choose Tools | Templates
# and open the template in the editor.
__author__="epasseto"
__date__ ="$02/08/2012 09:17:28$"
#In class you wrote a function mean that computed the mean of a set of numbers."""
#Consider a case where you have already computed the mean of a set o... |
ca2afe3b615372b62457636b02e28348c72031f0 | gabriellaec/desoft-analise-exercicios | /backup/user_114/ch56_2019_04_04_01_05_11_564979.py | 268 | 3.578125 | 4 | def calcula_total_da_nota(x, y):
i=0
final=0
while i<len(preco):
total=preco[i]*quantidade[i]
i=i+1
final=final+total
return final
preco=[10,15,20,30,40,50]
quantidade=[3,5,6,4,2,7]
print(calcula_total_da_nota(preco,quantidade)) |
2c1d04c35f932e4c341661714a47251ab395b962 | kiwi-33/Programming_1_practicals | /p14-15/p14p5.py | 533 | 4.09375 | 4 | '''define function
prompt for input
check if negative
enter for loop range 0 to input:
print message that shows progression towards the base case and also calls the function'''
def fibrecur(x):
if x <= 1:
return x
else:
return(fibrecur(x-2)+fibrecur(x-1))
series = int(input("Enter the numb... |
b9494d454a1a9bae4582cd2ef302d17e146b3996 | tcwxcn/Amazon-Title-Price-Webscraper | /Amazon Product Soup Scraper.py | 908 | 3.671875 | 4 | from bs4 import BeautifulSoup
import requests
import time
import datetime
import smtplib
#asks user for amazon listing
URL = input("Enter URL of Amazon Listing")
headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36", "Ac... |
77057192e4338c959645cf90cd6bd0a3489d58d1 | Spookiel/British-Informatics-Olympiad-Solutions | /Code/2021/Q1/q1c-faster.py | 355 | 3.734375 | 4 | # see https://reasoning.page/30391/bio-2021-question-1 for an explanation of how this works
from functools import lru_cache
@lru_cache
def arrangements(nodes: int) -> int:
if nodes == 1:
return 1
total = 0
for i in range(1, nodes):
total += arrangements(i) * arrangements(nodes - i)
ret... |
8df9b6d13f607696fbcb3ad1c003a616f8a1db58 | harshmalviya7/LeetCode_Coding_Questions | /symmetricTree.py | 673 | 4 | 4 | # 101. Symmetric Tree
# https://leetcode.com/problems/symmetric-tree/
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def isSymmetric(self, root: TreeNode)... |
5e0e6558e4f256dc268f5f8ec20c5d827bd42662 | nmpluta/Python | /Exam/D12.py | 298 | 3.546875 | 4 | # -*- coding: utf-8 -*-
# D12 (17) usunie duplikaty ze słownika.
def d12(dic):
seen = {}
for key, value in dic.items():
if value not in seen.values():
seen[key] = value
return seen
d = {1: [1, 2, 3], 2: 3, 3: [1, 2], 4: [1, 2, 3], 5: 3, 6: [2, 1]}
print(d12(d))
|
83833dab2baac479f752af8fe0df502d2aa6fe34 | erolkahraman/python | /Temel Veri Yapıları ve Objeler/range.py | 73 | 3.625 | 4 | liste = list()
for i in range(1,10):
liste.append(i)
print (liste)
|
b94c65c68e66c3b79535b0b39fe8dca30bd96cc5 | sooyeun-park/project.d- | /student-point_class.py | 731 | 3.6875 | 4 | #! /usr/bin/env python
class Student:
def __init__(self, kp, ep, mp):
self.__korean = int(kp)
self.__english = int(ep)
self.__math = int(mp)
def showKorean(self):
k = self.__korean
return k
def showEnglish(self):
e = self.__english
return e
def ... |
40a5896a7c31203fe5aa0d03949d4b06afc7bb3e | kyeeh/holbertonschool-interview | /0x0C-nqueens/0-nqueens.py | 1,307 | 3.984375 | 4 | #!/usr/bin/python3
"""
The N queens puzzle is the challenge of placing N non-attacking queens on an
N×N chessboard
"""
from sys import argv, exit
def queens(N, row, col, solutions):
"""
Set queens on N-board recursevily to find the solutions
"""
while col < N:
if solve(row, col, solutions):
... |
f3d4244bdfd94fb55133c5f35d4f6dbd0e454748 | fredford/cmput404 | /lab2/proxy_server.py | 1,827 | 3.5 | 4 | #!/usr/bin/env python3
import socket, sys
HOST = ""
PORT = 8001
BUFFER_SIZE = 1024
def get_remote_ip(host):
# Try getting the IP of the host connection
try:
remote_ip = socket.gethostbyname(host)
except socket.gaierror:
print("Hostname could not be resolved. Exiting")
sys.exit()
... |
57c2b3534134d3b65e5254c2df812b38a60529bb | hehehe47/LeetCode | /Akuna/Cicular Array.py | 704 | 3.671875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2019/10/21 21:56
# @Author : Patrick
# @File : Cicular Array.py
# @Software: PyCharm
def circularArray(n, endNode):
d = {k: 0 for k in range(1, n + 1)}
start = endNode[0]
for end in endNode[1:]:
if end < start:
end += n
... |
b94a9feda059219b74caa1429d5a6f28326c228a | anhnguyendepocen/Programming_Python | /Practice Python/reverse_word_order.py | 238 | 3.90625 | 4 | answer = ''
w = str(input("Any words"))
word_list = w.split(' ')
reversed = word_list[::-1]
for i in reversed:
answer += i
answer += ' '
print(answer)
# 짧게 만들기 !!!
def reverseWord(w):
return ' '.join(w.split()[::-1])
|
db1658abc618e046f48e0e06c53043b8968dc580 | kasamdh/python | /threeChar.py | 310 | 4.4375 | 4 | '''
Write a for loop that iterates over a list of strings lst and prints the first three characters of every word.
If lst is the list ['January', 'February', 'March'] then the following should be printed:
'''
lst=['January', 'February', 'March']
for i in lst:
print(i[:3])
'''
Output:
Jan
Feb
Mar
'''
|
3fdc6482b269e1b4bfc1e30936b602a28bab0721 | alty-io/Reddit-Meme-Counter | /Strash.py | 6,650 | 3.90625 | 4 | '''
This algorithm takes a list of phrases, and dynamically determines
keywords for a real language referentiable hash table, to be used for
searching natural language strings for phrases without having to resort
to search for each substring.
By Tyler Sullivan and Alex Hildreth
'''
import nltk
def strash(ra... |
a083441f9cbabaa4e1b433fc0090ed2ef3a7330c | NebN/work-trip | /test/parsing/test_parsing.py | 1,827 | 3.53125 | 4 | import unittest
from datetime import date
from src.parsing import *
class ParsingTests(unittest.TestCase):
def test_parse_expense_only_amount(self):
expense = parse_expense(' 29.95')
self.assertEqual(expense.amount, '29.95')
self.assertEqual(expense.payed_on, date.today())
def test_... |
bd390da7006da137311d74bd1a06e5f13da13b97 | Daetheys/Skull | /mini/mini.py | 2,089 | 3.734375 | 4 | import random
player_turn = 0
class Won(Exception):
def __init__(self,i):
pass
class Player:
""" Player class """
def __init__(self):
self.hand = [1,0,0,0] #1-> Skull // 0-> Flower
self.won = 0
def link(self,game):
#Have a link to the game configuration
self.g... |
1ab456c3ab3a50879ec3db220d4b7230a893703d | Wil10w/Beginner-Library-3 | /Practice Test/APAAuthors.py | 2,714 | 3.84375 | 4 | #APA citation style cites author names like this:
#
# Last, F., Joyner, D., & Burdell, G.
#
#Note the following:
#
# - Each individual name is listed as the last name, then a
# comma, then the first initial, then a period.
# - The names are separated by commas, including the last
# two.
# - There is also an ampers... |
727252e35a5c4349b0b08ab306f833da542b2b37 | coremedy/Python-Algorithms-DataStructure | /Python-Algorithms-DataStructure/src/leet/113_PathSumII.py | 1,038 | 3.65625 | 4 | '''
Created on 2015-08-03
'''
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
# @param {TreeNode} root
# @param {integer} sum
# @return {integer[][]}
def pat... |
6cca7465cbf03bf08a49282f171752400134487b | alfie-mc/py-test | /Files/ifstate.py | 190 | 3.71875 | 4 | a = 52
b = 92
print("Hello and welcome to ifstate.py!")
print("'A' contains a value of 52!")
print("'B' contains a value of 92!\n")
if b > a:
print("B has a bigger value!")
|
f25cb6d8a792def137ff810de9ffd7976148d2e1 | SamuraiNights/SamuraiNights.Sublime | /Week1/Day2/Weird_Thing.py | 241 | 3.984375 | 4 | age = input("How old are you? ")
if int(age) > 11:
print("You are older than 5 years old")
print("You are in middle school")
print("Good Luck")
if int(age) > 11:
print("You are older than 5 years old")
print("You are in middle school")
|
7ae3ebea46b9b80898dd81e577a77a9b24042e08 | rafaelperazzo/programacao-web | /moodledata/vpl_data/50/usersdata/108/17908/submittedfiles/contido.py | 371 | 3.515625 | 4 | # -*- coding: utf-8 -*-
from __future__ import division
n = input ('Digite n:')
a = []
for i in range (0,n,1):
a.append (input ('Digite um elemento de a:'))
m = input ('Digite m:')
b = []
for i in range (0,m,1):
b.append (input ('Digite um elemento de b:'))
cont = 0
for i in range (0,len(m),1):
... |
55477b9b25ef0210a59e7f1a770c34578b5a309c | aslinurtaskin/SHEDIO | /_Scripts/Python_codes/picamera-with-button-test.py | 588 | 3.65625 | 4 | from gpiozero import Button
from picamera import PiCamera
from signal import pause
import time
redPin = 3
pushbutton = 4
camera = PiCamera()
def take_picture_with_button():
image_path = '/home/pi/Desktop/SHEDIO-copy/RaspberryPI/a_%s.jpg' % int(round(time.time() * 1000)) #change the path of where you want the phot... |
b4cf8f6bb48927f971b0d34a9c116484494dc473 | Chien10/coding-exercises | /2.strings/string_interning.py | 479 | 3.734375 | 4 | """
String interning is a method of storing only one copy of each distinct string value
More about string interning in Python: http://guilload.com/python-string-interning/
More about memory in Python: https://dzone.com/articles/python-memory-issues-tips-and-tricks
"""
import sys
a = 'jian'
b = 'jian'
print(a is b) ... |
49a908f58759f5ea710f42319eb6e1e26b07818a | pbs526443/Py1901Advance | /0402/demo01.py | 598 | 3.921875 | 4 | '''
通过生成器节省内存
生成器特点:后续元素由前方元素确定
通过异常捕获 捕获生成器元素获取完毕
可以使用for循环或者next遍历生成器
'''
import sys
list1 = [x for x in range(100000)]
print(sys.getsizeof(list1))
print(list1[100],type(list1))
list2 = (x for x in range(100000))
print(sys.getsizeof(list2))
list3 = (x for x in range(100))
print(sys.getsizeof(list3))
for i in li... |
769747bcde41c8da7184ac249f7cd90183b0519c | RishabhJM/cprograms | /prog1.py | 388 | 4.09375 | 4 |
givenstr=(input('enter'))
upcase=0
lwrcase=0
special=0
digits=0
for x in givenstr:
if 'a' <= x and x <= 'z':
lwrcase+=1
elif 'A' <= x and x<= 'Z':
upcase+=1
elif '0' <= x and x<='9':
digits+=1
else:
special += 1
print ('lowercase =', lwrcase,'special characters =', spec... |
84fd7cc1a61cbfc47724d5d67836d0a3edff2406 | LIEBEALLES/Algorithm | /Programmers1/Solution15.py | 718 | 3.90625 | 4 | # -*- coding:utf-8 -*-
#두 개 뽑아서 더하기
#정수 배열 numbers가 주어집니다.
#numbers에서 서로 다른 인덱스에 있는 두 개의 수를 뽑아 더해서 만들 수 있는 모든 수를 배열에 오름차순으로 담아
#return 하도록 solution 함수를 완성해주세요.
def solution(numbers):
answer = set()
print(type(numbers))
for i in range(numbers.__len__()):
for j in range(i+1, numbe... |
1377a87974852413e41e26ed3eb44621f0dc5bb8 | manognachowdary7/Turtle | /program5.py | 160 | 3.640625 | 4 | import turtle
turtle.bgcolor("white")
turtle.color("green")
turtle.pensize(1)
for angle in range(0,360,10):
turtle.seth(angle)
turtle.circle(50)
|
10531a07928234af678f76ee14d4be1d7ff961dd | inyong37/Study | /II. Book/iii. Korean/코딩셰프의 3분 딥러링, 케라스맛/Chapter_2/Chapter_2_2_Regression.py | 1,857 | 3.828125 | 4 | # -*- coding: utf-8 -*-
# Modified Author : Inyong Hwang (inyong1020@gmail.com)
# Date : 2020-07-01-Wed
# Title : 코딩셰프의 분 딥러닝, 케라스맛 Chapter 2. 케라스로 구현하는 ANN(인공신경망)
from keras import layers, models
class ANN(models.Model):
def __init__(self, Nin, Nh, Nout):
hidden = layers.Dense(Nh)
... |
85a57d5a294f10113fa34906ccc115969f63bb89 | aeseva/programming-learning | /python-grade12/notes/testing labs/testing.py | 186 | 3.53125 | 4 | def nums_one_to_ten_list():
one_to_ten_list = []
for num in range(1, 11):
one_to_ten_list.append(num)
return one_to_ten_list
a = nums_one_to_ten_list([4])
print(a)
|
0327dbbfef3325e610464bbdd97593c07e59d7c9 | wdavis40/PomodoroTimer | /Timer.py | 838 | 4.15625 | 4 | #!/usr/bin/python
import time
class PythonTimer:
# This is a python class.
# Constructor
def __init__ (self, time):
self._time_left = time
self.paused = False
self.running = False
# Returns the amount of time left on the timer
def get_time_left(self):
return self._time_left
def set_ti... |
5cbf55bb142df851073c0160520b6dd4ec49f2de | irina08/Python | /ex4/helpers.py | 2,983 | 3.734375 | 4 | #!/usr/local/bin/python3
# Creator: Irina Golovko
# Name: helpers.py
# Description: Classes, namespaces, main function
# July 7, 2018
# For pi
import math
# Use _main() for testing the module
def _main():
print("#" * 28,"\n", "Testing...1, 2, 3...testing!\n", "#" * 28, "\n", sep="")
# code to test area() ... |
9ad4092edbd7b0720eda770cabc3ccf72917575e | gutierrezfamily/calculator | /functcalc.py | 926 | 4.15625 | 4 | def addition (a,b):
x = (a) + (b)
return (x)
def subtraction (a,b):
x = (a) - (b)
return (x)
def multiplication (a,b):
x = (a) * (b)
return (x)
def division (a,b):
x = (a) / (b)
return (x)
print "________________________________"
print " THIS IS THE CALCULATOR PROGRAM"
print "_______... |
0a90db7ec2e5dc43654a6bd5f201fa49195e1790 | Vihanevend/is12-programmeerimise_algkursus | /kast2.py | 438 | 3.734375 | 4 | #!/usr/bin/env python
# -*- coding: utf8 -*-
korgus = int(raw_input("Sisestage kasti kõrgus: "))
laius = int(raw_input("Sisestage kasti laius: "))
def kast(korgus, laius):
y = 0
while y < korgus:
x = 0
y = y + 1
while x < laius:
p... |
e9c11aa1fb05d18251e643f37f217a5e7b4a390e | ganeshnischayp/IS | /lab9/cyclic.py | 765 | 3.984375 | 4 | def encrypt(pk, plaintext):
key, n = pk
cipher = ((plaintext) ** key) % n
return cipher
cipher = int(input("Enter ciphertext: "))
N = int(input("Enter N: "))
e = int(input("Enter e:" ))
append_arr = []
C1 = encrypt((e,N),cipher)
while True:
C2 = encrypt((e,N),C1)
append_arr.append(C2)
if C2 =... |
5a00d41f4945774c8bfbfa1f0de165afecc282a3 | odairlemos/Python | /exercicio_04.py | 864 | 4.03125 | 4 | """
class Troco:
def valida_troco (self, valor1, valor2):
if valor1 > valor2:
print("Troco = R$", valor1 - valor2)
else:
print("Valor que falta = R$ ", -(valor1 - valor2))
calculando = Troco()
valor_pago = int(input ("Insira o valor pago: R$ "))
preco_produto = int(input ("Insira o valor do pro... |
187955c1a17790d6af024567b0d2496f77f37ced | ProgrammerFreshers/ProgrammerFreshers | /file.py | 449 | 3.96875 | 4 |
# open file
myFile=open('myFile.txt','w+')
# get some information
print('name:', myFile.name)
print('is closed:',myFile.closed)
print('opening mode:',myFile.mode)
# write to file
myFile.write(' i love python')
myFile.write(' i am java')
myFile.close()
# append to file
myFile= open('myFile.txt','W')
myFile... |
ff2781431d486573eb566fed4212ca869a2af7ee | paige0701/studyAlone | /python/data-structures/dictionaries.py | 765 | 3.71875 | 4 | # Dictionaries
def dictionaries():
tel = {'jack': 4000, 'paige': 5000}
print(tel['jack']) # 4000
tel['jenny'] = 6000
print(tel) # {'jack': 4000, 'paige': 5000, 'jenny': 6000}
del tel['paige']
print(tel) # {'jack': 4000, 'jenny': 6000}
print(list(tel)) # ['jack', 'jenny']
print(sorte... |
bfaf0ab5d581cca4c6f17ddbfe9fe3a12092c06d | jagadeesh1414/assignment7_note.py | /assign7_prog1.py | 308 | 3.96875 | 4 | rows = 4
for i in range(0, rows):
for j in range(0, i + 1):
print("*", end=' ')
print("")
n=int(input("Enter the number of integers : "))
a=[]
for i in range(0,n):
elem=int(input("Enter integers: "))
a.append(elem)
avg=sum(a)/n
print("Average of integers in the list",round(avg,2)) |
13ea1aebf1c6571963e658e1c173741264750ddb | DnPlas/adc-softwaresystems | /lab8.1/phonebook.py | 2,746 | 3.71875 | 4 | #! /usr/bin/env python
"""
This program manages a phone book (like the yellow pages). Saved data includes:
- Name
- Email
- Age
- Country of origin
Instances can be created or deleted, all data can be accessed by email and age,
and the full record can be displayed.
Since emails are unique, this will be... |
c6880b7753d78073bd0c127d9cf668526bbb4a79 | jaganathsai/Webscrapping-and-Mongo-DB | /Web-Scraping Mongo DB/Web-Scraping-master/scrape_mars.py | 2,971 | 3.53125 | 4 | # Dependencies
from bs4 import BeautifulSoup as bs
import pandas as pd
import requests
import os
def scrape():
# Read static HTML file
file = os.path.join('NewsNASAMarsExplorationProgram', 'News_NASA_Mars_Exploration_Program.html')
with open(file) as f:
html = f.read()
# Initialize one dict to... |
90ee9dad04e8d585d8fe6cf29eec8e22429d84a9 | bermec/challenges | /stepping.py | 181 | 3.703125 | 4 | a = '123'
x = 0
while True:
slice = a[x:x + 2]
if int(slice) > 27:
print('too big')
x += 1
break
print(slice)
x += 2
#print(slice)
|
45b1f82349b9a10b491cf02ef1abdd9dd908356f | ben-eysenbach/NoteScanner | /shrink.py | 508 | 3.6875 | 4 | import numpy as np
import Image
import sys
def shrink(filename, factor=10):
'''Shrinks a given image by a given factor'''
img = Image.open(filename)
np_img = np.asarray(img)[::factor, ::factor, :]
small_img = Image.fromarray(np_img)
base, ending = filename.split('.')
small_img.save(base + '_smal... |
72938189b59a98feebfa2e65948447654489f2d3 | Larry-Nkengbeza/ICS3U-Unit-3-03-Python | /number_guessing_game_two.py | 630 | 4.15625 | 4 | # !/usr/bin/env python
# Created by Larry Nkengbeza
# Created on December 2020
# This program is a guessing game program
import random
def main():
# This function makes user guess number which will be correct.
# Input
user_guess = int(input("Enter the random number: "))
print("")
computer_answ... |
df0ca4aa204a0d317077e5546a500537db0a11ab | Clarenceeo/NLP | /chatbot/idiom_game/idiom_game.py | 3,022 | 3.65625 | 4 | # coding: utf-8
import random
class IdiomGame(object):
def __init__(self):
self.idiom_pinyin = {}
self.pinyin_idiom = {}
self.inputs = ""
self.outputs = ""
def play(self):
self.build_dict()
self.outputs = random.choice(list(self.idiom_pinyin.keys()))
... |
71cd014ea1c36e067a633602baccbb4f326e4333 | alibaizhanov/LeetCode | /BubbleSort.py | 297 | 3.890625 | 4 | n = [3,4,1,2,9,7,12,10,22,23,23,12,11]
def BubbleSort (arr):
length = len(arr)
n = 0
while length > n:
n = n + 1
for i in range(length - n):
if arr[i] > arr[i+1]:
temp = arr[i]
arr[i] = arr[i+1]
arr[i+1] = temp
return arr
print(BubbleSort(n))
|
1766d9e9f55d6e1c371c26286d5e52554a990434 | RainMoun/python_programming_camp | /day30/task1/multi_progress.py | 1,535 | 3.625 | 4 | # 在多核CPU下多进程的执行效率
import time
from multiprocessing import Process
import threading
def func_io(): # io密集型
time.sleep(2)
time.sleep(1)
time.sleep(2)
def func_cal(): # 计算密集型
result = 0
for num in range(1000000000):
result += num
if __name__ == '__main__': # 多进程和多线程下的效率对比
# 多进程下
... |
3118ed681105c1f0d010fe725c0a1cf32e2a3a79 | eeclaire/internal-displacement | /internal-displacement/scraper.py | 3,655 | 3.609375 | 4 | import newspaper
import csv
class Scraper(object):
'''Scraper that accepts a url (or urls) and returns an instance of Article
Parameters
----------
urls: a url to be scraped
Returns
-------
article: instance of Article containing body text and
'''
# Helper Functions #
de... |
6ca11dcc66d2a057caba351c5fb038f22a958c13 | henriquecl/Aprendendo_Python | /Exercícios/Lista 4.1 - Seção 7 - Matrizes/Questão 23 - Elevar matriz ao quadrado.py | 448 | 4.21875 | 4 | """
Questão 23 - Faça um programa que leia uma matriz A de tamanho 3x3 e calcule B = A²
"""
a = [[], [], []]
b = [[], [], []]
for i in range(3):
for j in range(3):
numero = float(input(f'Digite o valor equivalente a posição [{i}][{j}]da primeira matriz '))
a[i].append(numero)
for i1 in range(3):
... |
e329d72ae4b88432c778dd1fb8d1efa621e41e31 | linheimx/python_master | /oop_design_pattern/abstract_factory/elevator_example_improve_v1.py | 3,943 | 3.875 | 4 | import abc
from constant import *
class Door(abc.ABC):
def __init__(self):
self._door_status = DOOR_STATUS.CLOSED
@property
def door_status(self):
return self._door_status
def close(self):
if self._door_status == DOOR_STATUS.CLOSED:
return
self.do_close()... |
9ce7c5c897235a5cea8fce9a9db9ed351aaff9d3 | joseph-palermo/ICS3U-Unit6-05-Python | /marks.py | 1,036 | 4.3125 | 4 | #!/usr/bin/env python3
# Created by: Joseph Palermo
# Created on: December 2019
# This program calculates the average of marks inputted by the user
def calculate(list_of_marks):
# This function calculates the average of the user's marks
# Variables
mark_average = 0
# Process
for counter in list... |
9f30444c2c5110c867b415c031203a85fc38fb13 | ziolkowskid06/Python_Crash_Course | /ch04 - Working with Lists/4-04. One Million.py | 206 | 3.84375 | 4 | """
Make a list of the numbers from one to one million, and then use a for loop to print the numbers.
"""
numbers = []
for number in range(1, 1000001):
numbers.append(number)
print(number)
|
310a4464bb4fbdde0541093b0840b3e61fde3a3d | ebhose/Code-Practise | /HackerRank/Calendar Module/solution.py | 265 | 3.8125 | 4 | # Enter your code here. Read input from STDIN. Print output to STDOUT
import calendar
mm,dd,yyyy = map(int,input().split())
day = ["MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY","SATURDAY","SUNDAY"]
val = int (calendar.weekday(yyyy,mm,dd))
print(day[val])
|
15e1161a8a530d3eb6fcc944f0d000d4ace45254 | aike-s/holbertonschool-higher_level_programming | /0x03-python-data_structures/6-print_matrix_integer.py | 245 | 4 | 4 | #!/usr/bin/python3
def print_matrix_integer(matrix=[[]]):
for one in matrix:
for i, element in enumerate(one):
if (i != 0):
print(" ", end='')
print("{:d}".(element), end='')
print("")
|
9d7a81a318dd31df94ff2f0a5d557ecf7d799e2e | sqoshi/metaheuristic-alghoritms | /population_based/genetic_algorithm_agent_walk_mul/__init__.py | 11,328 | 3.75 | 4 | import random
import time
import matplotlib.pyplot as plt
import numpy as np
# from task_03.Initial import initial_solution
def follow_way_succed(board, x, y, path):
"""
Follow path and return path to entertance if found.
:param board:
:param x:
:param y:
:param path:
:return:
"""
... |
b3d0d34b63797e84ba8a099878971bfa1f575676 | bmallred/FibonacciFun | /src/mathex/fibonacci/Binet.py | 391 | 3.59375 | 4 | from math import log
phi = (1 + 5 ** 0.5) / 2
def fib(n):
'''
Find the Fibonacci number using Binet's formula.
'''
return int(round((phi ** n - (1 - phi) ** n) / 5 ** 0.5))
def fibinv(f):
'''
Inverse Fibonacci function using Binet's formula.
'''
if f < 2:
... |
2d95166a2f8cb00e0dea674d00bc03e5b2f59cb4 | pandagame2019/py_workspace | /test/student.py | 9,763 | 3.5 | 4 | import re
import os
filename='students.txt'
def menu():
'''输出的菜单'''
print('''
----------学生信息管理系统-----------
==============功能菜单===============
| 1、录入学生信息 |
| 2、查找学生信息 |
| 3、删除学生信息 |
| 4、修改学生信息 |
| 5、排序 ... |
7c832f977fc05e1c0329ac0b50e140122bb01a99 | krajat0110/DS-Algos | /DFS.py | 2,044 | 4.09375 | 4 | class Adjnode:
def __init__(self, data): #constructor to set the data in a node and generate its branches
self.vertex = data
self.next = None
class Graph:
def __init__(self, vertices): #constructor to set the total no. of nodes and create a graph of that many nodes
self.V = verti... |
9503ca4dcb09d1a5ca9cb6b93084f957e7f31261 | computingForSocialScience/cfss-homework-Amarie2016 | /Assignment5/barChart.py | 3,202 | 3.5625 | 4 | import unicodecsv as csv
import matplotlib.pyplot as plt
def getBarChartData():
#open the csv files for reading, also I switched it from artists to artist because I named my csv file wrong earlier
f_artists = open('artist.csv')
f_albums = open('albums.csv')
#read the csv files, returns an object
a... |
391f7e8de7ab3fd71a48adb803396c52e1487243 | 4ndr3w/omniros | /src/pathtest/scripts/Waypoint.py | 1,387 | 3.734375 | 4 | from math import sqrt, pow, fabs, radians, degrees, sin, cos
def distance(a,b):
return sqrt(pow(a.x-b.x, 2)+pow(a.y-b.y, 2))
def midpoint(a,b):
return Waypoint((a.x+b.x)/2.0, (a.y+b.y)/2.0)
def isBetween(a, b, c):
"Return true iff point c intersects the line segment from a to b."
return (collinear(a,... |
b8b0aca4ee4c4850a06c896f988323a659fd0e3e | dr-aheydari/Coding_Practice | /LinkedLists/ReverseLinkedList.py | 3,087 | 4.09375 | 4 | '''
Reverse a singly linked list.
Example:
Input: 1->2->3->4->5->NULL
Output: 5->4->3->2->1->NULL
Follow up:
A linked list can be reversed either iteratively or recursively. Could you implement both?
'''
# Definition for singly-linked list.
class ListNode(object):
def __init__(self, val=0, next=None):
s... |
6425ade210928771db535df0f3ec1e41887b7e4a | splogamurugan/python-learning | /example_try.py | 242 | 3.84375 | 4 | print('Which version of python you have ?')
version = input()
try:
if (int(version)>2):
print('Its quite updated one!')
else:
print('Its not an updated one!')
except ValueError:
print('Please enter a valid value')
|
861df0ea231beb31b8ecd1d7a66922798c4bec04 | Koozzi/Algorithms | /BJ/G5_13549_20210319.py | 988 | 3.53125 | 4 | from collections import deque
def find_sister(start_node, end_node):
time = [2e9 for _ in range(100001)]
time[start_node] = 0
q = deque([start_node])
while q:
current_node = q.popleft()
next_node_1 = current_node - 1
next_node_2 = current_node + 1
next_node_3 = current_n... |
d6d6a7555dd36eaef1cd1988f90148f3648ebe28 | curest0x1021/Python-Django-Web | /Tan_ShinYi/Assignments/Python_Fundamentals/Scores_And_Grades.py | 749 | 3.90625 | 4 | scores=[]
def scores_and_grades():
for counter in range(0,10,1):
score=raw_input('Please enter a test score (60-100): ')
while int(score)>100 or int(score)<60:
score=raw_input('Error: Incorrect Input. Please enter a test score (0-100): ')
score = int(score)
scores.append... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.