blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
fd2a85f35be78939583abe8dcd83ef649371b1bb | sangeetha19399/pythonguvipgm | /timemins.py | 58 | 3.578125 | 4 | mins=int(input())
hr=mins//60
mins=mins%60
print(hr,mins)
|
406f9e9d0073c5720fcc0342f52bcb3ec056a31f | lhr0909/SimonsAlgo | /_peuler/001-100/020.py | 83 | 3.5625 | 4 | from math import factorial
print sum(int(digit) for digit in str(factorial(100)))
|
7f2696741019c7a1633681a3b173c48a8941bb8b | cmkemp52/PythonExercises | /upper.py | 55 | 3.703125 | 4 | st = input("Please enter a string: ")
print(st.upper()) |
4e47aaa602764d1da19fbacf7457c948ff175faf | kooshanfilm/Python | /Exercise/numberof_char.py | 408 | 4.375 | 4 | #
#
# Write a Python program to count the number of characters (character frequency)
# in a string. Go to the editor Sample String :
# google.com' Expected Result : {'o': 3, 'g': 2, '.': 1, 'e': 1, 'l': 1, 'm': 1, 'c': 1}
def num_char(str):
count = 0
dic = {}
for i in str:
if i in dic:
... |
5bef5f08944cc9bca5eacce62820120dc46366bb | crescent-and-sheezer/python_text1 | /11.1.py | 758 | 3.515625 | 4 | # _*_ coding:utf-8
# 作者:凡
# @Time: 2021/2/12 17:45
# @File: 11.1.py
'''
import unittest
from city_function import city_functions
class test(unittest.TestCase):
def test1(self):
city_country = city_functions('santiago','chile')
self.assertEqual(city_country,'Santiago Chile')
unittest.main()
'''
impo... |
6ec8d622f4e070d93d1295e7348cf2203c951d76 | danbao571/python- | /64-线程.py | 1,011 | 3.9375 | 4 | # 线程:执行代码的分支,默认程序中只有一个线程
import time
import threading
def AA(count):
for i in range(count):
print('aa')
time.sleep(0.2)
def BB(count):
for i in range(count):
print('bb')
time.sleep(0.2)
if __name__ == '__main__':
# 创建子线程执行对应的代码
# target表示目标函数
# args:表示以元组方式传参
... |
d87c075f626ddf41c62d37b094616e1d7f23d024 | monkeylyf/interviewjam | /tree/leetcode_Add_And_Search_Word_Data_Structure_Design.py | 3,121 | 3.6875 | 4 | """Add and search word data structure design
leetcode
Design a data structure that supports the following two operations:
void addWord(word)
bool search(word)
search(word) can search a literal word or a regular expression string containing only letters a-z or .. A . means it can represent any one letter.
For example... |
c531a0a2748d0aeaceb773c56dcd73fc1e0514e8 | gamerwalt/PythonTutorials | /main.py | 441 | 4.0625 | 4 |
#day 1
#test = input("What is your name?")
#print(f"Length of your name is {len(test)}")
#day1 - 1st Challenge
#a = input("a:")
#b = input("b:")
#temp = a
#a = b
#b = temp
#print("a = " + a)
#print("b = " + b)
#day1 - 2nd Challenge
print("Welcome to the Band Name Generator.")
city = input("What's the name of the c... |
f6bc0f1e20d4fd464862abe9619933de78553626 | danieljaouen/dotfiles | /topics/bin/generate_password_hash | 1,017 | 3.734375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import division, print_function, unicode_literals
import getpass
from passlib.hash import sha512_crypt
def prompt():
password1, password2 = None, None
prompt1 = 'Enter your desired password: '
prompt2 = 'Once more: '
invalid = "Error: yo... |
f2490401bf0f1e596887f5a608b14b69e824b69c | andrewnester/python-problem-solutions | /problems/arrays/sum_of_four.py | 1,913 | 3.671875 | 4 | """
Find all four sum numbers
Given an array A of size N,
find all combination of four elements in the array whose sum is equal
to a given value K.
For example, if the given array is {10, 2, 3, 4, 5, 9, 7, 8} and K = 23,
one of the quadruple is "3 5 7 8" (3 + 5 + 7 + 8 = 23).
Input:
The first line of input contains a... |
2ecc3140b883e5a80a0205e522dbc84de439612f | gislaine-a-sa/Python---Estrutura-de-Repeticao | /Estrutura de Repetição 13.py | 387 | 4.0625 | 4 | print ('Estrutura de Repitação - Exercício 13')
base=int(input('Informe a base:'))
valor_base=base
expoente=int(input('\nInforme o expoente:'))
if (expoente==1) or (expoente==0):
if (expoente==1):
print('\nResultado: %s' % (base))
else:
print('\nResultado: 1')
else:
for i in (range(expoente-1... |
e51ceed79735fbc316380b29db204f056193120c | ekrueger19/crispycode | /final.py | 564 | 4 | 4 | y = 0
x = raw_input("> ")
print "Hello. Will you help me? Answer y/n"
if x == "y":
print "Thank you. I am a genie and can tell your future."
print "Do you want to know your future? Answer y/n"
if x == "y":
print "You will die in approximately thirty seconds."
elif x == "n":
print "Good c... |
ba41fb7674ef43c6253102da696332e6a8e0ae98 | nervig/Starting_Out_With_Python | /Chapter_2_programming_tasks/task_10.py | 576 | 3.96875 | 4 | #!/usr/bin/python
''' 1,5 glass of sugar }
1 glass of oil } = 48 cookies
2.75 glass of flour }
'''
glass_of_sugar = 0.028
glass_of_oil = 0.021
glass_of_flour = 0.057
amount_of_cookies = int(input("Please, enter the amount of cookies: "))
amount_sugar = amount_of_cookies * glass_of_sugar
amount_oil = glass_o... |
15e12f2775a5ac2dc968dab50eaeef3e322f2601 | nwweber/time_tagging | /aligners.py | 4,577 | 3.671875 | 4 | import re
__author__ = 'niklas'
"""
Containing different classes implementing the align-interface.
Writing your own:
Recommended method:
Make your own class
Inherit from AbstractAligner
Implement align() method
This would look something like this:
class MyAlignerWhichDoesCoolStuff(AbstractAlig... |
fea0c4615381d80d8a6c29ac69bf1cb82b26becc | sakshi72000/PythonPrograms | /Program5.py | 199 | 4 | 4 | # Assignment 1
# Program 5 : Program to display the numbers
def Display():
iCnt = 10
while iCnt > 0:
print(iCnt)
iCnt = iCnt - 1
def main():
Display()
if __name__ == "__main__":
main()
|
fa799975c815e8fce239c83696583635b4f2210e | kimmincheol7/ComputerVision | /5.py | 816 | 3.8125 | 4 | Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:43:08) [MSC v.1926 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> if x == 3:
print "X equals 3."
elif x == 2:
print "X equals 2."
else:
print "X equals something else."
print "This is outside the ‘if’."
Sy... |
64d438c64084e70477b896a1b6f338e90db3c86f | iso1234/majorwork | /website/templateEngine.py | 17,445 | 3.59375 | 4 | import re
import html # Used to stop html injections
import copy # Used to make deepcopys of dictionarys
def renderTemplate(filename:str, context:dict):
""" Renders HTML from a template file """
# Get template string
with open("templates/" + filename, encoding='utf-8') as f:
template = f.read()
... |
d1c08b7aba6fd22593327cc5ccec7a3fb2324f74 | FengZhe-ZYH/CS61A_2020Summer | /debug.py | 1,827 | 3.75 | 4 | # Interactive Debugging
# python -i file.py
# python ok -q <question name> -i
# Visualizer
# http://pythontutor.com/composingprograms.html#mode=edit
# python ok -q <question name> --trace
# doctest
# python3 -m doctest file.py
# python3 -m doctest file.py -v
# Note: prefixing debug statements with the specific strin... |
03daefc047af77a8e27364eb145b1a1bcc3ac87e | 520Coder/Python-Programming-for-Beginners-Hands-on-Online-Lab- | /Section 7/Student Resources/Assignment Solution Scripts/assignment_tuples_01_basics.py | 1,861 | 4.53125 | 5 | # Tuples
# Assignment 1
tuple_numbers = (1, 2, 3, 4, 5)
tuple_groceries = ('coconuts', 'bananas', 'onions', 'spinach', 'tomatoes', 'cilantro', 'milk')
groceries_inventory = ('coconuts', 'tomatoes', 'onions', 'coconuts', 'bananas', 'onions', 'spinach', 'tomatoes', 'cilantro', 'milk', 'spinach', 'tomatoes', 'cilantro', ... |
01cc8af42c78b54f2ebe3989904359c29f5015e8 | paradigmadigital/hackathon-image-processing | /formacion02.py | 889 | 3.890625 | 4 | import cv2
import numpy as np
# Create a black image
img = np.zeros((512, 512, 3), np.uint8)
# Draw a diagonal blue line with thickness of 5 px
# PARAMETERS
# img : The image where you want to draw the shapes
# color : Color of the shape. for BGR, pass it as a tuple, eg: (255,0,0) for blue. For grayscale, just pass t... |
bfd843b1547e2d96d87df5fcf36acf426da08b84 | SakuraSa/MyLeetcodeSubmissions | /Jump Game/Accepted-13672434.py | 1,215 | 3.5625 | 4 | #Author : sakura_kyon@hotmail.com
#Question : Jump Game
#Link : https://oj.leetcode.com/problems/jump-game/
#Language : python
#Status : Accepted
#Run Time : 196 ms
#Description:
#Given an array of non-negative integers, you are initially positioned at the first index of the array.
#Each element in... |
25ceef79216d5ac68a3d98a724c6f7cad181ae43 | 20171609/programmers | /printer.py | 574 | 3.53125 | 4 | from collections import deque
def solution(priorities, location):
answer = 0
que = deque([i for i in priorities])
maxnum = max(que)
while (que):
if que[0] == maxnum:
que.popleft()
answer += 1
if location == 0:
break
... |
239d2cde02bfe97b25ffa67d7cab9fcd05953e47 | Aries5522/daily | /2021届秋招/leetcode/哈希表/数组中出现次数超过一半的数字.py | 1,118 | 3.640625 | 4 | '''
数组中出现次数超过一半的数字
数组中有一个数字出现的次数超过数组长度的一半,请找出这个数字。
你可以假设数组是非空的,并且给定的数组总是存在多数元素。
'''
from typing import List
class Solution:
def majorityElement(self, nums: List[int]) -> int:
hash_map={}
n=len(nums)
# if n==0:
# return None
for i in nums:
if i not in hash_ma... |
2016a56b3f902cac5d9e4a88b2b952fd602596bd | ClavinSBU/CSE304 | /hw5/codegen.py | 18,340 | 3.953125 | 4 | import ast
import absmc
# TODO:
# ??
####################################################################################################
# Global vars that hold label objects for different expressions / statements
label_scope = []
# This holds the label used for a `continue` statement in a loop
# For `for` loops, ... |
dcf80887bbd12d029d545862ac0d188756aa7da3 | WilbertHo/hackerrank | /challenges/algorithms/warmup/maximizing_xor/py/maximizingxor.py | 1,537 | 4.0625 | 4 | #!/usr/bin/env python
import fileinput
import math
def maximize(l, r):
""" Return the maximum value of A XOR B, where L <= A <= B <= R
log2 of n is the number of times n has to be divided
by 2 to be less than or equal to 1, so it can tell us where
the most significant bit is.
ex: ... |
cf91aac116f92f699121576242273a7baca84b18 | lelilia/advent_of_code_2020 | /day23.py | 2,424 | 3.609375 | 4 |
def print_list(head):
for _ in range(length):
if not head:
break
print(head.value)
head = head.next
def print_result(head):
while head.value != 1:
head = head.next
res = ""
head = head.next
while head.value != 1:
res += str(head.value)
he... |
4fce804681a410b5a58f177ab3382e36476b21ab | stefroes/Programming | /5-control-structures/pe5_1.py | 176 | 3.78125 | 4 | score = int(input('Geef je score: '))
if score > 15:
print('Gefeliciteerd!\nMet een score van {} ben je geslaagd!'.format(score))
else:
print('Sorry, je bent gezakt')
|
29b1e05a36678df7b5484bd82bf7134a4e04a6c8 | SteephanSteve/Python | /unique.py | 329 | 3.53125 | 4 | #!usr/bin/python
n=int(raw_input("Enter the no. of elements :"))
a=[]
b=[]
print "Enter the elements :"
for i in xrange(n):
x=int(input())
a.append(x)
for i in xrange(n):
for j in range(i+1,n):
if a[i]==a[j]:
a[i]=a[j]=0
for i in xrange(n):
if not a[i]==0:
pri... |
5b32b0e4e32cb94ac457387f4b282bea1449e983 | Cloud-cover/tf_aws_lambda_s3_trigger | /lambda.py | 2,258 | 3.578125 | 4 | """"
A sample implementation of a Lambda function that is expected to be invoked
by creation of an *.csv file in a specific S3 bucket. The function compresses
it and writes the compressed data into another file in the S3 bucket. The
function usess SNAPPY compression https://github.com/google/snappy and
https://git... |
486de4df17abe8adb91a8bcfe34429523e20813f | lmorales17/cs61a | /trends/find_centroid.py | 1,918 | 4.34375 | 4 | def find_centroid(polygon):
"""Find the centroid of a polygon.
http://en.wikipedia.org/wiki/Centroid#Centroid_of_polygon
polygon -- A list of positions, in which the first and last are the same
Returns: 3 numbers; centroid latitude, centroid longitude, and polygon area
Hint: If a polygon has 0 a... |
b664b6c6205e4f3841045c5b48ddd9f398dfb069 | michail82/TestMikl | /MIklTest2_Week2_12_ Chess_board.py | 469 | 3.671875 | 4 | a1 = int( input() )
a2 = int( input() )
b1 = int( input() )
b2 = int( input() )
if (a1 + a2 + b1 + b2) % 2 == 0:
print( 'YES' )
else:
print( 'NO' )
# Заданы две клетки шахматной доски.
# Если они покрашены в один цвет,
# то выведите слово YES, а если в разные цвета – то NO.
# Формат ввода
# Вводятся 4 числа - ... |
cc85896c949b6bbf1e53492bf4b770fa2e81039a | weyyifoo/FunProjects | /Palindrome-N-Prime/palindrome-n-prime.py | 1,096 | 4.0625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Feb 10 10:29:26 2018
@author: Wey Yi
"""
# code checks to see if the number is a prime number
def isPrime(s):
s = int(s)
d = 0
for n in range(3,s):
if s % n == 0: # if there is a remainder from dividing s by the counter, n, then the code adds 1 to d
... |
8aaefd99032365bb59eb8f5507436e6c8b76e9e0 | xuliucun/first | /bg-python/base_part/test01_studentManage.py | 2,029 | 4 | 4 | #!/usr/bin/python
def showInfo(): # 显示功能列表
print("学生管理系统V1.0")
print("1:addInfo")
print("2:delInfo")
print("3:modifyInfo")
print("4:searchInfo")
print("5:displayInfo")
print("0:quitInfo")
def getInfo():
key = input("请选择序号:")
return int(key)
def addInfo(stuInfoListTemp):
name... |
879a265b8da26a7115f34dfec87bde64cfdb6fef | suddenlykevin/cs550library | /Example 1 - Hello World!/helloworld.py | 6,742 | 4.125 | 4 | """
Kivy Example 1: Hello World!
Kevin Xie CS550
This example files gives a short introduction to programming
Kivy widgets in Python. It uses a number of widgets from popups
to sldiers to buttons to Codeinputs. However, it may seem messy!
This is because Kivy works best when typed in kv, where widget
trees and behavi... |
e887e3183209d538db3950888ffee56b20c3ee7f | DipuKP2001/python_for_ds_coursera | /7.1.py | 137 | 4.0625 | 4 | # Use words.txt as the file name
fname = input("Enter file name: ")
fh = open(fname)
for i in fh:
i = i.strip().upper()
print (i) |
8e3a51e563811504a85a113ad5b8bf5b15075c0c | jayjacobs/csmatrix | /ch2/The_Vector-firstpass.py | 2,213 | 3.609375 | 4 | # version code 0d1e4db3d840
# Please fill out this stencil and submit using the provided submission script.
from GF2 import one
def add2(v, w):
return [v[0]+w[0], v[1]+w[1]]
def minus2(v, w):
return [v[0]-w[0], v[1]-w[1]]
def scalar_vector_mult(alpha, v):
return [ alpha*v[i] for i in range(len(v)) ]
de... |
c8a3a22cc9cb74be75e4477082cf56778d5cc80e | deyukong/pycharm-practice | /practice/list_methods.py | 261 | 3.625 | 4 | a = [1,9,2,10,3,4,4,3,3,3,3,6]
b = [100, 101, 102]
a.append(100)
print(a)
a.extend(b)
print(a)
a.insert(1, 99)
print(a)
a.remove(100)
print(a)
a.pop(0)
print(a)
print(a.count(3))
a.sort(reverse = True)
print(a)
c = a.copy()
print(c)
a.clear()
print(a)
|
7a60d9b24e531499d4555936eacd65b836f35aa7 | balloonio/algorithms | /leetcode/problems/621_task_scheduler.py | 3,608 | 3.5 | 4 | # 1. Using sorting
class Solution:
def leastInterval(self, tasks, n):
"""
:type tasks: List[str]
:type n: int
:rtype: int
"""
if not tasks:
return 0
if not n:
return len(tasks)
task2freq = collections.defaultdict(int)
... |
0e9871d7e0a74b069152a790ff4a0c38a1005926 | kartik0001/Day7 | /Modules/Q5.py | 117 | 3.953125 | 4 | # Q5.
from datetime import date
x=date(2021,12,24)
print("Date is: ",x.day)
'''
Output:
Date is: 24
''' |
cc81033abc8a9b65e417cb532e678e6effb8acc4 | gschen/where2go-python-test | /1906101001周茂林/2020寒假/力扣171/1.py | 698 | 3.84375 | 4 | '''
「无零整数」是十进制表示中 不含任何 0 的正整数。
给你一个整数 n,请你返回一个 由两个整数组成的列表 [A, B],满足:
A 和 B 都是无零整数
A + B = n
题目数据保证至少有一个有效的解决方案。
如果存在多个有效解决方案,你可以返回其中任意一个。
示例 1:
输入:n = 2
输出:[1,1]
解释:A = 1, B = 1. A + B = n 并且 A 和 B 的十进制表示形式都不包含任何 0 。
示例 2:
输入:n = 11
输出:[2,9]
'''
def getNoZeroIntegers(n):
for i in range(1, n):
if '0' not in ... |
4554a516ff48f666f950e895e46967388d9d0090 | nidhiatwork/Python_Coding_Practice | /30DayLeetcodeChallenge_April/Week2/11_diameterOfBinaryTree.py | 1,203 | 4.21875 | 4 | '''
Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may not pass through the root.
'''
import sys
class TreeNode(object):
def __init__(self, val, left=None, right=None)... |
67990a9cebe259010e180fe74a6149ae651328ef | Treelovah/Colorado-State-University | /Python-164/chapter.5/lab5.33/TextMsgAbbreviation.py | 778 | 3.78125 | 4 | '''
/*
(1) If a user's input string matches a known text message abbreviation, output the unabbreviated form, else output: Unknown.
Support two abbreviations: LOL -- laughing out loud, and IDK -- I don't know. (4 pts)
Sample input/output:
Input an abbreviation:
LOL
laughing out loud
(2) Expand to also decode thes... |
c665b465f0e22ae1d5a2e66a31e32a99b8dc54fd | shreyajarsania/python_training | /git_ass_py_2/question9.py | 609 | 4.1875 | 4 | ##################################################################################################
#
# Write a Python program to sum of two given integers. However, if the sum is between 15 to 20
# it will return 20.
#
################################################################################################... |
541093f02de52d797169a02ceaec446a12f89eb9 | ResearchInMotion/CloudForce-Python- | /Scrutiny/Dictionary/DictionaryIteration.py | 287 | 3.859375 | 4 | phonebook = {"John" : 938477566,"Jack" : 938377264,"Jill" : 947662781}
for name, number in phonebook.items():
print("Phone number of %s is %d" % (name, number))
check = {"sahil":8,"Nikki":9,"Vmal":9}
for name,number in check.items():
print("Age of %s is %d"%(name,number))
|
76f6ac8c9d551eeb40b78e9d15db3f6c5e2fce77 | Nathanael-L/pw-calc | /pw.py | 1,637 | 3.640625 | 4 | #!/usr/bin/python
import string
from random import randint
import sys
def main(length, passes, mode):
pw = []
sz = ['!','$','%','&','?','@','>','<']
for p in range(passes):
for i in range(length):
r4 = randint(0, mode)
if r4 == 0:
pw.append(randint(0, 9))
elif r4 ==... |
935a2691af5bd1b38bd995201dafe97b09e436e9 | ravipapisetti954/pythonkids-beginners | /examples/02-turtle/03-colors/TiltedMultiColoredSquareSpiralWithBgColor.py | 389 | 3.921875 | 4 | # Drawing square
# Try changing the range value
# Try changing the degrees
import turtle
t = turtle.Pen()
# Visit http://www.tcl.tk/man/tcl8.6/TkCmd/colors.htm for all the supported 03-colors
colors = ["red", "green", "blue", "orange"]
turtle.bgcolor("black")
for x in range(100):
t.pencolor(colors[x%4])
t.forw... |
e26e48b36268550b14f91def4aa32e0a5f2400fe | lmacionis/Exercises | /6. Fruitful_functions/Exercise_7.py | 1,056 | 3.859375 | 4 | """
Write a function to_secs that converts hours, minutes and seconds to a total number of seconds. Here are some tests that should pass:
test(to_secs(2, 30, 10) == 9010)
test(to_secs(2, 0, 0) == 7200)
test(to_secs(0, 2, 0) == 120)
test(to_secs(0, 0, 42) == 42)
test(to_secs(0, -10, 10) == -590)
"""
import sys
def to... |
27b7bdedcced86dc1ef16abd4e592a3de52372dc | balajisaikumar2000/python_modules | /OOPS'S IN PYTHON/Property Decorators.py | 1,809 | 4.0625 | 4 | """
when we did this ,it works fine but we have to print like this print(emp_1.email())
but we want email as variable(variable is called "property" in javascript
def email(self):
return '{} {}@email.com'.format(self.first,self.last) """
class Employee:
def __init__(self,first,last):
... |
36692a4cb3db6f41db9ac7db4547a95a65f3fbc7 | techkids-c4e/c4e5 | /Nhat Linh/btvn 26.6/Assignment 3/3+4.py | 600 | 4.1875 | 4 | from turtle import*
x=int(input('location 1'))
y=int(input('location 2'))
length=int(input('length'))
def draw_star(x,y,length):
penup()
setposition(x,y)
pendown()
for x in range(5):
forward(length)
right(144)
draw_star(x,y,length)
speed(0)
color('blue')
for i in range(100):
import ... |
f36a31066fcb2f99d8d4ad08722b2342bfcc20e4 | Neha-bora/Python | /argu_parameter.py | 1,688 | 3.75 | 4 | Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:21:23) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> def about(name,age,likes):
sentence = "meet{}!they are{}years old and they like {}".format(name,age,likes)
return sentence
>>> about("neha",22,"h... |
abef0d17164eaf292ce45ff9a8bee32b62404907 | yanbinkang/problem-bank | /ik_problems/linked_lists_stacks_queues/pair_wise_swap.py | 1,029 | 4.0625 | 4 | """
solution: http://www.geeksforgeeks.org/pairwise-swap-elements-of-a-given-linked-list-by-changing-links/
initial: 1->2->3->4->5->6->7->None
result: 2->1->4->3->6->5->7->None
# 1 -> 2 -> 3 -> 4 => 2 -> 1 -> 4 -> 3
"""
from sll import *
def pair_wise_swap(head):
if head == None or head.next == None:
... |
5f2f8f3b9df8f70f5db6690d26e981709a4cf3a6 | distractedpen/datastructures | /queue.py | 1,454 | 4.15625 | 4 | #queue implementation
class Queue():
def __init__(self, MAXSIZE):
self.q = [0] * MAXSIZE
self.MAXSIZE = MAXSIZE
self.front = 0
self.rear = -1
self.itemCount = 0
def peek(self):
return self.q[self.front]
def isFull(self):
return self.itemCount == se... |
6bf3d331f60bcc04da9739e3cbbfaface350503c | kaushalaneesha/Coding-Practice | /PythonPractice/src/interview_questions/pharm_easy/insert_elem_middle.py | 1,681 | 4.09375 | 4 | """
Insert element at the middle of a circular linked list
"""
class Node:
"""
Node of a linked list
"""
def __init__(self, val: int):
self.val = val
self.prev = None
self.next = None
class CircularLinkedList:
def __init__(self, h: Node):
self.head = h
s... |
a96e3cd4d0a42850413cf4c3540da72f87b5fbfa | rafaelperazzo/cc0003 | /codigo/calculadora.py | 1,009 | 4.375 | 4 | '''
Escrever uma função que represente uma máquina de calcular,
com as opções das operações fundamentais, fatorial, potência e raiz quadrada.
'''
def fatorial(n):
fat = 1
for i in range(1,n+1,1):
fat = fat * i
return (fat)
def calculadora(operacao,a,b):
if (operacao=='+'):
... |
69d251e73e0443cc61908081f589ac5de4ec0dfd | summershaaa/Data_Structures-and-Algorithms | /剑指Offer/剑指24_反转链表.py | 798 | 3.625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 16:57:45 2019
@author: WinJX
"""
#剑指offer-24 : 反转链表
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
# 返回ListNode
def ReverseList(self, pHead):
#三指针交换
p... |
96a584c4e016e7f73e9d0e023b74a5be59f147ac | sungwooman91/python_code | /01.jump_to_python/chapter5/5_5 내장함수/234_abs.py | 168 | 3.921875 | 4 | print(abs(-3))
print(abs(3))
int_list=[1,2,3,4,5]
for i, name in enumerate(['body','foo','bar']):
print(i,name)
print(list(filter(lambda x:x>0,[1,-3,2,0,-5,6]))) |
27211fb2171c086a1e4fce8ac5d583aae209c2bf | claudio-unipv/pvml | /pvml/normalization.py | 6,414 | 3.59375 | 4 | import numpy as np
def meanvar_normalization(X, *Xtest):
"""Normalize features using moments.
Linearly normalize each input feature to make it have zero mean
and unit variance. Test features, when given, are scaled using
the statistics computed on X.
Parameters
----------
X : ndarray, s... |
c127abb838950cef5942239a4a52504277db7f0d | sneezydwarf2107/Python | /SiebDesEratosthenes/set_up_and_calculation.py | 528 | 3.5 | 4 | def get_List(grenze):
my_list = list(range(2, grenze+1))
return(my_list)
def calculation(my_list, grenze):
for x in range(0, len(my_list)):
if x >= len(my_list):
break
if my_list[x] != 0:
term = my_list[x]
for y in range(x+1, len(m... |
89f12ea1a42558a73b536857984ebf39f452b902 | SebastianAthul/pythonprog | /DATACOLLECTIONS/list/present_notpresent.py | 222 | 3.765625 | 4 |
a=[1,2,3,4,5,6,8,9,10,22]
def present(a):
user=int(input("enter the element tocheck: "))
for i in a:
if i == user:
print("present")
break
else:
print("not present")
present(a)
|
ab2712e51dc9c0bf8860050792a3799a6b88d278 | senku-kz/cv-pa2 | /Canny.py | 9,056 | 3.8125 | 4 | # credit: Juan Carlos Niebles and Ranjay Krishna
import numpy as np
def conv(image, kernel):
""" An implementation of convolution filter.
This function uses element-wise multiplication and np.sum()
to efficiently compute weighted sum of neighborhood at each
pixel.
Args:
image: numpy arr... |
5624a9ec0cb14a608cfd4e1dc26ab476a4b79084 | korosaiki/pyewq | /strip 用法 isalnum检验字符串.py | 196 | 3.8125 | 4 | user = input("请输入用户名:")
移除前后空格
add = user.strip()
print(add)
if add.isalnum():
注意:isalnum = isnum+isalpha
print("注册成功")
else:
print("注册失败")
|
2c55d1f2f16380739ba6684804d3f77835566a63 | Ivaylo-Atanasov93/The-Learning-Process | /Python Advanced/Comprahensions-Exercises/Word Filter.py | 79 | 3.84375 | 4 | string = input().split()
[print(word) for word in string if len(word) % 2 == 0] |
a3f18d464a1c66146d1064969a4c701968475e59 | michelejolie/PDX-Code-Guild | /bankaccount_3.py | 421 | 3.796875 | 4 | class BankAccount:
def __init__(self, f_name, l_name, balance):
self.f_name = f_name
self.l_name = l_name
self.full_name = self.f_name + ' ' + self.l_name
self.balance = balance
self.setup()
def setup(self):
print('You have create an account for {}.'.format(self.... |
85c181bf96bf6e0b52638c61657966b43e0ae850 | Ilhamw/practicals | /prac_03/that_name_thing.py | 312 | 3.84375 | 4 | def main():
"""Get name thing, without functions."""
name = get_name()
print_name(name, 3)
def print_name(name, step=2):
print(name[::step])
def get_name():
name = input("Name: ")
while name == "":
print("Invalid name.")
name = input("Name: ")
return name
main() |
71c027aab9ffc237127e8102a13e1aad5f9bcdb4 | zchenkui/MySimpleDNNLib-v1.0 | /time_series.py | 41,469 | 3.765625 | 4 | import numpy as np
import sys, os
from word2vector import Embedding
from basic_functions import softmax, sigmoid
from basic_layers import Softmax
class RNN:
""" Recurrent Neural Network model (single block)
A single block of RNN, which is the base of time series nerual network.
"""
def _... |
48e188ba605cb201653ac47f2d4d297f142dcb5f | Yelimbert/Registro | /registrov2.py | 1,823 | 3.65625 | 4 | import os
nombreArchivo = "registro.txt"
def agregar():
print("Ingrese los siguientes datos")
nombre = input("Nombre: ")
ape = input("Apellido: ")
edad = input("Edad: ")
cedula = input("Cedula: ")
registro = nombre + ", " + ape + ", " + edad + ", " + cedula
y = input("De... |
bf1d745241860c52b9ebf11db521c4ea1851bd3a | danqiye1/bandit | /bandits/epsilon_greedy.py | 3,542 | 3.578125 | 4 | import random
from bandits import BernoulliBandit
class EpsilonGreedy:
def __init__(self, bandits: list, epsilon=0.05):
"""
Constructor for the epsilon-greedy algorithm
:param bandits: A list of bandits to play
:type bandits: list
:param epsilon: Exploration vs exploitat... |
c77b1236b87919920a769469b80a6f085c27c30a | reviakin/SICP | /coins_exchange.py | 540 | 3.609375 | 4 | def first_denomination(kinds_of_coins):
if kinds_of_coins == 1: return 1
if kinds_of_coins == 2: return 5
if kinds_of_coins == 3: return 10
if kinds_of_coins == 4: return 25
if kinds_of_coins == 5: return 50
return 0
def cc(amount, kinds_of_coins):
if amount == 0: return 1
if amount < 0... |
8de599c8c16b4c629e12543cd0d8a4003285afcd | wangxiao4/programming | /Num5/5.3_GuessNumber.py | 291 | 3.921875 | 4 | import random
rand_number=random.randint(1,100)
guess_number=-1
while guess_number != rand_number:
guess_number=eval(input("enter your number\n"))
if guess_number>rand_number:
print("too high\n")
elif guess_number<rand_number:
print("too low\n")
print("you win") |
26ea01e211cc0a6d69cb4f07a77fa39cc9b7eaa9 | kingking888/2019- | /python学习/实训/nine/c1.py | 2,066 | 4 | 4 | class Student():
# name='aaa'
# age=0
sum1=0
# name='s'
def __init__(self,name11,age):
self.name=name11
self.age=age
self.__score=0
# print(self.__dict__)
# print(name) 访问的是形参的name,所以将形参的名字改了之后就会报错
# self.__class__.sum1+=1
# print(Student.... |
0c282384e4d79b96af8cf505e6cf441655d341ab | SNBhushan/BASICS-OF-PYTHON | /py2.py | 282 | 3.953125 | 4 | #palimdrome
# def ispalindrome(s):
# s=s.lower()
# for item in range(len(s)//2):
# if s[item]!=s[len(s)-item-1]:
# return False
# return True
def ispalindrome(s):
s=s.lower()
return s==s[::-1]
s="madam"
print(ispalindrome(s))
|
42c6e46eae1222ca6332c52353ee7dfbafd5a512 | aaron6347/leetcode_April30Days | /venv/day10_min_stack.py | 1,684 | 3.6875 | 4 | """day10_min_stack.py
Created by Aaron at 10-Apr-20"""
class MinStack:
# app1
# def __init__(self):
# """
# initialize your data structure here.
# """
# self.ar = []
# def push(self, x: int) -> None:
# self.ar.append(x)
# def pop(self) -> None:
# self.... |
9a4838ccabcbd419526d9cc5efbfd83e7101607b | meher1087/learn_ros_python | /ros_ws/src/jarvis/Calendar/archive/w2n_full_text.py | 6,489 | 3.703125 | 4 |
# a mapping of digits to their names when they appear in the
# relative "ones" place (this list includes the 'teens' because
# they are an odd case where numbers that might otherwise be called
# 'ten one', 'ten two', etc. actually have their own names as single
# digits do)
class my_w2n:
__ones__ = { 'one': 1, '... |
0dd552d23bf21038145704d58045d6a3f1a66705 | CoderJuan21/C-106 | /codeIcecream.py | 697 | 3.53125 | 4 | import csv
import numpy as np
import plotly.express as px
def getData():
icecream_sales = []
colddrink_sales = []
with open ("dataIce.csv") as f:
csv_reader = csv.DictReader(f)
for row in csv_reader :
icecream_sales.append(float(row["Temperature"]))
colddr... |
c3146fd800333020f7521454c247b010330784c8 | chayankathuria/Feature_Engineering- | /Categorical.py | 5,820 | 3.546875 | 4 | import pandas as pd
import numpy as np
# Transforming Nominal Data
'''
Nominal data consists of names as labels and we need to transform these labels into numbers so that the algortithm can understand.
One such technique is Label Encoding which converts labels into integers starting from 1.
'''
vg_df = pd.read_csv('d... |
e9aabe0b86722a82aa5836d9d50cb4063613be9b | JoaquinRodriguez2006/Roboliga_2021 | /Robot_movement.py | 1,892 | 3.578125 | 4 | from controller import Robot
import time
timeStep = 32 # Set the time step for the simulation
max_velocity = 6.28 # Set a maximum velocity time constant
nothing = 0
# Make robot controller instance
robot = Robot()
# Define the wheels
wheel1 = robot.getDevice("wheel1 motor") # Create an object to co... |
a65617a5d14ea6e61b6a55bc01ca2b3f23d91ea3 | kodsnack/advent_of_code_2019 | /machalvan-python/utils.py | 689 | 3.59375 | 4 | def read_input():
input_file = open("../../input.txt", "r")
lines = input_file.readlines()
input_file.close()
return lines
def write_output(result):
output_file = open("../../output.txt", "w")
output_file.write(result)
output_file.close()
def check_result(result):
answe... |
ca0948d560615339cf62c20f98c87f875c3cc46f | 596050/DSA-Udacity | /practice/data-structures/stacks/stack.py | 378 | 3.71875 | 4 | class Stack:
def __init__(self):
self.items = []
def size(self):
return len(self.items)
def push(self, value):
self.items.append(value)
def pop(self):
return self.items and self.items.pop()
def top(self):
if self.items:
return self.items[0]
... |
1783baaf6e9a35bf53f833d37af41abef53b7ea8 | lernerbruno/python-trainning-itc | /one_liners/filter_dividable.py | 427 | 3.90625 | 4 | """
It makes one liners functions
Author: Bruno Lerner
"""
def filter_dividable(numbers, divisors):
'''
for each number in the list provided, it checks if it is divisible by any of the divisor
:param numbers:
:param divisors:
:return:
'''
return [x for x in numbers if any([x % divisor == 0... |
6be67c7b175f4166a8180c4c11edfb0dfca836d5 | LogicalFish/DiscordBot | /python/modules/reminders/reminder_manager.py | 1,056 | 3.5625 | 4 | from datetime import datetime
class ReminderManager:
def __init__(self):
self.reminders = []
def add_reminder(self, delta, message_string, target):
self.reminders.append((datetime.now() + delta, message_string, target))
self.reminders.sort(key=lambda tup: tup[0])
def pop_reminde... |
5848eb28061158df60002a40ed1dd7889cef2236 | roechi/advent_of_code_2019 | /day_1/fuel_calc.py | 635 | 3.5625 | 4 | from functools import reduce
from math import floor
def calculate_fuel(weight: int) -> int:
return floor(weight / 3) - 2
def calculate_fuel_for_many(weights: [int]) -> int:
fuel_results = list(map(calculate_fuel, weights))
return reduce(lambda l, r: l + r, fuel_results, 0)
def calculate_fuel_recursive... |
0ac8ee75c140e24ac2470b9a23cc9bb07f6fd4af | batra98/Mario_Testing | /20171114_assignment3/20171114_part1/Refactored/start_screen.py | 2,200 | 3.78125 | 4 | """gaurav"""
import color
class Start(object):
"""gaurav"""
def __init__(self, height, width):
self.height = height
self.width = width
self.start_screen = \
[" ____ ___ ___ ___", \
"| | || || | | Instructions:", \
"|... |
139547a2a8793101bdd8d6cb8b57190a9e9118a6 | peterwj/advent-of-code-2015 | /day11.py | 2,259 | 3.6875 | 4 | #!/usr/bin/python
import sys
import unittest
class TestDay11(unittest.TestCase):
def test_check_validity(self):
assert(includes_run('hijklmmn'))
self.assertFalse(no_verboten_letters('hijklmmn'))
assert(includes_two_pairs('abbceffg'))
self.assertFalse(includes_run('abbceffg'))
d... |
69f18d8c28ec972c7d7ec1285548d288b0448374 | priscilafraser/AtividadesModulo1 | /Exercicio 11.05.2021/exercicio6.py | 599 | 3.8125 | 4 | """ def ficha(jogador='Não informado', gols=-1):
print('-'*40)
print(f'{"Jogador":<20}{"Gols":<20}')
if gols == -1:
print(f'{jogador:<20}{"Não informado":<20}')
else:
print(f'{jogador:<20}{gols:<20}')
ficha()
ficha('ana')
ficha(gols=5)
ficha('marta', 3) """
""" def notas(a,b,c):
me... |
39f094b71fee416dc5694c1b7c9e07e184af423f | niki1729/AutoCar | /Tests/FirstAttempt/MotorsWork/turn.py | 391 | 3.65625 | 4 | import os
class Turn:
"""
This class works or with arduino or with the motors directly through relays and turn right or left
"""
def __init__(self):
self.IN1 = 6 # IN1
self.IN2 = 13 # IN2
self.IN3 = 19 # IN3
self.IN4 = 26 # IN4
def turn_right(self):
pr... |
067b9ed55f2223cf4cf7a480db4fbf6408b566dc | kuroitenshi9/Xmass-python | /10/10.py | 569 | 3.890625 | 4 |
'''
Zaznacz prawidłowe odpowiedz/i:
The first snippet leaves the file open whereas the second does not.
The second snippet iterates more efficiently through the file.
The second snippet opens the file for reading and writing blocks whereas the first only for reading.
The second snippet opens the file for reading ... |
faa61d915b009e4748001eff219c448c16228dc6 | encdec2020/Python-BlockPy | /bouncingballrevised.py | 1,035 | 3.765625 | 4 | import pygame
import time
pygame.init()
# set up the drawing window
screen = pygame.display.set_mode((500, 300))
y = 0
x = 0
running = True
increment = 1
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
else:
while y <= 300:
screen.fill((255,... |
4ec4f2c4e8a152d1340fd911cf2d561c2b22561a | DavidStoilkovski/python-fundamentals | /text-processing-fundamentals/activation_keys.py | 1,180 | 3.71875 | 4 | key = input()
line = input()
while not line == "Generate":
line = line.split(">>>")
command = line[0]
if command == "Contains":
substring = line[1]
if substring in key:
print(f'{key} contains {substring}')
else:
print("Substring not found!")
elif comman... |
dd7d4cb8b051a5a455d64bb394bb12032360c12a | RaulNinoSalas/Programacion-practicas | /Practica7/P7E7.py | 619 | 4.03125 | 4 | """RAUL NIO SALAS DAW 1
Ejercicio_07
Escribe un programa que lea una frase, y la pase como parmetro a un procedimiento. El
procedimiento contar el nmero de vocales (de cada una) que aparecen, y lo imprimir por
pantalla.
"""
nombre=raw_input("Dime una frase ")
def cuantos ():
conta1=nombre.count("a")
... |
cd0ac69ca101c22ecd6053681c4e76a43ff3575b | doer001/Programs66 | /58.2左旋转字符串.py | 723 | 3.796875 | 4 | ''' ********************************************************************
题目描述
对于一个给定的字符序列S,请你把其循环左移K位后的序列输出。例如,
字符序列S=”abcXYZdef”,要求输出循环左移3位后的结果,即“XYZdefabc”。
******************************************************************** '''
# -*- coding:utf-8 -*-
class Solution:
def LeftRotateString(self, s, n)... |
2f3c1479763fcb5c63c3ae3d48885b51b08e46c7 | bjknbrrr/hillel_kiseev | /lesson_04/op_continue.py | 304 | 4.15625 | 4 | # i = 0
# while i < 100:
# i += 1
# if i % 3 == 0:
# continue
#
# print(i)
num = int(input('Please enter a number: '))
while num != 0:
if num < 0:
break
print('Your number:', num)
num = int(input('Please enter a number: '))
else:
print('No negative value.')
|
d9c6923b80d8faeabbd9bdd0387b6c1d703a5196 | rahuljngr/My-Projects | /A4_GUI_App/frontend.py | 2,928 | 4.03125 | 4 | '''
A program that stores this book information:
Title, Author
Year , ISBN
User can:
View all records
Search an Entry
Add entry
Update entry
Delete
Close
'''
from tkinter import *
import backend
def get_selected_row(event):
try:
global selected_tuple
index=list1.curselection()[0]
select... |
a7d54b3a0ae666bcbd3c3d141029b1576956413c | philwade/Euler | /euler7.py | 441 | 3.890625 | 4 | #By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
#What is the 10001st prime number?
start = 3
count = 2
import math
def is_prime(num):
start = 2
end = int(math.ceil(math.sqrt(num)))
for n in range(start, end + 1):
if num % n == 0:
re... |
9901363aec80b3b3f452b1096b841e1badd34ec1 | gabrieltren/urionline | /1257.py | 1,649 | 3.609375 | 4 | def posicaoN(letra):
if letra == 'A':
return 0
elif letra == 'B':
return 1
elif letra == 'C':
return 2
elif letra == 'D':
return 3
elif letra == 'E':
return 4
elif letra == 'F':
return 5
elif letra == 'G':
return 6
el... |
5c860a1e82d09dbf352992b597a60963560b4aa0 | telelvis/projecteuler | /projecteuler/problem4.py | 497 | 3.734375 | 4 | #!/usr/bin/python
"""
(c) projecteuler.net
Largest palindrome product
Problem 4
A palindromic number reads the same both ways. The largest palindrome made
from the product of two 2-digit numbers is 9009 = 91 x 99.
Find the largest palindrome made from the product of two 3-digit numbers.
"""
f... |
2f831d5efaf0c47929f86681239d7b3255d22677 | alinemitri/Python_para_zumbis | /Lista_II/L2E2.py | 280 | 3.796875 | 4 | ano = int( input ('Digite o ano: '))
if ano % 4 != 0 :
print ('O ano %d não é bissexto!' %ano)
elif ano % 100 != 0 :
print ('O ano %d é bissexto!' %ano)
elif ano % 400 != 0 :
print ('O ano %d não é bissexto!' %ano)
else :
print ('O ano %d é bissexto!' %ano)
|
ca3fc1769382eb8a55ae6b15f0086266d81102f9 | duong22/Test_Task_Neuro | /Test_Task_LD_Flask/src/yandex_geocoder.py | 3,555 | 3.53125 | 4 | from decimal import Decimal
from typing import Tuple
import requests
import json
from math import sin, cos, sqrt, atan2, radians
from src.exceptions import InvalidKey, NothingFound, UnexpectedResponse
class YandexGeocoder(object):
def __init__(self, api_key):
self.api_key = api_key
self.long_mosc... |
bd914ec7b2550d6c1aae0509a9b68702aaf5ee11 | Musokeking/projects | /dictionary.py | 84 | 3.828125 | 4 | x=0
dict={}
for x in range(x,15):
sqrt= x**2
dict[x]=sqrt
print(dict) |
ab0e6193637d06ff7f25c911df386258cb71c031 | fxpxzh/pythonStu | /PythonTest/src/com/fangxp/func/sortedFucTest.py | 379 | 3.59375 | 4 | # -*- coding: utf-8 -*-
'''
Created on Mar 22, 2016
@author: xianpanfang
'''
L = [('Bob', 75), ('Adam', 92), ('Bart', 66), ('Lisa', 88),('adb',99)]
def by_score(t):
return t[1]
L2 = sorted(L, key=by_score,reverse=True)
print(L2)
def by_name(t):
return t[0].lower() #str.lower(t[0])
L3 = sorted... |
10f93d2044eda8d6840069224491a862dc71dcff | gaoxuboy/cs | /questionnaire/x1.py | 1,700 | 3.875 | 4 | # 什么是可迭代对象?其中含有__iter__方法,返回迭代器
# 什么是迭代器?
"""
1. 自定义可迭代对象
class Foo(object):
def __init__(self,arg):
self.arg = arg
def __iter__(self):
return iter([11,22,33,44,55])
obj = Foo("as")
for row in obj:
print(row)
"""
# class Foo(object):
#
# def __init__(self,arg):
# self.arg ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.