blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
1f3888a1032344825cbbbe98d29265499d3e5c74
careynation/python_class
/Chapter2/exercise2.py
370
4.03125
4
# @author Carey Nation # @title Chapter 2, Exercise 2 # @description Calculate profit PROFIT_MARGIN = 0.23 total_sales_s = input("Please enter your total sales: ") try: total_sales = float(total_sales_s) profit = total_sales * PROFIT_MARGIN print("Your profit is: %2.2f" % profit) except: print(tota...
211f1e368438f0ed837b4ffa0651de54e920f697
rich-s-d/Python-Tutorial
/AdventOfCode/day4_part1.py
1,140
3.578125
4
# My overcomplicated answer for part 1. # Looked for a better example for part 2 from the the megathread. # I was relying too much on conditional if statements. Better to use key validation. def group_passports(txt_file): # Groups passports based on a single blank line of seperation in text file. conten...
b07e2afc7b72fc7c3307ac6f9fc55fa1c5a85b41
Ran4/dd1331-public
/ex01/grupdat/ran_sekunder.py
620
3.546875
4
#!/usr/bin/env python3 """ 2. Pythonkramaren, uppgift 24: Skriv ett program som frågar efter ett antal sekunder och skriver ut hur många dagar, timmar, minuter och sekunder det är. Lösning: [sekunder.py](sekunder.py). """ totalt_antal_sekunder = int(input("Hur många sekunder? ")) rest_sekunder = totalt_antal_sekunde...
9752da14fa61d78d4b7a98aca798dabb151f8b98
OmkarThawakar/Turtle-Programs
/turtle6.py
335
3.84375
4
import turtle def forward(distance): while distance > 0: if (turtle.xcor() > 100 or turtle.xcor() < -100 or turtle.ycor() > 100 or turtle.ycor() < -100): turtle.setheading(turtle.towards(0,0)) turtle.forward(1) distance = distance - 1 ...
69dbbd8239a57a9560ef3707af6f388f852445d9
thormeier-fhnw-repos/ip619bb-i4ds02-audio-text-alignment
/lib/src/model/Interval.py
2,694
4.1875
4
from typing import Any class Interval: """ Defines and interval with a start and an end """ def __init__(self, start: Any, end: Any): """ Constructor :param start: float or character :param end: float or character """ self.start = start self.e...
e8436985781595079d7ca2cd2d0b7a8a0fb28d84
praveenRI007/Basics-of-python-programming
/basics of python programming in 1hour/python basics #6_loops.py
814
3.875
4
nums = [1,2,3,4,5] for num in nums: if num==3: print('found') break #comes out of loop print(num) print('\n') for num in nums: if num==3: print('found') continue #goes for next iteration of loop print(num) pri...
7196e03d735b1a571ea41ae7d850b7aad509d10b
Indra2311/BasicPythonProgram
/sumThree_0.py
1,064
4.15625
4
""" * Author - Indrajeet * Date - 03-06-2021 * Time - 6:02 PM * Title - Read in N integers and counts the number of triples that sum to exactly 0. """ def find_triples(arr, n): """ :param arr: containing all the elements :param n: number of elements :return: """ found = True co...
05aeb626bd3f91cbb09b425ccbf719b34910d5bd
embisi-github/gjslib
/tests/primes.py
2,105
3.8125
4
#!/usr/bin/env python def calculate_x_n_mod_p( x, p, x_n_mod_p=None, n=1 ): """ Calculate x^n mod p, returning result. Requires x<p. A cache of results is kept in x_n_mod_p (dictionary of n => x^n mod p) If n=0 then x^n mod p =1 If n in x_n_mod_p.keys() then =x_n_mod_p[n] Else split n into (a,...
7e3ab40de3cad70871aaf36b4b2af7ae5ebb54d9
emilkloeden/Project-Euler-Solutions
/Python Scripts/12.py
998
3.546875
4
# The sequence of triangle numbers is generated by adding the natural numbers. # So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. # The first ten terms would be: # 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... # Let us list the factors of the first seven triangle numbers: # 1: 1 # 3: 1,3 # 6: 1,2,...
c77b5cef3f3eaf5c710d2438942e4ec860565a1a
BigEggStudy/LeetCode-Py
/LeetCode.Test/TestHelper.py
980
3.640625
4
import sys, queue sys.path.append('LeetCode') from ListNode import ListNode from TreeNode import TreeNode def generateLinkList(nums: []) -> ListNode: if nums is None or len(nums) == 0: return None head = ListNode(-1) current = head for num in nums: current.next = ListNode(num) ...
a75135952395f51c1d5719c22c90dce6a2c96d75
Sheep-coder/practice2
/Python00/chap07list0715.py
737
3.984375
4
# 行列の和を求める(行数/列数/値を読み込む) print('行列の和を求めます。') height = int(input('行数:')) width = int(input('列数:')) a = [None]*height for i in range(height): a[i] = [None]*width for j in range(width): a[i][j] = int(input('a[{}][{}] : '.format(i,j))) b = [None]*height for i in range(height): b[i] =[...
8ee75cfac184610c357a7d39f67a19d9c1e93da0
vfcrawler/TEST190805
/22.py
286
3.9375
4
def get_missing_letter(str_input): #方法1 手输a-z字符串 s1 = set('abcdefghijklmnopqrstuvwxyz') s2 = set(str_input.lower()) # 排序字符串 ret = ''.join(sorted(s1-s2)) return ret if __name__ == '__main__': print(get_missing_letter("python"))
8f5ba4185a47002a4638172807cce68352a5202a
fainaszar/pythonPrograms
/multithreading/listIdioms.py
266
3.71875
4
a_list = ['a','b','c','d','e'] print(a_list) (first,second,*rest) = a_list print(first) print(second) print(rest) (first,*middle,last) = a_list print(first) print(middle) print(last) (*head,penultimate,last) = a_list print(head) print(penultimate) print(last)
9f854bceb4ee2a6fa5dd6354c423c0a55134bab1
jay3272/python_tutorial
/control/function.py
415
3.546875
4
def ask_ok(prompt,retries=5,reminder='Please try again'): while True: ok=input(prompt) if ok in ('yes'): return True if ok in ('no'): retries=retries-1 if retries<0: raise ValueError('invalid user response') print(reminder) as...
6cba118aa6688920ff839d2e74a0db88e30eff60
harkaranbrar7/30-Day-LeetCoding-Challenge
/Week 2/backspace_String_Compare.py
1,951
4.15625
4
''' Backspace String Compare Given two strings S and T, return if they are equal when both are typed into empty text editors. # means a backspace character. Example 1: Input: S = "ab#c", T = "ad#c" Output: true Explanation: Both S and T become "ac". Example 2: Input: S = "ab##", T = "c#d#" Output: true Explanation: ...
7c1f01702ce00efed4b5224d3882a6afa37a7149
svaccaro/codeeval
/simple_sort.py
183
3.640625
4
#!/usr/bin/env python from sys import argv input = open(argv[1]) for line in input: line = line.rstrip() nums = sorted(line.split(' '), key=float) print ' '.join(nums)
380378e9c0c7bccc9ebba297f846a1890841adcd
Rhongo15/amazon_scrapper
/amazon_scrapper.py
1,395
3.640625
4
from selectorlib import Extractor import requests import json #getting input from user and appending it to the url item = input() item = list(item.split(' ')) item = '+'.join(item) url = 'https://www.amazon.com/s?k=' + item #yml file containing the selectors needed to extract data e = Extractor.from_yaml...
c23aa3913578bc9835c438218be9459fd21e72a1
DaHuO/Supergraph
/codes/CodeJamCrawler/16_0_3/noahingham/C.py
1,136
3.53125
4
import math def primes_sieve(limit): limitn = limit+1 not_prime = set() primes = [] for i in range(2, limitn): if i in not_prime: continue for f in range(i*2, limitn, i): not_prime.add(f) primes.append(i) return primes primes = primes_sieve(10000...
d05a3c2f6f1023540917ef410ed54fa1fa19507e
Mohamed711/Intermediate-python-nanodegree
/Lessons Exercises/T9 Predictive Text/gold.py
1,791
3.5625
4
"""Reference solutions to each of the pieces of the T9 exercise. Sure, these are some solutions. They're right here, if you reall need to see them. """ import collections import functools import operator from helper import keymap def parse_content(content): """Parse the content of a file into a dict...
1f7a924740b1780834049bf235705239111f17bf
Mrinanka/Bank-Account-by-Python
/Tick tack Toe Game By me.py
4,832
4.09375
4
#!/usr/bin/env python # coding: utf-8 # In[40]: from IPython.display import clear_output def display_board(board): print(" "+'|' +" "+'|'+" ") print(' '+board[1]+' | '+board[2]+' | '+board[3]) print("______"+'|'+"______"+'|'+"______") pr...
caf9ea987205d9710b671d75eaa986d4b9214d15
meyerjo/python-spielereien
/addierer.py
240
3.578125
4
print ("Hallo ich bin der Addi, bitte 2 ZAhlen...") def start(): a = input ("Zahl 1") b = input ("Zahl 2") a = float (a) b = float (b) print ("Ergebnis: ") print (a + b) x = input() start()
81284e4934c1327195137ccdb40fb4f669a165c8
susanpray/python
/while.py
100
3.71875
4
counter = 1 while counter <= 5: print "Type in the", counter, "number" counter = counter +1
def5d3978c2eae8782af06dae41683f14832e0f5
BenjzB/GUI-Projects
/tKinterTest.py
627
3.8125
4
from tkinter import * top = Tk() playList = [] def results(): print(playList) def addToList(): newItem = E1.get() playList.append(newItem) E1.delete(0, END) #This is a Label widget L1 = Label(top, text = "Playlist Maker") L1.grid(column = 0, row = 1) #This is an Entry widget E1 = ...
2e78bf5f820700d4126f5e0e06148b7792c6a933
ddindi/xyz
/fetch/download_json.py
491
3.546875
4
import urllib2 import json def download_json(query = 'https://api.github.com/search/repositories?q=language:python&sort=stars&order=desc', max_repos = 5): response = urllib2.urlopen(query) json_string = response.read() data = json.loads(json_string) for i, item in enumerate(data['items']): if i == max_rep...
4d15a9cf76205a55ddbff3890596365d43fb826d
SanchitaChavan/Space_Invader
/Game.py
1,772
3.734375
4
import pygame import random # Initialize the pygame pygame.init() # Create the screen screen = pygame.display.set_mode((800, 600)) # Title and Icon pygame.display.set_caption("Space Invaders") icon = pygame.image.load('si.png') pygame.display.set_icon(icon) # Player playerImg = pygame.image.load('sii...
2ddee7fad720e8c9b8b797fab6501d180f928d38
zackmdavis/dotfiles
/bin/fake_italics
1,111
4.0625
4
#!/usr/bin/env python3 """ Given a text file with Markdown-like underscore-emphases, replace it with one where the emphases are given as Unicode "mathematical" pseudo-italics """ import argparse import unicodedata def pseudo_italic(char): try: codepoint_name = "MATHEMATICAL ITALIC SMALL {}".format(char....
63d0b325095c80db39284098f683b2585c06b59c
abbindustrigymnasium/python-kompendium-abbkevkla
/Kompendiet/Kompendium_uppgifter_6.2.py
2,296
3.5
4
import requests #6.1 # siffra = int(input("välj ett heltal annars blir jag arg :) ")) # url = "http://77.238.56.27/examples/numinfo/?integer="+str(siffra) # r = requests.get(url) #vi sätter värdena vi får i en variabel # response_dictionary = r.json() #vi använder .json för att göra om innehållet till ett läsbart form...
bcf9384a3ba2dc993e7a171a9f57a487a8e6dd9e
ipa-srd-kd/udacity-python
/debugging/lesson2/time.py
1,206
3.859375
4
class Time: def __init__(self, h = 0, m = 0, s = 0): assert 0 <= int(h) <= 23 assert 0 <= int(m) <= 59 assert 0 <= int(s) <= 60 self._hours = int(h) self._minutes = int(m) self._seconds = int(s) def invariant_check(self): assert 0 <= self.hours() <= 23 assert 0 <= self.minu...
5304e5a277ecfd7b3c6f5b29fccc22a8a76fd9f6
chrislevn/vnlearntocode
/30_Day_Leetcode_Challenge/Week 3/Day15_ProductOfArrayExceptSelf.py
703
3.890625
4
class Solution: def productExceptSelf(self, nums: List[int]) -> List[int]: """Calculate the product of other elements of the array, except itself. Args: nums: the input array. Returns: An array output such that output[i] is equal to the product of all the elem...
49189da9498a3591c9b9d1a65268792acb6d8eee
ekomissarov/edu
/py-basics/uneex_homework/19.py
1,942
3.609375
4
''' Ввести строку, содержащую произвольные символы (кроме символа «@»). Затем ввести строку-шаблон, которая может содержать символы @. Проверить, содержится ли в исходной строке подстрока, совпадающая со строкой-шаблоном везде, кроме символов @; на месте @ в исходной строке должен стоять ровно один произвольный символ....
b887d25aa31e2bafc1ed7d6220e747821745f787
sujaykadam/prac_examples
/Python pracs/L2/pr5.py
147
3.515625
4
#exchange number w/o 3rd var n1=int(input("Enter first number ")) n2=int(input("Enter second nukmber ")) n1=n1+n2 n2=n1-n2 n1=n1-n2 print(n1,n2)
4b4dc99de9dfb95c39636472787862d91d70ca94
beautyseeker/N-back-task
/Pseudorandom_seq.py
3,984
3.640625
4
import random import time class Pseudorandom: """基于当前数,n步长后的数一致的概率维持在0.3-0.5间""" def __init__(self, step=2, interval=1.8, trials=30): self.step = step # N back中的步长N self.interval = interval # 数字刷新间隔,单位为秒 self.trials = trials # 数字刷新次数 self.dictate_count = 0 # 报数计数 se...
7ee24fb9dfc72bc8952ad0e45660c2fc24507824
daniel-reich/turbo-robot
/58RNhygGNrKjPXwna_20.py
973
4.28125
4
""" Write a function that returns the **longest non-repeating substring** for a string input. ### Examples longest_nonrepeating_substring("abcabcbb") ➞ "abc" longest_nonrepeating_substring("aaaaaa") ➞ "a" longest_nonrepeating_substring("abcde") ➞ "abcde" longest_nonrepeating_substrin...
d6b587bf925f75652a5a682119f2573405761b60
CTHS-20-21/Lab_3_03_War
/war.py
1,148
3.84375
4
# War starter code ############## import random # name: shuffled_deck # purpose: will return a shuffled deck to the user # input: # returns: a list representing a shuffled deck def shuffled_deck(): basic_deck = list(range(2, 15)) * 4 random.shuffle(basic_deck) return basic_deck deck = shuffled_deck() pri...
52d8eca55a2084b6ece5d476e04260f81437eddd
MrHamdulay/csc3-capstone
/examples/data/Assignment_7/bthpor002/question1.py
568
4.3125
4
#A program that prints out a unique lists without duplicates #By Portia Buthelezi #create an empty string x_list= [] #Let the user input strings x_string= input('Enter strings (end with DONE):\n') #append the inputs to the list while x_string !='DONE': x_list.append(x_string) x_string= input...
9c03af2ac0e1362b30a69cb3a630ad2328b8aa5e
liuhao940826/python-demo
/yield_while的测试.py
485
3.515625
4
# encoding:UTF-8 def test_while_yield(): yield "哈哈哈" yield "下面的我" page = 0 # while True: # print("我也进来了") # page += 1 # if page > 3: # print("我现在是:", page) # yield page # print("我被调用了") if __name__ == '__main__': print("我被执行了") result =...
fe006598a3f96e1590e73f2a1f8acc0823f9f734
vishalpmittal/practice-fun
/funNLearn/src/main/java/dsAlgo/namedAlgo/MinMax_PickLastStick.py
4,463
3.734375
4
""" Tag: algo minmax / minimax / mm algorithm In Minimax the two players are called maximizer and minimizer. The maximizer tries to get the highest score possible while the minimizer tries to do the opposite and get the lowest score possible. Every board state has a value associated wit...
9aa9270db678881bd60c6a669f43e3ebf1cb58d3
kurumeti/Data-Structure-and-Algorithms
/Assignment-2/4/collecting_signatues.py
1,825
4.0625
4
""" ***************SAFE MOVE**************** => Sort given segments based on right end ***************ALGORITHM**************** => Check whether right end is to the right of next segment left end i.e., > b[i] >= a[i + 1] => if not increment the count and add b[i + 1] to the ...
918876e76fb7585799b191f390722ac2612f2465
sudhansom/python_sda
/python_fundamentals/10-functions/fizzbuzz.py
493
4.03125
4
user_input = int(input("Enter the number: ")) # for num in range(1, user_input): # if num % 3 == 0: # if num % 5 ==0: # print("FizzBuzz") # else: # print("Fizz") # elif num % 5 == 0: # print("Buzz") # else: # print(num) for num in range(1, user_input)...
eee5d59cc2f8f59e03a066bd4a182ba2ff8ac1c2
blad00/PythonLearning
/real_decorators/Deco1.py
2,486
3.875
4
# Functions def add_one(number): return number + 1 add_one(2) # First-Class Objects def say_hello(name): return f"Hello {name}" def be_awesome(name): return f"Yo {name}, together we are the awesomest!" def greet_bob(greeter_func): return greeter_func("Bob") greet_bob(say_hello) greet_bob(be...
eb56feada29e38a0c0035a4263dc82c5c33ca3d7
gustaslira/Random-Codes
/Pedra Papel Tesoura Lagarto Spock/pplts_v2.0.py
543
4.0625
4
sheldon, raj = input().split() pedra, papel, tesoura, lagarto, Spock = 'pedra','papel','tesoura','lagarto','Spock' if sheldon == raj: print('De novo!') elif ( (sheldon == pedra and (raj == lagarto or raj == tesoura)) or (sheldon == papel and (raj == pedra or raj == Spock)) or (sheldon == tesoura and ...
cb4f009d6fd1eae75b198ab0960e9e7af380c0b7
Qiumy/leetcode
/Python/136. Single Number.py
668
3.75
4
# Given an array of integers, every element appears twice except for one. Find that single one. from functools import reduce class Solution(object): def singleNumber(self, nums): """ :type nums: List[int] :rtype: int """ if len(nums) == 1: return nums...
6e171e5ca72cfcd51ad21c6bd70afc1ef50e9bc0
jtorain21/CS-115
/highway_robbery.py
4,601
4.1875
4
# Joshua Torain CIS 115 FON04 # write main function to control logic # write functions to get the users name, age, and # of traffic violations # write functions to determine risk code and risk type based on users input # write a function to determine the insurance price based on user input # write a function to display...
2e3e8ade78847f8464acfb4f4959ac57b884e4e1
Futureword123456/Interview
/Interview/6/59.py
1,094
4.25
4
# -*- coding: utf-8 -*- # @Time : 2021/3/11 0011 # @Author : yang # @Email : 2635681517@qq.com # @File : 59.py """Python 插入排序""" """"(1)首先对数组的前两个数据进行从小到大的排序。 (2)接着将第3个数据与排好序的两个数据比较,将第3个数据插入到合适的位置。 (3)然后,将第4个数据插入到已排好序的前3个数据中。 (4)不断重复上述过程,直到把最后一个数据插入合适的位置。最后,便完成了对原始数组的从小 到大的排序。""" def insertion(arr): """遍历整个列表...
1604299801f4aa4fe0f074f6c6ab35f696bf6a00
thxa/1MAC
/ATM Solution/atm_class.py
2,080
3.84375
4
class ATM: def __init__(self, balance, bank_name): self.balance = balance self.bank_name = bank_name self.withdrawals_list = [] def withdraw(self, request): print "welcome to " + self.bank_name print "Current balance = %d" % self.balance print "=" * 34 i...
fb6fe2ee50dbefdd961a1053ce2a49420f16983e
rscalzo/subpipe
/Utils/Record.py
10,626
3.53125
4
#!/usr/bin/env python # ============================================================================ # RS 2012/02/13: Implementation of Record class hierarchy # ---------------------------------------------------------------------------- # This code defines a class hierarchy for constructing "record"-like objects, # ...
6d56212c0b0f188e7b3c939c8d57350daaf04f53
bakkerjangert/AoC_2016
/Day 3/day3b.py
780
3.65625
4
# Advent of Code 2016 - Day 2 part a import numpy as np with open('input.txt') as f: lines = f.read().splitlines() triangles = [] triangle1 = [] triangle2 = [] triangle3 = [] for line in lines: triangle1.append(int(line.split()[0])) triangle2.append(int(line.split()[1])) triangle3.append(int(line.spl...
99a4db49287d29f3095200a7aa235d4d422691df
elixias/kaggle-python
/datacamp4.py
1,842
3.84375
4
"""Opening files""" filename = "" file = open(filename, mode='r') text = file.read() print(text) file.close() #check w print(file.closed) #using with statement/context manager #creates a context with the file open #once completed file is no longer opened #this is binding in a context manager construct #with open(filen...
80ee2149be303c0343542df4f9cfddaca9b27a4e
z1223343/Leetcode-Exercise
/012_75_SortColors.py
1,645
3.734375
4
""" 2 ideas of solutions: 1. count sort (by myself, two pass) 2. one pass (三向切分快速排序?) 1. 2. time O(N) space O(1) """ class Solution(object): def sortColors(self, nums): """ :type nums: List[int] :rtype: None Do not return anything, modify nums in-place instead. """ countli...
f6eb57df0069d0766cb2774e79f709c4abbd2270
uselessrepo/21jan
/p31.py
229
4.40625
4
def change(string): if string[0:2] == 'Is' or string[0:2]=='is': final = string else: final = "Is "+string return final string = input("Enter A String : ") final = change(string) print(final)
9d118f5304c4e235435e48678c24887a3bfbfca2
inwk6312winter2019/week4labsubmissions-sahithyabathini5
/lab5_2.py
666
3.703125
4
import math class Rectangle(point): def __init__(self,width=0.0,height=0.0,corner=point(0.0,0.0)): self.width=width self.height=height self.corner=corner def find_center(Rectangle): x1 = (Rectangle.width)/2 x2 = (Rectangle.height)/2 return (x1,x2) p = point() rect=Rectangle(10,20,p) centre= find_...
55027c728bbdd853f1d193c79fc4e6b66e608a01
harleydutton/passgen
/passgen.py
803
3.671875
4
import random import argparse parser = argparse.ArgumentParser(description='Generate a password of given length.') parser.add_argument('length',metavar='len',type=int, help='the length of the password') parser.add_argument('-cap', dest='cap', action='store_const', const=True, default=False, help='Add...
a90ae58b70ea5f8b1d9cc5a43477818b214a64b8
ShvarevArthur/course
/check.py
113
3.84375
4
print("input a") a = int(input()) print("input b") b = int(input()) for i in range (0, b - a): print("*\n")
4e42824aebad8d05d56b3e259183c41309276c8e
sidhu177/PythonRepo
/CurvePlot.py
433
4.15625
4
# -*- coding: utf-8 -*- """ Created on Sat Oct 29 08:31:22 2016 ## Plot the curve y = t^2 exp(-t^2) for t values between 0 and 3. @author: SIDHARTH """ import numpy as np from matplotlib import pyplot as plt t = np.linspace(0,3,50) y = (t**2)*np.exp(-t**2) plot1, = plt.plot(t,y, label='Line') plt.titl...
91a535cae2574514a55a84432a912f3e9f05668a
zhyu/leetcode
/algorithms/reorderList/reorderList.py
988
3.8125
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: # @param head, a ListNode # @return nothing def reorderList(self, head): if head is None or head.next is None: return slow = fa...
0414fe95c6deb11a7309f61f62833c20d53a78b2
sandeep9889/datastructure-and-algorithm
/problems/stacks/stack using deque/test.py
280
3.796875
4
from collections import deque stack= deque() #it isn for appending stack.append('a') stack.append('b') stack.append('c') print("initial stack") print(stack) # for pop print(stack.pop()) # lifo principle then c will remove print(stack.pop())#remove b print(stack.pop())# remove c
4f15fea4c7c64f0fee41c569bf52e01aad4d29ea
GhostDovahkiin/Introducao-a-Programacao
/Monitoria/Estrutura de Decisão/15.py
494
4.09375
4
lado1 = float(input("Primeiro Lado: ")) lado2 = float(input("Segundo Lado: ")) lado3 = float(input("Terceiro Lado: ")) if (lado1+lado2 > lado3 or lado3+lado1 > lado2 or lado3+ladob2 > lado1): if lado1 == lado2 and lado1 == lado3 and lado1 == lado3: print("Triângulo Equilátero") elif lado1 == lad...
acbc10559d80426188d20971184e5b13f63caeb3
drmrsmoke/GeekBrains
/hw4/hw4.py
156
3.6875
4
print(f"Числа кратные 20 и 21 в диапазоне от 20-240 {[n for n in range(20, 240) if n % 20 == 0 or n % 21 == 0]}") # print(my_list)
a743498cfb4426a0d46dc1bcb2d867206f4c5a1b
CGayatri/Python-Practice1
/outputs.py
3,591
4.21875
4
############## Output Statements ############### ## print() stmt print() ''' F:\PY>py outputs.py F:\PY> ''' ## print("string") stmt print("Hello Double quotes") ''' Hello Double quotes ''' print('Hello Single quotes') ''' Hello Single quotes ''' # use of escape character - \n, \\, \t, \', \", \\n print("This...
dea5074676431dd20bb2ef6e216eb91d6bff1801
MVasanthiM/guvi
/programs/min-hr_min.py
47
3.53125
4
m=int(input()) hr=m//60 min=m%60 print(hr,min)
642df7341124cbde0923116f88b6138ee60949ad
vishalsingh8989/karumanchi_algo_solutions_python
/Dynamic Programming/knapsack_2.py
375
3.5
4
""" repetition of items allowed. """ def knapsack(W, wt, val, n): dp = [0]*(W+1) for i in xrange(W+1): for j in wt: if j <= i: dp[i] = max(dp[i], dp[i - j] + j) return dp[-1] if __name__ == "__main__" : W = 10 val = [1, 3, 2] wt = [5, 10, ...
a84b5661175b0b10fe37fa70022323b49fdd7dc0
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/hamming/80246a917385418d845439527c945483.py
285
3.515625
4
__author__ = 'tracyrohlin' def distance(string_1, string_2): hamming_number = 0 for n in xrange(len(string_1)): if string_1[n] == string_2[n]: pass else: hamming_number += 1 return hamming_number print distance('GATACA', 'GCATAA')
79fa2101e37db7197c6203f7c8f0c03c29b2559e
xinxin3713/programs
/design设计模式/observer_design/drinks.py
1,874
4.25
4
#!/usr/bin/env python # -*- coding:utf-8 -*- """ __created__ = '2018/1/16' __author__ = 'zhaohongyang' """ class Tea(object): """Class Tea""" def __init__(self): self.name = 'Tea' self.price = 2 self.__subscribers = [] def get_price(self): return self.price def get_...
dbec152b0e60aa09ce68aa161d19fae6b4bc1645
CarolineXiao/AlgorithmPractice
/TopKLargestNumbers.py
475
3.734375
4
import heapq class Solution: """ @param nums: an integer array @param k: An integer @return: the top k largest numbers in array """ def topk(self, nums, k): if len(nums) <= k: return sorted(nums, reverse=True) heap = [] for i in range(len(nums)): ...
73566405be4484d48d674f728c7b9ef29a7d0b15
manofpeace1/webapplication_study_archive
/python_ruby/String/1.py
318
4.15625
4
print("Hello World") print("Hello") print("Hello 'World'") print('Hello "World"') print('Hello '+'world') print("Hello World "*3) print("H ello"[1]) print('hello world'.capitalize()) print('hello world'.upper()) print('hello world'.__len__()) len('hello world') print('Hello world'.replace('world'[2], 'programming'))
f43d645b151461e34547da8cb0d7945c1236bcb3
SoyeonHH/Algorithm_Python
/LeetCode/148.py
1,428
3.78125
4
''' LeetCode 148. Sort List 연결리스트를 O(n log n)에 정렬하라. ''' # Definition for singly-linked list. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: def mergeTwoLists(self, l1: ListNode, l2: ListNode) -> ListNode: if l1 an...
e80284b248387774fe6f1796ea4acf3048873ff7
vkagwiria/thecodevillage
/Python Week 4/Day 2/exercise1.py
208
4.28125
4
# ask user for radius # use a lambda function to calculate the area area =lambda radius: radius*radius*3.142 radius = int(input("Please insert the radius here: ")) print("The area is", area(radius))
16a4fe28ddc40dac810c265ff6b21d7120694b2e
ashokreddy7013/python
/Python 8 to 9AM/RegualrExp/Demo6.py
90
3.921875
4
import re s1 = "Hello this is naveen" result = re.sub("naveen","sathya",s1) print(result)
2f8dcabb14aade7a00ff8b0df9634ca2bfd7880a
Monikabandal/My-Python-codes
/Detect cycle in directed graph.py
1,166
3.609375
4
class graph: def __init__(self,V): self.vertices=V self.node={} def addedge(g,u,v): try: g[u].append(v) except: g[u]=[v] def check_cycle(node,V,i,stack,visited): stack[i]=1 visited[i]=1 try: for j in node[i]: if vi...
51a6e795a4cf86ffd742fbbcab813a702adb2957
sunshinescience/dim_red_cluster
/figures.py
918
3.765625
4
import matplotlib.pyplot as plt def plot_images(data, reshape=None, save_fname=None, show=False): """ Provides a figure with eight images plotted. Parameters: data: image data (e.g., digits.images) reshape: Input reshape values as a tuple of two numbers (e.g., (8, 8)). save_fnam...
3c2924ea9a593f799f548f558f77b2a97bc1217b
disorn-inc/data_structure_algo_i
/data_structure/array/63_arrays_intro/strings.py
147
3.5625
4
strings = ["a", "b", "c", "d"] strings[2] strings.append("e") strings.pop() strings.insert(0, "x") strings.insert(2, "alien") print(strings)
b47c02046b7ab21d83514cb8bcf945753dda0918
abhinav3398/similarities
/helpers.py
1,277
3.578125
4
def lines(a, b): """Return lines in both a and b""" lines_O_a = a.split('\n') lines_O_b = b.split('\n') lines_O_a = set(lines_O_a) lines_O_b = set(lines_O_b) common_lines = lines_O_a.intersection(lines_O_b) return list(common_lines) def sentences(a, b): """Return sentences in both a...
fc585a57255fa96d28bd560186a16f46d4daee22
TeluguOCR/datagen_initio
/counters/count_unichars.py
442
4.03125
4
#!/usr/bin/env python3 import sys from collections import Counter if len(sys.argv) == 1: print('''Usage:{0} input_file Counts the number of occurences of each unicode character in the given <input_file>'''.format(sys.argv[0])) sys.exit() file_name = sys.argv[1] count = Counter() with open(fil...
dfc950230c319e471f735e3d12c21bdf2adb432a
zero060699/Practice-Python
/kiemtrasonguyento.py
354
3.515625
4
while True: n = int(input("Nhập 1 số nguyên dương:")) dem=0 for i in range(n,n+1): if n%i == 0: dem+=1 if dem==2: print(n,"Là số nguyên tố") else: print(n,"Không là số nguyên tố") hoi = input("Tiếp tục ko?:") if hoi is "k": break pr...
6bf6a1f365ef34ed3c878e150956b5557a952d6b
AllHailTheSheep/eulers
/16.py
136
3.6875
4
# sum the digits of 2^1000 from math import pow num = int(pow(2, 1000)) sum = 0 for char in str(num): sum += int(char) print(sum)
c68a9f0109d4d936f3a1148f5fe42743a1aa8ede
Dev-rromanov/-----------
/temp.py
233
3.609375
4
def foo(temperature): if int(temperature) > 25: return 'Hot' elif int(temperature) > 15 and int(temperature) < 25: return 'Warm' elif int(temperature) < 15: return 'Cold' print (foo(26))
447ed845c9abf515d3a52e72025e91f192219855
EveEuniceBanda/Beginners-Labs
/try_this Lab 12.py
1,893
4.21875
4
#!/usr/bin/env python3 #Global promptFunction get_user_age #Function name: get_user_age def get_user_age(): # Initialize your prompt string prompt_age_msg = "Please enter your age" ############################################################# # The prompt strng has been changed to a GLOLB...
275f04cb38322decc37546f1b3d1f5b7aabb659e
RakeshSuvvari/Joy-of-computing-using-Python
/factorial.py
630
4.21875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Mar 4 23:23:52 2021 @author: rakesh """ def factorial_ite(n): answer = 1 for i in range(1,n+1): answer = answer * i return answer ''' base case or anchor case point where recursion stops ''' def factorial_rec(n): if(n == 0): ...
c44e3e766eb98e97a6582676b5ad62e4fec95ece
DanielJChong/PythonStack
/python/Day1_Notes.py
2,261
4.15625
4
# # var_name = "Some value"; # # "=" this is NOT and equals, it means "set as" # # Primitive # some_string = "Some value" # string # some_number = 123 # integer # some_decimal = 1.23 # floats # some_boolean = True # boolean # some_boolean_2 = False # boolean # some_none = None # None == null # # Composite # s...
3a06ffa2ccdf987ef1fa50e43a88d4afac343988
skreynolds/python_practiceExercises
/46rot13/rot13.py
1,167
4.5625
5
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ ROT13 is a simple letter substitution cipher that replaces a letter with the letter 13 letters after it in the alphabet. ROT13 is an example of the Caesar cipher. Create a function that takes a string and returns the string ciphered with Rot13. If there are numbers or...
058ac196c75c9c5c9d9622db1bbba0e5a7a76e66
python-yc/pycharm_script
/w3cschool/tmp.py
214
3.515625
4
def f(): c = 1 def fa(): d = c + 1 return d return fa a = f() print(type(a)) print(a()) def f(): c = 1 def fa(): c = c + 1 return c return fa a = f()
0a5875cf9390b7b142e3b94fc9d95d08f57987c8
IngSimon/Project-Repository
/script 5.file_gen.py
1,383
3.796875
4
""" This script creates a txt file with a specified percentage. The name of directory: provided by user """ import os import sys import random def trim_data(percent, name2, filename2, filename3, num2= 1024, filename1="./data/all_params.txt"): num1 = int(round((num2*percent/100), 0)) with open...
0bc7c5a6a2d81fca4e6d955e81f5f2084c42d953
mondchopers/roi
/ROI/test.py
707
3.84375
4
import itemkey as itk ## Testing that all buildings in dictionary are in the correct format ## itemList = list(itk.itemDict.keys()) for i, building in itk.buildingDict.items(): check = True # Input Check for item in building[2]: if len(item) == 0: continue if item[0] not in ite...
08ddebb75d4c65f081ec8cceab3153917db321ac
dalalsunil1986/Algoexpert-4
/Easy/13-CaesarCipherEncryptor.py
1,226
3.796875
4
# Solution 1 # def caesarCipher(string, key): # ''' # Time: O(n) # Space: O(n) # ''' # ans = '' # for letter in string: # asci = ord(letter) # encrypt = asci + (key % 26) # if encrypt <= 122: # ans += chr(encrypt) # else: # ans += chr(96 + ...
c97d27aa75300dd6a59cd466ff0eb78805641041
BruceLiu163/pythontutorial
/python_oop/about_class_property.py
734
4.09375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ property: 使用property装饰器,定义属性 @property装饰器就是负责把一个方法变成属性调用 Python内置的@property装饰器就是负责把一个方法变成属性调用 Python内置的@property装饰器就是负责把一个方法变成属性调用 Python内置的@property装饰器就是负责把一个方法变成属性调用 """ class Student(object): @property def name(self): return s...
7b06158802ae136ade8c5e57d52be20b6cc34039
kuronbo/maze
/maze/solver.py
441
3.546875
4
def dfs(maze): """深さ優先探索により迷路のスタートからゴールまでの経路を探す""" def _dfs(path): if maze.is_goal(path[-1]): return path for posi in maze.next_road_positions(path[-1]): new_path = None if posi not in path: new_path = _dfs(path+[posi]) if new_path:...
d400f3cdfb19d280a2a8ca1d9b3a2d3b246f2e88
AnkitMittal0501/PythonProject
/oops2.py
225
3.65625
4
class cons: def __init__(self, a, b): self.a = a self.b = b def sum(self,d): return self.a+self.b+d def sub(self): return self.a-self.b c=cons(3,2) print(c.sum(5)) print(c.sub())
f1f7fe2c25d024e95a20b9c636fcb001a056521a
RandyHodges/Self-Study
/Python/controlStructures/InvestmentCalculator.py
1,625
4.34375
4
# ================= Compulsory Task ================== # Create a new Python file in this folder called "InvestmentCalculator.py". # At the top of the file include the line: # import math # Ask the user to input: # The amount that they are depositing, stored as ‘P’. # The interest rate (as a percentage), stored...
a9c4c03fcb56365e720027c97623e7785bfb810c
Hitbee-dev/Data_Science_with_Book
/02_DeepLearning-from-scratch-2/common/dataset.py
4,109
3.65625
4
# https://github.com/WegraLee/deep-learning-from-scratch-2 # 여러가지 dataset 생성기를 딥러닝 라이브러리 없이 구현 import sys import os sys.path.append('..') import urllib.request import pickle import numpy as np class Spiral: def __init__(self, sample_num=100, feature_num=2, class_num=3): self.sample_num = sample_num ...
b8c5b6562387976ead48601daa4741c12e68702c
haoen110/FullStackPython
/02.Python/01.PythonBasic/codes/006if.py
239
3.609375
4
# 006if.py n = int(input("请输入一个数,判断数是否大于100、小于0、介于20~50之间")) if n > 100: print("这个数大于100") elif n < 0: print("这个数小于0") elif 20 < n < 50: print("这个数介于20~50之间")
05fb9cb9b6cda319de611a46860019be4998d70e
csatyajith/leetcode_solutions
/september_challenge/root_to_leaf_sum.py
1,160
3.921875
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 traverse_tree(self, node, num, nums): if node: num += str(node.val) if not node....
df401f43a0e4e7182f5dc4b223315867d636bd3a
aurel1212/Sp2018-Online
/students/darrell/wk6 - assignments/calculator-activity/calculator/subtracter.py
255
3.71875
4
""" This module provides a subtraction operator """ class Subtracter(object): """ subtractor class """ @staticmethod def calc(operand_1: object, operand_2: object) -> object: """ calc method """ return operand_1 - operand_2
30e9e1f2b4e5705eca4b2a5855f2852e4e2ab821
constans73/ejercicios_basicos
/listas2.py
750
4.3125
4
""" Escribir un programa que almacene las asignaturas de un curso (por ejemplo Matemáticas, Física, Química, Historia y Lengua) en una lista y la muestre por pantalla el mensaje Yo estudio <asignatura>, donde <asignatura> es cada una de las asignaturas de la lista. """ asignaturas = ["Matematicas", "Física", "Qu...
f5cc7cbd79ee0c2989817a63deada9ad5d5eb8f5
hika019/AnacondaProjects
/Python/numpy/nought_and_cross.py
1,204
3.5
4
# -*- coding: utf-8 -*- import numpy as np nought = 0 cross = 1 user = nought #初手 X = 3 Y = 3 win = 3 def bord(): global bord bord = np.zeros([Y, X]) bord[:,:] = np.nan return bord def select_XY(): print('X座標Y座標') put = str(input()) return put def put(): while True: ...
9f94511f86a9953633ce33603b74d27219224e17
kennykingcodes/NUMPY-USER-INPUT-SIMPLE-INTEREST-CALCULATOR-
/import numpy_financial as npf.py
553
3.5625
4
""" USE $ pip install numpy-financial TO GET MODULE """ import numpy_financial as npf """ USE $ pip install numpy TO GET MODULE """ import numpy as np #Simple interest principal = int(input("enter principal amount: ")) # Principal Amount annual_rate = float(input("enter annual interest rate: ")) #...
59a5c42dab59a5e8bb69aa65bcdaa4008db98752
maulia-c/Python-Project-Protek
/Protek-Chapter-6-Python/statistik.py
370
3.8125
4
def sum(*all): m=0 for x in all: m+=x print(m) def average(*all): m=0 n=0 for x in all: m+=x n+=1 avg=m/n print(avg) def max (*all): m=all[0] for x in all: if(x>m): m=x print(m) def min(*all): m=all[0] for x in al...
a2f9f655dedddd02dcbf07cf499e0eb09cbfce64
sameersaini/hackerank
/Strings/separateNumbers.py
1,176
3.875
4
#!/bin/python3 import math import os import random import re import sys # Complete the separateNumbers function below. # algo is to start from smallest number and then generate its next number and then search it in the string till all the numbers are found. # if this fails then repeat the step one for numbers of grea...
041f8570ca006cce0c8b94c8b26ad44ed6cffdff
danielforero19/taller-30-de-abril
/ejercicio 3.py
142
3.546875
4
n1 = int(input("ingresa el primer numero: ")) n2 = int(input("ingresa el segundo numero: ")) op = n1+n2 print("la suma", n1,"+", n2, "da", op)
63f0e2c12f909c17fe39167aa35fb318b09fcf4d
siyoon210/Python-Practice
/Do-it-first-python/mission/5-02.py
409
3.578125
4
# 치즈 접시가 비어 있어요 cheeze = [] # 치즈 접시에 문자열 '치즈'가 무한으로 추가되고, 그때마다 '치즈 추가!'를 출력해요 while True: cheeze.append('치즈') print('치즈 추가!') # cheeze 속 치즈가 50개가 되면 추가를 멈추고 '아이~ 배불러!'를 출력해요 if len(cheeze) == 50: print('아이~ 배불러!') break
b3d99395f21b98e2719d07e5ffdc1b589621a6c7
ghostkilla/python_100
/src/1/nlp_9.py
405
3.609375
4
import random str = 'I couldn’t believe that I could actually understand what I was reading : the phenomenal power of the human mind .' shuffled_words = [] for word in str.split(): if len(word) > 4: shuffled_word = word[:1] + ''.join(random.sample(word[1:-1], len(word) - 2)) + word[-1:] shuffled_words.append(shu...