blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
6102d68bb9ca862f8b22ecd8d7b2b3bd47889764
achkataa/Softuni-Programming-Fundamentals
/Dictionaries/2.A Miner Task.py
296
3.84375
4
command = input() result = {} while command != "stop": quantity = int(input()) if command in result: result[command] += quantity else: result[command] = quantity command = input() for key, value in result.items(): print(f"{key} -> {value}")
badee42efb7aa5ce62a9fc6d05d126d7d3c744df
ariel98po/SC101-projects
/SC101/SC101_week4/factorial.py
463
4.25
4
""" File: factorial.py Name: -------------------------- This program shows what a recursion is by implementing factorial function """ def main(): print(factorial(0)) # 1 print(factorial(1)) # 1 print(factorial(5)) # 120 print(factorial(10)) # 3628800 def factorial(...
1466ed416af5a477521976b16159374cb6f955ad
LegolasShaw/codeExercise
/code4.py
525
3.6875
4
# -*- coding:utf-8 -*- #题目描述 #用两个栈来实现一个队列,完成队列的Push和Pop操作。 队列中的元素为int类型。 class Solution: stack1 = [] stack2 = [] def push(self, node): self.stack1.append(node) def pop(self): if len(self.stack2) == 0: while len(self.stack1) > 0: node = self.stack1.pop(-1) ...
2938673b84fde03adf0bee7e0fa58a33e0288a09
lulzzz/Artificial-Inteligence-for-Robotics
/Lesson 1/test.py
3,432
3.65625
4
#Code for a very simple example of discrete localization #Uses both sensorial information represented by the sense #function as well as simulates movement of the robot through #function move. # n=5 # p=[1./n]*n # p=[0,1,0,0,0] # pHit = 0.6 # pMiss = 0.2 # pExact = 0.8 # pOvershoot = 0.1 # pUndershoot = 0.1 # # world=[...
b2ada6fa159712d6d9434249a3ebce512911440c
SergioCifuentes/alien_invasion
/ship.py
1,570
3.96875
4
import pygame from pygame.sprite import Sprite class Ship(Sprite): """A class to manage the ship""" def __init__(self, ai_game) -> None: """Initialize the ship and set its starting position""" super().__init__() self.screen = ai_game.screen self.settings =ai_game.settings ...
b5e02ccf796d0efe415d571f01fcd8ef3b8c4c3a
avnayak/Data_Structures_Algorithms
/Data_Strcutures_and_Algorithms/Search/insertionSort.py
399
3.796875
4
class insertionSort: def insertionSort(self): arr=[2,5,1,89,54,23,677,78] for i in range(1,len(arr)): j=i-1 while j>=0: if arr[j]>arr[j+1]: arr[j],arr[j+1]=arr[j+1],arr[j] j-=1 ...
800ed55e25d670cd40539e8d018be3559244be34
shakirul15-311/URI
/1165.py
295
3.96875
4
import math def is_prime(n): if n%2 == 0 and n>2: return False return all(n%i for i in range(3,int(math.sqrt(n))+1,2)) T = int(input()) for _ in range (T): n = int(input()) if (is_prime(n)): print('%d eh primo' %n) else: print('%d nao eh primo' %n)
f25cce5d56ce3bbc24200724f8a40a0ed5b93e73
siddharth20190428/DEVSNEST-DSA
/DA010_Subsets-II.py
472
3.984375
4
""" Given an integer array nums that may contain duplicates, return all possible subsets (the power set). The solution set must not contain duplicate subsets. Return the solution in any order. --------------- Constraints 1 <= nums.length <= 10 -10 <= nums[i] <= 10 """ def subsetsWithDup(nums): if len(nums) == 1...
0423791695f9d116f940f35c94b163967ce55488
TripTheThird/general
/mad_libs.py
792
4
4
adjective = input('Adjective: ').lower() animal = input('Animal: ').lower() verb = input('Verb: ').lower() exclamation = input('Exclamation: ').capitalize() verb2 = input('Another Verb: ').lower() verb3 = input('Another Verb: ').lower() name = input('A Name: ').upper() print("\nHere is your finished mad lib!") print(...
78055e891b35b3a5ff080d8a97fe4bfc3ef1606e
KOP604/Python-Place
/Exercises_with_solutions041.py
1,959
3.921875
4
# coding: utf-8 # # Student Alcohol Consumption # ### Introduction: # # This time you will download a dataset from the UCI. # # ### Step 1. Import the necessary libraries # In[24]: import pandas as pd import numpy # ### Step 2. Import the dataset from this [address](https://github.com/guipsamora/pandas_exercis...
03ed28f1d9da782d6cfbebe6c8d0a3986ea42e6b
pyhunters/Challenges
/Week3/challenge1.py
2,571
4.375
4
''' hello Dear hunters Todays' our challenge is : Write a Python program to create the multiplication table (from 1 to 10) of a number that has been taken from the user . أكتب برنامج يقوم بإنشاء جدول الضرب من 1 الى 10 لعدد يقوم بإدخاله المستخدم مثال input 6 output ...
a32b29b548ab4d9a1ddba67d64037312777e42c2
jdhouti/Dame
/src/file_name_generator.py
1,104
3.796875
4
# generator.py - This file contains the functions that generate the names for the # files generated in the data_analysis.py file. # Author: Julien Dhouti import random class Name_Generator(object): def generate_name(self, filepath, column, analysis): """Generates a name for a given filepath filep...
a203a5869bfe4c03bb1aa6528f1b76b3731f81e6
robert-bayer/CPSCIClassWork
/Module12ClassActivity4_Robert_Charles.py
3,892
3.53125
4
#Pobert Bayer and Charles Charter #Module 12 Class Activity 4 #Finds number of duplicate words in a sentence ... writes a check amount given in numbers in letters import random def dupword(sentence): newsentence = sentence.upper() sentlist = newsentence.split() sentlist.sort() word = "" f...
6fdec0227faee6ce99783bd254526717c814cf8d
ShumbaBrown/uFlow-deprecated
/graph.py
582
3.53125
4
import turtle def graphPoints(coords): myTurtle = turtle.Turtle() theta = 360 / len(coords) myTurtle.seth(0) for i in range(len(coords)): myTurtle.goto(0, 0) myTurtle.seth(i * theta) myTurtle.begin_poly() myTurtle.fd(200) myTurtle.end_poly() myTurtle.pen...
cb264178744921ff400330c57798a40f76e41bd6
ArnoldTingSu/python
/OOP/user_banking.py
1,528
3.71875
4
class User: def __init__(self, username, email_address): self.name = username self.email = email_address self.account_balance = 1000 self.wallet = 1 def make_deposit(self, amount): if amount > self.wallet: print("not enough money to deposit") ...
04f20dfaa47935d0397bf625c5f9849f0460890d
eechoo/Algorithms
/LeetCode/PopulatingNextRightPointersinEachNode.py
854
3.96875
4
#!/usr/bin/python # Definition for a binary tree node class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None self.next = None class Preorder(object): # @param root, a tree node # @return nothing def connect(self, root): if(root =...
1bf9f51e7300375c3a47f88caf62de9cfd2f35c0
romulovieira777/Programacao_em_Python_Essencial
/Seção 04 - Variáveis e Tipos de Dados em Python/Exercícios da Seção/Exercício_25.py
386
3.96875
4
""" 25) Leia um valor de área em acres e apresente-o convertido em metros quadrados m². A fórmula da conversão é: M = A*4048.58, sendo M a área em metros quadrados e A a área em acres """ acres = float(input('Enter the value of the acres: ')) square_meters_area = round(acres * 4048.58, 2) print(f'The value of the acre...
75fbb870dd47fbee7e37f508ac3a4d6bbe0f64cc
slavaGanzin/ramda.py
/ramda/min_by.py
229
3.625
4
from toolz import curry @curry def min_by(f, x, y): """Takes a function and two values, and returns whichever value produces the smaller result when passed to the provided function""" return x if f(x) < f(y) else y
3a00eb957de60f1ffc35518ff5f5043d28ba866b
yashsaluja/python-programing
/binary_search.py
390
3.96875
4
def binarySearch(list, item): first = 0 last = len(list)-1 found = False while first<=last and not found: midpoint = (first + last)//2 if list[midpoint] == item: found = True else: if item < list[midpoint]: last = midpoint-1 ...
1f009feaefd7e7c929cc118f5a07087c828d3e1b
zcybupt/leetcode
/081_search_in_rotated_sorted_array_ii/Solution.py
750
3.578125
4
class Solution: def search(self, nums: list, target: int) -> bool: # return target in nums arr_len = len(nums) l, r = 0, arr_len - 1 while l <= r: while l < r and nums[l] == nums[l + 1]: l += 1 while l < r and nums[r] == nums[r - 1]: r -= 1 mid = ...
aeacfd0bef3746c6e58cc02adebeeb531766e025
dkatragadda/Election_Analysis
/PyPoll.py
3,681
4.21875
4
# Election Data Analysis # Open the dataset # Calculate the total number of votes cast # Compile list of candidates who received votes # Calculate total number of votes received by each candidate # Percentage of votes each candidate won # Determine the winner of the election based on popular vote # Importing packages ...
aa0c6497d8b76aa9e47e0bcfa1c283ed4ce60bcf
lonzor/holbertonschool-higher_level_programming
/0x0B-python-input_output/10-student.py
888
3.796875
4
#!/usr/bin/python3 """ Module contains the class Student. Instantiates object with first_name, last_name, and age. Returns dictionary description of Studen object (JSON). """ class Student: """ Definition of class Student. """ def __init__(self, first_name, last_name, age): """ Initia...
b292d2fb1f58eaedd2313a05b1f1734b134f60eb
Snehal2605/Technical-Interview-Preparation
/ProblemSolving/450DSA/Python/src/dynamicprogramming/MinimumNumberOfJumps.py
1,085
3.90625
4
""" @author Anirudh Sharma Given an array of non-negative integers nums, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Your goal is to reach the last index in the minimum number of jumps. You can assume that you can alwa...
12db9fc05b2d71ab2bfeb697000d5a4705d561b0
clickok/Code-Snippets
/Python-Programming/tuple_math.py
3,853
4.3125
4
""" Routines for doing math with tuples. """ import operator from numbers import Number # Example use of map and operator methods def tuple_add(a, b): return tuple(map(operator.add, a, b)) def tuple_div(a, b): return tuple(map(operator.truediv, a, b)) def tuple_mul(a, b): return tuple(map(operator.mul,...
9cdab069dfd6ae0b025d34d1426f1edba67cffbe
ddubbu/AI-Study-with-python
/0. Algorithm/[Jan_week4] Allergy/combination.py
911
3.90625
4
# 문제의 코드 def combination(m, k): # 0~m-1 까지의 숫자 중에서 k개를 추출할 수 있는 경우의 수 list_num = list(range(0, m)) print("list is", list_num) result = [] print("m: %d, k: %d" % (m, k)) def generate(chosen): if len(chosen) == k: print("chosen is", chosen) print("before result ...
407429839624bc5619c63183f587d28b00b2c6c2
cleiton016/Codigo-Encoinfo
/lpoo Encoinfo.py
6,255
3.640625
4
import random class Pessoa: def __init__(self,nome): self.nome=nome class Inscricao: def __init__(self): self.valor=0 class Inscricao_de_Aluno(Inscricao): def __init__(self,univercidade): super().__init__() self.valor=50 self.univercidade=univercidade clas...
c806c3b8046fa97ce0653e823e6336600c6925e1
sugam74/365programs
/sumit/kadene.py
458
3.625
4
# Kadene's Algorithm def kadene(arr): max_so_far = 0 max_ending_here = 0 for i in range(len(arr)): max_ending_here = max_ending_here + arr[i] if max_ending_here < 0: max_ending_here = 0 elif max_so_far < max_ending_here: max_so_far = max_ending_here re...
365bd869bed490a4532815091748d8bab7a9943e
MACHEIKH/Datacamp_Machine_Learning_For_Everyone
/22_Advanced_Deep_Learning_with_Keras/3_Multiple_Inputs_3_Inputs_and_Beyond/plottingModels.py
520
3.59375
4
# Plotting models # In addition to summarizing your model, you can also plot your model to get a more intuitive sense of it. Your model is available in the workspace. # Instructions 1/4 # 35 XP # Save the model plot to the file 'model.png'. # Import and display 'model.png' into Python using matplotlib. # Imports impo...
ff2eaad0f7b7027bd84106cc5b7799a68d19f565
delafields/Algos-Datastructs
/DataStructures/Graphs/path_exists.py
3,141
4.0625
4
''' Determine whether there is a path between two nodes in a graph Constraints The graph is directed Assume we already have a Node and Graph class Assume this is a connected graph Assume inputs are valid Assume it fits in memory Test Cases Input: add_edge(source, destination, weight) ...
583a8fd12e576bac1f97776318ae9ec6d733f640
MariiaBurda/LITS
/homework2/count_holes.py
533
3.703125
4
def count_holes(input_num): try: input_num = str(input_num) input_num = int(input_num) input_num = str(input_num).lstrip('0').lstrip('-') sum_of_numbers = 0 dict_of_numbers = {'0': 1, '4': 1, '6': 1, '8': 2, '9': 1} for i in input_num: sum_of_numbers += d...
ae573d88046dae51ecf212f7af0fbcc360d6975c
PollobAtGit/python-101
/oj/leet_code/leet-code-203.py
1,470
3.78125
4
# Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def removeElements(self, head, val): """ :type head: ListNode :type val: int :rtype: ListNode """ if head: ...
fd07c3537fc762f7c62a4fed182c943e439f19dd
AdamZhouSE/pythonHomework
/Code/CodeRecords/2126/60708/306062.py
110
3.859375
4
s=input() if(s=="1,2,3"): print([1,2]) elif(s=="1,2,4,8"): print([1,2,4,8]) else: print([2, 4, 8])
0110efcaab011d6cf815b2438f18663fce70bac6
liugingko/LeetCode-Python
/Leetcode/LeetCode2/862. Shortest Subarray with Sum at Least K.py
785
3.515625
4
import collections class Solution(object): def shortestSubarray(self, A, K): n, dp = len(A), [0] # 初始化dp[i] = A[0]+A[1]+...+A[i-1] for v in A: dp.append(dp[-1] + v) queue, res = collections.deque(), n + 1 # 初始化队列、结果变量 for i in range(n+1): while queue and dp[i] <= dp...
889142530f25951d10fb0eb701143213636f54c8
wangfaping0707/PythonProject
/Basic_Python/chapter9/demo9.6.py
2,539
4.4375
4
""" python中的迭代器详解: 1.迭代是什么? 我们知道可以对list,tuple,dict,str等数据类型使用for...in的循环语法,从其中依次取出数据,这个过程叫做遍历,也叫迭代。迭代是访问集合元素的一种常用的方式。 2.可迭代对象是什么? 简单来说,可以用for...in循环语句,从其中依次取出数据的对象,就是可迭代对象。例如,列表、元组、字典、字符串都是可迭代对象。整数、浮点数、布尔值都是不可迭代的。 3.迭代器是什么? 在可迭代对象进行迭代的时候,即用for...in...循环语法依次取出数据时,过程是怎样的呢? 我们发现,每迭代一次(即在for...in...中每循环一次)都会返回对象中的下一条数据...
391db084f736b5eb88cb1672678a993dca662306
naoyat/hebrew
/hebrew/root.py
973
3.53125
4
#!/usr/bin/python # -*- coding: utf-8 -*- class Root: def __init__(self, letters): if isinstance(letters, str): if len(letters) != 3: self.letters = letters.split(' ') else: self.letters = letters else: self.letters = letters ...
eb7baccc0b97f4312edc18b62d8b97823b63a3c5
ostrodivski/awake-gdq
/awake_gdq/schedule.py
3,443
3.6875
4
#!/usr/bin/python3 ## the class schedule consists of a basic structure of chained list ## [entry_1] <-> [entry_2] <-> ... <-> [_] ## the last entry is always empty ## there's no implementation of addition, deletion or substitution because we don't need them class Schedule : def __init__(self, identified = Tru...
2244dfcbda336bd43f122d83868f9da6b8570a9a
truongquang1993/truongvanquang-Fundamentals-c4e26
/SESSION1/Homework/Bai2.py
69
3.8125
4
import math r = int(input("Radius?")) print("Area:", math.pi * r * r)
3ce559586b5d77b3c168ab9177daa65061afbea4
messier16/m16_mlutils
/m16_mlutils/pipeline/DataFrameSelector.py
663
3.53125
4
from sklearn.base import BaseEstimator, TransformerMixin # A class to select numerical or categorical columns # since Scikit-Learn doesn't handle DataFrames yet # From: https://github.com/ageron/handson-ml/blob/master/02_end_to_end_machine_learning_project.ipynb class DataFrameSelector(BaseEstimator, TransformerMixi...
0c0ca85281c9646161c8e109709a7c2f0d067855
baraksamesh/CVCursor
/mouse_control.py
689
3.5625
4
from pynput.mouse import Button, Controller class mouse_control: mousec = Controller() def _init_(self): mousec = Controller() (cord_x, cord_y) = mousec.position def move_mouse(self, x, y): self.mousec.move(x, y) def gesture(self, kind): if kind == 'rig...
834c27928f121fd65799e589e06518c4a286af64
ppsirg/gl_tryout
/e5.py
1,421
4.25
4
""" Write a python program in an object-oriented way to achieve the following: Below there’s an example of how it should work, see it carefully: > mylist = List() > mylist.append(1).append(2).append(3).append(4).append(5) > list(mylist.items()) [1,2,3,4,5] > list(mylist.map(lambda x: x*x).items()) [1, 4, 9, 16, 25] > l...
388692e51c2104f9a34be5584d4321b10ce76260
LauraBerry/Assignment-2-haptics
/A2.py
1,100
3.578125
4
#http://theatticlight.net/posts/Reading-a-Rotary-Encoder-from-a-Raspberry-Pi/ #http://www.allaboutcircuits.com/projects/building-raspberry-pi-controllers-part-5-reading-analog-data-with-an-rpi/ #http://www.hertaville.com/interfacing-an-spi-adc-mcp3008-chip-to-the-raspberry-pi-using-c.html #https://www.raspberrypi.org/f...
cd40b8301ed07579cef4877c54ca01bff77c2ecb
casper1403/Reference-Scripts
/MathScripts/randommaths.py
666
3.75
4
import random from statistics import mean """Script that calculates the average number of RGN needed to count up to one""" # Function which sets a counter and a number and returns the times the random function needed to be called to add up to 1 def random_maths(): counter = 0 number = 0 while number <= 1...
6f1039941a470211c6144c27686e222eee7fd395
SaintsZhang/python-data-analytic
/Python-All/saints/python/Basics.py
1,257
3.9375
4
# -*- coding: utf-8 -*- #from math import exp, floor, ceil # this is the first comment ''' a block of comment + - * / // # floor division discards the fractional part % # returns the remainder of the division ** # the powers abs, exp floor, ceil 3 * 'abc' # 'abc' repeated 3 times len(s) str rang...
2051ba50aafe32ab532cda430b6875ee2112a449
yujie6/MLsystem
/FashMnist/LinearX.py
1,388
3.546875
4
from tensorflow.examples.tutorials.mnist import input_data import numpy as np def ComputeSingleCost(theta, X, b_, y): m = len(y) h = np.matmul(X, theta) + b_ return -1 / m * (np.dot(y, np.log(h)) + np.dot((1 - y), 1 - np.log(h))) def ComputeGrad(theta, X, b_, y): h = np.matmul(X...
d29683ba7e66be421a14eabf06e6063a20b85363
catarinafonseca/PythonIsEasy
/lectures/ifstatements.py
530
4.125
4
# Basic structure of an if statement """ if condition: Action """ click = False Like = 0 click = True if click == True: Like += 1 click = False # print(Like) Temperature = 30 Thermo = 15 # print(Thermo) if Temperature <= 15: Thermo += 5 # print(Thermo) if Temperature >= 20: Thermo -= 3 #...
fc178863c00809125b80d149adbebd92898caa3d
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_118/2235.py
481
3.59375
4
import sys import math import pdb def isPalindrome(n): return str(n) == str(n)[::-1] T = int(sys.stdin.readline().strip()) for i in range(T): (A, B) = [int(j) for j in sys.stdin.readline().strip().split()] count = 0 for n in range(A, B+1): if isPalindrome(n) : sqrt = i...
2e687de7f1bddf9d30ef34bd24d1c217ba2428fb
Anirban2404/LeetCodePractice
/743_networkDelayTime.py
2,764
3.8125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Jul 26 09:59:28 2019 @author: anirban-mac """ """ 743. Network Delay Time There are N network nodes, labelled 1 to N. Given times, a list of travel times as directed edges times[i] = (u, v, w), where u is the source node, v is the target node, and w ...
25984065c4741a6050859077ad4d0a826ee31141
mariaminoiu/Licenta
/python/egresie.py
4,301
3.546875
4
# -*- coding: utf-8 -*- """ Created on Mon Jun 1 10:58:58 2020 @author: maria """ # Pandas is used for data manipulation import pandas as pd # Read in data as pandas dataframe and display it df = pd.read_csv('DF.csv') print(df) print('The shape of our features is:', df.shape) # Descriptive statistic...
8a7e029dc39898052bc007e5eafe49e4c9ff0132
onlyu4/LY
/Study/购物车.py
1,079
3.53125
4
data = [("iphone x max" , 8888), ("macbook" ,12888), ("华为p30 pro",6999), ] shopping_list = [] recharge = input("请输入您要充值的金额:").strip() if recharge.isdigit(): recharge = int(recharge) while True: for k,v in enumerate(data): #打印列表的下标 print(k,v) user_input = input("请输入您要购买的商品编号:") ...
22c12377c175c6b4fd87da817675f8f282ef9f4a
MHM18/hm18
/hmpro/xuyiheng/a18_2_5/test1.py
112
3.90625
4
num = input('输入一个数字') num =int(num) if (num%2) == 0: print("偶数") else: print("偶数")
a3b971e74ea66a67c909f6251819facf73857125
guilhermepirani/100daysofcode
/day001/inputexercise/input_exercise.py
155
4.40625
4
'''Write a program that prints the number of characters in a user's name.''' user = input('Enter your name: ') print(f'Your name has {len(user)} letters')
c522cf721d99138c2e57113fb084668d09c20688
MrHamdulay/csc3-capstone
/examples/data/Assignment_3/mphmam013/question1.py
232
4
4
# assignment 3 # Mphuthi mamorena # queation 1 def main(): n=eval(input("Enter the height of the rectangle: \n")) l=eval(input("Enter the width of the rectangle: \n")) for i in range(n): print("*"*l) main()
8f61c6c5f24c0baeb88ca417ea5e1b79f1c32713
kwhit2/holbertonschool-higher_level_programming
/0x0B-python-input_output/12-pascal_triangle.py
504
4.15625
4
#!/usr/bin/python3 """ Technical interview preparation: Create a function def pascal_triangle(n): that returns a list of lists of integers representing the Pascal’s triangle of n: """ def pascal_triangle(n): """ pascal_triangle method: Args: n (int) Returns: A list ...
614fd2c2bf6a9fea09c8b81cd968bc83bc536023
PRkudupu/Algo-python
/array_strings/py/stack_op.py
498
3.90625
4
#!/usr/bin/env python # coding: utf-8 # In[5]: def stack_op(): stack =[] stack.append("open") stack.append("close") print("stack[0] ",stack[0]) print("stack[1] ",stack[1]) #Remove the item at the given position in the list, and return it. #If no index is specified, a.pop() removes an...
3271b5988aa85e1972a7f6051f2f6eea718167d2
kyungguyeo/MIDSw205_Exercise2
/EX2Tweetwordcount/histogram.py
644
3.765625
4
from sys import argv import psycopg2 def hist(k1, k2): """ Takes in 2 numbers as sys arguments and outputs all word-count pairs that is greater than or equal to the smaller number and less than the second number. """ conn = psycopg2.connect(database="tcount", user="postgres", password="password", host="localhost",...
7aea03e0b3284332e944f4cd03846adf48fc8466
bishnusilwal/python-files
/1.print_the_sum_of_three_numbers.py
525
4.40625
4
#Lab_Exercise_1 # Q1. Write a program that takes three numbers and prints their sum. Every number is given on a separate line. print("This program takes three numbers from you and print the sum of the numbers") firstNum = float(input("Enter the first Number")) secondNum = float(input("Enter the first Number")) thirdNu...
a0cf419cf40deb8909ceec62072931f6a9bf0497
flaviaalexandra11/lectii-python
/ex-turtle/exercitii/turtle_sticker.py
1,157
4.375
4
""" Ex: Turtle stickers Sa se citeasca o culoare (rosu, galben, verde, sau albastru) si o forma pentru cursor (in limba romana) si apoi sa se deseneze, folosind turtle, minim 3 stampile pe ecran cu forma si culoarea cerute de utilizator. """ import turtle culoare = input("Intruduceti culoarea: ") form...
1f736cca98619ed2bd7a200407da2a6e4f2a0b93
alifsyr/Code_Playlist
/python/H05_16519080_03.py
62
3.734375
4
n = [1,2,3] len = 0 for i in n: len = len + 1 print(len)
430432f8508de3e84e6a748f8d251c51f37eecea
bokyungJ/this_is_coding_test
/implementation/4_3_왕실의나이트.py
504
3.625
4
now = input() now_list = [] cols = 'abcdefgh' for i in range(len(cols)): if now[0] == cols[i]: now_list.append(i+1) now_list.append(int(now[1])) # 우우상, 우우하, 좌좌상, 좌좌하, 상상좌, 상상우, 하하좌, 하하우 dx = [2, 2, -2, -2, -1, 1, -1, 1] dy = [-1, 1, -1, 1, -2, -2, 2, 2] count =0 for i in range(8): nx = now_l...
d22c889b21b0abb50f6035de2e20b93906fa17ce
It5Me/Datastructure
/recursion/hanoi.py
910
3.71875
4
def move(n,A,B,C): if n > 0: move(n-1,A,C,B) l[C-1].append(l[A-1].pop()) print("move",n,"from ", chr(ord('A')+A-1), "to", chr(ord('A')+C-1)) print("| | |") printall(l[0], l[1], l[2], size) move(n-1,B,A,C) def printall(a,b,c,x): if x == 0: return else...
05069fe681c2debf2f4a5927c384674fc5e1ba6c
valar-m0rghulis/Python
/Infosys-Foundation-Program/MODULES/Module_1_Programming_Fundamentals/Assignment44.py
633
3.671875
4
import time print(time.time()) print(time.localtime()) print(time.localtime(time.time())) print(time.asctime()) mytime = (2016,7,27,15,45,23,0,0,0) print(time.localtime(time.mktime(mytime))) ''' OUTPUT : 1538244789.969973 time.struct_time(tm_year=2018, tm_mon=9, tm_mday=29, tm_hour=23, tm_min=43, tm_sec=9, tm...
8a2716c384b11c15d580bcc2070a18249809e0b2
kiminhan/Python
/inhan/문제18.py
725
3.765625
4
def check_number(a): if a % 10 == 0: print("10의 배수입니다.") elif a % 10 != 0: print("10의 배수가 아닙니다. 멍청아") while True: a = (int(input("숫자를 입력하세요 : "))) if a == -1: print("프로그램을 종료합니다.") break check_number(a) # while True: # number = (int(input("양수를 입력하세요 : "))) # ...
7b36dac8e8d721792c803f9a596983887b3c8789
magcurly/Data_Structure
/Homework-Part3/homework1.py
1,770
3.59375
4
class Stack: def __init__(self): self.list=[] def IsEmpty(self): if len(self.list)==0: return True else: return False def Push(self,x): self.list.append(x) def Pop(self): if not self.IsEmpty(): return self.list.pop(le...
f6717f2381ca703bae087c7d9845b37512e0f00c
Lisser/python-training
/8.py
573
3.59375
4
# !/usr/bin/env python3 fname = "limerick.txt" f = open(fname, "rb") linecount = 0 wordcount = 0 charcount = 0 bytecount = 0 for linebuf in f: linecount += 1 wordcount += len(linebuf.strip().split()) charcount += len(linebuf.decode('utf-8')) bytecount += len(linebuf) print(linebuf) f.close() p...
32982d323b4d59b26e19ce04d4c17c05a11ff246
Ramoo25/projecteuler
/T_4.py
577
3.5625
4
import time def is_palindrome(x): s = str(x) if len(s)%2==0: s1 = s[:len(s)//2] s2 = s[len(s)//2:] s2 = s2[::-1] else: s1 = s[:(len(s)-1)//2] s2 = s[(len(s)-1)//2+1:] s2 = s2[::-1] if s1==s2: return (True) else: return (False) start_t...
83d8dd9ee8cc1e93c047eba19242114a018a3727
manunag/GUVI
/beg_s1_q7.py
112
3.765625
4
a=input() if a.isalpha(): print("Invalid") else: a=int(a) for i in range(a): print("Hello")
f2384ddd459c7e19eba4e44471b94a5509e2bd36
wan-si/pythonLearning
/nowcoder/sortStr.py
155
3.71875
4
num=int(input()) lst =[] for i in range(num): lst.append(str(input())) # lst.sort() # for i in lst: # print(i) for i in sorted(lst): print(i)
86589d75bb7e890ecfb65254309d59f7c9ff8fc9
Samuel1043/leetcode
/code/637.py
916
3.59375
4
import collections # 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 averageOfLevels(self, root: TreeNode) -> List[float]: q=collections.deque([(ro...
2eb515c3d1ccc85c7ae7a2604f187adfd4060eac
supercavitation/Compsci
/CompSci class stuff(ignore)/moreLoops.py
152
3.9375
4
#Joshua Bloch #2/19/13 #more loops ##import math ##for i in range (1,11): ## print math.sqrt(i) ## name= 'Joshua Bloch' for ch in name: print ch.upper()+'!'
3e7901ac883c14a2b857f5e18a0a74509e7451da
MStevenTowns/Advanced-Data-Structures
/Homework04/BuildTree.py
307
3.890625
4
import BinaryTree def buildTree(list): for i in range(0, len(list)): if(i==0): r=BinaryTree.BinaryTree(list[0]) elif(i>0 and i%2==0): r.insert_left(list[i]) else: r.insert_right(list[i]) return r list=[1,2,3,4,5] r=buildTree(list) r.inOrder() print() r.postOrder() print() r.preOrder()
3f85f2ec1ea9798986af51a2e0a53b85200448f4
bravocharliemike/comp_sci
/programming_principles/module_7/username_gen.py
1,189
3.78125
4
import pprint students = { 60254: 'John Smith', 60255: 'Gert Du-Cart', 60256: 'Sun Po', 60257: 'Bort Woods', 60258: 'Andrew Butters', 60259: 'Betty Ho' } # ------ Begin program ------- usernames = dict() for k, v in students.items(): v = v.lower().replace('...
c2821cc94f7e514a7d39d49b38cdc457e769a6f3
bmk316/daniel_liang_python_solutions
/4.26.py
193
3.9375
4
a, b, c = eval(input("Enter 3 positive integers: ")) if a == c: print(str(a) + str(b) + str(c) + " is a palindrome") else: print(str(a) + str(b) + str(c) + " is not a palindrome")
3229b9c79580884264219ff4482b2e6536f3c9eb
lucasptcastro/projetos-curso-em-video-python
/ex072.py
444
3.84375
4
numeros = ('zero','um','dois','três','quatro','cinco','seis','sete','oito','nove','dez','onze','doze','treze','quatorze','quinze','dezesseis','dezesete','dezoito','dezenove','vinte') n1 = int(input('Informe um número entre 0 e 20: ')) for c in numeros: if n1 > 20: n1 = int(input('Tente novamente! Informe um...
fdb169ea59d316f5c07026c5b04afe4d1be202d6
elenaborisova/Python-Fundamentals
/10. Lists Advanced - Exercise/10_inventory.py
1,027
4.09375
4
def is_item_in_list(items, item): if item in items: return True return False def collect(items, item): if not is_item_in_list(items, item): items.append(item) def drop(items, item): if is_item_in_list(items, item): items.remove(item) def combine(items, item): old_item, ...
c2bc5ebb65114ed24b83e52c3419e7e2a1c4cb73
PdxCodeGuild/class_Binary_Beasts
/Students/bobby/python/lab_13.py
649
4.3125
4
conversion = { # Dictionary holding my key value pairs 'feet': 0.3048, 'mile': 1609.34, 'meter': 1, 'km': 1000, 'yard': 0.9144, 'inch': 0.0254 } distance = float(input('What is the distance you wish to convert? ')) # input for distance unit_from = input('What is the unit you would like to conve...
65f17737361231ed9e900ae2208051ce9a9f73e5
marzsolt/juicethirstyfruitwarriors
/src/utils/Timer.py
811
3.515625
4
class Timer: """" Timer that executes a function in a clock signal count delayed ticks. Needs setup i.e. giving a clock signal by calling its update function periodically. """ sch_list = [] @staticmethod def sch_fun(delay, fun, arg): """" Schedule a function. """ Timer.sch_l...
289907c8b7beeeaa4ac23382bb74517d779bebf7
libowei1213/LeetCode
/151. Reverse Words in a String.py
322
3.75
4
class Solution(object): def reverseWords(self, s): """ :type s: str :rtype: str """ s = s.split() size = len(s) return " ".join([s[size - i - 1] for i in range(size)]) if __name__ == '__main__': r = Solution().reverseWords("the sky is blue") print(r...
d70249def15cba71b81ee2e46f982964d6c0b37f
Carnivictid/rpggame
/townhubs.py
1,869
3.625
4
import map import items import npc import random import enemies class MapTile: # May have to call the player class so we can change quest statuses. def __init__(self, x, y): self.x = x self.y = y self.enemy = [] def intro_text(self): raise NotImplementedErro...
6291a6698cad0ded501e67e9a95fdf05b148134b
taylor-swift-1989/PyGameExamplesAndAnswers
/examples/minimal_examples/pygame_minimal_color_lerp_2.py
1,262
3.875
4
# How to fade from one colour to another in pygame? # https://stackoverflow.com/questions/51973441/how-to-fade-from-one-colour-to-another-in-pygame/68702388#68702388 # # GitHub - PyGameExamplesAndAnswers - Color # https://github.com/Rabbid76/PyGameExamplesAndAnswers/blob/master/documentation/pygame/pygame_color.md im...
0b73f49f4c70592cc1025a518d24eeb52c636629
sunilvarma9697/Code-Basics
/Types_of_variables.py
335
3.71875
4
#types of variables - 1. Instancec variable, 2.Static variable #Instance variable #Class variable class Car: wheels = 4 def __init__(self): self.milage = 10 self.comapny = "BMW" c1 = Car() c2 = Car() c1.milage = 3 Car.wheels = 4 print(c1.comapny,c1.milage,c1.wheels) print(c2.comapny,c2.mi...
f41e10f3d46a3ca4ab8fe8832a46426301ae01d4
ryanhoang15/Python
/4.11 Lab Ch04: Convert a number to its month name.py
436
3.96875
4
# Define constants. ##### Use the given variable "NAMES" as is, and DO NOT CHANGE its type, format and contents ####### NAMES = "January, February March April, May June July August September October November December " NAMES = NAMES.replace(","," ") NAMES = NAMES.split() num=int(input("E...
d21226ff7858b6e72aa8c33af994fe9e9275b95f
Bruce168/untitled
/02hello.py
470
3.8125
4
# hello print("hello python") """ 多行注释注释(感觉不够只能呢) """ print("注释") ##对不起连续输出三次 print("对不起 " * 3) ###两个*可以乘方计算 print(2 ** 3) ##格式化输出 name ="Bruce" print("我的名字叫 %s" % name) age=20 print("我今年 %d岁" %age) height=1.78 print("身高 %.2f米" % height) ##在字符中如果要打%,就得用%%的方式 life=0.25 print("人生轨迹刚开始 %.2f %%" %(life*100))
30c4f6c235c877eab48506bc453196af6719c0eb
yingthu/MySandbox
/1_tree/LC250_Count_Univalue_Subtrees.py
1,085
3.765625
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution(object): def countUnivalSubtrees(self, root): """ :type root: TreeNode :rtype...
1ca1c614c6ef1461ce80f031d8912bf2c654fc90
CodeInteresting/PythonPlayGround
/2021_09_02_BinarySearch.py
2,961
4.0625
4
# Binary Search # [] intervals def binary_search(array, target_num): """ Binary Search return -1 if not found. return index if found. """ left = 0 right = len(array) - 1 while left <= right: # Exit when the interals become empty [] mid = left + (right - left) // 2 # Remember t...
b77bd595793ca1f230673e85d222913c6efa719c
jamesmunns/trying_it_out
/one_million_monkeys.py
2,107
3.875
4
__author__ = '03mcginley33' # not sure why I have to import string really... # AJM - you have to import string to get access to string.xxx that you use below. import string import random # Its better practice to always use variables, rather than "Magic Numbers", especially # if you use it multiple times. MAX_TRIES =...
32cb83a38a57f2205ecd73569615b8b4f33e14b1
a350621/python
/hw3/homework3/code1.py
463
3.875
4
#作業1.1 #把99乘法表包裝成函式,可做成nxn 乘法 #def list(n1,n2): def list(n1=10,n2=10): for n1 in range(1,10): for n2 in range(1,10): print(n1,"*",n2,"=",n1*n2) #1.2把四則運算幾包裝成函式 def count(n1,n2,op): if op=="+": print(n1+n2) elif op=="-": print(n1-n2) elif op=="*": print(n1*n2...
598edd899d60e140bff7b177637df4ab4b041075
hew123/python_debug
/ratMaze.py
2,169
3.84375
4
def cellsAround(array, point): row = len(array) col = len(array[0]) x, y = point #return [(a,b) for a in range(x-1,x+2) # for b in range(y-1,y+2) # if a>=0 and a < col and b>=0 and b<row and (a!=x or b!=y)] return [(a,b) for (a,b) in [(x+1,y),(x-1,y),...
dacab1b8903fc0d6c05033cdfe4005f55a096658
quyixiao/python_lesson
/kelihua/kelihua4.py
998
4.1875
4
# 一个加法函数,想增强化的函数功能,能够输出被调用的参数信息 # def add(x,y) # return x + y # 增加信息的输出功能 # def add(x,y): # def print(call add ,x + y )# 日志输出到控制台 # return x + y # 上面的函数是完成了需求,但是以下的缺点是 # 打印语句的耦合太高 # 加法的函数属于业务,能输出信息的功能,属于非法业务功能代码 ,不该入在业务函数加法中 # 在一个函数调用的前面和后面打印这些参数,如果这些,如果有这么一些函数,我们能不能不用 def add(x, y): return x + y def add1(x, y, ...
3940075733ac4fb7bc8d05136bdabfc1f203c2b0
rawnoob25/PythonOOPReview
/n1.py
3,009
4.59375
5
# -*- coding: utf-8 -*- """ Created on Mon Aug 7 22:49:41 2017 This is a small example of nested classes in Python 3. For now the inner class People.Person is visible to code outside of class People. This is not what we would ideally want. However, it nevertheless demonstrates some basic OOP principles. It demons...
b8ac3a16a9dcb5851b0ce6d079bd21c8926f44ba
lamfsantos/showmethecode
/test/create_database/insert.py
1,425
3.53125
4
import sqlite3 from sqlite3 import Error def create_connection(db_file): conn = None try: conn = sqlite3.connect(db_file) except Error as e: print(e) return conn def create_planos(conn, plano): sql = ''' INSERT INTO planos(descricao,minutos) VALUES(?,?) ''' cur ...
981437433369987102296985c0e6cf011f775744
flisz/udacity
/fsnd/2017/2017/turtles/draw.py
354
3.578125
4
import turtle def draw_halfhex(t,size): t.color('green','black') t.pensize(1) for _ in range(0,3): t.forward(size) t.right(60) return t def __init__(): window = turtle.Screen() window.bgcolor("white") res=60 brad=turtle.Turtle() for _ in range(0,3): brad = draw_halfhex(brad) brad.right(120) turn...
f6fa2720dfc5b518c04c8b74bab09d23899a2d61
yanviegas/small_codes
/final_exam_coh-piah.py
6,837
3.9375
4
import re def le_assinatura(): # '''A funcao le os valores dos tracos linguisticos do modelo e devolve uma assinatura a ser comparada com os textos fornecidos''' print("Bem-vindo ao detector automático de COH-PIAH.") print() print("Assinatura do texto-modelo:") wal = float(input("Entre com o ...
4619ab262d151366b5148380ad02fd18b87f29b6
lukegil/png_parser
/src/compression/huffman.py
16,040
3.53125
4
import random, sys class HuffByte(object): """ a data object representing a byte, its encoding, and its frequency in a given document """ def __init__(self, value=bytes(), encoded_value=int(), frequency=float()): """ value @type - bytes @param - t...
f60cf2c38eb9130a5e76596e58edb0ad9fcdde99
kaewinn/cyber
/vcipher.py
3,242
4.15625
4
# Kaelyn Nguyen # CSC 442-001 # Program 2: Vigenere Cipher: encrypts or decrypts messages # Python 3: "python3 p2.py -e mykey" import sys def readFile(): if sys.stdin.isatty() == False: #isatty() returns false if there's something in stdin #there is a file text = sys.stdin.read() # read file ...
6bb9e2d3c39ca1a3143d8d9744adaaa1b0128e6c
ecz5032/hw3-python
/main.py
274
3.703125
4
#Author: Eric Zhang ecz5032@psu.edu def digit_sum(n): if n == 0: return 0 else: z = n % 10 return z + digit_sum(n//10) def run(): value = int(input("Enter an int: ")) print(f"sum of digits of {value} is {digit_sum(value)}.") if __name__ == "__main__": run()
fefe842a311abf8349b3895b545f886c6da8a811
mrdsr/maskApi
/task1.py
1,173
3.671875
4
#coding:utf-8 ###过滤列表中大于0的数据#### import timeit from random import randint data = [randint(-10,10) for _ in range(10)] print(data) # random_number_0 = [[randint(0,8) for i in range(2)] for j in range(12)] # print(random_number_0) #filter(function, iterable) #function -- 判断函数。 iterable -- 可迭代对象。 #关于filter()方法, python3...
e2ad37c37564f4294e333adb6b35681f7625dbe7
Raihansatar/algo-lab-1
/Q14.py
116
3.921875
4
text = input('Enter a text: ') st = text.split(' ') for i in range(len(st)): print(st[i][::-1], end =' ')
316fc8cf98f737926ecca4f5a51b789e24856ad6
soblin/algorithm_list
/bintree/binsearch_insertion/main.py
2,054
3.984375
4
# -*- coding: utf-8 -*- import sys input = sys.stdin.readline class Node: def __init__(self, val=0, parent=None, left=None, right=None): self.val = val self.parent = parent self.left = left self.right = right class Tree: def __init__(self): self.root = None def ins...
cc2cbd9c72790ac09c86df17247874b67549eb6d
johnnyvuanly/Capstone-Lab-2
/python_dataclass.py
903
4.09375
4
# Editing our Student class and turning it into a dataclass from dataclasses import dataclass @dataclass # dataclass is a decorator # Python has generated an init method for us and also generated a string method class Student: name: str college_id: str gpa: float def __str__(self): return f'N...
3ba6235c7bdbcfb3eabdcd4dbe27e208da8660c5
sorayeon/python
/advanced/py9_generators_function.py
2,026
3.71875
4
# 제너레이터 # iterator객체의 한 종류 (next함수호출) # 만드는 방법 : 제너레이터 함수(function) 제너레이터 표현식(expression) def gen_num(): # 제너레이터 함수정의 print('first number') yield 1 # yield가 하나라도 들어가면 제너레이터가 됩니다. print('second number') yield 2 print('third number') yield 3 # 제너레이터 함수를 호출해도 실행하지 않고 제너레이터객체를 만들어 변수에 담는다. gen = ...