blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
323fa5abed4d11fb7a19fadd15c233c638974cba | babiswas/pythonlessons | /setter_getter.py | 638 | 3.921875 | 4 | class A:
def __init__(self,a,b):
self.a=a
self.b=b
def __str__(self):
return f"{self.a} and {self.b}"
@property
def seta(self):
return self.a
@property
def setb(self):
return self.b
@seta.setter
def seta(self,a):
self.a=a
@setb.setter
def setb... |
d6b8ecce9a6c4c5ac1f590c3ec58e3e8796c6804 | TYalison/Python | /shellsort.py | 592 | 3.84375 | 4 | List=[]
def ShellSort(List):
print("输入对应12个月的需要排序的数据:")
for i in range(12):
List.append(int(input()))
mid=6
while mid>=1:
for m in range(mid,12):
tmp=List[m]
pos=m
for n in range(m-mid,-1,-mid):
if List[n]>tmp:
... |
8519046f530ba6b8d9f264802f416883f44d28fe | caioboffo/python-playground | /classmethod.py | 875 | 4.125 | 4 | class Date:
def __init__(self, day, month, year):
self.day = day
self.month = month
self.year = year
def __str__(self):
return 'Date({}, {}, {})'.format(self.year, self.month, self.day)
def set_date(self, y, m, d):
self.year = y
self.month = m
self.d... |
8a31413b7a91c0293bae3efd36ce91c61aa128e9 | SafonovMikhail/python_000577 | /001383WiseplatMarathPyBegin/day6_igra-kamen-nozhnicy-bumaga.py | 1,510 | 3.921875 | 4 | igrok1 = 0
igrok2 = 0
win = 0
draw = 0
lose = 0
list_choises = ['Камень', 'Ножницы', 'Бумага']
print("(Камень - 1, Ножницы - 2, Бумага - 3) Игрок 1, введите ваш номер:")
igrok1 = int(input())
while 1 < igrok1 > 3:
print("Введен некорректный номер")
print("(Камень - 1, Ножницы - 2, Бумага - 3) Игрок 1, введите... |
462e1ea2f4b9e6a5cd9c96116956a0eeeb82b7bc | DracoKali/python_demo | /comparing-list.py | 515 | 4.21875 | 4 | list_one = [1, 2, 5, 6, 2]
list_two = [1, 2, 5, 6, 2]
if list_one == list_two:
print "The lists are the same"
else:
print "The lists are not the same"
list_one = [1, 2, 5, 6, 5]
list_two = [1, 2, 5, 6, 5, 3]
if list_one == list_two:
print "The lists are the same"
else:
print "The lists are not the same"
list_on... |
d9ba4fc31c0e707892981632d53b948374aa5416 | amancer34/new_wordstatis | /new_wf.py | 4,182 | 3.515625 | 4 | # coding=gbk
import os
import sys
import re
import operator
import argparse
#1ͳƵʸ
def total_words1(filename):
with open(filename,encoding='utf-8') as f:
str1 = f.read()
str1 = re.sub('[^a-zA-Z]',' ',str1) #sub ĸÿո
str2 = str1.lower().split() #еʱΪСдͳ
words_dic = {}
total = 0
for word in str2:
if word i... |
455e712cc5f8e584180ba6e7e73597152c344b80 | Nandhacse94/python-training | /day-4/Exception_handling.py | 2,269 | 4.09375 | 4 | # Exception Handling in python
# try
# except
'''
try:
n1 = int(input("Enter num1: ")) # ValueError: if value is not int
n2 = int(input("Enter num2: "))
result = n1/n2 # Possibilty of ZeroDivisionError
print(result)
except ZeroDivisionError:
print("You can not divide a number by zero")
excep... |
7b89c4859c8a6abd4948b75691ea764f3b7d7d8b | thaisnat/LP1 | /TST/unidade5/vida_collatz/vida_collatz.py | 294 | 3.9375 | 4 | # coding: utf-8
# Unidade 5 - Vida Collatz
# Thaís Nicoly - UFCG 2015.2 - 11/04/2016
num = int(raw_input())
antec = num-1
valor = []
valor.append(num)
while True:
if num % 2 == 0:
num = num / 2
valor.append(num)
else:
num = 3*num + 1
valor.append(num)
if num == 1:
break
print len(valor)
|
f815e1e778961daa2da1d66a41d5e4dc9fcf882a | AlinGeorgescu/Problem-Solving | /Python/1614_maximum_nesting_depth_of_the_parentheses.py | 341 | 3.84375 | 4 | #!/usr/bin/env python3
def main() -> None:
s = input("Enter s: ")
depth = 0
max_depth = 0
for c in s:
if c == "(":
depth += 1
if depth > max_depth:
max_depth = depth
elif c == ")":
depth -= 1
print(max_depth)
if __name__ == "_... |
35bfb74ba02d5b706088a4dedd7fe7c18f2f8c49 | alforsii/Learn_Python_Basics | /try-catch.py | 1,006 | 4.34375 | 4 | # To handle an error
# sometimes in our program when something goes wrong it will break the code
# and will give us an error
# to prevent that we can use try to catch if any error and not to break our code
# 1.
try:
number = int(input('Enter a number: '))
print(number)
except:
print('Invalid input')
# now ... |
b25255fa566cf1d428d97c000bef9c2f61df4d7e | adil-ahmed/learrnPython | /hello.py | 1,313 | 4.21875 | 4 | '''
print("hello")
number1 = 10
number2 = 11.4
number3 = "Good"
#printing
print(number1, number2, number3)
#checking types
print(type(number1))
#casting
a = 12
b = 15.5
result = a+b
print(result)
#Taking input
name = input("Enter your name: ")
print("Welcome dear", name)
#python automatically takes input as string... |
da5d91d184bd7753e960b191b98bcd9d18def120 | jaymulins65/Udacity-Data-Structures-and-Algorithms | /2_ShowMeTheDataStructures/SolutionsAndExplanations/problem_2_FileRecursion.py | 1,466 | 4.15625 | 4 | import os
def find_files_using_walk(suffix, path):
for root, dirs, files in os.walk(path):
for file in files:
if file.endswith(suffix):
print(os.path.join(root, file))
return None
def find_files(suffix, path):
"""
Find all files beneath path with file name suffix.... |
d094108fd16744850c880aa77cfcde0a0cd6c212 | lekasankarappan/PythonClasses | /Day5/listassignmenton zip.py | 329 | 3.9375 | 4 | #pop(),remove(),c;lear()
oldlist=["Rose","Jasmine","lily","lotus","Hibiscus","Tulip","bluebell","sunflower","Poppy","Daffodil","Snowdrop","cherrybz"]
newlist=["carrot","cabbage","Beans","Tomato","Turnip","cucumber","Brocoli","cauliflower","yam","Spinach"]
print(oldlist)
print(newlist)
for z in zip(oldlist,newlist):
... |
3c7b9e8107c67f63a3afa484437f362e1cd891d4 | kingtvarshin/pythonprac | /python_assignments/assignment2/getbinarystring.py | 494 | 3.78125 | 4 | def printAllCombinations(pattern, i=0):
if i == len(pattern):
print(''.join(pattern), end =" ")
return
# if the current character is '?'
if pattern[i] == '?':
for ch in "01":
# replace '?' with 0 and 1
pattern[i] = ch
# recur for the remaining pattern
printAllCombinations(pattern, i + 1)
# ... |
a358818e25e28aa5c400483d6ab0a6a60fa19887 | shay-d16/Python-Projects | /6. Tkinter and Sqlite/encapsulation_example.py | 1,069 | 4 | 4 | # Python: 3.9.4
#
# Author: Shalondra Rossiter
#
# Purpose: The purpose of ENCAPSULATION is to wrap your code in one single unit that
# restricts access from functions and variables from being directly changed
# or modified by accident within a class.
# Protected is prefixed with a single und... |
a20704620541a99b3f84e1dbb41df01887c2aa59 | codeAligned/Leet-Code | /src/P-169-Majority-Element.py | 825 | 3.671875 | 4 | '''
P-169 - Majority Element
Given an array of sizen, find the majority element. The majority
element is the element that appears more than⌊ n/2
⌋times. You may assume that the array is non-empty and the
majority element always exist in the array. Credits:Special thanks
to@tsfor adding this problem and c... |
db3bfa997b8e90cd404da1e778a1dbf03d6987bb | jhn--/sample-python-scripts | /python3/doctest_example1.py | 113 | 3.578125 | 4 | def multiply(a, b):
"""
>>> multiply(4,3)
12
>>> multiply('a',3)
'aaa'
"""
return a*b |
f5b55f399d2c0a3c3862147e051cb3611c53047b | akyare/Python-Students-IoT | /1-python-basics/1-baby-steps/1-start/MutableInmutable.py | 790 | 4.5 | 4 | # Reserving memory space:
x = 420
# Lets lookup the memory location:
print(f'memory address of variable x: {id(x)}, value: {x}')
# String, boolean and Integers are immutable so the python interpreter
# will allocate a new memory location if we alter the value of a variable:
x = 42
print(f'memory address of variabl... |
1d5ddb8e0fc055fa9b2dc2b2f52f47957ada7901 | arnabs542/Data-Structures-And-Algorithms | /Backtracking/Generate all Parentheses II.py | 1,344 | 4.0625 | 4 | """
Generate all Parentheses II
Problem Description
Given an integer A pairs of parentheses, write a function to generate all combinations of well-formed parentheses of length 2*A.
Problem Constraints
1 <= A <= 20
Input Format
First and only argument is integer A.
Output Format
Return a sorted list of all possib... |
e4169a0ff7e20ddb31f276141c2055acfe53b6ee | novayo/LeetCode | /0114_Flatten_Binary_Tree_to_Linked_List/try_1.py | 914 | 3.984375 | 4 | # 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 flatten(self, root: Optional[TreeNode]) -> None:
"""
Do not return anything, mo... |
e0c2718b65bf4fc2ddf3053f58d8aa85e576f46b | MaciejZawierzeniec/BlackJack | /BlackJack.py | 3,457 | 3.734375 | 4 | import random
suits = ('Hearts', 'Diamonds', 'Spades', 'Clubs')
ranks = ('Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Jack', 'Queen', 'King', 'Ace')
values = {'Two':2, 'Three':3, 'Four':4, 'Five':5, 'Six':6, 'Seven':7, 'Eight':8, 'Nine':9, 'Ten':10, 'Jack':10,
'Queen':10, 'Kin... |
bc8e9825708cdd25db65a89159f9500a7d965da3 | roboto100/ShufflingTest | /ShuffleTest.py | 8,282 | 4.09375 | 4 | import random
class deck:
'''
A class for simulating deck shuffling
__init__: Initializes the deck. Creates a sorted list of numbers 1-52; sets the number of times sorted to 0
sort: Replaces the list with a new one, with range 1-52; increases the timesSorted variable by 1
shuffle_once: app... |
f67392cdac896371fcb643f20e21432e1afb5f99 | CharonAndy/scikit-fda | /examples/plot_explore.py | 2,216 | 3.84375 | 4 | """
Exploring data
==============
Explores the Tecator data set by plotting the functional data and calculating
means and derivatives.
"""
# Author: Miguel Carbajo Berrocal
# License: MIT
import skfda
import matplotlib.pyplot as plt
import numpy as np
################################################################... |
7091fac3cb984a79d965995a8a5cdc77c2078e7f | amonik/pythonnet | /fib.py | 1,850 | 3.53125 | 4 | """"
def main():
print(cal(8))
def cal(n):
if n > 0:
n += cal(n - 1)
return n
if __name__ == '__main__':
main()
class Person:
def __init__(self):
self.__name = ""
def set_name(self, name):
self.__name = name
def get_name(self):
return self.__name
cl... |
e02d59b22803b11a426f2fb1e4bef65588a05591 | RichardYang58/test | /backup/hello1.py | 123 | 3.59375 | 4 | print('hello world')
print('what is your name')
myName= input()
print('nice to meet you'+ myName)
print(len(myName))
|
28c335649243750024c45399ad856897c2ec7a52 | daniel-reich/turbo-robot | /qTmbTWqHNTtDMKD4G_19.py | 2,364 | 4.21875 | 4 | """
It's been a long day for Matt. After working on Edabit for quite a bit, he
decided to go out and get a beer at the local bar a few miles down the road.
However, what Matt didn't realise, was that with too much drinks you can't
find the way home properly anymore. Your goal is to help Matt get back home by
telling... |
ac6da67bb7824e2bf0a7c86cbf761fa9b0aa78e0 | DeanDro/monopoly_game | /cards_classes/cards.py | 774 | 3.96875 | 4 | """Super class for all cards in the game"""
import pygame
class Cards:
"""Name, owner and saleable will be available across all cards"""
def __init__(self, name, saleable, board_loc, owner=None):
self.name = name
self.board_loc = board_loc
self.saleable = saleable
self.owner ... |
223e1113031d71df8d6892e7419c3045684df352 | wenziyue1984/python_100_examples | /006斐波那契数列.py | 464 | 4 | 4 | # -*- coding:utf-8 -*-
__author__ = 'wenziyue'
'''
斐波那契数列。
斐波那契数列(Fibonacci sequence),又称黄金分割数列,指的是这样一个数列:0、1、1、2、3、5、8、13、21、34、……
'''
def fb(n):
if n == 0:
return 0
if n == 1:
return 1
if n >= 2:
return fb(n-1)+fb(n-2)
if __name__=="__main__":
fb_list = []
for i in range(20):
fb_list.append(fb(i))
pr... |
48760640600abea47d0ee0a7e96bb7b161476f4b | guswns1659/Algorithm | /lec11_ArrayStack & LinkedListStack ADT.py | 1,224 | 4.15625 | 4 | """
배열리스트와 연결리스트로 스택의 추상적 자료구조 구현하기
연산의 정의
-길이 얻어내기 : size()
-비었는지 확인하기 : isEmpty()
-push 하기 : push()
-pop 하기 : push()
-peek 하기 : peek()
"""
class ArrayStack:
def __init__(self):
self.data = []
def size(self):
return len(self.data)
def isEmpty(self):
return self.size() == 0
def ... |
efaac95909bd0bedd728c00b3246f87e8aa743f7 | daniel-reich/ubiquitous-fiesta | /yiEHCxMC9byCqEPNX_6.py | 430 | 3.859375 | 4 |
def is_palindrome(p, r = None, i = None):
if r == None:
symbols = list('/?,.><@#-_!$%^~\';:')
for symbol in symbols:
p = p.replace(symbol, '')
p = p.lower().replace(' ', '')
r = ''.join(list(reversed(p)))
i = 0
return is_palindrome(p, r, i)
elif i == len(p) - 1:
return p[i] == r[i... |
fe5b4441e80c30872bba4bebf14b219f3e71409c | tesschinakoo/Blob | /findTheBlobPart1Template.py | 3,530 | 3.65625 | 4 | import Myro
from Myro import *
from Graphics import *
from random import *
#init("sim")
width = 500
height = 500
sim = Simulation("Maze World", width, height, Color("gray"))
#outside walls
sim.addWall((10, 10), (490, 20), Color("black"))
sim.addWall((10, 10), (20, 490), Color("black"))
sim.addWall((480, 10), (490, 4... |
150a7e972731ead21c282973a0fd0905b5199baa | alkudakaev/MyHomework | /MyCalendar/my_function/my_calendar_function.py | 1,162 | 3.53125 | 4 | def choice_of_action(number):
number = int(number)
if number == 1:
view_task_list()
elif number == 2:
add_new_task()
elif number == 3:
edit_task()
elif number == 4:
finish_task()
elif number == 5:
restart_task()
elif number == 6:
calendar_exit(... |
72f9c774423a1ebfde372c61fef376eba006d47b | houziershi/study | /python/py/02.cookbook/0102/exp.py | 742 | 3.625 | 4 | # coding=utf-8
print ord('a') # 97
print chr(97) # a
print ord(u'\u2020') # 8224
print repr(unichr(8224)) # u'\u2020'
print map(ord, 'ciao')
# [99, 105, 97 111]
print ''.join(map(chr, range(97,100))) # abc
#将Unicode转换成普通的Python字符串:"编码(encode)"
unicodestring = u"Hello world"
utf8string = unicodestring.en... |
fec7c3461925245a1024778b64d8a7236c20033e | fanliu1991/LeetCodeProblems | /23_Merge_k_Sorted_Lists.py | 3,169 | 4.03125 | 4 | '''
Merge k sorted linked lists and return it as one sorted list.
Analyze and describe its complexity.
Example:
Input:
[
1->4->5,
1->3->4,
2->6
]
Output: 1->1->2->3->4->4->5->6
'''
import sys, optparse, os
class Solution(object):
def mergeKLists(self, lists):
"""
:type lists: List[ListNo... |
ff3aeee5c342bc376eb7d32abe0950b58b287bf8 | 0siris7/Think-python-repo | /mysqrt.py | 496 | 4.0625 | 4 | from math import sqrt
def mysqrt(a):
x = 3
y = (x + (a/x)) / 2
while True:
if abs(y - x) < 0.0000001:
return y
else:
x = y
y = (x + (a/x)) / 2
def test_square_root():
a = int(input("Enter the number (a): >"))
print("a\tmysqrt(a)\tmath.sqrt(a)\... |
daa99cfd149d8bbbdc1ba2e8548317a0b9978b5e | kathrinari/python-internship | /python-internship/trivia.py | 12,929 | 3.890625 | 4 | #trivia animation
#mini game for the final project
#the following code is written by Naomi Reichmann
#except for the Button class, which I borrowed from Tech With Tim (YouTube channel)
import pygame, sys, random
from pygame.locals import *
pygame.init()
score = 0 #variable to track the score the user achiev... |
2bce9f4b860cbd1306c5ba53ecd06f2e4d35d76f | stoneflyop1/fluent_py | /ch02/bisect_test.py | 659 | 3.59375 | 4 | import bisect
import sys
HAYSTACK = [1, 4, 5, 6, 8, 12, 15, 20, 21, 23, 23, 26, 29, 30] # ordered list
NEEDLES = [0, 1, 2, 5, 8, 10, 22, 23, 29, 30, 31] # values to find
def demo(bisect_fn):
for needle in reversed(NEEDLES):
position = bisect_fn(HAYSTACK, needle)
print (position)
offset = po... |
e261949bff60587a9afd753cdeb0a74a5e1eed06 | sirmarcius/Media_Escolar_Python | /MediaEscolar.py | 698 | 3.859375 | 4 |
print('##### Bem-vindo ao sistema de media escolar #####')
for a in range(1,5):
nome = str(input('\nAluno n°{} '.format(a)))
nota1 = float(input('Entre com a nota n°{} '.format(1)))
nota2 = float(input('Entre com a nota n°{} '.format(2)))
nota3 = float(input('Entre com a nota n°{} '.format(3)))
no... |
325db5e73be987d2984c6d80d6b0b3ed723e656d | gaojk/LeetCode_Answer | /strStr.py | 708 | 3.59375 | 4 | # coding=utf-8
# author='Shichao-Dong'
# create time: 2018/8/30
'''
实现 strStr() 函数。
给定一个 haystack 字符串和一个 needle 字符串,在 haystack 字符串中找出 needle 字符串出现的第一个位置 (从0开始)。
如果不存在,则返回 -1。
当 needle 是空字符串时我们应当返回 0
注意两个都为空的情况
'''
class Solution(object):
def strStr(self, haystack, needle):
"""
:type haystack: s... |
0648cd2115fc9599c05d6217674336a363d7c716 | jaxonjames123/Budgeting-Program | /Classes/bank.py | 2,710 | 3.890625 | 4 | from Database.db_functions import insert_bank, check_bank_exists, update_bank, load_bank
class Bank:
# Must change location to address, city, state, zip
def __init__(self, name, location, bank_id=0):
self._name = name
self._location = location
self._bank_id = bank_id
def __str__(... |
08fed683f9ec31fdbf5667a9bf0572279474d59b | binarioGH/hotkeyspanish | /hotkeyspanish.py | 975 | 3.53125 | 4 | #-*-coding: utf-8-*-
from keyboard import add_hotkey, wait, write
import ctypes
def CAPSLOCK_STATE():
hllDll = ctypes.WinDLL ("User32.dll")
VK_CAPITAL = 0x14
return hllDll.GetKeyState(VK_CAPITAL)
def spanishy(letter, dot=False):
result = ""
if letter == "a":
result = "á"
elif letter == "e":
result ... |
730892d610b92cf5ad1a30fd05e6aba06a98abbf | eminkartci/PythonLectures | /Lecture1.py | 231 | 3.984375 | 4 | # print("Hello World")
# x = "12"
# y = 150
# print(x,y+y,sep="\n")
# x = 50
# print(x,x**2)
# i = 12
# for i in [1,3,5,6]:
# print(i)
# print(i)
num1 = int(input("num1: "))
num2 = int(input("num2: "))
print(num1 + num2)
|
f9157203a4ba826e38826d6b898b6754e456a445 | yanglinjie8823857/android-app-advertisement-spider-with-xposed | /android-app-advertisement-spider-with-xposed/android_mobile_creative_monitor.git 2/scripts/open.py | 1,083 | 3.609375 | 4 | #!/usr/bin/env python2
#-*-encoding:utf-8-*-
import os,sys
def listdir(dir,myfile):
#myfile.write(dir + '\n')
fielnum = 0
list = os.listdir(dir) #列出目录下的所有文件和目录
for line in list:
filepath = os.path.join(dir,line)
if os.path.isdir(filepath): #如果filepath是目录,则再列出该目录下的所有文件
#myf... |
af0ec45b03cfc57a8082e0b69afaf66092366f35 | noelis/coding_challenges | /decoder.py | 656 | 4.28125 | 4 | def decode(code):
""" Decode the given string.
A valid code is a sequence of numbers and letters.
Each number tells you how many characters to skip before finding a valid letter.
>>> decode("0h")
'h'
>>> decode("0h1ae2bcy")
'hey'
>>> decode("2hbc")
'c'
"""
decoded_word... |
f6807454c0a8dec29d723647438207e1188a6d19 | KoeusIss/holbertonschool-machine_learning | /supervised_learning/0x13-qa_bot/1-loop.py | 388 | 3.78125 | 4 | #!/usr/bin/env python3
"""QA Bot module"""
EXIT_KEYWORD = ('bye', 'goodbye', 'quit', 'exit')
if __name__ == "__main__":
while True:
print('Q:', end=' ')
question = input()
if question.lower() in EXIT_KEYWORD:
answer = 'Goodbye'
print('A: {}'.format(answer))
... |
6d5ce9574759c4b46beccfd8641c0a6ddce7f4a1 | crl0636/Python | /code/MajorityElementII.py | 526 | 3.6875 | 4 | class Solution(object):
def majorityElement(self, nums):
"""
:type nums: List[int]
:rtype: List[int]
"""
dict = {}
for num in nums:
if num not in dict:
dict[num] = 1
else:
dict[num] += 1
ans = []
... |
0614e5184382f4215c6f350592b4de7f1e946d15 | Lokhi-Torano/Projects | /Shuffler for Games.py | 2,302 | 4 | 4 | import random
player_list=["lokhi","satheesh","ramya","aadhi","nithya","kishore","praveen","bharat"]
print(" LUDO TALENT SHUFFLER")
print(" THE PLAYERS ARE : \n")
for name in range(0,len(player_list)):
print(name+1,player_list[name],"\n")
def add_players():
num_mem_add=int(input("enter number... |
05a2d8e4d5ecc98c5c0b45e349e69f9611a9d268 | sughosneo/dsalgo | /src/sorting/QuickSort.py | 970 | 3.96875 | 4 | # Still there is some problem which needs to be sorted out.
# Ref : https://www.youtube.com/watch?v=SLauY6PpjW4
def quickSortWrapper(arr):
quickSort(arr,0,len(arr)-1)
def partition(arr,low,high,pivot):
print(arr)
while (low <= high) :
while(arr[low] < pivot) :
low += 1
whi... |
ec878857dc1a5119c5a4e22edb11f095cf5e345b | tianweidut/CookBook | /algo/plan21/w3/lru_self_146.py | 1,970 | 3.6875 | 4 | class Deque:
class Node:
def __init__(self, key=0, val=0, prev=None, next=None):
self.key = key
self.val = val
self.prev = prev
self.next = next
def __init__(self):
self.head = Deque.Node()
self.tail = Deque.Node()
self.he... |
7c188aec7bd1e40304f27fbf7733be6148d83e75 | jackmartin12/Projects | /Projects/Hypothesis testing.py | 7,265 | 3.53125 | 4 | #!/usr/bin/env python
# coding: utf-8
# Jack Martin
#
# I399, Spring 2021
#
# Independent Data Project, Part 2
# Overview: Counties in the United States are given a NCHS urbanization code based on their population. Lagest to smallest classes: Large Central Metro, Large fringe metro, medium metro, small metro, micro... |
28e4e6e5d6df14d86bd6c6c565de3246f480969d | zeldaxlov3/Python4Fun | /guess.py | 360 | 4.15625 | 4 | #### What's the Number ? ####
import random
number = random.randrange(1, 100)
your_answer = int(input("Your Answer: "))
if your_answer == number:
print("You've guessed it right")
else:
print(f"Right answer is {number}, your answer {your_answer}")
if your_answer > 100:
print("The number is not in range, pl... |
28694205fe4078a5466764b4b591ccb7fc02cc7e | qq76049352/python_workspace | /day05/字典的嵌套.py | 278 | 3.734375 | 4 | dic = {
"name":"汪峰",
"age":58,
"wife": {
"name":"国际章",
"salay":"180000",
"age":37
},
"children":[
{"name":"老大","age":18},
{"name":"老二","age":18}
]
}
# print(dic)
print(dic["children"][1]["name"]) |
4d03ac0738f0d94462e8dcfebfa179c34b070fb2 | cpt-nem0/leetcode | /shuffle_the_array.py | 286 | 3.78125 | 4 | def shuffle(nums, n):
result = []
for i in range(n):
result.append(nums[i])
result.append(nums[i+n])
return result
if __name__ == "__main__":
nums = list(map(int, input('> ').split()))
n = int(input('> '))
print(shuffle(nums, n))
|
3b9ee581a4e0bb614151a6a17788e927c4fd0c95 | client95/s.p.algorithm | /week_2/00_00클래스기본.py | 561 | 3.53125 | 4 | class JSS:
def __init__(self):
self.name = input("이름 : ")
self.age = input("나이 : ")
def show(self):
print("나의 이름은 {}, 나이는 {}세입니다.".format(self.name, self.age))
a = JSS()
a.show()
class JSS2(JSS):
def __init__(self):
super().__init__()
self.gender = input('성별 : ')
... |
b0668b0b65baf37d236e072a9b70d55cca413c27 | IoanaIlinca/University | /Fundamentals of programming/exam prep/exam.py | 146 | 3.65625 | 4 | a = lambda x: [x+1]
b = a(5) # b = [2]
print (b)
c = lambda x: x + b
d = c([1, 2])
a = 1
b = 3
print (a, b, c(4), d[2]) # 1, 3, 7, 2
print (d)
|
aea9b526917cfd144e682e610acce9676629ad37 | zouyuanrenren/Leetcode | /src/Problems/Linked_List_Cycle.py | 824 | 3.859375 | 4 | '''
Created on 17 Nov 2014
@author: zouyuanrenren
'''
'''
Given a linked list, determine if it has a cycle in it.
Follow up:
Can you solve it without using extra space?
'''
'''
Can be done with two pointers:
1. one fast pointer;
2. one slow pointer;
3. the list has a cycle iff fast == slow at some point
'''
# Defi... |
be6490ae123de2d17c92923cda233f0b5ac3a9b0 | bachns/LearningPython | /exercise12.py | 238 | 4.375 | 4 | # Write a Python program to print the calendar of a given month and year.
# Note : Use 'calendar' module.
import calendar
year = int(input("Enter the year: "))
month = int(input("Enter the month: "))
print(calendar.month(year, month))
|
f64821f8624afe05127e4ec3356c31f31d775371 | nastiakuzminih2011/macarrioni | /HW2.py | 210 | 3.765625 | 4 | a = int ( input() )
b = int ( input() )
c = int ( input() )
if ( a * b == c ) :
print ( "YES" )
else :
print ( "NO" )
if ( a // b == c ) :
print ( "yes" )
else :
print ( "no" )
|
37e3ebf9114af9da47aa037792c357411b1616a9 | DabicD/Studies | /The_basics_of_scripting_(Python)/Exercise1.py | 1,124 | 3.921875 | 4 | # Exercise description:
#
# "Napisz funkcję, która znajdzie i zapisze do pliku wszystkie liczby z zadanego
# przez użytkownika przedziału, których suma cyfr jest liczbą pierwszą."
#
##################################################################################
# Functions
def sumOfDigits(number):
... |
17a953c45b45c0c9a8ee553da337a932fcfc451e | MohammedFerozHussain/guvi1 | /123.py | 87 | 3.59375 | 4 | #gfghghghg
n1,m2=input().split()
if(n1.find(m2)==-1):
print("no")
else:
print("yes")
|
101d90eb09257f6f370482d008721916fb8ac56e | k4bir/PythonLab | /Lab_1/qn5.py | 1,019 | 4.125 | 4 | """
A school decided to replace the desks in three classrooms. Each desk sits two students.
Given the number of students in each class, print the smallest possible number of desks
that can be purchased.
The program should read three integers: the number of students in each of the three
classes, a, b and c respectively.... |
310491698c07cc8df6ce7bbad138a41ec0b5d378 | zhaozongzhao/learngit | /Basic_grammar/高阶函数/闭包装饰器/常用的装饰器.py | 3,992 | 3.9375 | 4 | # 日志打印装饰器
def logger(func):
"""
:param func: 这是装饰器函数,参数 func 是被装饰的函数
:return: 返回内部函数的函数名
"""
def wrapper(*args, **kw):
print('主人,我准备开始执行:{} 函数了:'.format(func.__name__))
# 真正执行的是这行。
func(*args, **kw)
print('主人,我执行完啦。')
return wrapper
@logger
def add(x, y):... |
b7cb4d6cd00fc48acceb988733a0d3532263a330 | pvargos17/pat_vargos_python_core | /week_03/labs/07_lists/Exercise_01.py | 318 | 3.984375 | 4 | '''
Take in 10 numbers from the user. Place the numbers in a list.
Using the loop of your choice, calculate the sum of all of the
numbers in the list as well as the average.
Print the results.
'''
def user_sum(l):
sum = 0
for n in l:
sum += n
print(sum)
print(user_sum([1,2,3,4,5,6,7,8,9,10]))
|
09a24b889002640693c994c5df0edc31b3077071 | AndreAmarante/user_management_sr | /user_management_platform_corrected.py | 7,827 | 3.9375 | 4 | import getpass
import os
class WrongFormatException(Exception):
pass
DATABASE = "private_users_database.txt"
USER_LOGIN_ERR_MSG = "Username or password is incorrectw!"
def create_account():
print("-------------Creating User-------------")
username = input("Username: ")
password = getpass.getpass(prompt="Password... |
55083d7e224025491c47ac161debca9851e16de6 | eternalseptember/CtCI | /04_trees_and_graphs/11_random_node/random_node_sol_1.py | 1,900 | 3.78125 | 4 | # Option 6
# O(log N), where N is the number of nodes.
from random import *
class Node:
def __init__(self, data=None, left=None, right=None):
self.data = data
self.left = left
self.right = right
self.size = 1
def get_random_node(self):
if self.left is None:
left_size = 0
else:
left_size = self... |
bf261c126c95112a7553e1ac682ce3b603b0396e | vincesanders/cs-module-project-iterative-sorting | /src/iterative_sorting/iterative_sorting.py | 4,547 | 4.15625 | 4 | import random
# TO-DO: Complete the selection_sort() function below
def selection_sort(arr):
# loop through n-1 elements
for i in range(0, len(arr)):
cur_index = i
smallest_index = cur_index
# TO-DO: find next smallest element
# (hint, can do in 3 loc)
# Your code here
... |
85db9d90fdd9e8e74615b918f3043a6f7abb7817 | qiujiandeng/- | /python1基础/day02/if_express.py | 186 | 3.75 | 4 | # if_express.py
# 商场促销,满100减20
money = int(input("请输入商品总金额:"))
pay = money - 20 if money >=100 else money
print("您需要支付:",pay,'元') |
e4816c83a06d2b7cf951144816c2b0af69bc0a43 | deadpool10086/love-python | /Tensorflow2.0/CheckCode/generater.py | 2,935 | 3.53125 | 4 | """ makeVerification.py 文件"""
import random
import os
from PIL import Image,ImageDraw,ImageFont,ImageFilter
# 设置图片宽高
width = 60
height = 20
"""
"""
def getRandomColor(is_light = True):
"""
生成随机颜色
:param is_light: 为了设置浅色和深色
:return: (r, g, b)
"""
r = random.randint(0, 127) +int(is_light)* 128... |
f5c65c801a38e696976db85ca3a79fbb30aeecb1 | canattofilipe/python3 | /basico/dicionarios/dicionarios_pt2.py | 566 | 4.28125 | 4 | """
Exemplos de dicionários em Python3.
"""
# criando um dicionario.
pessoa = {'nome': 'Alberto', 'idade': 43, 'cursos': [
'React', 'Python']}
# sobreescreve um valor da lista.
pessoa['idade'] = 44
# adiciona um elemento a valor do tipo lista.
pessoa['cursos'].append('Angular')
print(pessoa)
# le um valor do di... |
06302ea5d820b1a609bdffb3084f02a6be39d528 | takayuk/basset | /lib/wordlist.py | 985 | 3.6875 | 4 | #!/home/takayuk/local/bin/python
# encoding: utf-8
# coding: utf-8
class Wordlist(object):
def __init__(self):
self.wordlist = {}
self.__wordid = 1
def __iter__(self):
for word, info in self.wordlist.items():
yield (word, info)
def keys(self):
return self.word... |
2b1e27585d2bc7ef169a4834af46037b87f1f802 | ShakarSaleem/Python-Tic-Tac-Toe-Game | /main.py | 1,278 | 3.765625 | 4 | from gameboardfixed_st import GameBoardFixed
from player_st import Player
def main():
gboard = GameBoardFixed(3)
p1 = Player("X", gboard) # create player 1 object
p2 = Player("O", gboard) # create player 2 object
# place players 1 and 2 in tuple for turn based game.
players_lst = (p1, p2)
... |
8d79491262717a5820d209d56d8ed1457d849722 | iammateus/challenges | /challenge.3.py | 1,944 | 3.765625 | 4 | # Largest Triple Products
# You're given a list of n integers arr[0..(n-1)]. You must compute a list output[0..(n-1)] such that, for each index i (between 0 and n-1, inclusive), output[i] is equal to the product of the three largest elements out of arr[0..i] (or equal to -1 if i < 2, as arr[0..i] then includes fewer th... |
0c4d06fd38ab304c074bbb6dfff27f57d8cb00e1 | sparshg05/Testing | /question2b.py | 289 | 3.6875 | 4 | n=int(input('enter a number between 5-10: '))
l=[]
for i in range(0,n):
l.append(input())
#for k in range(0,n):
# print(l[k])
count=0
for j in range(0,n):
if (l[j] == 5):
count=count+1
print('The number 5 is',count,'times in the above list.')
|
bfef0b3ce417960debe1c650fc4b16918d8bb518 | CharlieButterworth/kennel2 | /customers/request.py | 911 | 3.953125 | 4 | CUSTOMERS = [
{
"email": "cb@gmail.com",
"password": "cb",
"name": "chuck Butters",
"id": 1
},
{
"email": "t@gmail.com",
"password": "cam",
"name": "Tyler tyler",
"id": 2
},
{
"email": "cv@df",
"password": "dfdf",
... |
e6dd8cf1d683f6d6d3ffebe46e9cb602f8ef5e8e | tharinduHND/HDCN181P022 | /hw.py | 549 | 4.25 | 4 | total = 0.0
# Loop continuously using while loop
while True:
# Get the input using input.
number = input("Enter number here :")
# If the user press enter without put value
if number == '':
# ...break the loop.
break
# Else try to add the number to the total.
try:
... |
f3922815b296e63ea3f9d53e52fbebda549aec59 | jrother91/Mensaauskunft | /mensapagescraper/mensapagescraper.py | 5,696 | 3.546875 | 4 | # -*- coding: utf-8 -*-
import requests, bs4, codecs, json
import codecs
import os
import glob
from datetime import datetime, timedelta
def mensa_download(url):
"""
Grabs the html code of this week's mensa plan
returns it as a bs4 object
"""
response = requests.get(url)
html = response.text
... |
bdd4ec7412db67f93412281f1121ddac29916d60 | AYYYang/little-games | /mars_rover.py | 638 | 3.578125 | 4 | import sys
"""
This is a game to explore Mars.
Mars is represented in an nxn grid/matrix. At some coordiates (x,y), where x,y is {0,n-1};
there are some special sites for exploration.
The main character is a rover that can:
1. move A units in 4 directions
2. explore and find out whether the destination is an explor... |
445890c285dce6c643a961a2c9b9eb5f7753a448 | AndreaCrotti/my-project-euler | /prob_30/prob_30.py | 308 | 4.1875 | 4 | #!/usr/bin/env python
# -*- encoding: utf-8 -*-
# The maximum number must be 5 * 9^5
BOUND = 5 * 9**5
def to_power(n):
"Return the sum of the 5th power of each digit"
digits = (int(x) for x in str(n))
return sum(x**5 for x in digits)
print(sum(x for x in range(2, BOUND) if to_power(x) == x))
|
2e078352482d188e86b590dd9ea551da2f4e825c | lanicow/uch | /magic/python/appendAllFilesWithColHeaders.py | 2,160 | 3.5625 | 4 | # Purpose: reads all .txt files in a folder to create a single data file to be imported into a SQL table.
# Author: randy suinn
# python: v3.x
# Notes:
# -- assumes the 1st line (ie line 1) of each input file is the column header.
# -- only .txt files will be read.
import os
the_input_file_list = []
the_fol... |
16f4aad06825b2fe75523740c4687954b025b549 | vishalpmittal/practice-fun | /funNLearn/src/main/java/dsAlgo/leetcode/P0xx/P015_3Sum.py | 1,622 | 3.75 | 4 | """
Tag: math, array
Given an array nums of n integers, are there elements a, b, c in
nums such that a + b + c = 0? Find all unique triplets in the
array which gives the sum of zero.
Note: The solution set must not contain duplicate triplets.
Example:
Given array nums = [-1, 0, 1, 2, -1... |
5228f50262d6f4b0202cdf329252b174ea836f7f | JeromeEngena/python-prax | /age.py | 155 | 4.21875 | 4 | age = input('How old are you?\n')
age = int(age)
if age >12 and age <20:
print("Teenager")
elif age >=20:
print("Adult")
else:
print("Infant") |
8651b8ee6fce4286aacad4c3c93d1506d072dc38 | daniela2001-png/holbertonschool-higher_level_programming | /0x06-python-classes/2-square.py | 956 | 4.15625 | 4 | #!/usr/bin/python3
"""
define a private instance object
and then use raise for errors that can pass
"""
class Square:
"""
incilaizo mis instancias en el init
"""
def __init__(self, size=0):
"""
evaluo errores con raise
"""
if (type(size) is not int):
raise ... |
126da926361b964f82301ff047a2777961c20d81 | AlexaVega-lpsr/class-samples | /drawTriPattern.py | 655 | 3.734375 | 4 | import turtle
def drawtriangle(nyeh):
nyeh.forward(10)
nyeh.right(120)
nyeh.forward(10)
nyeh.right(120)
nyeh.forward(10)
nyeh.right(120)
def drawTri(papy):
hill = 4
while hill > 0:
drawtriangle(papy)
papy.penup()
papy.forward(20)
papy.pendown()
hill = hill - 1
def drawtripattern1(heeh):
o = 0
... |
303762c12176b85421d72a4789f92c8d40902cdc | HallidayJ/comp61542-2014-lab | /src/comp61542/sorter.py | 4,554 | 3.734375 | 4 |
class Sorter:
def sort_asc(self, data, index):
# return data.sort(key=lambda tup: tup[index])
for idx in range(0, len(data)):
tmpAuthor = list(data[idx])
# Split the name into an array
# print tmpAuthor[0]
nameArray = str(tmp... |
3800359a11e37189ddb685b629d00b83b7d856a0 | Alex-Beng/ojs | /FuckLeetcode/2. 两数相加.py | 1,073 | 3.625 | 4 | # Definition for singly-linked list.
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution:
def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode:
l1_ptr = l1
l2_ptr = l2
res_ptr = None
res_head = None
... |
f7e80582d30d980d991f0f5fdabc9a83e1053f67 | tmaria17/learn_python_the_hard_way | /ex11.py | 323 | 3.984375 | 4 | print("How old are you?", end='')
age = input()
print("How tall are you?", end= '')
height = input()
print("How much do you weigh?", end = '')
weight = input()
print(f"So you're {age} old, {height} tall and {weight} heavy.")
print("What is your cat's name?", end='')
cat = input()
print(f"And your cat's name is {cat}... |
a2f8fdc8c4c4cc66b89b8e0c1e82cf8d564f7fd8 | kirtigarg11/guvi | /hunter/set11/6.py | 176 | 3.53125 | 4 | a = input()
b = input()
x = min(len(a), len(b))
for i in range(x):
print(b[i]+a[i])
for i in range(x, len(a)):
print(a[i])
for i in range(x, len(b)):
print(b[i]) |
7d471985785cba59fe8baab8cdf1f53a3b250cf2 | kamata1729/the-cryptopals-crypto-challenges | /set2/c15.py | 1,024 | 3.765625 | 4 | class InvalidPaddingError(Exception):
pass
def is_valid_padding(input: bytes, max_pad_length: int = 16):
pad_size = input[-1]
if pad_size >= max_pad_length-1:
return True
try:
for i in range(1, pad_size):
if input[-i] != pad_size:
raise InvalidPaddingError('... |
5e911c1db061d043a9ef83ca641616ee3049ba96 | carodewig/advent-of-code | /advent-py/2015/day_21.py | 2,904 | 3.578125 | 4 | """ day 21: rpg simulator 20XX """
from collections import namedtuple
import itertools
Equipment = namedtuple("Equipment", ["cost", "damage", "armor"])
class Character:
def __init__(self, hp, damage, armor):
self.max_hp = hp
self.hp = hp
self.damage = damage
self.arm... |
4d0a8800a9ddb4b90e510f6bb7335ad51d324157 | l3e0wu1f/python | /JoshLewis_HolyHandgrenade.py | 837 | 4 | 4 | # INF322 Python
# Josh Lewis
# Week 1 – How To Defeat the Killer Rabbit of Caerbannog
print('Brother Maynard: On what count shalst thy lob the Holy Hand-grenade of Antioch?')
print('King Arthur: ')
answer = input()
while int(answer) != 3:
print('Brother Maynard: The correct answer is 3, not ' + str(int(answer)) +
... |
4fd1d8f87d860bf24adcca469ebc9ed51a3bc34f | Uncccle/Learning-Python | /16.py | 4,346 | 3.953125 | 4 | #-----------------学院管理系统--------------
# 存储学员信息的列表
student=[]
# 功能界面
def sel_function():
print("请选择功能:")
print("1.添加学员")
print("2.删除学员")
print("3.修改学员信息")
print("4.查询学员信息")
print("5.显示所有学员")
print("6.退出系统")
print("-"*20)
# 添加学员功能函数:
def add_num():
"""添... |
f95269ee7636b5e3d8e30b7675bd55ca459f252c | laggage/rainbow | /MyTkinter程序/棋盘覆盖/BoardCover.py | 11,011 | 3.59375 | 4 | # -*- encoding=utf-8 -*-
import math
import time
import tkinter
import tkinter.colorchooser as color
from tkinter import *
shunxu_cur = 0
class chessboard:
def __init__(self, sx, sy, k):
self.sx = sx
self.sy = sy
self.size = pow(2, k)
self.chess = [[-1 for i in range(self.size)] ... |
f7735d24d9f7c8b47393fbb9728c10f1c2908603 | Kraks/Leetcode | /101_SymmetricTree/Solution.py | 844 | 4.03125 | 4 | # 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
# @return {boolean}
def isSymmetric(self, root):
if root: return self.aux(root.left, root.right... |
c45070eac54770e71969efe51cc3961c0dfc388c | Silencio0/Silencio | /silencio/client/client_network.py | 3,773 | 3.5625 | 4 | import sys
import socket
import datetime
import select
class network(object):
"""This class is designed to handle network message sending and recieving for the client end"""
def __init__(self, server_addr, server_port):
""" Default constructor for client network. Requires the server address and port... |
e4969667a91d91f77c5f6c49b45bf8b6d5ba3a27 | jc135210/CP1404_prac | /prac1/menu.py | 1,225 | 3.96875 | 4 | x_value = int(input("enter the X value: "))
y_value = int(input("enter the Y value: "))
print("{:3}. Show the even numbers from {} to {}".format('i', x_value, y_value))
print("{:3}. Show the odd numbers from {} to {}".format('ii', x_value, y_value))
print("{:3}. Show the squares from {} to {}".format('iii', x_value, y_... |
827d36ae9f113ff83464e01a0d7d11b148edbe50 | zhizhin-ik/3semestr | /laboratory_8/task_4.1.py | 298 | 4 | 4 | def function(a):
return print(a**2)
def print_map(function, iterable):
iterator=iterable.__iter__()
while True:
try:
value=iterator.__next__()
except StopIteration:
break
function(value)
iterable=[0,1,2,3,4]
print_map(function,iterable) |
fc746e04b2c09c95e3ef2d9cd058eb950ec108b9 | earl-grey-cucumber/Algorithm | /211-Add-and-Search-Word---Data-structure-design/solution.py | 1,321 | 3.953125 | 4 | class TrieNode(object):
def __init__(self, c):
self.val = c
self.children = dict()
self.end = False
class WordDictionary(object):
def __init__(self):
self.root = TrieNode("")
def addWord(self, word):
cur = self.root
for c in word:
if c not in cur... |
5db138e21313cbbe02cb6d2fb19af6df7106832b | kalbertmata/Python | /IS-python/python-week1/weekonecodealone2.py | 332 | 3.984375 | 4 | x=5
x=x+2
print(x)
x+=2
print(x)
x = 3.0 * x + 1.0
print(x)
interest_rate = 4
interest_rate = x/interest_rate
print(interest_rate)
pay_rate= 12.0
minutes = 1140
hours = minutes / 60
results=pay_rate*hours
print("Pay result is $" + str(results))
x = 43
interestRate = 3
interestRate = x / interestRate
print(int(in... |
fec612be21bbb8360f32d8b2863157357a1a1494 | fport/feyzli-python | /25.0 Fonksiyonlar.py | 705 | 3.75 | 4 | liste = [1,2,3,4,5,2,23,2,2,2]
#liste.append(1)
#print(liste)
#a =liste.count(2)
#print(a)
"""a = liste.reverse()
print(liste)"""
"""
def topla(a,b):
return a+b
a= topla(5,6)
print(a)
print(topla(alfa,beta))
"""
def karesiniAl(a):
return a**2
#print(karesiniAl(5))
def bilgileriGöster(... |
90fd0bc94160b70fdf353e77e401da1dd9280868 | AnshulDasyam/python | /syntax/scratch_21.py | 318 | 3.828125 | 4 | '''Asking the user for a input file and finding lines starting with _______ '''
a = open(input("file name:"))
c = 0
g = 0
for b in a :
if b.startswith("X-DSPAM-Confidence:") :
b = b.rstrip()
print(b)
e = float(b[20:26])
print(e)
c +=1
g +=e
print("The average is",g/c)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.