blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
25d56ce810d258616f38301e379fdecb4d1cb628
zqlbling/week1
/Python_Lianxi/2.20Number.py
1,896
3.96875
4
#!/usr/bin/env python # -*- coding:utf-8 -*- # 返回数字的绝对值 a1 = -10 print(abs(a1)) # 比较两个数的大小 print((10>9)-(10<9)) # 1 a3,a4 = 100,200 print(max(a3,a4)) # 返回给定参数的最大值 print(min(a3,a4)) # 返回给定参数的最小值 # 求x的y次方 print(pow(2,5)) # 32 # round(x[,n]) 返回浮点数x 的四舍五入的值,如果n有值,代表四舍五入到后n位 print(round(3.456)) print(round(3.4...
2d7b9dba56dd104bed8fe0db126e84105b07c83a
zqlbling/week1
/week/w4.py
1,074
3.765625
4
#!/usr/bin/env python # -*- coding:utf-8 -*- ''' 随机生成一个包含1000个字母的字符串, 然后统计该字符串中每个字母的数量,并输出结果(要求结果以字典方式存储) ''' # import random # str = "abcdefghijklmnopqrstuvwxyz" # str1 = "" # 新的字符串 # for i in range(1000): # str1 += random.choice(str) # print("生成的随机字符串是:",str1) # dict = {} # for i in str1: # key = dict.get(...
8dcc052f64cd2d994653033143d3dd081bdcaca6
dalangston/Guessing_Game
/guess.py
1,816
4.125
4
from random import randint from os import system, name MAX_GUESS = 3 MIN_NUM = 1 MAX_NUM = 20 def clear(): if name == 'nt': _ = system('cls') else: _ = system('clear') if __name__ == '__main__': clear() print(''' You approach and old bridge spanning an enormous gorge. An ...
63195ec456aa26f1a27901f0eb7cde9181c5dc51
Parthgaba/programming
/cp_practice/fact.py
105
3.71875
4
# your code goes here import math for _ in range(int(input())): print(math.factorial(int(input())))
0b2084fff4f93ef1deeb8289206fad13ec244593
Parthgaba/programming
/Arrays/Python/RemoveDuplicates.py
355
3.5
4
class Solution: def removeDuplicates(self, nums: List[int]) -> int: n = len(nums) num = sorted(list(set(nums))) res = len(num) for i in range(len(nums)): if i<res: nums[i] = num[i] else: nums[i] = '_' return res S = Sol...
c540fe9f83c6fd2a99c4bde1909ee1ae6df47cf6
Luoyuequan/project
/中空_小星星.py
1,671
3.65625
4
lines = int(input('请输入行数:')) lines_nei = int(input('请输入掏空行数:')) tao = 1 for top_line in range(1, lines + 1): # print(type(line),line) numbers = 2 * top_line - 1 lastNumbers = 2 * lines - 1 spaces = lastNumbers // 2 - (numbers // 2) for space in range(spaces): print(' ', end='') ...
b2dab0aa1f3c0bc38ff4f2376313fc2fcb009e49
sq271/e.primes
/primefinder.py
426
3.578125
4
#!/bin/python # primefinder.py <length of prime> import sys digits=int(sys.argv[1]) f = open('e10000') file = f.read() def isprime(a): if a % 2 != 0: return all(a % i for i in range(3,a,2)) def collector(a): for i in range(2,500): out = '' for x in range(i,i+a): out +...
ca8134f37284e9a586dafe171f3be8b97a8e845f
nkukarl/ctci
/1_1.py
658
4.09375
4
''' Implement an algorithm to determine if a string has all unique characters. What if you can not use additional data structures? ''' def is_unique(string): temp = '' for i in string: if i not in temp: temp += i else: return False return True def is_unique2(str...
f5f7baeb53b93d2e560722a6d65a257b97461ad6
marialitovchenko/Coursera-Programming-on-Python-by-MIPT
/1_DiveIn_Python/Week_2/Key-value_storage.py
1,561
4
4
""" Save key - value pairs into the file storage.py. If one argument is given (--key) retrieve the pair from the file: storage.py --key key_name If two arguments are given (--key, --val), put the pair into the file: storage.py --key key_name --val value Several values can be assigned to one key """ import argparse ...
d94affa3fefbe8977f379cd0adff91bd258834ff
mclausaudio/python_playground
/else_if_elif.py
347
4.34375
4
# if, elif, else # comparions... ==, !=, >, <, >=, <=, name = input('What is your name? ') if name == "Michael": print('Yes, name == "Michael') elif name == "Renee": print('Yes, name == Renee') else: print('No, name is not Michael or Renee. In fact, it is {}'.format(name)) if name != "Michael": print(...
1697168db0a64cfb7cfda99f5753b4175c44ab95
mclausaudio/python_playground
/booleans.py
712
4.125
4
# Booleansa print( bool('Michael') # => True ) print( bool(42) # => True ) # Emptiness is Falsey print( bool("") # => False ) # can negate with the 'not' keyoword. Similar to ! in JavaScript print(not True) # => False print(not False) # => True # 'and' keyword.. evaluates True if all expressions e...
c2cb7846d0d2b64c26872691d36d80468a09e6f7
janacarvalho/codility-tasks
/FrogRiverOne/FrogRiverOne.py
760
3.734375
4
def solution(X,A): """ A small frog wants to get to the other side of a river. The frog is initially located on one bank of the river (position 0) and wants to get to the opposite bank (position X+1). Leaves fall from a tree onto the surface of the river. :param X: Number of falling leaves used...
60be77b3481b46ae21d11de122a61e8ec04c79d6
Lakshya0744/PreCourse_2
/Exercise_5.py
930
3.765625
4
# Python program for implementation of Quicksort # This function is same in both iterative and recursive def partition(arr, l, h): i=l-1 pivot = arr[h] for j in range(l,h): if arr[j]<pivot: i=i+1 arr[i],arr[j]=arr[j],arr[i] arr[i+1],arr[h]=arr[h],arr[i+1] return i+1 ...
2887dba3e441a3992db0dc65bf2b17559e229c96
FranklinA/CoursesAndSelfStudy
/PythonScript/PythonBasico/operadoresConValorPordefecto.py
195
3.71875
4
def sumar(numero1=0,numero2=0): return numero1+numero2 valor=sumar(5,5) print ("El resultado de la FUNCION sumar es ",sumar(5,5)) print ("El resultado de la VARIABLE valor es igual ",valor)
29fb99feb5446f1a648b9d64cd926444d2ffd965
FranklinA/CoursesAndSelfStudy
/PythonScript/PythonIntermedio/cap_1/metodosDeClase.py
430
3.5625
4
#USAR metodos de clase class Persona: def __init__(self): pass def despedir(self):# Metodo de ... print("Adios") @classmethod # Siempre se pone @classmethod el decorador para usar un metodo de clase def saludar(cls,nombre):# Metodo de clase se pone el cls print("Estoy saludando",nombre) #con los metodos ...
971baea25fe9fb754fb29dd4f9b6a86d3f509bf6
leeang/Communication-Networks
/ws3/code/section2/wsmmchelper.py
7,676
3.6875
4
# -*- coding: utf-8 -*- """ Created on Tue Jul 15 11:43:50 2014 Classes to help ELEN90061 Workshop MMc Simulation @author: alpcan """ import math import numpy as np import heapq as hq from collections import deque as dq class EventQueue: ''' This class handles discrete events in the simulato...
215e929661d065db89279cc73eb59621c654c9b5
leeang/Communication-Networks
/ws1.5/calculator.py
595
4
4
# -*- coding: utf-8 -*- import sys while 1: option = input('input option') if option == 1: num1 = input('add 1st') num2 = input('add 2nd') print num1 + num2 elif option == 2: num1 = input('subtract 1st') num2 = input('subtract 2nd') print num1 - num2 eli...
a558002790392a46d92c7edacf8ea6dc2c3f6b48
caweinshenker/Algorithms
/Graph/DirectedEdge.py
640
3.5
4
class DirectedEdge(object): def __init__(self, fr, to, weight=0): self.fr = fr self.to = to self._weight = weight def __str__(self): return "{} --> {}, {}".format(self.fr, self.to, self._weight) def __lt__(self, other): return self.weight < other....
bede7a5c4a77be74c26ee45213e34c5d28cd01b2
WorldBank-Transport/MTurk
/HIT Data Cleaner.py
4,626
3.84375
4
import csv import string #Given a response_dict dictionary, containing keys of responses mapping to their frequency, and a total, this return #the majority response if it's more than one and more than half the total, along with the number of people who put #that response. If no such response exists, this just re...
864a2764cf9fcc0151d13dfb17b24a4241e5ed28
daviddroste01/ucla-2019
/Dictionary.py
310
3.921875
4
dictionary = { "tatogucci":"everythings alright", "mmg":"mommy made eggs", "mmb":"i love my mom", "hdp":"happy birthday", } sentence="tatogucci mmg mmb hdp" wordList=sentence.split(" ") print(wordList) for word in wordList: if word in dictionary.keys(): print(dictionary[word])
a8b63be40c2e594c9c246c72c73044e72a860b6c
klong124/Spotify-TechQuestions
/changePossibilities.py
955
3.90625
4
def changePossibilities(amount, denominations): if amount == 0: return 1 if amount < 0 or len(denominations) <= 0 or denominations[0] == 0: return 0 return changePossibilities(amount - denominations[0], denominations) + changePossibilities(amount, denominations[1:]) print changePossibil...
c19dd6d34a2927639c8873eabd9cf53815c86e9f
rookiy/Leetcode
/ReverseLinkedList.py
878
4.0625
4
#!/usr/bin/env python # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: # @param {ListNode} head # @return {ListNode} def reverseList(self, head): r = None # here is a interesting fact, code ...
c8ff013cc4d2b9e61f7f966939b609ef79b55bdc
rookiy/Leetcode
/RomanToInteger_2rd.py
771
3.671875
4
#!/usr/bin/env python class Solution: # @param {string} s # @return {integer} def romanToInt(self, s): d = {'I':1, 'V':5, 'X':10, 'L':50, 'C':100, 'D':500, 'M':1000} sum = 0 if s.find('IV') != -1: sum -= 2 if s.find('IX') != -1: sum -= 2 if s.f...
981d6755e9dd100ea7c9feeffbcc33e3af47d29c
rookiy/Leetcode
/CountPrimes_2rd.py
582
3.703125
4
#!/usr/bin/env python import sys class Solution: # @param {integer} n # @return {integer} def countPrimes(self, n): count = 0 List = [1 for i in xrange(n)] for i in xrange(2,n): if List[i] == 1: count += 1 factor = i while f...
978aaadcd19cb9595d30e062a47725e3748cc4a5
rookiy/Leetcode
/SameTree.py
1,256
3.953125
4
#!/usr/bin/env python # -*- coding:utf-8 -*- class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None # 使用递归。Preorder。 class Solution: # @param {TreeNode} p # @param {TreeNode} q # @return {boolean} def isSameTree(self, p, q): if not p or...
04bf2ec84045e4b37ae51871edac7622ac09c3fb
rookiy/Leetcode
/ReverseBits.py
435
3.59375
4
#!/usr/bin/env python import sys class Solution: # @param n, an integer # @return an integer def reverseBits(self, n): l = [] for i in range(32): l.append(str(n%2)) n /= 2 ans = int(''.join(l), 2) return ans def main(): sys.stdin = open('./1.txt',...
e4d3c19d3411fc22a676cc4f27b1a5b335482878
rookiy/Leetcode
/LongestCommonPrefix.py
561
3.71875
4
#!/usr/bin/env python class Solution: # @param {string[]} strs # @return {string} def longestCommonPrefix(self, strs): if strs == []: return '' ans, flag, length, i = [], True, len(strs[0]), 0 while flag and i < length: current = strs[0][i] for tmp...
b1875a837d063c772fee734f916e609e31c93797
JamieVic/ratingsystem
/rating.py
928
3.984375
4
import sqlite3, datetime def submitRating(): getToday = datetime.datetime.now() today = getToday.strftime("%x") conn = sqlite3.connect("DATABASE FILE") cur = conn.cursor() cur.execute("INSERT INTO ratingstbl (ratings, ratingdate) VALUES (?, ?)", (rating, today)) conn.commit() conn.close() ...
a0e412a4ee8f975999718936c838bec2663e110e
jozdashh/agra
/hw05/space/space.py
1,925
3.5625
4
# Estudiante: Josue Peña Atencio # Código: 8935601 # Fecha: 13/10/2018 from sys import stdin deltar = [0, -1, 0, 1] deltac = [-1, 0, 1, 0] class dforest(object): """implements an union-find with path-compression and ranking""" def __init__(self, size=10): self.__parent = [ i for i in range(size) ] self....
f21825eb1c1974afbe30b767ef49712706047720
twonp168/MatrixInverse
/MatrixInversion.py
10,677
3.859375
4
#!/usr/bin/env python # coding: utf-8 # ![Matrix Inversion Logo](Matrix_Inverse_Logo.png) # # Dirt Simple Matrix Inversion # [MatrixInversion on Github](https://github.com/ThomIves/MatrixInverse) # We are going to walk thru a brute force procedural method for inverting a matrix with pure Python. Why wouldn’t we just ...
c07fae5faa0f4b72bcae14e43f67f6f9399b56cf
ComputerVisionaries/PSF
/util/inflate_image.py
890
4.0625
4
import numpy as np def inflate_image(pieces, rows, columns): """Assembles image from pieces. Given an array of pieces and desired image dimensions, function assembles image by stacking pieces. :params pieces: Image pieces as an array. :params rows: Number of rows in resulting image. :para...
4c740b3e55b3d21c426e8f8af2ef36630a0c3a43
brutusk94/cti110
/P3T1_AreasOfRectangles_KenricBrutus.py
726
4.3125
4
# CTI-110 # P3T1 Area of Rectangles # Kenric Brutus # 6/19/2018 # Calculating which rectangle has the highest area. # The dimensions of rectangle 1. length1 = int(input("Enter the length of rectangle 1: ")) width1 = int(input("Enter the width of rectangle 1: ")) # The dimensions of rectangle 2. lengt...
83bcd60dddbd8ebc1d9c5265ae7bd34272e553ac
zivzone/NCTU_Programming_Language_Exercise
/hw10_0517/Homework_E10/primes.py
317
3.828125
4
import sys def is_prime(n): if n == 2: return 1 for i in range(2 , pow(n, 0.5)): if n % i == 0 : return 0 return 1 number = int(sys.argv[1]) num_primes = 0 for n in range(2, number+1): if is_prime(n) == 0: continue num_primes += 1 print(str(num_primes))
9015032bb3b2519346f01e4cf26331bc3317db5c
zivzone/NCTU_Programming_Language_Exercise
/Quiz_E180514/Q4.py
596
3.765625
4
numbers = [50.9, 50.3, 48.7, 89.2, 60.0, 74.0, 54.2, 101.6, 84.9, 82.1, 79.4, 93.8] print("numbers = " + str(numbers)) def my_medium(list): list_length = len(numbers) #print(list_length) numbers.sort() #print(numbers) #print(int(3/2)) num_1 = numbers[int(list_length / 2)] #print(i...
8b1436d67b70e91e713c0a1e8aef8e1c369fc63a
zivzone/NCTU_Programming_Language_Exercise
/quiz5/Q4.py
571
4.15625
4
Numbers = [54, 26, 93, 17, 77, 31, 44, 55, 20] def selection_sort(list): for i in range(len(list)): mini = min(list[i:]) #find minimum element min_index = list[i:].index(mini) #find index of minimum element list[i + min_index] = list[i] #replace element at min_index with first element ...
c3732238c5bc2b53dcf56a6f9a9630509cff7bdf
zivzone/NCTU_Programming_Language_Exercise
/Quiz_E180514/Q6.py
309
3.578125
4
#def distant_count(height,time): # if time > 0: # return height*2 + 2 * distant_count(height/2,time) # else: # return 0 height = 100 #print(distant_count(100/2,2)) sum = 0 for i in range(0, 9): height = height / 2 sum = sum + height * 2 sum = sum + 100 print(sum)
304643bf8c422d4000371e45cea7f5dac154714d
andreanidouglas/tweetpy
/tweetpy/tweet_search.py
1,753
3.796875
4
""" Uses twitter endpoint to search for a specific word """ import sys import urllib import json import oauth2 as oauth from tweetpy.tweetpy import OAuthClient as OAuthClient import tweetpy.tweet as tweet class TweetSearch(): """ Uses twitter search api """ def __init__(self): self.__url = '...
55ccb6a3d17a49ab0efd7d133e78530551cfdf37
elreplicante/udacity
/cs-212-design-of-computer-programs/src/poker/poker.py
3,160
3.859375
4
''' Created on 20/04/2012 @author: repli ''' def poker(hands): "Return the best hand: poker([hand,...]) => hand" return max(hands, key=hand_rank) def kind(n, ranks): """Return the first rank that this hand has exactly n of. Return None if there is no n-of-a-kind in the hand.""" for r in ranks: ...
57b6a690e46c27cc5e922c89384e64e75b8ab804
thisusernameistaken/PythonThings
/Chris-Python/UbbiDubbi.py
723
3.671875
4
from Tkinter import * def insert(original, new, pos): return original[:pos] + new + original[pos:] def cmd(): vowels=['a','e','i','o','u','y'] newsent='' sent=txt.get() newsent=list(sent) if 'a' in sent: newsent.insert(sent.find('a',8),'ub') newsent.insert(sent.find('a...
4a2ca818366918b084136bd0bd30ac50cfcf8ba8
thisusernameistaken/PythonThings
/Chris-Python/Python Labs/Lab 13.2.py
256
3.515625
4
def countVowels(s): z=s z=z.lower() z=str(z) z[1:] x=0 if(z[0]=='a')or (z[0]=='e')or(z[0]=='i')or(z[0]=='o')or(z[0]=='u'): x+=1 if (len(s)==1): return x return x + countVowels(z[1:]) print countVowels("HER")
b383f9893d1cb79299fb56da48ab2c930a2ad121
yuvrajschn15/Source
/Python/04-variables.py
298
4.125
4
# variables can be defined in python by just assigning a value to them # they do not need to be explicitly defined like in C, C++ or Java num1 = 32 num2 = 45 print("The sum of the two numbers is", num1 + num2) # Defining a string str1 = "This is a string" # Printing a variable print(str1)
a3cc1cadc29d0ed297aab66610c916f7739a0253
yuvrajschn15/Source
/Python/19-lists.py
2,761
4.5625
5
# List : mutable, ordered, allows duplicate elements # we can use this function to iterate over the list def prlist(name): for item in name: print(f"{item}", end=" ") # A list can be defined by [] or list list1 = ["This", "is", "the", "first", "list", "."] print(list1) prlist(list1) list3 = ["This",...
f3a36554ee81e0502f2d09ade63b6472c5d14166
yuvrajschn15/Source
/Python/46-map.py
384
4.15625
4
# map is a built-in function in python which is used to map an iterable as defined by the function ## Usage: map(func, *iterable) --> map object x = [2, 4, 6, 8, 10, 12] c = map(lambda a: a/2, x) print(c) # To print the value of c we need to cast c into a set or list or tuple print(set(c)) c = map(lambda a: a/2,...
ba972aef359879ba332932ea08e4fc1e9d28e448
anguyen216/blob-detection
/paddings.py
4,587
3.953125
4
#!/usr/bin/env python3 import numpy as np from utils import get_pad_size def pad_values(img, size, pad_values): """ Pads image with a constant Mimicks the behavior of np.pad(array, size, 'constant') Inputs: - img: 2D 2D array of input image need to be padded - size: int, list or tuple; the si...
cb8535608d4f890a59e6c4b8e23f29f6668a94d5
EricksonOn/Guessing_games
/feelgame_1.py
7,064
3.875
4
def rateme(numberchoices2,first): if first==True: numberchoices2=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15] first=False else: pass print("WELCOME \n") my_name = input("PLAYER ONE, ENTER NAME: \n\t\t") your_name = input("PLAYER TWO, ENTER NAME: \n\t\t") print(my_name) prin...
d5c2a033a60145f8deb7cc4392b95f8dc420b27e
shickey18/DataCamp-Exercises
/Regular Expressions in Python.py
13,684
4.15625
4
# String Manipulation # Find characters in movie variable length_string = len(movie) # Convert to string to_string = str(length_string) # Predefined variable statement = "Number of characters in this review:" # Concatenate strings and print result print(statement + " " + to_string) # Artificial Review # Select the...
96f061bd214a2fc53f69cefdd273d62540def53f
Jugglecomemid/Algorithm-and-data
/数据结构/tree/树的遍历(栈).py
4,545
4.03125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2020/3/19 11:21 AM # @Author : Charles He # @File : 树的遍历(栈).py # @Software: PyCharm class node(object): def __init__(self,elem=-1,lchild=None,rchild=None): self.elem=elem self.lchild=lchild self.rchild=rchild class tree(object)...
ebc8f40d022f6a2e4bdc36c226eabfda077084bc
Jugglecomemid/Algorithm-and-data
/数据结构/tree/树的遍历(递归).py
2,269
4
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2020/3/19 11:23 AM # @Author : Charles He # @File : 树的遍历(递归).py # @Software: PyCharm class node(object): def __init__(self, elem=-1, lchild=None, rchild=None): self.elem = elem self.lchild = lchild self.rchild = rchild class ...
68fac6e3a800219221574d83f797c3e096762b92
vinayakgaur/Algorithm-Problems
/Count the Numbers of Consistent Strings.py
647
4.09375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Jan 13 22:20:38 2021 @author: VGaur """ #You are given a string allowed consisting of distinct characters and an array of strings words. A string is consistent if all characters in the string appear in the string allowed. #Return the number of consist...
1b7a3da28e99769b0fd75842f42ff37f6fc1e78e
vinayakgaur/Algorithm-Problems
/Check of Two String Arrays are Equivalent.py
875
3.953125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jan 18 10:29:38 2021 @author: VGaur """ #Given two string arrays word1 and word2, return true if the two arrays represent the same string, and false otherwise. #A string is represented by an array if the array elements concatenated in order forms the...
8b136c42ccd16eb37dbc83d3df2aa458a6894ebd
kylestormcloud/coding-challenges
/sudoku/sudoku.py
1,944
4.28125
4
from numpy import zeros, arange def remove_empty(x): """ Remove the space characters from a collection An empty square on the sudoku board is denoted with a string containing a single space. It is necessary that these empty squares be removed before the uniqueness of the values is verified. ...
f94990765de8c7075e0c0c4377bbac6fe8eaa313
cassiadev/sparta_algorithm
/week_1/03_01_find_max_occurred_alpahabet.py
580
4.03125
4
input = "hello my name is sparta" def find_max_occurred_alphabet(string): # 이 부분을 채워보세요! alpahbet_array = ["a", "b", "c", "d", "e", "f", "g"] max_occurence = 0 max_alphabet = alpahbet_array[0] for alphabet in alpahbet_array: occurrence = 0 for char in string: if char =...
c256646ad738dffa07e26232abd092c23460a167
tyrone877/cp1404practicals
/prac_05/emails.py
654
4.0625
4
def main(): email_to_name = {} email = input('Email: ') while email != '': full_name = return_name_from_email(email) confirm_full_name = input(f'Is your name {full_name}? (Y/n) ') if confirm_full_name == 'n': full_name = input("Name: ").title() email_to_name[em...
5574a2bb891eb47cd0953b996fdad2eb3c43db60
tyrone877/cp1404practicals
/prac_06/guitars.py
829
3.90625
4
from prac_06.guitar import Guitar def main(): guitars = [] print("My guitars!") name = input("Name: ") while name != "": year = int(input("Year: ")) cost = float(input("Cost: ")) add_guitar = Guitar(name, year, cost) guitars.append(add_guitar) print(add_guitar,...
1db20f868ef330e7d4de9200dd4fdab1d8828e1c
SophiaMo/BootCamp2017
/ProbSets/Computation/wk1_hw/oop.py
3,376
4.25
4
#oop.py """OOP Sophia Mo 06/26/2017 """ import sys #Problem 1 class Backpack(object): """A Backpack object class. Has a name, color, max size, and a list of contents. Attributes: name (str): the name of the backpack's owner. color(str): the color of the backpack. max_size(int): the max size of the ...
93d93b4c828f4e3456049169465650baa86c4593
Aoi-shiori/python_study
/Study/GJPY.py
1,225
4.25
4
#这是我的python程序! name ="小ABCDEF" age = 99 print( "\"name[0]\"\nname[1]") print(name+"我的家人") print(name *3 ) print("K" in name ) print(name.upper().isupper())#转换字母为大写,并判断是不是大写,是则输出true print(name.islower())#判断是不是大写,是则输出true print(name.index("DEF"))#返回某个特定字符或者字符串的位置 print(name.replace("ABC","YYY"))#替换函数,可以方便的替换需要替换的内容 prin...
9b8cb54c9485995b8731ab3f8738acefae6aeb2e
NileshNehete/Learning_Repo
/Python_Pro/Modules/calmodule.py
768
4.09375
4
ITERATOR=0 def add (num1,num2): sum = num1 + num2 print ("Addition of two numbers: %d" % sum) print ("=" *50) def sub (num1,num2): if (num1<num2): print ("Sorry!! Enter First number greater than Second!!") else: sub = num1 - num2 print ("Substraction of two numbers: %d" % s...
726066be2c0ed1143b9cbf15fcbb548eef91b26e
sudoabhinav/my_code
/algorithms/greatest_common_divisor_euclidean.py
652
3.84375
4
""" Python program to calculate GCD of two numbers,using the euclidean algorithm. Euclidean algorithm - https://en.wikipedia.org/wiki/Euclidean_algorithm eg. If we want to find the GCD of 50 and 20, then we divide 50 by 20. The remainder is 10 and now we divide 20 by 10, remainder is 0, and hence 10 is the GCD of 50 ...
52f3fc42c50ef588e30b4a614ccd90b52243ac61
cpardue/seb_repo
/Return Multiple Values From a Function.py
181
3.921875
4
def name(): return "John","Armin" # print the tuple with the returned values print(name()) # get the individual items name_1, name_2 = name() print(name_1, name_2)
59a15190e019e2433cbd299e6a9c002b469980f9
bragon9/leetcode
/2AddTwoNumbers.py
1,214
3.546875
4
class Solution: def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode: head = None carry = 0 while l1 or l2: # Check to see if we can end the loop early due to l1/l2 not existing if carry == 0: if not(l1): node.next = l2 ...
cabeb4b76f120189740e22f449f8a9b496928dda
bragon9/leetcode
/143ReorderList.py
1,717
3.8125
4
class Solution: def reorderList(self, head: ListNode) -> None: """ Do not return anything, modify head in-place instead. """ if not(head) or not(head.next) or not(head.next.next): return fast = head slow = head ptr = 0 while fast.next: ...
f71e4c8031d7dd382b6e61749e9ea4cf84174513
PetraSH-ENG/Python_Engeto
/projekt2_BULL.py
2,269
3.53125
4
# formatovani import random oddelovac = '=' * 40 # uvod print("Vitejte v nasi hre BYCI & KRAVY!".center(30, ' ')) print(' ') print("""Mame pro Vas nahodne vygenerovane 4-mistne cislo a Vasim ukolem je ho uhodnout v co nejkratsim case.""".center(40, ' ')) print(oddelovac) print("PRAVIDLA:".center(40, ' ')) print("""...
bb3c6e964f79a557bbe109644d70703c4f9fc0d7
Mlittle-dev/musicPlayer
/musicplayer.py
539
3.765625
4
""" program: musicplayer.py author: mike 4/13/2021 simple program to play an audio file """ from pygame import mixer #store the file name in a variable for easy reference file = "getlove.mp3" #initialize the mixer mixer.init() #load the music file into the mixer mixer.music.load(file) #play the load...
009cca52ba9cdc599b69da9cc2e5d5dac8dab9ab
sebastian011511/Game-of-Craps
/Craps.py
7,211
3.609375
4
""" Created by Sebastian Vasco This program is a simulation of the game craps. PLEASE NOTE TO MODIFY THE DIRECTORY TO MATCH YOUR HOME DIRECTORY FOR READING AND WRITING FILES """ import random import sys import os rollAgain=False def checkvalues(value1, value2): totalvalue = value1 + value2 if totalvalue...
e1439162bd64b7940e1dc642a1564e87c2439792
raghavan93513/Polynomial-Addition-using-lists
/Polynomial-Addition-using-lists.py
318
3.59375
4
n1 = int(input()) a = [] for i in range(n1+1): a.append(int(input())) n2 = int(input()) b = [] for i in range(n2+1): b.append(int(input())) if len(a) > len(b): big = a smol = b else: big = b smol = a for i in range(1,len(smol)+1): big[-i] = big[-i] + smol[-i] print(big)
ba2952da6c1dfeabe245996779f811945aff8e14
AntimaRai/leetcode
/leetcode/200-number-of-islands.py
972
3.5625
4
# 200-number-of-islands.py # # Copyright (C) 2019 Sang-Kil Park <likejazz@gmail.com> # All rights reserved. # # This software may be modified and distributed under the terms # of the BSD license. See the LICENSE file for details. class Solution: def numIslands(self, grid: List[List[str]]) -> int: # Depth-f...
955cc9a6ffda3082eae12cf48079b9696d5de1c4
luiz-alt/Python-LP2-git
/modulo.py
497
3.890625
4
def soma(x, y): z = x + y return z #TESTE DAS MINHAS FUNCÕES def test_soma1(): assert soma(3, 5) == 8 #Passo o parametro chamando a função que gistaria de testar e coloco o == para #passar o meu resultado o meu resultado #Tenho que criar cada função para cada teste com os ou...
462791a2e8e388a713c6b13517829e79c473cb31
leonhostetler/undergrad-projects
/computational-physics/04_visual_python/lattice_nacl.py
508
3.609375
4
#! /usr/bin/env python """ Uses VPython to show a 3D model of the lattice structure of NACl. Leon Hostetler, Feb. 3, 2017 USAGE: python lattice_nacl.py """ from __future__ import division, print_function from visual import * L = 5 R = 0.5 for i in range(-L, L+1): for j in range(-L, L+1): for k in range(...
604302d76f379fb0794cbe5b118c8764e06cb019
leonhostetler/undergrad-projects
/numerical-analysis/06_root_finding/mullers_method_single_root.py
1,570
4.59375
5
#! /usr/bin/env python """ Finds a single complex root of a given polynomial. Muller's method is similar to Newton's method except, instead of finding the root of a tangent line, we find the root of an interpolating quadratic. Leon Hostetler, Mar. 3, 2017 USAGE: python mullers_method_single_root.py """ from __future...
2b8f0245f9a7599fed3b5594590630bd37bd2bd6
leonhostetler/undergrad-projects
/numerical-analysis/12_matrices_advanced/qr_method.py
2,391
4.09375
4
#! /usr/bin/env python """ Here we start with an upper Hessenberg matrix and convert it to an upper triangular matrix using Givens rotations. The result is the QR factorization of the matrix. Leon Hostetler, Mar. 7, 2017 USAGE: python qr_method.py """ from __future__ import division, print_function import numpy as n...
739b60d45f244499caa8653561c4420aee1c213f
leonhostetler/undergrad-projects
/numerical-analysis/10_matrices_pivoting_solvers/matrix_generators.py
4,001
4.09375
4
# # matrix_generators.py i # # Leon Hostetler # Jan. 21, 2017 # #! /usr/bin/env python """ Includes several different matrix generators (including random matrices). These functions can be included in other programs where random matrices are needed. Leon Hostetler, Jan. 21, 2017 USAGE: python matrix_generators.py ...
f450a1662dbb6250c1696a205a71c922eec15d76
leonhostetler/undergrad-projects
/computational-physics/10_root_finding_modular/lagrange_point.py
1,183
4.25
4
#! /usr/bin/env python """ Finds the root of a fifth degree polynomial to find the distance from the center of Earth to the L1 Lagrange point between the Earth and its moon. Leon Hostetler, Mar. 25, 2017 USAGE: python lagrange_point.py """ from __future__ import division, print_function import mymodule_root_finding ...
e2308087d5f15f9717bec20b69b3321076dc30de
leonhostetler/undergrad-projects
/computational-physics/05_floating_point_precision/quadratic_equations.py
2,800
4.4375
4
#! /usr/bin/env python """ Solve a quadratic equation in three different ways. The first method uses the familiar form of the quadratic formula, and the second form uses a rearranged form of the quadratic formula. Both of them suffer from numerical error when b^2 >> 4ac. The third method eliminates these numerical erro...
1c0d40c95a101e76358d1f3c1216c67ad849c027
leonhostetler/undergrad-projects
/computational-physics/04_visual_python/cannon_ball.py
1,319
3.8125
4
#! /usr/bin/env python """ Shoots a cannon ball. Leon Hostetler, Feb. 15, 2017 USAGE: python cannon_ball.py """ from __future__ import division, print_function from visual import * # Constants g = 9.80 # (m/s^2) v_0x = 5 # Initial speed in x-direction v_0y = 50 # Initial speed in y-d...
5634a7f88f83a4d52219928f15e0f91330c9ed76
leonhostetler/undergrad-projects
/computational-physics/13_odes_modular/mymodule_ODEs.py
1,028
3.765625
4
#! /usr/bin/env python """ Module mymodule_ODEs.py is a module containing a collection of user-defined classes and functions for working with ordinary differential equations. Leon Hostetler, Apr. 9, 2017 USAGE: To be used as a supplement to a main program. """ from __future__ import division, print_function class ...
22d67c01529179d6885bad2eb295d82fc0b0918f
leonhostetler/undergrad-projects
/computational-physics/12_odes/runge_kutta_example.py
1,922
3.953125
4
#! /usr/bin/env python """ The fourth-order Runge-Kutta method is a standard method for solving a system of coupled first-order ordinary differential equations. Leon Hostetler, Apr. 9, 2017 USAGE: python runge_kutta_example.py """ from __future__ import division, print_function import matplotlib.pyplot as plt import...
9429bbea475a31d6e51ed5b61182f6faa7d2f57a
denck007/growControl
/growControl/sensor_volume.py
14,575
3.625
4
import datetime import os import sys import time import json try: import RPi.GPIO as GPIO except: print("Sensor_ph: Unable to import raspberry pi specific modules" +\ "\tWill only be able to run in csv mode!") class Sensor_volume: ''' Defines a sensor for measuring the volume in th...
013e8fc9f17882f05304497d7d655a382b21fd5a
souk2109/python-study
/파이썬 기초문법 정리/10. 람다.py
343
3.5625
4
# 람다 함수로 간편하게 함수를 작성할 수 있다. # 한 번만 사용 할 함수가 있는 경우 사용한다. array = [('kim', 50), ('jang', 20), ('kin', 40), ('dme', 80)] print(sorted(array, key=lambda x: x[1])) list1 = [1, 4, 2, 3, 1] list2 = [2, 1, 3, 4, 2] print(list(map(lambda x, y: x+y, list1, list2)))
a769bc134c460b90cc1c88e8a1c1eb58807d2da8
XenonMolecule/CS-Principles-Work
/human_machine_language/commands/move.py
1,585
3.5
4
from commands.command import Command class Move(Command): def __init__(self, text, line_num, right_side, position, pos_spec): super(Move, self).__init__("MOVE", text, line_num) self.right_side = right_side self.position = position # -4 = RHCard, -3 = LHCard, -2 = RHPos -1 = LHPos only if po...
e84e41e86bd6b85f722d0e215957f4b4bd644714
SaschMosk/hw_8
/lect_9.py
1,459
3.65625
4
# f = open('hell', 'rt') # print(f.read()) # print(f.readline()) # with open('hell') as f: # print(f.read()) # print('fail zakrit {}'.format(f.closed)) # например, сколько раз Пьер и Наташа встретились в одном абзаце в войне и мире # count = 0 # with open('_') as f: # for line in f: # if 'Наташ' in line...
258310707f3ede0bd5dc2c893bf2d551791efd82
jazzlor/LPTHW
/ec3.py
1,380
4.6875
5
#line 2 will display "I will now count my chickens:" print("I will now count my chickens:") #line 4 will display hens, then math up 25 + 30 / 6 print("Hens", 25 + 30 / 6) #line 6 will display "Roosters" then math up 100 - 25 * 3 %4 print("Roosters", 100 - 25 * 3 % 4) #line 8 will display "Now I will count the eggs: pri...
fa488807453490c19e06c7be9ad26573982dc36c
jazzlor/LPTHW
/ex16.py
1,701
4.34375
4
#The below line says that the module named sys will import the thing called argv from sys import argv #The below line says script,filename = argv script, filename = argv #The below line prints the greentext & inserts the filename that you entered when running the program print(f"We're going to erase {filename}.") #The ...
990fd436790eab0214923a647e3d2698c89779d6
manimaran990/ebook_creator
/convert_utils.py
1,423
3.515625
4
import os class converter: def __init__(self, book_title_in_english, book_title, author, content,cover): self.book_title_in_english = book_title_in_english self.book_title = book_title self.author = author self.content = content self.cover = cover def convert_to...
9904b35f5af686269fddcd71c528fd13a5d967db
kzhereb/kpi-acts-asd2020-2021
/code-examples/lecture_3_recursion/tribonacci.py
161
4
4
def tribonacci(n): if n<2: return 1 return tribonacci(n-1)+tribonacci(n-2)+tribonacci(n-3) for i in range(20): print(str(i)+ ";"+ str(tribonacci(i)))
b3f3db47b42edf28ecfacce16d6bcc65cd164318
yumendexiluo/python_ppq
/ppq/maxLens.py
466
3.71875
4
# 最大不重复字符串 def max_lenth(str='abcdassasdefg'): pmax = "" for i in range(len(str)): b = 1 for j in range(i, len(str[i:])): if str[j] in str[i:j]: b = 0 break if len(str[i:j + b]) > len(pmax): pmax = str[i:j + b] print(pmax) if ...
0bf30c5794ae35f02c36f66c83023d4edc2a4952
Guilherme-Rodrigues-Almeida/Aulas-de-python
/Aula 4/desafio008.py
199
3.90625
4
print("") valor_em_metros = float(input("Digite o valor em metros: ")) print("") print(f"O valor em centímetros é: {valor_em_metros * 100} cm;\nO valor em milímetros: {valor_em_metros * 1000} mm")
4a2242b938ea214f345676bbe06075e51e0101aa
Guilherme-Rodrigues-Almeida/Aulas-de-python
/Exercicios/ex015.py
206
3.75
4
print("") dias= float(input("Quantos dias alugados? ")) km_rodados = float(input("Quantos Km rodados? ")) total_pagar = (dias * 60) + (km_rodados * 0.15) print(f"O total a pagar é de R${total_pagar :.2f}")
2da0d93a31b71e2cdc90f70866902f3c6782b6d9
Guilherme-Rodrigues-Almeida/Aulas-de-python
/Exercicios/ex013.py
234
3.765625
4
print("") salario = float(input("Qual é o salario do Funcionário? R$")) print("") novo_salario = salario + (salario * 0.15) print(f"Um funcionário que ganhava R${salario}, com 15% de aumento, passa a receber R${novo_salario :.2f}")
505728088081b4c58f080541fc3c609f97fe42ad
kryskaliska/KurcheuskayaLiza
/Homework/Kurchevskaya_Liza.py
1,796
3.5625
4
a = 'Не знаю, как там в Лондоне, я не была. Может, там собака — друг'\ ' человека. А у нас управдом — друг человека!' print(a) b = len(a) print('1. Посчитать количество символов. ' +'Количество символов: '+ str(b)) c =a[::-1] print('2. Развернуть строку. ' +'Результат переворачивания исходной строки: '+c) print('3. Сде...
9f40a22368c05ae5a826ebcacb7f8dd808968981
yusuke-hi-rei/python
/14. class/class001.py
182
3.5625
4
#! #! Class. #! class MyObj: message = "OK" # self is this pointer(near). def print(self): print(self.message) obj = MyObj() obj.message = "Hello Python!!" obj.print()
381480860df458c87e5cf101bb9259c71ffeca3f
yusuke-hi-rei/python
/23. pip(external_package)/03. pillow/imageProcessing3.py
339
3.578125
4
## Convert to monochrome. from PIL import Image #! Exception processing is performed assuming #! that the image file cannot be opened. try: img1 = Image.open("image.jpg", "r") #! L: grayscale. img2 = img1.convert("L") img2.save("image_saved3.jpg", "JPEG") print("saved...") except IOError as error...
dbb16049040fad3d91f0e93335abe5dd8bf39e50
yusuke-hi-rei/python
/19. standard_library/02. Random/Random.py
266
3.5625
4
# Import all elements in a module from random import * print(random()) print(randrange(10)) print(randrange(100, 200)) data = ["one", "two", "three", "four", "five"] shuffle(data) print(data) item = choice(data) print(item) res = sample(data, 3) print(res)
5be5f49334f1b4293cd6922e7fbcf31a0d59f1b1
yusuke-hi-rei/python
/14. class/class002.py
228
3.625
4
#! #! Class. #! class MyObj: # __init__ is constructor(near). def __init__(self, msg): self.message = msg # self is this pointer(near). def print(self): print(self.message) obj = MyObj("Hello!") obj.print()
4cda5b03d7ecc93c407eadae674d46db71e2aa46
yusuke-hi-rei/python
/06. list/003.py
142
3.703125
4
#! #! Get the list informations. #! a = [10, 30, 50, 70] b = a[1:3] print(b) c = len(a) print(c) d = min(a) print(d) e = max(a) print(e)
b2b1b4309998d0e1ae5c774188322423fc015df5
yusuke-hi-rei/python
/25. generator/generator001.py
292
3.640625
4
def getPrime(max): for i in range(2, max + 1): flg = True for j in range(2, (i//2) + 1): if i % j == 0: flg = False break if flg: yield i for n in getPrime(100): print(n, end=" ")
fe099d46c4b1261c3e6f518c067ee0664eda1a1f
yusuke-hi-rei/python
/02. method/002.py
169
3.65625
4
#! #! Variables and assignments. #! # Execute with F5. #! Note that assignment can be made even if the type is different. a = 100 b = a * 2 # This. a = "ABC" print(a)
81fbfe26b6ed1d155158aa502532570a801dff07
cclauss/forum_questions
/ui_flds_to_csv/solutionv2.py
2,272
3.71875
4
import ui from os.path import exists import csv _csv_filename = 'myoutputV3.csv' def calc_button_action(sender): ''' Here your calc button will call 3 functions. 1. do_calculations, so you calculate and put the values in your fields 2. collect_data, will collect all the data from your view and return it as a lis...
a6f8d0052b5251b31b984fd7cc22b92a93e5b533
flyingleaves/Code
/work8.py
1,398
3.640625
4
# coding=utf-8 #输入这个代码就可以让PY源文件里面有中文 db = {} def newuser(): prompt = '请输入您的昵称: ' while True: name = input(prompt) if name in db: prompt = '该昵称已被占用,请重新输入: ' continue else: pwd = input("请输入您的密码:") db[name] = pwd ...
289472b07f63ff7a0ece3203f6f023047c64547b
nkr4m/Python-DSA
/List/11. Factorial of Large numbers.py
163
3.6875
4
def fact(n): if(n == 0): return 1 return n * fact(n-1) a = int(input()) for i in range(a): n = int(input()) ans = fact(n) print(ans)
ece6af210fa0bc5026c5a457705056c978ab0d03
sriniketh28/Python-DSA
/DSA-Questions/postfix-to-infix.py
371
3.953125
4
OPERATORS = set(['+','-','/','*','(',')','%','^']) def postfix_to_infix(expression): stack = [] for ch in expression: if ch not in OPERATORS: stack.append(ch) else: val1 = stack.pop() val2 = stack.pop() stack.append("("+val2+ch+val1+")") return...