blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
2f7e6f021c3ed05aa61091d0d55a8425423134d5
akash-kaushik/Basic-Programs-Python
/Python Program to check Armstrong Number.py
677
3.859375
4
# -*- coding: utf-8 -*- """ Created on Sun Sep 20 10:45:56 2020 @author: Akash Kaushik """ def user_input(): number = "Wrong" while number.isdigit() == False: number = input() if number.isdigit() == False: print("Please Enter number only!") return in...
b20b9dbf76f4e117ffc74ce5853f29d142504a1c
akash-kaushik/Basic-Programs-Python
/Python Program for Program to find area of a circle.py
392
4.03125
4
# -*- coding: utf-8 -*- """ Created on Mon Sep 21 09:03:38 2020 @author: Akash Kaushik """ def user_input(): r = "Wrong" while r.isdigit() == False: r = input("Enter the Radius: ") if r.isdigit() == False: print("Enter the Correct Input!") retur...
ec72975409e3eda6707fcb67778244299c00431e
Rhotimie/ZSSN
/lib/util_sort.py
1,361
4.125
4
import itertools def sort_tuple_list(tuple_list, pos, slice_from=None): """ Return a List of tuples Example usage: sort_tuple_list([('a', 1), ('b', 3), ('c', 2)]) :param status: list of tuples :type status: List :param list: :param int: :return: sorted list of tuples e.g [('a', ...
b445be9fa502014837bbc795a20d74940eb7d72d
NotBobTheBuilder/conways-game-of-life
/conways.py
2,242
4.125
4
from itertools import product from random import choice def cells_3x3(row, col): """Set of the cells around (and including) the given one""" return set(product(range(row-1, row+2), range(col-1, col+2))) def neighbours(row, col): """Set of cells that directly border the given one""" return cells_3x3(ro...
fae794e3b78517e388e20cbf4cc0235cb93d6e4c
kl98735/whatsthatbridge
/mysite/bridge/scraping.py
3,750
3.59375
4
import requests from bs4 import BeautifulSoup from .models import Bridge def get_bridgehunters_page(url, county): """ this function will open the page and return the entire contents of the page :param county: the name of the county of interest :param url: the url for the state of interest :return...
66dd5d112a122295f193971f2e75d847c95e71f2
becsully/Exercises
/hangman.py
3,422
3.875
4
import random import string def display(misses): hangman_dict = {0: "O", 1: "|", 2: "/", 3: "\\", 4: "/", 5: "\\"} game_dict = {0: " ", 1: " ", 2: " ", 3: " ", 4: " ", 5: " "} if misses: for i in range(len(misses)): game_dict[i] = hangman_dict[i] print """ _____ | \| %s | %s%...
8f9ae47a4515c47e0e8b7f4ce6f76be423815cb9
purexiaoxiao/test-software-and-gadgets
/tozip.py
1,799
3.5
4
def main(): import tkinter as tk import tkinter.filedialog import tkinter.messagebox import os import xlwt import zipfile def mytozip(): if text2.get() == '': tk.messagebox.showerror('名称错误', '压缩文件名称为空') return if text1.get() == '': tk.mess...
f725dd90893e562100ae72c3eb5ad3695e38700e
Manjuchandan/SL-LAB
/SEE/4/rectangle.py
287
4
4
class rectangle: def __init__(self,breadth,length): self.breadth=breadth self.length=length def area(self): return self.breadth*self.length print("enter the length") a=int(input()) print("enter the breadth") b=int(input()) obj=rectangle(a,b) print("area:",obj.area())
75a50b30576330555af23ed2708df343a3f3a8cb
EvgeniiGrigorev0/home_work-_for_lesson_2
/lesson_5/hw_6_lesson_5.py
1,231
4
4
# 6. Необходимо создать (не программно) текстовый файл, # где каждая строка описывает учебный предмет и # наличие лекционных, практических и лабораторных # занятий по этому предмету и их количество. Важно, # чтобы для каждого предмета не обязательно были все # типы занятий. Сформировать словарь, содержащий # название п...
1db2a4fbd6827d302d3adb1562911e404b3ed2f5
EvgeniiGrigorev0/home_work-_for_lesson_2
/Lesson_3/HW_2_Lesson_3.py
1,162
4.125
4
# 2. Реализовать функцию, принимающую несколько параметров, # описывающих данные пользователя: имя, фамилия, год рождения, # город проживания, email, телефон. Функция должна принимать # параметры как именованные аргументы. Реализовать вывод # данных о пользователе одной строкой. ... name = input('Введите ваше имя: ')...
0329acb60cb7e2109c76e74f44ada0c34a1093bf
EvgeniiGrigorev0/home_work-_for_lesson_2
/lesson_5/hw_5_lesson5.py
788
3.90625
4
# 5. Создать (программно) текстовый файл, # записать в него программно набор чисел, # разделенных пробелами. Программа должна # подсчитывать сумму чисел в файле # и выводить ее на экран. def summary(): try: with open('пятое задание.txt', 'w+', encoding="utf-8") as my_file: line = input('Введите...
f898ae48a631cd8093c3b388989f62de4238bd7f
N140191/Turtle-Graphics
/tkinter_test.py
301
3.75
4
from tkinter import * def main(): rt=Tk() rt.title("My first tkinter App") rt.minsize(width=300,height=300) rt.maxsize(width=300,height=300) button=Button(rt,text="Click!!",width=12,height=1) button.pack() rt.mainloop() if __name__=="__main__": main()
2abacb72e43b209506c59c312e8a3990102b8244
rovalantra/pythonProject
/lotstuff.py
198
3.828125
4
def checkEqual(a): for i in a: if i == a[i]: print(i) thisdict = { "ford": "mustang", "grout": "grout gun", "chevy": "chevy"} checkEqual(thisdict)
1c853c84061e2079fcaf9a3fe777d2bb49853175
amitdshetty/MapColoring
/Without Visualization/America/Without_Heuristic/ForwardChecking.py
9,962
3.578125
4
# Python program for solution of M Coloring # problem using backtracking import time stateDictionary = {} colorDictionary = {"1":"red", "2":"green", "3":"yellow", "4":"blue"} ResultDictionary = {} DomainDictionary = {} class Graph(): def __init__(self, vertices): self.V = vertices self.graph...
07108ea2214082f5d0369df32d22354ce517cea5
dntlakfn/algorithm
/boj/2562.py
146
3.828125
4
max_num = 0 lo = 0 for i in range(1, 10): num = int(input()) if max_num < num: max_num = num lo = i print(max_num) print
165e3ae62c156a9899c9fbd7189b5802449e7104
sheanaaron/AlgorithmsAndAnalysis
/Assign1-s87643-s67890-JAVA (1).zip_expanded/Assign1-s87643-s67890-JAVA/assign1TestScript.py
8,178
3.5625
4
# # Script to perform automated testing for assignment 1 of AA, 2021 semester 2 # # The provided Python script will be the same one used to test your implementation. # We will be testing your code on the core teaching servers (titan, jupiter etc), so please try your code there. # The script first compiles your Java cod...
7493bd29512b106bffb3f010e08a7b014ac706e1
nahiphog/mathematics
/recreational_number_theory.py
4,332
3.65625
4
###################################################### ##### [1] Digital Sum ###################################################### from eulerlib.numtheory import * print( digital_sum(input_number) ) ###################################################### ##### [2] Digital Root #########################################...
6cc2fc74b14b222d6e48553a2228f765bf178390
ALT-Browne/Sudoku
/play.py
587
3.625
4
from create_Sudoku import * def playNewSudoku(size, symbols, num_clues): """ Find a valid Sudoku puzzle with num_clues clues. param size: int - square number between 4 and 100 inclusive param symbols: str - either "numbers" or "letters" param num_clues: int - (e.g. for size 9, must be between ...
ad7c654fe28a7eba1bd25dd1c86d0bd44ea91230
Acang98UP/LeetcodeInPython
/1473-粉刷房子Ⅲ-Hard/minCost.py
1,510
3.625
4
from functools import lru_cache from typing import List def minCost(houses: List[int], cost: List[List[int]], m: int, n: int, target: int) -> int: @lru_cache(None) def dfs(idx, color, t): if t < 0 or t > m - idx: return float("inf") if idx == m: return 0 curr = ...
5d84f0e4f422f42c9f6c5aa368eef50010199b03
Acang98UP/LeetcodeInPython
/746-花费最小力气爬楼梯-Simple/minCostClimbingStairs.py
379
3.640625
4
from typing import List def minCostClimbingStairs(cost: List[int]) -> int: n = len(cost) dp = [0] * n dp[0], dp[1] = cost[0], cost[1] for i in range(2, len(cost)): dp[i] = min(dp[i - 2], dp[i - 1]) + cost[i] return min(dp[-2], dp[-1]) def main(): cost = [10, 15, 20] print(minCostC...
3d685ebd95ef4fe7aae87fce5a9d80145e27176d
Acang98UP/LeetcodeInPython
/867-转置矩阵-Simple/transpose.py
545
3.96875
4
from typing import List def transpose(matrix: List[List[int]]) -> List[List[int]]: row, column = len(matrix), len(matrix[0]) res, temp = [], [] for i in range(column): for j in range(row): temp.append(matrix[j][i]) res.append(temp) temp = [] return res def main():...
e634b0fe0224d8f7c703cee0813dc6e1acf97386
Acang98UP/LeetcodeInPython
/80-删除有序数组中的重复项Ⅱ-Mid/removeDuplicates.py
733
3.75
4
from typing import List def removeDuplicates(nums: List[int]) -> int: if len(nums) <= 2: return len(nums) else: index = 1 flag = 0 while index != len(nums): if nums[index] == nums[index - 1] and flag == 0: index += 1 flag = 1 ...
1c3b66d11a482489a027563e7595e31d0f3ccab8
Acang98UP/LeetcodeInPython
/509-斐波那契数-Simple/fib_dp.py
248
3.578125
4
def fib(n: int) -> int: # 便捷的解决方案:动态规划 dp_0, dp_1 = 0, 1 for _ in range(n): dp_0, dp_1 = dp_1, dp_1 + dp_0 return dp_0 def main(): n = 4 print(fib(n)) if __name__ == '__main__': main()
db9dca955420ce43992d8043081386398bbe1542
Acang98UP/LeetcodeInPython
/721-账户合并-Mid/accountsMerge.py
2,095
3.625
4
from typing import List class UnionFind: def __init__(self): self.father = {} # 根节点所在集合的所有账户 self.accounts = {} def find(self, x): if not self.father[x]: return x # 递归的路径压缩处理 self.father[x] = self.find(self.father[x]) return self.father[x]...
0972408be543a44050a1968d552a888fa1d1bc10
Acang98UP/LeetcodeInPython
/435-无重叠区间-Mid/eraseOverlapIntervals.py
248
3.640625
4
from typing import List def eraseOverlapIntervals(intervals: List[List[int]]) -> int: return 0 def main(): intervals = [[1, 2], [2, 3], [3, 4], [1, 3]] print(eraseOverlapIntervals(intervals)) if __name__ == '__main__': main()
e9fa53ee984dafd56d172ce4970da69ef680182e
Acang98UP/LeetcodeInPython
/872-叶子相似的树-Simple/leafSimilar.py
1,141
3.6875
4
# Definition for a binary tree node. from typing import List class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def leafSimilar(self, root1: TreeNode, root2: TreeNode) -> bool: res1 = self.bfs(roo...
b63289293c7f64c7430caa12bf056b2a3c0601f3
Acang98UP/LeetcodeInPython
/697-数组的度-Simple/findShortestSubArray.py
602
3.671875
4
import collections from typing import List def findShortestSubArray(nums: List[int]) -> int: left, right = dict(), dict() counter = collections.Counter(nums) for i, num in enumerate(nums): if num not in left: left[num] = i right[num] = i counter[num] += 1 degree = m...
6e174df4133d2e903206421a48a2f23f76ca4c6a
Acang98UP/LeetcodeInPython
/628-三个数的最大乘积-Simple/maximumProduct.py
445
3.859375
4
from typing import List def maximumProduct(nums: List[int]) -> int: nums = sorted(nums) if nums[0] < 0 and nums[1] < 0: maxNumber = max(nums[0] * nums[1] * nums[-1], nums[-1] * nums[-2] * nums[-3]) else: maxNumber = nums[-1] * nums[-2] * nums[-3] return maxNumber def main(): nums...
026142518ddc65e5cccd3db3b65bfd169aae1fd2
Acang98UP/LeetcodeInPython
/566-重塑矩阵-Simple/matrixReshape.py
912
3.671875
4
from typing import List def matrixReshape(nums: List[List[int]], r: int, c: int) -> List[List[int]]: M, N = len(nums), len(nums[0]) if M * N != r * c: return nums res = [[0] * c for _ in range(r)] row, col = 0, 0 for i in range(M): for j in range(N): if col == c: ...
28edadd0bef4add75cbf34cfd9397301b6095b32
ukriish/cs-for-all-python
/editDistance.py
477
3.96875
4
def distance(first, second): ''' Rerturns the minimum edit distance between two strings ''' if not first: return len(second) elif not second: return len(first) elif first[0] == second[0]: return distance(first[1:], second[1:]) else: replace = 1 + distance(first[1:], second[1:]) insertion = 1 + ...
c96a641604e36bfff1b9354cbc4bffeec69dee88
nabeelahmed/so_answers
/recursion/print_back.py
178
3.90625
4
def print_backward(num): if num == 10: return num += 1 print(num) print_backward(num) print("yeah") print(num) print() print_backward(6)
c0c2c2384f72288c4194fa94098c904d50b168a9
kyle123c/Python-ISM4403-Class-Projects
/Assignment2.py
1,488
3.859375
4
# 1 x = True mylist = [] while x: userlist = input("Please enter your favorite game(Enter 'Game Over!' to stop):") print("The game entered was: " +str(userlist)) if userlist == "Game Over!": print("The input was Game Over!. Exiting...") x = False else: mylist.append(userlist) continue print("G...
a2fc3df3abaa5ddc16870865fc6acfe0bb69e66e
abdullah594/udacity_intro_prog
/Adventure Game Project/adventure_game_abdullah.py
5,595
4.0625
4
# Configuration import time import random # Repetitive Functions def print_pause(message): print(message) time.sleep(1.5) def answer(opition1, opition2, function1, function2): print_pause('\nWhat do you want to do?') while True: answer = input('\nEnter (1) if you want to ' + opition1 + '\nOR...
faf7414fc3ad4e7b0be32fb79ea6a94fe840a3c2
IMSRIJAN04/python_scripts
/all_subarrays_of_an_array.py
168
3.984375
4
arr=[1,2,3,4,5] n=len(arr) size=1 for k in range(n): for i in range(k,n): print("@@@@@") for j in range(k,i+1): print(arr[j])
0fbc41363a0f99f60c87ccd18bfa75209defad4d
dowobeha/moses_mpe_experiments
/align.py
2,107
3.859375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- from collections import defaultdict import fileinput import random import sys ####################################################### def lexicalPT(filename): condprob = defaultdict(lambda: defaultdict(int)) for line in fileinput.input(filename): value...
2e3e0ee14690892934b82f509eb903b26bd204b3
Smilliam/aoc-2020
/day6/customs.py
1,399
3.625
4
class CharSet(): def __init__(self, string): self._chars = [0 for x in range(0, 26)] self.add_answers(string) def add_answers(self, answers): for ch in answers: letter_idx = ord(ch) - 97 self._chars[letter_idx] ^= 1 def num_unique_answers(self): ret...
7ba3d15de5c18eb40f5772c186962e9bb7ffca4c
Shandris1/QAC-work-Python
/Python/AddingClasses.py
305
3.625
4
class Replicate(): """docstring for Replicate""" def __init__(self, A=0, B=0, C=0): self.a = A self.b = B self.c = C def __add__(self, other): print("2+2") return self.a * other.a china = Replicate(5) japan = Replicate(7) print(china + japan) 6 + 4
3ce604d78137fee8c8c50a4b12ed4a18aeb4a537
Shandris1/QAC-work-Python
/Python/CopyWithAlteration.py
551
3.828125
4
FileLocation = input("LOCATE A FILE FOR ME, MORTAL") #FileLocation = "war-and-peace.txt" F = open(FileLocation, "r") #F = open("war-and-peace.txt", "r") W = open("Result.txt", "w") W.close W = open("Result.txt", "a") Data = F.read() LetterToReplace = "T" LetterReplaceWith = "Liveform Annihilated" LetterToReplace = in...
deb44e634cfb9e63cabb2ef80681d1918579812f
4DimensionalNinja/FileScoring
/bb_dictFcts.py
874
4.0625
4
"""Functions for manipulating dictionaries with numeric keys""" def sortDictByNumVal(dictIn): """sort a dictionary by its positive numeric values""" sortedList = list(dictIn) for i in range(len(sortedList)): highest = 0 highestIndex = 0 for j in range(i, len(sort...
7b2130e77eba12f27d2281d202414ba3db973dda
Neeraj-kaushik/Coding_With_Us
/Python/String/Highest_Occuring_Character.py
292
3.765625
4
ASCII_SIZE=256 def max_occuring_character(str): count=[0]*ASCII_SIZE max=-1 c='' for i in str: count[ord(i)]+=1 for i in str: if max<count[ord(i)]: max=count[ord(i)] c=i return c str=input() print(max_occuring_character(str))
236c8b724e42f0966bdb84605e3bf1d6a1ff04be
Neeraj-kaushik/Coding_With_Us
/Python/Array_List/Triplet_Sum.py
382
3.53125
4
def triplet_sum(li,num): count=0 for i in range(len(li)): for j in range(i+1,len(li)): for k in range(j+1,len(li)): if li[i]+li[j]+li[k]==num: count=count+1 print(count) t= int(input()) while t>0: n=int(input()) li=[int(x) for x in input().sp...
35bf2b414313a862aa2535eb7ba42c2b0468c716
Neeraj-kaushik/Coding_With_Us
/Python/Two_Dimensional_List/Largest_Row_Or_Column.py
691
3.625
4
def largest_sum(li,n,m): max_row=-1 max_column=-1 sum1=0 sum2=0 for i in range(n): for j in range(m): sum1+=li[i][j] if max_row<sum1: max_row=sum1 row=i sum1=0 for i in range(n): for j in range(m): sum2+=li[j][i] ...
64ad25f801c6b64a1fb268c44521fb7b7e30b1fc
jsjessen/355_ProgrammingLanguageDesign
/6hw/skeleton_code.py
6,901
3.578125
4
#!/usr/bin/env python import sys, re # Put your name and submission date here. # This submission is based on the template interpreter: # A simple postscript interpreter. It provides only minimal error # checking. # CptS 355 students have permission to use this code as the basis # for their SSPS interpreter (...
fa6a1fbe8c18ad08127f5f4915e2f20ecbbc9bd3
jsjessen/355_ProgrammingLanguageDesign
/sps/d
883
3.515625
4
#!/usr/bin/env python3 def debug(*s): """Print but only when debugging""" if debugging: print(*s) def test(function, outputs, *inputs): """Test function with inputs and compare actual outputs with expected""" result = True for o, i in zip(outputs, *inputs): actual = function(*i) ...
787519a372341b8b8be37a7df7e108f4eb3e7d6d
R34prZ/PyGar.io
/world.py
4,651
3.53125
4
import pygame import enemy, player from random import randint from math import sqrt class World(): def __init__(self, surface, size : int, x = 0, y = 0): """ Set up world generation. Consider "size" as the number of times the screen size you want the game map to be. """ ...
c5f932aa2235d4115bfd2b9c152219a25179c0ae
mahi27/ProjectEuler
/problem14.py
394
3.671875
4
lookup = {} def countTerms(n): if n not in lookup: if n == 1: lookup[n] = 1 elif not n % 2: lookup[n] = countTerms(n / 2)[0] + 1 else: lookup[n] = countTerms(n*3 + 1)[0] + 1 return lookup[n], n for _ in range(int(input())): ...
a6dc5e3f5f22304bde64ae5b184af4bcc9cdd702
GedTest/PCS-IT3
/projekt-python-master/03-types/set.py
2,122
4
4
''' Set je množina jedinečných hodnot Set je neuspořádaná a neindexovaná množina V Pythonu je zapisujeme mezi složené závorky ''' my_set = {2, 3, 9, 7} print('Množina my_set: ', my_set) print('Typ my_set: ', type(my_set)) # Vytvoření množiny ze seznamu hodnot (list) numbers = [1, 4, 1, 5, 3, 3, 1, 2, 8, 2] print(...
f95a9ae71e7fc6f6d4c9510ee4573c6a0ee5e682
sluzynsk/aoc2017
/day3p1.py
663
3.546875
4
# Advent of code # day 3 puzzle 1 # # (C) 2017 Steve Luzynski <steve@luzynski.net> # this puzzle is twisted and made my head hurt # example puzzle board # # 17 16 15 14 13 # 18 5 4 3 12 # 19 6 1 2 11 # 20 7 8 9 10 # 21 22 23 24 25 # 0,0 is the 1 square from math import sqrt, floor, ceil...
79ca0ac9c5f73f71a91ea237c68acf940944c0c9
sluzynsk/aoc2017
/day5p1.py
502
3.609375
4
# Advent of code # day 5 puzzle 1 # # (C) 2017 Steve Luzynski <steve@luzynski.net> lines = [] with open('test.txt') as f: for line in f: lines.append(int(line)) print len(lines) pc = 0 jump = 0 count = 0 while pc < len(lines): print("pc ", pc, " count ", count) count += 1 # increment instructio...
21e09edf99e14539083b8506a844ec9ec2ce79c8
sgennari/cmpt_100_tutorials
/functions/solutions/solution1.py
289
3.921875
4
def total_slices(num_pizzas, slices_per_pizza): """ (int, int) -> int Return the total number of slices in num_pizzas pizzas that each have slices_per_pizza slices. >>> total_slices(2, 30) 60 >>> total_slices(1, 8) 8 """ return num_pizzas*slices_per_pizza
13b3a94339ce7d50f8673bd7e0107284b54c348b
sgennari/cmpt_100_tutorials
/dictionaries/solutions/solution4.py
556
4.0625
4
def invert_dictionary(d): """ (dict) -> dict Precondition: Values of d are immutable Return a new dictionary where the keys in the new dictionary are the values from d, and the values are lists of the keys that are associated with those values from d. >>> invert_dictionary({"cherry": "red", "...
f53dd5cc62988bb3010243b551b5b379c3cfe8be
SaiSriLakshmiYellariMandapaka/python_programs
/perfect_square.py
204
3.84375
4
#perfect square is a product of two equal integers #Program to find if a given number is perfect square or not import math def isPerfect(n): value = math.sqrt(n) return((value - floor(value) == 0)
c028bdd2a059beca3f9606d8d8af87f4ef4a5b0c
ims010/py
/variable_scope.py
2,104
4.0625
4
# LEGB - Local(function), Enclosing(enclosing function), Global(top-level), Built-in x = 'global x' def test(): y = 'local y' # print(y) print(x) test() # print(y) print(x) # local and global variables def test(): x = 'local x' print(x) test() # updating global va...
19c5a9790c9e0caf01a9d9a821f191a1c0b77097
ims010/py
/lists.py
6,378
4.65625
5
# Lists are bag which holds any data types and are mutable(we can change the content on the fly), in python lists are kind of arrays(as in other language). my_list = [1, 2, 3] print(my_list) # can't do my_list + 5 but can do with other things to list like print(my_list + [4, 5]) print(my_list) # this can be p...
0e7208757ec6e80f6c3c82f36828f34141d82d5a
ims010/py
/Basisc_Ref.py
1,009
3.890625
4
courses = ['History', 'Math', 'Physics', 'CompSci'] # print(courses) # print(courses[0]) # print(courses[1]) # print(courses[2]) # print(courses[3]) # print(courses[4]) # print('*******') # print(courses[-1]) # print('*******') # courses.reverse() # print(courses) # print('*******') # courses.insert(0, 'Ar...
d85b56ef76b8e26fdf952196a1f2938ff7589023
ims010/py
/generators.py
2,116
3.984375
4
# Generate don't hold the result in memory, they yeild one result at a time # def square_numbers(nums): # result = [] # for i in nums: # result.append(i * i) # return result # my_nums = square_numbers([1, 2, 3, 4, 5]) # # my_nums = [x *x for x in [1, 2, 3, 4, 5]] # print my_nums # #...
bc01c4e3eee0e2f1ab0d5ffd924e8491e356b1bd
Lucytheanimefan/CS330-algs
/activitySelection.py
727
3.78125
4
''' You are given n activities with their start and finish times. Select the maximum number of activities that can be performed by a single person, assuming that a person can only work on a single activity at a time. ''' from sort import fullMergeSort start = [1, 3, 0, 5, 8, 5]; finish = [2, 4, 6, 7, 9, 9]; def so...
657dd46470579e9cfdc9a6a541b44739e5f70448
emir-naiz/first_git_lesson
/Courses/1 month/2 week/day 6/while t1.py
116
3.546875
4
i = 0 summary = 0 while i < 10: summary = summary + i print(i,summary) i = i + 1 # 1+2+3+4+5+6+7+8+9
fac6aff5f461a5ab66f44a36a336ab2db4570f15
emir-naiz/first_git_lesson
/Courses/1 month/3 week/day 4/Задача №2.2.py
213
3.890625
4
string = 'File not found' str_count = string.count('f') if str_count == 1: print(string.count('f')) elif str_count >= 2: print(string.find('f'), string.rfind('f')) elif str_count == 0: print('No f')
3061109c774e6bfe17552d631e55586301b42582
emir-naiz/first_git_lesson
/Courses/1 month/4 week/day 1/Задача №4 count_vowels.py
198
3.984375
4
def count_vowels(txt): vowels = ['a','e','o','i','u'] count = 0 for letter in txt: if letter in vowels: count += 1 return count print(count_vowels('Celebration'))
8e51161755be78b5033e7f5353b5dcc2a57f24eb
emir-naiz/first_git_lesson
/Courses/1 month/4 week/day 1/Задача №1 curzon_number.py
184
3.578125
4
def is_corzon(number): result1 = 2 ** number + 1 result2 = 2 * number + 1 if result1 % result2 == 0: return True else: return False print(is_corzon(5))
c5b638d3bb9940c3d92c8d1f5bb6616b0244256d
emir-naiz/first_git_lesson
/Courses/1 month/3 week/day 5/Задача №1.py
344
4.28125
4
# Программа имеет список и выводит список из 3 элементов: # первого, третьего и второго с конца элементов. list1 = [1,2,3,4,5,6,7,8,9,10] list2 = [] list2.append(list1[0]) list2.append(list1[2]) list_len = len(list1) list2.append(list1[list_len-2]) print(list2)
49c614a7918cb3b3c9a89201c24f2bc2de963891
emir-naiz/first_git_lesson
/Courses/1 month/1 week/day 4/Ищем знак числа.py
213
3.921875
4
# Ищем знак числа number = int(input()) if number > 0: # если число > 0 print(1) elif number < 0: # также если число < 0 print(-1) else: # число == 0 print(0)
d4e3ac4a05bf660c28c6c152145ca35044cdd863
emir-naiz/first_git_lesson
/Courses/1 month/2 week/day 10/home task/task 7 колл-во положительных элементов.py
244
3.953125
4
# Найдите колл-во положительных элементов в данном списке. number_list = [1,-1,2,-2,3,-3] i = 0 while i < len(number_list): if number_list[i] > 0: print(number_list[i]) i = i + 1
dfa9bb7879a686ce98558edd1ef466d721fc2a57
emir-naiz/first_git_lesson
/Courses/1 month/2 week/day 7/1.py
626
3.890625
4
numbers = [1,'red',2,'yellow','green',3,5.7,10.9,[10.5,10,'lalala']] int_list = [] float_list = [] str_list = [] i = 0 while i < len(numbers): if isinstance(numbers[i],str): str_list.append(numbers[i]) elif isinstance(numbers[i],float): float_list.append(numbers[i]) else: int_list.ap...
7fb6feefe6a33ca78efa8528f5b37b2524e562da
emir-naiz/first_git_lesson
/Courses/1 month/2 week/day 6/while.py
86
3.5625
4
i = 10 # счетчик цикла while i <= 10: print(i) i = i + 1 print(i)
84dd23ce7becb96732463fb1e45209c710bfb0c3
emir-naiz/first_git_lesson
/Courses/1 month/1 week/day 5/111.py
612
3.96875
4
time = int(input('Введите время: ')) breakfast = False lunch = False dinner = False if 0 <= time < 24: if 8 <= time < 12: breakfast = True print(f'Завтрак! {breakfast}', lunch, dinner) elif 12 <= time < 16: breakfast = True lunch = True print(f'Обед!{lunch}', breakfast, ...
3a138f569de9b1e4d5e2227e1ee290489eb5883c
emir-naiz/first_git_lesson
/Courses/1 month/4 week/day 1/Задача №5 setify number.py
353
4.125
4
def setify(number_list): number_list.sort() empty_list = [] for number in empty_list: if number not in empty_list: empty_list.append(number) return empty_list print(setify(1,2,3,3,4,4,6,6,5,5)) print(set(([1,2,3,3,4,4,6,6,5,5]))) # при помощи set можно удалить дублирующие цифры
c6d504bd177c2c59b586733502e707ba2079ab96
emir-naiz/first_git_lesson
/Courses/1 month/1 week/day 2/домашка/дом 1.py
260
4.09375
4
# пирожки a = int(input("Стоимость пирожка в рублях")) b = int(input("Стоимость пирожка в копейках")) n = int(input("Кол-во пирожков")) cost_a = (a * n) cost_b = (b * n) print(cost_a,cost_b)
7b5605de682f69957bde8f08769a10003db78abe
rishavhack/Natural-Language-Processing-NLP-
/Regular Expression/Program 2.py
182
3.625
4
import re sentence = "I was born in the year 1996" re.match(r".*",sentence) re.match(r".+",sentence) re.match(r"[a-zA-Z]+",sentence) sent = "a" ab = re.match(r"ab?",sent) print ab
d2326fc9fe91a5832537054e2eb5f831eb6d4d32
mmdii/Just-For-Fun
/py-calc/calculator.py
5,351
3.5625
4
from tkinter import * from PIL import Image from PIL import ImageTk expression = "" def press (num): global expression expression = expression + str(num) equation.set(expression) def equalpress(): try: global expression result = str(eval(expression)) equation.set(result) ...
edce44458f4e5bf8a83fb1c2c311da629dcf68d5
jamj2000/Programming-Classes
/Intro To Python/semester1/Week14_OpenChallenge.py
1,552
4.09375
4
""" THIS WEEK IS GOING TO BE DIFFERENT... The challenges are simpler than some we've done before, BUT: There is no code to begin with... DUN DUN DUN! --- These three things we will do together Challenge 1 : Create a class, representing OUR PYTHON CLASS which has methods/attribu...
2355ee5a02dcbc66d33649b618d1c57e356e9ada
jamj2000/Programming-Classes
/Math You Will Actually Use/Week6_Sympy.py
725
4.3125
4
' "pip install sympy" before you do any of this ' import sympy # import the calculator with variable buttons :) from sympy import Symbol # -------------------------- first, solve the simple equation 2*x=2 x = Symbol('x') # create a "symoblic variable" x equation = 2*x - 2 # define the equation 2*x = 2 solution =...
0b6dae16fec055ad0eccb3d651b02f5643540e81
jamj2000/Programming-Classes
/Intro To Python/semester1/Week10_Challenge0.py
1,798
4.34375
4
''' This is a deep dive into FUNCTIONS What is a function? A function is a bunch of commands bundled into a group How do you write a function? Look below! CHALLENGES: (in order of HEAT = difficulty) Siberian Winter: Change the link of the Philly function Canada in Spring: Make the link an inp...
f2b971565911db95558f3fc699f37ebef676f6b7
jamj2000/Programming-Classes
/Intro To Python/semester1/Week15_receiver.py
1,057
3.6875
4
""" 1. Send a message to yourself by running both server and receiver 2. Change the content of the message 3. Change the IP address of the message to target a friend's computer 4. Make it so that you can use the input() function to send a message 5. Make it so that this server can also receive, mean...
f72d459af61aec6986db91017772b58519cd5097
jamj2000/Programming-Classes
/Math You Will Actually Use/Week11_Cowcooloose.py
4,635
4.0625
4
print( ''' Welcome to Cowcooloose, Here we will learn how cows are cool and often loosely correlated to math. /; ;\ __ \\____// /{_\_/ `'\____ \___ ---(=)--(=)--} ...
04c861a9c9e8fbe4e13f784ad040d64ee7b267cf
Harshith0307/Learn_Python
/Day_6_lets_review.py
349
3.765625
4
num_test_cases = int(input()) for item in range(0, num_test_cases): word = input() for element in range(0, len(word)): if element % 2 == 0: print(word[element], end='') print(" ", end='') for element in range(0, len(word)): if element % 2 != 0: print(word[ele...
e8bc2ee8ebc2de6e25297013673c8b5c686f2e71
VeraSa785/Ada-build
/02_programming_grammar.py
4,564
4.1875
4
# I'm a code comment. Python knows this is for people and not computers # Also, it is always taco time. taco_time = "Always" # This is a comment too. print("But this isn't.") # comments can be on the same line as code #This comment is not following good Python style practices because it does not have space after the ...
7ad288453f3f3f82a2a1826b70e093a4c7fbc5df
nanisaladi24/python_gui
/GUI_tkinter/layouts/gridLayout.py
553
3.78125
4
from tkinter import * root = Tk() l1 = Label(root,text="f1",fg="black",bg="yellow") #l1.pack() l2 = Label(root,text="Field2",fg="green") e1 = Entry(root) e2 = Entry(root) l1.pack(fill=BOTH,expand=True) l1.grid(row=0,column=0,sticky=E) l2.grid(row=1,column=0,sticky=E) e1.grid(row=0,column=1) e2.grid(row=1,column=1)...
6b6fda7b374c1b26080c4dd85b06141a8f9aa024
lambdamai/Tower_of_Hanoi_in_Term_AI
/AI.py
1,839
3.890625
4
prev_move = [] def check_can_move(pyr1, pyr2, i, j ): global prev_move if pyr1 == pyr2: raise(Exception("Trying to move to same pyramid dumbass")) try: pyr1_top = pyr1.get_top() except: pyr1_top = 0 try: pyr2_top = pyr2.get_top() except: pyr...
0111e35ee65f9a52037f426c5a8d1d97601e36fc
csmdoficial/aulas-python
/curso/venv/bin/exercicios/desafio 017.py
538
4.0625
4
'''faça um programa que leia o comprimento do cateto oposto e do cateto adjacente de um triangulo retangulo, calcule e mostre o comprimento da hipotenusa''' '''co = float(input('Comprimento do cateto oposto:')) ca = float(input('Comprimento do cateto adjacente:')) hi = (co **2 + ca **2)**(1/2) print('A hipotenusa vai m...
d3f6517aeea44395a9796ee175fc8ef0dcaacaa1
csmdoficial/aulas-python
/curso/venv/bin/exercicios/desafio 033.py
537
4.15625
4
"""faça um programa qu leia três números e mostre qual é o menor e o maior """ a = float(input("Digite um numero:")) b = float(input("Digite outro numero:")) c = float(input('Digite o ultimo numero:')) #verificando quem é o menor menor = a if b < a and b < c: menor = b if c < a and c < b: menor = c #verificando...
a1b800cb6c50d916f6d8c10cea4d4cfb542cf99a
csmdoficial/aulas-python
/curso/venv/bin/exercicios/exx007.py
147
3.625
4
prova1 = (float(input("Nota primeira Prova:"))) prova2 = (float(input('Nota segunda prova:'))) print("sua media é {}".format((prova1+prova2)/2))
41fc409d8f58b6ba5421c092589ab604e55fff18
csmdoficial/aulas-python
/curso/venv/bin/aulas/aula 6.py
661
4
4
# tipos primitivos# n1 = input('Digite um numero') n2 = input('Digite mais um numero') s=n1+n2 print('A soma vale', s) #vai dar errado pois ira mostrar o resultado dos conjunto 3+2= 32# n3 = int(input('Digite um Numero:')) n4 = int(input('Digite outro Numero:')) s2= n3+n4 #significado do numero primitivo #int = numero...
8d36d57060f92b8ab4d99b367f1fe3d34c501b25
csmdoficial/aulas-python
/curso/venv/bin/aulas/aula 011.py
790
3.8125
4
# cores no terminal """sempre que quiser representar uma cor em python você começa com \033[style;text;background m""" #\033[0;33;44m #style 0 (none) 1 (bold) 4 (underline) 7 (negative) #text 30 (white) 31 (red) 32 (green) 33(yellow) 34(blue) 35 (purple) 36 (ciano) 37(gray) #back 40 (white) 41 (red) 42 (green) 43(yello...
bfd77fcdf015cdb934401476da04db55c4a7fb5f
csmdoficial/aulas-python
/curso/venv/bin/exercicios/desafio 031.py
410
4.0625
4
"""Desenvolva um programa que pergunte a distancia de uma viagem em km. calcule o preço da passagem, cobrando R$ 0,50 por km para viagens até 200 km e R$ 0,45 para viagen mais longas""" distancia = float(input('Tamanho da Viagem em KM:')) if distancia <= 200.00: print("O Valor da sua viagem foi de R${}".format(dist...
27a91925367d76d724c0c8d0441da76b277a60c1
csmdoficial/aulas-python
/curso/venv/bin/exercicios/exx012.py
114
3.78125
4
salario =(float(input('Qual seu salario?'))) print("o seu salario vai passar a ser de {}".format(salario*(1.15)))
e543c991e7ad17b2a657274bb1a5483636fc0d4f
csmdoficial/aulas-python
/curso/venv/bin/exercicios/desafio 025.py
265
4.15625
4
"""crie um programa que leia o nome de uma pessoa e diga se ela tem 'silva' no nome""" nome = str(input('Digite um nome:')).upper().strip() print('SILVA'in nome) n = str(input('Digite um nume:')).upper().strip() print('Seu nome tem Silva? {}'.format('SILVA' in n))
de94594e11df0ff9b74190119a3c955f2150cff4
3453-315h/Profil3r
/profil3r/app/_permutations.py
1,061
3.625
4
from itertools import chain, combinations, permutations # return all possible permutations for a username # example : ["john", "doe"] -> ("john", "doe", "johndoe", "doejohn", "john.doe", "doe.john") def get_permutations(self): [self.items.append(separator) for separator in self.separators] combinations_list ...
6fb1b7fff352717f4654ee2f38548c0fff13cfb7
iulyaav/coursework
/stanford-algo-courses/matrix_multiplication.py
1,177
4.25
4
def matrix_add(X, Y): pass def matrix_multiply(X, Y): """ Let X = | A B | and Y = | E F | | C D | | G H | We have the products: P1 = A(F-H) P2 = (A+B)H P3 = (C+D)E P4 = D(G-E) P5 = (A+D)(E+H) P6 = (B-D)(G+H) P7 = (A-C)(E+F) Claim: X * Y = | (P5 ...
d743309546493f67c01e53dbbb6518b8b6c9e8fd
HarperThurlow/cp1404practicals
/prac_04/quick_picks.py
643
3.9375
4
from random import randint MIN_NUMBER = 1 MAX_NUMBER = 45 MAX_PICKS = 6 def main(): lines = int(input("How many lines? >")) while lines <= 0: print("Please enter a valid number of lines") lines = int(input("How many lines? >")) for line in range(lines): quick_pick = [] ...
586ad3d5556a090c62233b6c9adcd5b5be76c50e
HarperThurlow/cp1404practicals
/prac_10/wiki.py
330
3.53125
4
import wikipedia def main(): user_input = input(">> ") while user_input != "": try: x = wikipedia.page(user_input) print("{}\n{}\n{]".format(x.title, x.summary, x.url())) except wikipedia.exceptions.DisambiguationError: pass user_input = input(">> "...
ad291e7fa25471945efc95465a4589cd89a44e7a
mihir-liverpool/RockPaperScissor
/rockpaperscissor.py
841
4.125
4
import random while True: moves = ['rock', 'paper', 'scissor'] player_wins = ['paperrock', 'scissorpaper', 'rockscissor'] player_move = input('please choose between rock paper or scissor: ') computer_move = random.choice(moves) if player_move not in moves: print('please choose an option betw...
2658d8bd23271f4381340ead78844d2c8f1d36f3
karabanb/SDA_WstepDoProgramowania
/OO_programming.py
1,524
3.71875
4
import math # możemy to zrobić tak b = 4 def square_area(b): return b ** 2 def square_permiter(b): return 4 * b print(square_area(b)) # podchodząc obiektowo zrobimy tak: class Square: def __init__(self, a, x, y): self.a = a self.x = x self.y = y def area(self): ...
624cae42d66537a509b560473af825cd498f16b7
karabanb/SDA_WstepDoProgramowania
/erastothenes_sieve.py
1,161
3.703125
4
def erastothenes_sieve(n): """ This function returns primary numbers which are less tnan n """ if not n > 1: print('Bad data@') return sieve = [] for i in range(n): sieve.append(True) for i in range(2, n // 2): if sieve[i]: for j in range(2 * i, n, ...
44c75637e0dd0d3a4c080779a7bb797203daea79
aj-amitjain/Machine-Learning-A-Z
/clustering/clustering_complete_code.py
1,991
3.53125
4
# -*- coding: utf-8 -*- """ Created on Wed Jan 29 19:12:07 2020 @author: Amit Anchalia @Description: Clustering Complete Code """ ## Importing the library import pandas as pd import numpy as np import matplotlib.pyplot as plt ## Importing the dataset df = pd.read_csv('Mall_Customers.csv') X = df.iloc[:, 3:5] ## F...
5dc2772b87a4bb25fa3030ea4b4187079c3c569a
Dawood-I/Wine-Quality-Classifier
/Graphs.py
2,829
3.546875
4
import matplotlib.pyplot as plt import pandas as pd import numpy as np data = pd.read_csv("https://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-red.csv", delimiter=";") # reading data file and separating data by delimiter specified (;) # summing up alcohol content column by quality...
9b5828c211dd8c047b66a3cf022413722c345ebb
sombra721/Python-Exercises
/Sorting Searching and Data Structure/selection sort.py
493
3.734375
4
# -*- coding: utf-8 -*- """ Created on Wed Mar 12 19:43:53 2014 @author: Michael """ def selectionSort(List): for i in xrange(len(List)-1, 0, -1): Max = 0 MaxPosition = 0 for j in xrange(0, i+1): if List[j] > Max: MaxPosition = j Max = List[j] ...
1dbd6a073c1fbdae4bdc435d7a678e49e8709ab3
sombra721/Python-Exercises
/Regular Expression_ex.py
1,503
4.125
4
''' The script will detect if the regular expression pattern is contained in the files in the directory and it's sub-directory. Suppose the directory structure is shown as below: test |---sub1 | |---1.txt (contains) | |---2.txt (does not contain) | |---3.txt (contains) |---sub2 | |...
75f16b0d29936244b4115dd88c0ebf8642185148
sombra721/Python-Exercises
/Sorting Searching and Data Structure/Palindrome.py
190
3.671875
4
# -*- coding: utf-8 -*- """ Created on Thu Aug 21 22:55:10 2014 @author: Michael """ a = "55678" print a[::-1] if a == a[::-1]: print "is Palindrome" else: print "not Palindrome"