blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 545k | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 545k |
|---|---|---|---|---|---|---|
bcb92112d57bf053065767c681bfaa10896762a8 | djackreuter/coding-challenges-and-algorithms | /coding-challenges/rps.py | 2,383 | 4.03125 | 4 | import random
class RockPaperScissors:
def __init__(self):
self.user_score = 0
self.computer_score = 0
self.options = ["rock", "paper", "scissors"]
def get_user_input(self):
return input("Choose rock, paper, scissors\n").lower()
def get_computer_pick(self, options):
... |
11b3a0032cf6388234b005b4df976b769a16f22c | German-Programmers/python-Course | /4-list-array/exercise.py | 702 | 4.0625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 6 17:48:27 2020
@author: ahmad
"""
# 0 1 2 3 4 5
x = [2, 6, 8, 9, -5, 6]
# write a code to print the sum of even numbers inside x
storage = 0
for i in range(len(x)):
if x[i] % 2 == 0:
storage += x[i]
print(storage)
print("///... |
1a444d71dd8fc94e560b751259ba44d4913a612d | German-Programmers/python-Course | /2-for-loop/app.py | 486 | 3.96875 | 4 | #for x in range(10):
# print(x)
#for x in range(1, 11):
# print(x)
#for x in range(0, 21, 2):
# print(x)
#for x in range(1, 11):
# print(x * x)
# sum nimbers between 1 and 100
#storage = 0
#for x in range(1, 101):
# storage = storage + x
#print(storage)
#////////////////////////
for x in range(10,... |
874924405ba9b255f5387a4c6f65ab03d1230b32 | arthurnguyen510/GoogleCodeJam | /2016/QualificationRound/B/Revenge_of_the_Pancakes.py | 1,704 | 3.765625 | 4 | def flip_pancake(pancake, length):
flipped = ''
count = 0
for x in pancake:
if count <= length:
if x == '-':
flipped += '+'
elif x == '+':
flipped += '-'
else:
flipped += x
count += 1
return flipped
def is_happ... |
24e29b35cbfddc136eb812a52019b07bcd14915f | eishk/Python-Soccer-Project | /transfers_scrape.py | 4,694 | 3.671875 | 4 | """
Eish Kapoor & Kunal Bhandarkar
CSE 163 AD
Final Project
This file contains the code that uses the BeautifulSoup library
to scrape the TransferMarkt database for the transfers that occurred
in the British Premier League. Includes transfers in and out, and scrapes
the player's name, position, market value, actual fe... |
634f2f49a02150d44b9cda513c10e381ba547fee | pusiyugithub/codes | /Huawei_exercises/Python3_Implementations/字符串加解密.py | 1,272 | 3.9375 | 4 | import sys
def encrypt(a):
s = str()
for x in range(len(a)):
if a[x].islower() and a[x] is not "z":
s = s + str(chr(ord(a[x])+1).upper())
elif a[x] == "z":
s = s + "A"
elif a[x].isupper() and a[x] is not "Z":
s = s + str(chr(ord(a[x])+1).lower())
... |
bb4c03b87e7c1eed351c0adc16f19e85ad75093d | RomanKhripunov/LearningPython | /OneMoreTime/encrypt_data.py | 395 | 3.5625 | 4 | from simplecrypt import decrypt, DecryptionException
with open("encrypted.bin", "rb") as inp_file:
encrypted_data = inp_file.read()
passwords = [line.rstrip() for line in open("password.txt")]
for password in passwords:
try:
result = decrypt(password, encrypted_data).decode('utf8')
... |
f943693e92feb6a7ec50f7202bcb0022a10c4317 | RomanKhripunov/LearningPython | /Checkio_org/HOME/checkio_sun_angle.py | 561 | 3.65625 | 4 | def sun_angle(time):
splited_time = [int(i) for i in time.split(":")]
angle = ((splited_time[0] - 6) * 15) + (splited_time[1] * 0.25)
return angle if 0 <= angle <= 180 else "I don't see the sun!"
if __name__ == '__main__':
assert sun_angle("07:00") == 15
assert sun_angle("18:00") == 180
assert... |
db910935e1f36a6c09ceb3ffed2f9dcbf599e61d | RomanKhripunov/LearningPython | /Checkio_org/ELECTRONIC STATION/brackets.py | 1,300 | 3.859375 | 4 | def checkio(expression):
left_brackets = ('(', '{', '[')
right_brackets = {')': left_brackets[0], '}': left_brackets[1], ']': left_brackets[2]}
brackets_only = [ch for ch in expression if ch in left_brackets or ch in right_brackets]
queue_brackets = []
if len(brackets_only) == 0:
return T... |
a1b1bdced1aa97a4b83b1b5bcc893be5fd7dad3d | RomanKhripunov/LearningPython | /Checkio_org/ELEMENTERY/checkio_easy_unpack.py | 703 | 3.921875 | 4 | def easy_unpack(elements):
return elements[0], elements[2], elements[-2]
def easy_unpack_2(elements):
return tuple(elements[i] for i in (0, 2, -2))
if __name__ == '__main__':
import time
start = time.time()
assert easy_unpack((1, 2, 3, 4, 5, 6, 7, 9)) == (1, 3, 7)
assert easy_unpack((1, 1, ... |
039163c6f95b4b0b8f906a76c33a67f31478fd46 | RomanKhripunov/LearningPython | /Checkio_org/HOME/checkio_safe_pawns.py | 868 | 3.65625 | 4 | def safe_pawns(pawns):
cols = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']
saved_pawns = set()
pawn_positions = [[pawn[:1], int(pawn[1:])] for pawn in pawns]
for pawn_position in pawn_positions:
print(pawn_position)
p_list = []
for i in [+1, -1]:
p_list.append(cols[cols.i... |
7b8241125841ad4f17077ed706af394576f6a0dc | briand27/LPTHW-Exercises | /ex20.py | 1,172 | 4.15625 | 4 | # imports System
from sys import argv
# creates variables script and input_file for arguments
script, input_file = argv
# define a function that takes in a file to read
def print_all(f):
print f.read()
# define a function that takes in a file to seek
def rewind(f):
f.seek(0)
# defines a function that prints... |
38aa94d68254fe0903e6eb1de10d10c23eab47b6 | mlbudda/Checkio | /home/sort_by_frequency.py | 542 | 4.34375 | 4 | # Sort Array by Element Frequency
def frequency_sort(items):
""" Sorts elements by decreasing frequency order """
return sorted(items, key=lambda x: (-items.count(x), items.index(x)))
# Running some tests..
print(list(frequency_sort([4, 6, 2, 2, 6, 4, 4, 4])) == [4, 4, 4, 4, 6, 6, 2, 2])
print(list(frequency_... |
b2edfeef59563ca85ae59503a385cc2119619b36 | mlbudda/Checkio | /home/non_unique_elements.py | 566 | 3.734375 | 4 | # Non-unique Elements
def checkio(data: list) -> list:
numbers_remove = []
for number in data:
if data.count(number) == 1:
numbers_remove.append(number)
for number in numbers_remove:
data.remove(number)
return data
# Running some tests...
print(list(checkio([1, 2, 3, 1, 3])... |
08453389f502d9b6bd1737a01e085fe31973d18e | mlbudda/Checkio | /home/three_words.py | 553 | 4.03125 | 4 | # Three Words
def checkio(words: str) -> bool:
counter = 0
a = 0
for i in words.split():
if i.isalpha():
counter += 1
else:
counter = 0
if counter >= 3:
a = 1
if a == 0:
return False
else:
return True
# Running some
print(... |
e664d5093b90287e72a19e2b31627eb4e996893c | mlbudda/Checkio | /home/right_to_left.py | 540 | 3.84375 | 4 | # Right to Left
def left_join(phrases: tuple) -> str:
new = ''
for i in phrases:
changed = str(i)
new = new + changed.replace('right', 'left') + ','
return new[:-1]
# Running some tests...
print(left_join(("left", "right", "left", "stop")) == "left,left,left,stop", "All to left")
print(left... |
03389bd8ab6b7f1a14d681c6f209c264e2e27aad | mlbudda/Checkio | /o_reilly/index_power.py | 440 | 4.15625 | 4 | # Index Power
def index_power(array: list, n: int) -> int:
"""
Find Nth power of the element with index N.
"""
try:
return array[n] ** n
except IndexError:
return -1
# Running some tests..
print(index_power([1, 2, 3, 4], 2) == 9, "Square")
print(index_power([1, 3, 10, 100], 3)... |
d6760387a314db3a6de96e480e522257c8e015eb | mlbudda/Checkio | /home/counts_digits.py | 582 | 4.03125 | 4 | # Count Digits
def count_digits(text: str) -> int:
""" Count Digits """
counter = 0
for digit in text:
if digit.isdigit():
counter += 1
return counter
# Running some tests..
print(count_digits('hi') == 0)
print(count_digits('who is 1st here') == 1)
print(count_digits('my numbers is... |
d732bfc4c9ecf3121a0bdf897eddf0b3cd414638 | mlbudda/Checkio | /elementary/first_word_simplified.py | 256 | 3.96875 | 4 | # First Word (simplified)
def first_word(text):
""" Splits and returns first word """
return text.rsplit()[0]
# Running some tests...
print(first_word("Hello world") == "Hello")
print(first_word("a word") == "a")
print(first_word("hi") == "hi") |
4a442936b64bfd63e155d557db6dad95e4af3acb | jcktng/NNFS | /network.py | 1,513 | 3.578125 | 4 | import numpy as np
import nnfs
from nnfs.datasets import spiral_data
nnfs.init()
class Layer_Dense:
'''
n_inputs = number of features (per data sample or per output of the previous layer)
n_neurons = number of neurons (per layer)
'''
def __init__(self, n_inputs, n_neurons):
# Returns an array of shape n_i... |
473d7d7500ffc160f056d661b0ef8a1d297a84a7 | mnsupreme/artificial_intelligence_learning | /normal_equation.py | 2,911 | 4.3125 | 4 | #This code solves for the optimum values of the parameters analytically using calculus.
# It is an alternative way to optimizing iterarively using gradient descent. It is usually faster
# but is much more computationally expensive. It is good if you have 1000 or less parameters to solve for.
# complexity is O(n^3)
# ... |
d1f3e0538d8573baf8ab25baa9377a17ffb7ce45 | imneeteeshyadav98/KNN | /main.py | 898 | 3.609375 | 4 | import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
dataset=pd.read_csv("/home/data_science/Desktop/Mlops-ws/KNN/Social_Network_Ads.csv")
X=dataset[['Age', 'EstimatedSalary']]
y=dataset['Purchased']
from sklearn.model_selection import train_test_split
X_train,X_test,y_train,y_test=train_test_split... |
3182e9c532d11a9a035662a522591d301ca21c57 | code-lucidal58/python_inception | /examples/guess_the_number.py | 837 | 3.734375 | 4 | from random import randint
print("Hi! Welcome to Guess the Number Game!")
r_no = 0
play = True
while play:
max_no = 500
min_no = -500
r_no = randint(-500, 500)
g_no = -501
c = 0
while g_no != r_no:
g_no = int(input(f"start guessing in the range: {min_no} and {max_no}: "))
if r... |
ef2fb36ea0588d36aa6b49ad55d57ee4a5d64bc0 | dguest/example-text-parser | /look.py | 1,851 | 4.15625 | 4 | #!/usr/bin/env python3
import sys
from collections import Counter
from csv import reader
def run():
input_name = sys.argv[1]
csv = reader(open(input_name), skipinitialspace=True)
# first read off the titles
titles = next(csv)
indices = {name:number for number, name in enumerate(titles)}
# ke... |
0a89fb4a194227f7463e9945df4fed52a1304e83 | kingbhtang/leetcode | /two_sum/two_sum.py | 1,125 | 3.515625 | 4 | #!/usr/local/bin/python3
#-*- encoding=utf-8 -*-
def two_sum(nums, target):
for idx_a, number_a in enumerate(nums):
for idx_b, number_b in enumerate(nums):
if idx_a == idx_b:
continue
if number_a + number_b == target:
return [idx_a, idx_b]
retur... |
958bc0788779a133eda6eb3587c5823f67c9f842 | navneethkour/LeetCode-Python-1 | /LinkedList/RemoveNthNodeFromEndOfList.py | 575 | 3.78125 | 4 | # https://leetcode.com/problems/remove-nth-node-from-end-of-list/
# Given a linked list, remove the nth node from the end of list and return its head.
from ListNode import ListNode
class Solution(object):
def removeNthFromEnd(self, head, n):
tempHead = listNode = head
for _ in range(n) :
... |
01f2769c18ac7415bcf0038383060d5795352fa7 | navneethkour/LeetCode-Python-1 | /Array/ThirdMaximumNumber.py | 757 | 3.5625 | 4 |
import sys
class Solution(object):
def thirdMax1(self, nums):
# https: // discuss.leetcode.com / topic / 64696 / a - python - amusing - solution - which - actually - beats - 98 / 3
nums = set(nums)
if len(nums) < 3:
return max(nums)
nums.remove(max(nums))
nums.re... |
452658ce285cf8c78a12230847dc3bbf51f943c9 | navneethkour/LeetCode-Python-1 | /Tree/SameTree.py | 332 | 3.65625 | 4 | # Definition for a binary tree node.
from TreeNode import TreeNode
class Solution(object):
def isSameTree(self, p, q):
if not p and not q : return True
if not p : return False
if not q : return False
return (p.val == q.val) and self.isSameTree(p.left,q.left) and self.isSameTree(p.ri... |
beb3aab77660298284a8efade6bc1f390f12d6d6 | navneethkour/LeetCode-Python-1 | /Number/GuessNumberHigherOrLower.py | 832 | 4.09375 | 4 | # https://leetcode.com/problems/guess-number-higher-or-lower/
# We are playing the Guess Game. The game is as follows:
#
# I pick a number from 1 to n. You have to guess which number I picked.
#
# Every time you guess wrong, I'll tell you whether the number is higher or lower.
#
# You call a pre-defined API guess(int n... |
8f3d7b8bf0db7516cc8e9ba19669a067bf7a64a3 | navneethkour/LeetCode-Python-1 | /Number/ReverseInteger.py | 416 | 3.796875 | 4 | # https://leetcode.com/problems/reverse-integer/
# Reverse digits of an integer.
#
# Example1: x = 123, return 321
# Example2: x = -123, return -321
class Solution(object):
def reverse(self, x):
if x < 0 : return -self.reverse(-x)
result = 0
while x:
result = x % 10 + result * 10... |
e62b1d5d3b9929032bbf080ae85e4c3b76c358e5 | navneethkour/LeetCode-Python-1 | /Array/SortColors.py | 625 | 3.71875 | 4 | # https://leetcode.com/problems/sort-colors/
class Solution(object):
def sortColors(self, nums):
# https://discuss.leetcode.com/topic/36160/python-o-n-1-pass-in-place-solution-with-explanation/2
red,head,tail = 0,0,len(nums) - 1
while head <= tail:
if nums[head] == 0 :
... |
e071ed7687d0e35c28a370463bc08c49cbd5c2ea | bpabraham123/FantasyFootball21-22 | /editDF.py | 5,470 | 3.796875 | 4 | from bs4 import BeautifulSoup
import pandas as pd
from urllib.request import urlopen
# This function takes an int as its input, where the input corresponds to a year
# after 1999. The function returns a pandas dataFrame of the scraped data
def scrape(year):
url = "https://www.pro-football-reference.com/years/{}/f... |
084937315f25b39e07f7c402bc6c1442336bc86b | ldj5123/Linux | /PYTHON/chapter4/chap4_lab6_temperature.py | 233 | 3.640625 | 4 | maxCelsius = int(input('몇 도씨까지 출력 : '))
increase = int(input('증가 폭을 입력 : '))
for i in range(0, maxCelsius + increase, increase):
celsius = (i - 32) * 5 / 9
print(i, ' -> ', round(celsius, 2))
|
868537b2701e31b1eaf2351a0083a857c7c0d08e | ldj5123/Linux | /PYTHON/chapter4/chap4_lab2_middlechar.py | 229 | 3.71875 | 4 | str = input('문자열을 입력하시오 : ')
print(len(str))
if (len(str) % 2 == 0):
i = len(str) // 2
print('중앙글자는 ', str[i-1], str[i])
else:
i = len(str) // 2
print('중앙글자는 ', str[i]) |
e6e895f5e7de73079d1e1a90b53060a7856fcb63 | ldj5123/Linux | /PYTHON/chapter3/chap3_memory.py | 127 | 3.703125 | 4 | a = 300
b = 300
print(a is b)
print(a == b)
a = [5, 4, 3, 2, 1]
b = [1, 2, 3, 4, 5]
b = a
print(b)
a.sort()
print(b) |
dd0ec030f8e21fe2a8fc177625345bf8a2385a2d | ldj5123/Linux | /PYTHON/chapter6/chap6_lab2_stringFind.py | 265 | 3.578125 | 4 | str = input('문서를 작성하세요\n')
findStr = input('찾을 문자를 입력하세요 : ')
findIndex = 0
for i in range(len(str)):
if findStr == str[i]:
findIndex = i+1
print(findStr, '/', findIndex, '/', str.count(findStr))
|
d03469d76411573347da07d8f7c766e17ea189d3 | ldj5123/Linux | /PYTHON/chapter7/chap7_lab4_samename.py | 320 | 3.828125 | 4 | def findSameName(name):
for i in range(len(name)):
for j in range(len(name)):
if i != j and name[i] == name[j]:
print(name[i])
name = ['Tom', 'Jerry', 'Mike', 'Tom']
print(findSameName(name))
name2 = ['Tom', 'Jerry', 'Mike', 'Tom', 'Mike']
print(findSameName(name2))
|
4b7b6de8a345ea1f72d74e666e7888fe80d694cb | helloworld/AI | /lab2.py | 2,051 | 3.640625 | 4 | from string import ascii_lowercase
from pprint import pprint
import pickle
'''
+======================+
| Sashank Thupukari |
| Period 6 |
| Lab 2 |
| 9/9/2014 ... |
bdaafba3b5d899455166d1ba58bf9035becbb04b | alex-huff/advent-of-code-2020 | /day3.py | 1,184 | 3.90625 | 4 | def wrapHorizontal(index, size):
return index % size
def multipliedList(mList):
return multiplied(mList, 0, len(mList) - 1)
def multiplied(mList, start, finish):
if start == finish:
return mList[start]
return mList[start] * multiplied(mList, start + 1, finish)
biome = []
horizontalLength = ... |
73e4a5f278d5137ed57e5156b5db882a99acf242 | min1378/-algorithm | /kakao/12918_문자열다루기기본.py | 324 | 3.703125 | 4 | def solution(s):
answer = True
length = len(s)
# check = "123456789"
# for i in check:
# print(i, ord(i))
if (length != 4 and length != 6):
return False
for char in s:
if ord(char) < 48 or ord(char) > 57:
return False
return answer
print(solution("12345s... |
3ae8a473cdbcfbda6aff5ad96626344e9e147996 | min1378/-algorithm | /kakao/12903_가운데글자가져오기.py | 226 | 3.6875 | 4 | def solution(s):
answer = ''
length = len(s)
if length % 2 :
answer = s[length//2]
else :
answer = s[length//2-1:length//2+1]
return answer
print(solution("abcde"))
print(solution("qwer")) |
7d3b5507f0793d9b9b3753b78aedd9c95d1d988e | min1378/-algorithm | /kakao 2020/2.py | 190 | 3.5625 | 4 | def solution(expression):
multi_index = []
for char in expression:
if char == "*":
print(check)
return check
print(solution( "100-200*300-500+20")) |
e44ea727e4ae4cf4dcc9fd168a1e2f2aceebd7d8 | min1378/-algorithm | /SWEA/4873. 반복문자 지우기.py | 391 | 3.515625 | 4 | import sys
sys.stdin = open("input.txt", "r")
def inspect(temp):
stack = []
for i in temp:
if stack != [] and stack[-1] == i :
stack.pop()
else :
stack.append(i)
return len(stack)
T = int(input())
for test_case in range(1, T + 1):
temp = list(str(input()))
... |
deab3bf5eb74028a99be9e9b7c7fb0db849a5b5b | min1378/-algorithm | /kakao/17681.py | 523 | 3.5625 | 4 | def check(list, n):
if len(list) != n:
list = "0" * (n - len(list)) + list
return list
def check2(str):
temp = ""
for st in str:
if st == "1":
temp += "#"
elif st == "0":
temp += " "
return temp
def solution(n, arr1, arr2):
answer = []
for ... |
b9c95b485860f5d260e7faadc550d64be48ac8f4 | min1378/-algorithm | /hyundaecard/3.py | 793 | 3.640625 | 4 |
def check(string):
for s in string:
if ord("a") <= ord(s) <= ord("z"):
continue
return string[:string.index(s)],int(string[string.index(s):])
return string, 0
def solution(registered_list, new_id):
answer = ''
temp_id = new_id
string, number = check(temp_id)
while Tr... |
ae777ad793df0bc4ffd15c783e398307b3993df4 | min1378/-algorithm | /kakao/12921_소수찾기.py | 389 | 3.828125 | 4 | def solution(n):
answer = 0
is_prime = [False, False] + [True] * (n - 1)
primes = []
# print(is_prime)
for number in range(2, n + 1):
if is_prime[number]:
primes.append(number)
for multiple_prime in range(2 * number, n + 1, number): # 4 6 8 10
is_prim... |
3326854b4be059c4b69da4a65be09e8f44de2b77 | min1378/-algorithm | /SWEA/중위순회.py | 1,764 | 3.828125 | 4 | class Node(object):
def __init__(self, val):
self.val = val # 자신이 관리하는 값
self.left = None
self.right = None
class Tree: # Tree(object)
def __init__(self): # 초기화 함수
self.root = None # 트리는 루트노드의 필수
def add(self, val):
if self.root is None:
self.root =... |
21ebaf035e0a5bda9b9836a8c77221f20c9f4388 | timomak/CS-1.3 | /First try 😭/redact_problem.py | 692 | 4.21875 | 4 | def reduct_words(given_array1=[], given_array2=[]):
"""
Takes 2 arrays.
Returns an array with the words from the first array, that were not present in the second array.
"""
output_array = [] # Array that is gonna be returned
for word in given_array1: # For each item in the first array, ... |
fb38793cd1651ae6b6304889e08f4d99d7fa8afd | bastiaanhoeben/bikeshare | /bikeshare.py | 8,324 | 4.25 | 4 | import math
import time
import pandas as pd
# prevent collapsing of dataframe columns in output
pd.set_option('display.max_columns', 200)
CITY_DATA = { 'chicago': 'data/chicago.csv',
'new york city': 'data/new_york_city.csv',
'washington': 'data/washington.csv' }
def get_filters():
"... |
3f5381b9a889715eb2ca9b1a43ae80a04be223d4 | thonwhal/Algoritma-Analizi | /project2/qsort.py | 12,643 | 3.78125 | 4 | import time
import random
import sys
sys.setrecursionlimit(1500000000)
def insertionSort(array): # insertion sort function
for j in range(1, len(array)): # 10.000 (array length) times loop
key = array[j]
i = j - 1
while (i > -1) and key < array[i]: # checking values lower ... |
b2939b6b41e11c4d33b3e6127b90ba04d5686aa3 | velvet-2428/Lauchpad-Assignments | /problem3.py | 155 | 3.71875 | 4 | def rem(dup):
list=[]
for num in dup:
if num not in list:
list.append(num)
return list
dup=[1,2,2,3,4,4,5,6,7,7,8,9]
print(rem(dup)) |
7b9a2642641246ec32dc5b16b9015d6ad311dfca | nicolegates/CS342 | /set2ch9.py | 1,140 | 3.796875 | 4 | # pads message with PKCS#7 format with given block size
def padPKCS7(message, block_size):
# if the length of the given message is already equal to the block size, don't pad
if len(message) == block_size:
return message
# otherwise compute the padding byt, pad the message, and return it
ch = bl... |
d562fc2499e6a84e433831975e68dc179b919bf8 | sebasvj12/listasPython | /listas.py | 439 | 3.65625 | 4 | '''
Created on 20/02/2017
@author: Casper
'''
def fun(p1,p2,p3):
if len(p1)==1 and len(p2)==1 and len(p3)==1:
return p1+","+p2+","+p3
else:
if p1[0]<p[len(p)-1]:
return fun(p1[0],p2,p3)
print("menores numeros de varis listas")
lista1= raw_input("Ingrese lista 1... |
9b46d1e08ea5eb6c128399434509361f075d5b5e | dangerous1234/print-pattern | /increment_pattern.py | 154 | 3.71875 | 4 | for i in range(4):
for j in range(i+1):
print("#",end=" ")
print()
for k in range(4):
for l in range(4-k):
range(4)
print() |
3ad75bebc34572759149b5a3aff62ec8d7e63396 | YasminTorresMora/mi-proyecto | /codigo/seguridad.py | 3,274 | 3.609375 | 4 | import random
def nuevo_usuario():
try:
print("")
print("")
print(" PROGRAMA ESTADISTICA DESCRIPTIVA")
print(" =================================")
print(" Registro de Usuario y Clave")
print("")
usuario=input(" Nuevo Usuario: ")
cla... |
7a452f765545daace2d07e255254fa9bd81250e0 | filipAnt/alien_invasion | /alien.py | 1,139 | 3.625 | 4 | import pygame
from pygame.sprite import Sprite
class Alien(Sprite):
"""Class that represent single alien object"""
def __init__(self, ai_game):
"""Initialize aliena and start location"""
super().__init__()
self.screen = ai_game.screen
self.settings = ai_game.settings
... |
7065d348fa20871e65569968f68a9b9f0ad719da | Fixdq/python-learn | /day19/blog.py | 1,164 | 3.734375 | 4 | #!/usr/bin/env python3
# encoding: utf-8
# by fixdq
# 定义一个People类
class People:
country = 'China'
def __init__(self, name, age, sex):
self.name = name
self.age = age
self.sex = sex
def run(self):
print('%s is running' % self.name)
# 实例化三个对象
people1 = People('fixd01', 18,... |
270208ced7228b38c8c090ea9f62a590c519f133 | Fixdq/python-learn | /day14/blog.py | 484 | 3.546875 | 4 | # encoding: utf-8
# by fixdq
# variable = [out_exp_res for out_exp in input_list if out_exp == 2]
# out_exp_res: 列表生成元素表达式,可以是有返回值的函数。
# for out_exp in input_list: 迭代input_list将out_exp传入out_exp_res表达式中。
# if out_exp == 2: 根据条件过滤哪些值可以。
var =[item for item in range(10) if item % 2 == 0]
print(var)
gen=('egg%s... |
85ac79cc496e784f44bc8f591f2182acd573206c | Fixdq/python-learn | /day19/dog_bite_person.py | 929 | 3.765625 | 4 | #!/usr/bin/env python3
# encoding: utf-8
# by fixdq
class Person:
def __init__(self, name, agg, health=100):
self.name = name
self.agg = agg
self.health = health
def bite(self, enemy):
enemy.health -= self.agg
print('人:%s bite 狗:%s 品种:%s 伤害:%s 狗剩余生命:%s' %
... |
cb60260754185413848dbc625c395f5eea52ebd8 | leaffan/geo | /misc/custom_coordinates.py | 4,248 | 3.75 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# File: custom_coordinates.py
# Author: Markus Reinhold
# Contact: leaffan@gmx.net
# Creation Date: 2012/03/28 11:44:54
u"""
Classes to represent geographic coordinates using components of degrees,
minutes, and seconds.
A convenient way to add dms coordinates a... |
7bc040b7b3248290d4ac3be08714189e57e737a1 | Win-Victor/algs | /algs_3_t4.py | 701 | 3.828125 | 4 | """4. Определить, какое число в массиве встречается чаще всего."""
import random
SIZE = 10
MIN_ITEM = -1
MAX_ITEM = 52
array = [random.randint(MIN_ITEM, MAX_ITEM) for _ in range(SIZE)]
print(array)
max_count = 0
max_number = None
for i in range(MIN_ITEM, MAX_ITEM + 1):
i_sum = array.count(i)
if i_sum > max_c... |
5f21ab9fdf6d7bab8a4572054ca007bc62db42d8 | Win-Victor/algs | /algs_2_t8.py | 835 | 4.1875 | 4 | """8. Посчитать, сколько раз встречается определенная цифра в введенной последовательности чисел.
Количество вводимых чисел и цифра, которую необходимо посчитать, задаются вводом с клавиатуры."""
num = input('Введите цифру для подсчета в наборе чисел:\n')
count = int(input('Укажите сколько наборов чисел Вы будете ввод... |
18e723be3886ae08f3d2be8bebf3c6eebd9ece07 | taylorschimek/treehouse_projects | /fighting_game/game.py | 2,959 | 3.671875 | 4 | import sys
from character import Character
from monster import Dragon
from monster import Goblin
from monster import Troll
class Game:
def setup(self):
self.player = Character()
self.monsters = [
Goblin(),
Troll(),
Dragon()
]
self.monster = self.... |
a15708f29f98d9c1a87029cddd54d6e02f9dfdb5 | Laxous/yoyo_sele | /PycharmProjects/jiChu/test02.py | 135 | 3.5625 | 4 | # coding=utf-8
print("hello world")
a = 'True'
b = True
c = str(b)
d = bool(a)
if b == d and a == c:
print("pass")
else:
pass
|
7f35763a82a16c63edf07788c122e805992d5323 | navacaty/PLFinalProject_rd | /PLFinalProject-master/Part1/.idea/Onlystring.py | 298 | 3.625 | 4 | def Onlystring(values):
def is_string(value):
try:
return value == str(value)
except:
return False
def make_sent(value):
return value + "is a string item"
for item in values:
if is_string(item):
print(make_sent(item))
|
53a1fc67914d8245c66296937b8b126357401f95 | dinidininta/arkademy-bootcamp-2 | /Nomor5.py | 395 | 4.03125 | 4 | def ganti(string, charA, charB):
newstring = ""
if charA not in string:
newstring = "charA tidak terdapat pada string yang dimasukkan"
else:
for char in string:
if char == charA:
newstring += charB
else:
newstring += char
return ... |
a052610e5fd5032cd1a479121704f1dc354f2068 | VigneshJanarthanan/DataScience_Assignment4 | /2.1-List_OF_WORDS-to_LIST_OF_INTEGER.py | 242 | 3.921875 | 4 | def len_words(k):
length=[]
for i in range(len(k)):
x=len(k[i])
length.append(int(x))
return length
lst=["Vignesh","Janarthanan","ACADGILD","MACHINELEARNING"]
print("Length of each word given",len_words(lst)) |
e5d83b472451facb2a6f38a174e0c8c760bc0182 | avir100/ConsultAdd | /task2/task2_2.py | 2,005 | 4 | 4 | '''
Write a program in Python to perform the following operator based task:
Ask user to choose the following option first:
If User Enter 1 - Addition
If User Enter 2 - Subtraction
If User Enter 3 - Division
If USer Enter 4 - Multiplication
If User Enter 5 - Average
Ask user to enter the 2 numbers in a variable for fir... |
dfa668f57584dc42dbc99c5835ebc0a5c0b1e0cd | avir100/ConsultAdd | /task2/task2_10.py | 815 | 4.125 | 4 | from random import randint
'''
Write a program that asks five times to guess the lucky number. Use a while loop and a counter, such as
counter=1
While counter <= 5:
print(“Type in the”, counter, “number”
counter=counter+1
The program asks for five guesses (no matter whether the correct number was ... |
0386d42dfae2e6489d916e10af178dd42a31cf26 | TimeMachine00/pythonProject-4 | /Chose-rock-paper-scissor.py | 871 | 4.21875 | 4 | print("created by hussainatphysics@gmail.com(hussainsha syed)")
print("welcome to the game")
rock = '''
_______
---' ____)
(_____)
(_____)
(____)
---.__(___)
'''
paper = '''
_______
---' ____)____
______)
_______)
_______)
---.__________)
'''
scissors = '... |
1e3cd8b551a842059e58859e0513e053ebb260d0 | goodcheer/songorithm | /medium/week1/binary-tree-inorder-traversal_32ms_14mb.py | 1,482 | 4.0625 | 4 | class Node:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Solution:
"""solution from https://www.geeksforgeeks.org/inorder-tree-traversal-without-recursion/ """
def inorderTraversal(self, root: TreeNode) -... |
ed7d751da810e5d831e3488c5d7ab8cd1849440e | goodcheer/songorithm | /medium/week1/palindromic-substrings_128ms_14.4mb(expand).py | 1,057 | 3.578125 | 4 | class Solution:
def countSubstrings(self, s: str) -> int:
def expand(left: int, right: int) -> int:
count = 0
while left >= 0 and right < len(s) and s[left] == s[right]:
# count the palindrome and expand outward
count += 1
... |
906ad6a68acfc1755487f52ac01b2612db2b10b4 | ateeqmughal266/Python-Assignment | /Python Assignment3.py | 1,074 | 3.765625 | 4 | val1=int(input("Enter a number:"))
val2=int(input("Enter a number:"))
operand=str(input("Enter operand:"))
if operand=="+":
result=val1+val2
print(result)
elif operand=="-":
result=val1-val2
print(result)
elif operand=="*":
result=val1*val2
print(result)
elif operand=="/":
result=val1/val2
... |
76c2eb4bd642b6af3826514cf05fd481867fe9b7 | gxu12/Leetcode | /剑指Offer/7 前序中序推导二叉树.py | 1,776 | 3.640625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Oct 12 00:55:01 2020
@author: xuguiming
"""
# 根据前序以及中序 推出二叉树
# 1. 递归
def buildTree(preorder,inorder):
if len(preorder) == 0:
return None
ind = inorder.index(preorder[0])
root = TreeNode(preorder[0])
#ind表示左子树有多少个元素,所以这里是... |
34f95d8f063fc886569aa4b890f20beca8f19881 | Awesomeplayer165/Bagels-Game-with-Python | /main.py | 544 | 3.8125 | 4 | # main.py
secretNumber = "345"
numberOfGuesses = 0
while numberOfGuesses != 10:
userInput = input("Enter a 3 digit number: ")
if len(userInput) != 3: print("Enter a 3 digit number and try again"); continue
for index, char in enumerate(userInput):
if char in secretNumber and secretNumber[index] == char:
prin... |
9dc68b9e209f9810bc12836c0114ba18232b72e4 | jake-welch/102-Lab | /Week12-utlilities.py | 1,822 | 3.53125 | 4 | def PrintOutput(words):
print("OUTPUT",words)
def LoadFile(fileName):
newList = []
file = open(fileName,'r')
lines = file.readlines()
for i in lines:
newList.append(i[0:-1])
return newList
def UpdateString(daString,letter,index):
newString = ''
a = 0
for i in daString:
... |
b57312d8128cc79a9360310526bd92fa765a8208 | min0201ji/PythonStudy | /Ch03/data_type/01_data_type.py | 277 | 4 | 4 | # 정수 : int
num = 100
print(num, type(num))
# 실수 : float
PI = 3.14
print("PI :", type(PI))
# 문자옇 : str
name = '박민지'
print("name: ", type(name))
# bool
done = True
print("done: ", type(done))
# 변수의 자료형
a = 100 #class int
a = 'hello' #class str |
13cd9031d52ae07813bf35993350d2d1b94d27a1 | min0201ji/PythonStudy | /Ch03/파이썬내장함수/02_lambda식.py | 805 | 3.625 | 4 | # 7월6일(화) - 2교시
# 람다 식 : lambda - 교재 pp123
# # lambda : 실행 시(런타임) 생성해서 사용할 수 있는 익명 함수
# # 익명함수 : 이름이 없는 함수
# # 입력과 출력이 있는 간단한 한 행짜리 함수를 만들 때 사용
# # 같은 함수를 def 문으로 정의할 때보다 간결
# # 형식 : lambda 매개변수 : 표현식(lambda 매개변수 : 리턴값)
## 두개의 정수를 인수로 입력받아 더한결과를 출력하는 함수: 함수명 add(a,b)
# def로 정의한 함수
def add(a,b):
return a+b
pri... |
e3772c13fdd37954538cdd1756e764d5dbbb6964 | min0201ji/PythonStudy | /Ch03/tuple_dict_set/03_set연산.py | 342 | 3.734375 | 4 | A = {1,2,3}
B = {3,4,5,6}
# 합집합 - 반환결과 집합
#a|b
print(A|B)
# a.union(b)
print(A.union(B))
print('===================')
# 교집합 - 반환결과 집합
# a&b
print(A&B)
# a.intersection(b)
print(A.intersection(B))
print('===================')
# 차집합
# a-b
print(A-B)
# a.difference(b)
print(A.difference(B))
|
f22e40906f45e94bdb50b79d8901c729dd0b9c79 | min0201ji/PythonStudy | /Ch03/If/06_if_ex4.py | 252 | 3.828125 | 4 | x = int(input('정수1 입력: '))
y = int(input('정수2 입력: '))
z = int(input('정수3 입력: '))
if x>y and x>z:
print('제일 큰 수 : %d' %x)
elif y>x and y>z:
print('제일 큰 수 : %d' %y)
else:
print('제일 큰 수: %d' %z) |
c454288efe670d46e8b99e1f9a1130f1e2e08888 | min0201ji/PythonStudy | /Ch03/while/while_ex2.py | 198 | 3.65625 | 4 | # while 연습문제2
"""
sum = int(input('마지막 숫자를 입력 하시오: '))
i = 0 #초기변수
sum = 0 #누적 변수
while i <= sum:
if i % 2 == 1:
sum += i
i += 1
""" |
b9ae1ed388af01992a89da01a5716bbf1046e886 | min0201ji/PythonStudy | /Ch03/for/for_ex5.py | 387 | 4.09375 | 4 | # 다중 for문을 사용하여 다음과 같이 출력
for y in range(3):
for x in range (1,5):
print(x, end=' ')
print()
"""
a = 0
for i in range(3):
# a += 1 # 이 문장의 수행 횟수는? 3회
for j in range(4):
a += 1 # 이 문장의 수행 횟수는? 12회
print(a, end="\t")
a += 1 # 최종 a의 값은? 12회
print()
"""
|
51468ec7f20605b55b79b85a252d6839c9f579cf | min0201ji/PythonStudy | /Ch03/variable/06_constant.py | 605 | 3.515625 | 4 | # 상수
# 값이 변경되지 않는 값
# 파이썬에서는 별도의 상수가 없음
# 변수와 구분하기 위해 대문자로 사용할 뿐
# 나중에 상수의 값을 변경해도 오류 없음
PI = 3.141592
r = 10
area = r*r*PI
print(area)
INT_RATE = 0.03 #상수로 사용하기 위해 할당
deposit = 10000
interest = deposit * INT_RATE
balance = deposit + interest
print(balance)
print(int(balance)) #int() 정수형변환 함수
# 천단위 구분기호 사용
print(fo... |
f911e48ef0e97acc12b1f7b6c7593ca72df222b5 | min0201ji/PythonStudy | /Ch03/class_object/05_classs5_클래스예제.py | 1,396 | 3.796875 | 4 | # 7월6일 (화) 7교시
# 1. 숫자를 하나 증가하는 메서드
# 2. 숫자를 0으로 초기화 하는 메서드
# 3. 숫자를 저장하는 속성(멤버변수) - 생성자 함수
# 4. 현재 숫자값을 출력하는 메서드
class Counter:
def __init__(self):
self.num = 0
def increment(self):
self.num += 1
def reset(self):
self.num = 0
def print_current_value(self):
print('현재... |
21d59dd62eba9465bb961ae6ef9d030ddf5b302e | min0201ji/PythonStudy | /Ch03/string/isalpha_ex.py | 658 | 3.90625 | 4 | # print(input('문장을 입력하세요 : '))
# 알파벳:
"""
#선생님 강의
#count 누족변수 초기화
alphas=digits=space=others=0
#문장을 입력받는 코드
string=input('문자를 입력하세요: ')
# 입력된 문장을 하나씩 추출해서 판단하는 코드
for c in string:
#print(c) # c변수에 한 문자씩 대입
if c.isalpha(): #c.isalpha()==True
alphas = alphas + 1
elif c.isdigit():
digits += ... |
69b4ba23342c953f99a48ba5dbadd2dd841ced87 | min0201ji/PythonStudy | /Ch03/function/function_ex1.py | 380 | 3.890625 | 4 | # 연습 문제 1
def sum():
num1 = int(input('숫자1 입력: '))
num2 = int(input('숫자2 입력: '))
return num1 + num2
total = sum()
print('합: %d' %total)
"""
7월2일(금) - 4교시_7월1일 연습문제 풀이
def sum():
num1 = int(input('숫자1 입력: '))
num2 = int(input('숫자2 입력: '))
print('합: %d' %(num2 + num1))
sum()
""" |
214a5b7fb87d1986870cc699f5105c955e2588a6 | min0201ji/PythonStudy | /Ch03/function/function_ret_param_ex1.py | 422 | 3.875 | 4 | # 7월2일(금) - 5교시_7월1일 연습문제 풀이
# 사칙 연산 함수 작성
def add(a,b):
return a + b
def sub(a,b):
return a - b
def mul(a,b):
return a * b
def div(a,b):
return a / b
## 함수 호출 테스트 ##
x = 9
y = 3
print('%d + %d = %d' % (x,y, add(x,y)))
print('%d - %d = %d' % (x,y, sub(x,y)))
print('%d * %d = %d' % (x,y, mul(x,... |
07ebec8b82420cd301417d7ebcbbe8b6a004ba8a | meridiani/AoC-2017 | /day01/answer.py | 909 | 3.734375 | 4 | ### Maria Duffy
### My solution to Day 1 - Advent of Code
from numpy import *
### First read in the numbers
myFile = open('myList.txt','r')
myString = myFile.read()
myFile.close()
stringLength = len(myString)
### Fix the file so it has no extra character at some point
if (myString[0]==myString[-2]):
print "Oh n... |
ad0f8266f9f088212769b638ef2e1fb74ebb1b89 | metshein/python | /it19_if_laused.py | 668 | 3.84375 | 4 | tehtemark = input('''
Palun vali õige tehtemärk:
+ liitmiseks
- lahutamiseks
* korrutamiseks
/ jagamiseks
''')
number_1 = int(input('Esimene number: '))
number_2 = int(input('Teine number: '))
if tehtemark == '+':
print('{} + {} = '.format(number_1, number_2))
print(number_1 + number_2)
elif tehtemark == '-... |
8fdb362aa4fb0de01b740a5a840904bf329b5f22 | lzeeorno/Python-practice175 | /terminal&py.py | 696 | 4.125 | 4 | #how to use python in terminal
def main():
while True:
s = input('do you come to learn how to open py doc in terminal?(yes/no):')
if s.lower() == 'yes':
print('cd use to enter doc, ls to look the all file, python filename.py to open the py document')
s1 = input('do you unders... |
25d6dd3299b1a2785ce8116da56770237ade4776 | lzeeorno/Python-practice175 | /175 _labs/lab9_q2.py | 2,180 | 3.65625 | 4 | class Student:
def __init__(self, student_id, name, mark):
self.ID = student_id
self.name = name
self.mark = mark
def __str__(self):
return "\nID:{:10} name:{:20} mark:{}".format(str(self.ID), self.name, str(self.mark))
def __repr__(self):
return "\nID:{:10} name:{:... |
e27ada4c0d14ba5e57f4b9f1059a70d2e18da209 | lzeeorno/Python-practice175 | /175 _labs/lab1_q2.py | 1,294 | 3.921875 | 4 | f = open('lab1q2_input_earthquake.txt','r') # open the file
string = f.read() # read the file
list_of_string = string.splitlines() # split the lines between the string and create a list
def output():
# create the dictionary of earthquake data
# by spliting up the elements inside the list_of_stiring
# retu... |
db27825139d554441b2839d702e7a062650a04a5 | lzeeorno/Python-practice175 | /175_assignments/assignment3.py | 8,939 | 3.8125 | 4 | #assignment3
#Zheng Fuchen (Leon), 1465251
# step 1
import random
# import the random for shuffling the cards
suits=["D", "C", "H", "S"]
ranks=["2","3","4","5","6","7","8","9","0","A","J","Q","K"]
while True:
filename = input("please enter the game name(shuffleddeck): ") #prompt player to input the game name
... |
14a84fdbc18ce604fc44ae7faff93686e7622761 | Degureshaff/python.itc | /python/day17/def_1.py | 447 | 4.15625 | 4 | def calculator(num1, num2, suff):
if suff == '*':
print(num1 * sum2)
elif suff == '/':
print(num1 / num2)
elif suff == '**':
print(num1 ** num2)
elif suff == '+':
print(num1 + num2)
elif suff == '-':
print(num1 - num2)
num1 = int(input('Число 1: '))
num2 = in... |
f65b5fba33417f7eea92cbebe8871b50bb12b9c3 | Degureshaff/python.itc | /python/day19/main.py | 943 | 3.671875 | 4 |
# import module_0
# phone = input('Введите номер телефона: ')
# module_0.check_phone_number(phone)
# import module_0
# module_0.translate()
# fio = module_0.getFullName('Амантур', 'Торогулов')
# print(fio)
# import mylib.calc.calculator as calculate
# import random
# rstart = int(input('Введите начала рандома:... |
46f91e84678470fa56e0e2bc0bc333a57c8deed5 | Degureshaff/python.itc | /python/day22/try_0.py | 566 | 3.6875 | 4 |
try:
a = int(input('Введите первое число: '))
b = int(input('Введите разделитель числа: '))
z = a / b
print(z)
except NameError:
print('Ошибка: Неправильные переменные')
except IndentationError:
print('Ошибка: Отступы в коде')
except ValueError:
print('Ошибка: Текст не синтаксируется')
except ... |
1d1edccb227ef9c193756534653eccb0f80db859 | Degureshaff/python.itc | /python/day3/calculator.py | 319 | 4 | 4 | number1 = input('Введите первое число: ')
number2 = input('Введите второе число: ')
number1 = int(number1)
number2 = int(number2)
print(number1 + number2)
print(number1 - number2)
print(number1 / number2)
print(number1 * number2)
print(number1 % number2)
print(number1 ** number2)
|
05e222fc7c01e9875b5dc694892cbdf886681264 | Degureshaff/python.itc | /python/day18/def_0.py | 654 | 3.828125 | 4 |
# def my_function(name, number):
# print('World', name)
# print('Country')
# print('Great Jobs')
# name = name + ' REPUBLIC'
# print(name, '\n')
# if number < 0:
# print('Дай десятое число')
# else:
# number = number * number
# print(number)
# my_function(-7)
def... |
8cb1a0eb539da592941c6686a949c6947df629a6 | Degureshaff/python.itc | /python/day18/def_3.py | 221 | 3.515625 | 4 |
def perimetr(p):
return p * 4
def aiant(s):
return s * s
p = int(input('Введите сторону крадрата: '))
x = perimetr(p)
s = aiant(p)
print('Периметр: ', x)
print('Аянты: ', s)
|
d5e5857bec6f090de9f58ec0e44201544394c256 | NehaRapolu3/python-tasks | /task 3.py | 248 | 3.9375 | 4 |
function= input("enter names seperated by space")
words = function.split(" ")
length = 0
word = " "
for i in range(len(words)) :
if len(words[i]) > length :
length = len(words[i])
word = words[i]
print(word)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.