blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
bac616a2a50b93596d57a82a853148a1cc1999aa
gonchigor/ormedia
/ht3_1.py
671
4
4
""" Даны три числа. Вывести на экран “yes”, если среди них есть одинаковые, иначе вывести “ERROR” """ num1 = int(input("Введите первое число")) num2 = int(input("Введите второе число")) num3 = int(input("Введите третье число")) def equals(*args): for i in range(0, len(args) - 1): for j in range(i + 1, len...
c7803044ef6872fb8531bd32079ef3f13164c89f
prabinlamichhane70/python-assignment
/f-q14.py
276
4.21875
4
# Write a Python program to sort a list of dictionaries using Lambda. myDict = [{"name": "Ram", "age": 89},{'name': "hari", "age": 85},] print ("Original Dictionary is ", myDict) sortedDict = sorted(myDict, key = lambda x: x['age']) print ("Sorted Dictionary is", sortedDict)
0d69c1a42ae1fc686cc3e4f8ad89bab78250a1b7
prabinlamichhane70/python-assignment
/q4.py
327
4.03125
4
#Write a Python program to get a single string from two given strings, separated by a space and swap the first two characters of each string. #Sample String : 'abc', 'xyz' Expected Result : 'xyc abz' def mix_char(a, b): new_x = b[:2] + a[2:] new_y = a[:2] + b[2:] return new_x + ' ' + new_y print(mix_char('abc', ...
fd4084dac6557dd4c0568df5bc9cc4922ec0bf60
prabinlamichhane70/python-assignment
/f-q7.py
716
4.28125
4
# Write a Python function that accepts a string and calculate the number ofupper case letters and lower case letters. # Sample String : 'The quick Brow Fox' Expected Output : No. of Upper case characters : 3 , No. of Lower case Characters : 12 def string_upp_low(name): upper_count = 0 lower_count = 0 for ...
8d973749785f451f55f8d171763dd3699e73699f
prabinlamichhane70/python-assignment
/f-q16.py
358
4.34375
4
# Write a Python program to square and cube every number in a given list of integers using Lambda. myList = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] print("Original list:", myList) square_nums = list(map(lambda x: x ** 2, myList)) print("Square number from list", square_nums) cube_nums = list(map(lambda x: x ** 3, myList)) prin...
5862950bb5068ac493f132f2a05a528e96736935
prabinlamichhane70/python-assignment
/q34.py
159
3.75
4
# Write a Python script to merge two Python dictionaries. dict1 = {'a':10, 'b':20} dict2 = {'c':40, 'd':30} dict = dict1.copy() dict.update(dict2) print(dict)
dd7df0ca8d2be345f1fbceeb9a7508293a8063bc
tanneryould/datastrucutres_and_algorithms
/sorts/bubblesort.py
270
3.90625
4
def bubble_sort(arr): swaps = 0 sorted = False while not sorted: sorted = True for idx in range(len(arr) - 1): if arr[idx] > arr[idx + 1]: sorted = False arr[idx], arr[idx + 1] = arr[idx + 1], arr[idx] swaps += 1 return arr
5512436d71eeec98ee920ab1806c02047cfb87cf
aaronfox/Genetic-Algorithm-and-Niching-Variants
/main.py
2,961
4
4
import random import math # found all of this from https://hackernoon.com/genetic-algorithms-explained-a-python-implementation-sd4w374i # By Luiz Rosa def generate_population(size, x_boundaries):#, y_boundaries): lower_x_boundary, upper_x_boundary = x_boundaries population = [] for i in ran...
bb97ad40ef7836e80c2cd9d6349c714dfec10dcf
lecorref/room-25
/server/src/game.py
1,129
3.6875
4
""" This module will contain the game 'room 25' setup and run classes """ from enum import Enum from .board import Board class Mode(Enum): """Game modes""" suspicion = 1 solo = 2 team = 3 competition = 4 cooperation = 5 class Game(object): """Class that will run the game attributes: ...
f7dc2ca6540780021a3dc696a80c91af9840bb71
Rainmonth/PythonLearning
/demo/dec_demo.py
925
4.125
4
#!/usr/bin/env python # -*- coding: UTF-8 -*- # 作者: RandyZhang # 时间: 2017/8/23 # 字典定义,key必须为不可变对象 dict1 = {1: 'a', 2: 'b', 3: 'c'} print(dict1) dict2 = {'a': 1, 2: 'b', (1, 2, 3): [4, 5, 6]} print(dict2) # 修改字典的值 dict1[1] = 'abcd' print(dict1) dict2[(1, 2, 3)].append(7) # s 引用的是(1, 2, 3)这个key对应的value的地址 s = dict2[(1,...
93ecc71dff246101b9f6339e178f5b982c1f7ce0
edutomazini/courseraPython2
/semana6/elefantes.py
1,337
3.890625
4
def incomodam(n): if type(n) != type(1): return "" if n <= 0: return "" else: '''if n == 1: return "incomodam " else:''' return "incomodam " + incomodam(n-1) '''def elefantes(n): if type(n) != type(1): return "" if n < 0: return "...
da18dbcc89841bfcc167696a3fbf5a1551fc7368
edutomazini/courseraPython2
/semana4/buscasequencial.py
648
3.53125
4
def busca_seq(lista, elemento): for i in range(len(lista)): print(i) if lista[i] == elemento: return i return False def busca_binaria(lista, x): primeiro = 0 ultimo = len(lista)-1 while primeiro <= ultimo: meio = (primeiro+ultimo)//2 if lista[meio]==x: ...
e67f4f740f829636c277e22af51921cafbb7f114
yasi2010/GlobalAIHubPythonCourse
/python_practice/day5.py
990
3.515625
4
# -*- coding: utf-8 -*- """ Spyder Editor This is a temporary script file. """ class animals(): def __init__(self,age,color): self.age=age self.color=color def info_animals(self): print('my animal has age',self.age,'and color',self.color) class dogs(animals): ...
05675253e1021c312a4c565f26be4ee8eb0f73d1
sarschu/SemEval2016_Task4C
/src/data_statistics.py
2,730
3.5
4
#!/usr/bin/python # encoding: utf8 # -*- coding: utf-8 -*- #call python util.py corpus_data import string import sys from data_reader import CorpusReader from nltk.corpus import stopwords from nltk.probability import FreqDist #get insights into data def show_label_distribution(data): very_neg,neg,neu,pos,very_po...
60bf7b89c120035f0ad4424ecf5fe96b8169c3ed
Suganya108/guvi
/code-kata/Strings/Case_sensitively_equal_strings.py
246
4.09375
4
# Given 2 strings S1 and s2, check whether they are case senitively equal without using any predefined function(case sensitive). # If they are not same print 'no' s1,s2=input().split() if s1==s2: print('yes',end='') else: print('no',end='')
a71e0f047ac1c04d260987872548c2f76394f17b
Suganya108/guvi
/code-kata/Strings/Remove_extra_spaces.py
147
3.796875
4
# Given a sentence S take out the extra spaces.If no extra space is present print the same as output. s=input() print(" ".join(s.split()),end="")
13e50ba93b923ce97100892077786f5d1441b0a8
Suganya108/guvi
/code-kata/Basics/N_between_L_and_R.py
206
3.953125
4
# Given 3 numbers N , L and R. Print 'yes' if N is between L and R else print 'no'. n=int(input()) l, r = [int(x) for x in input().split()] if n>l and r>l: print("yes",end="") else: print("no",end="")
d4edd9c14ffd5cfb8242f52a898c7972460dd6ad
Suganya108/guvi
/code-kata/Companies/Possible_ways_to_shuffle_cards.py
139
3.625
4
# How many possible ways are to shuffle given number of playing cards?. n=int(input()) f=1 for i in range(1,n+1): f=f*i print(f,end="")
7f0f65e0be4ecf7f5f4db38485f71cb1a418b263
Suganya108/guvi
/code-kata/mathematics/Find_Engine_number.py
245
3.671875
4
# Engine no is sum of all the integers present on car’s Number plate. # Develop an algorithm which takes input as in form of string(Number plate) and gives back import math s=input() n = [int(i) for i in s if i.isdigit()] print(sum(n),end="")
f5f87a4aaeb01aff578305ff56514d6a4ed53acd
Suganya108/guvi
/looping/sum_of_all_natural_numbers_between_1_to_n.py
217
3.875
4
# Write a program to find sum of all natural numbers between 1 to n def na(n): sum=0 for i in range(1,n+1): sum=sum+i print("sum of n nos. is ",sum) return 0 n=int(input("Enter n : ")) na(n)
31e3568410d40488958db7ee035db15f22702444
Suganya108/guvi
/code-kata/Absolute-beginner/Area_of_equilateral_triangle.py
258
4.0625
4
# The area of an equilateral triangle is ¼(√3a2) where "a" represents a side of the triangle. You are provided with the side "a". Find the area of the equilateral triangle. import math a=float(input()) s=math.sqrt(3) print(round((1/4)*a*a*s,2),end="")
3e3775804d36ec3fb13038628f10c7201c5b157f
Suganya108/guvi
/code-kata/array/Merge_two_array_in_ascendind_and_descending_order.py
373
3.828125
4
# You are given with two arrays. Your task is to merge the array such that first array is in ascending order and second one in descending order. n, m=[int(x) for x in input().split()] a =[int(x) for x in input().split()] d =[int(x) for x in input().split()] a.sort() d.sort(reverse=True) s=a+d for i in range(len(s)): ...
7cd01906f57c1bcbcef26ffd2ebdb78aba0080ed
Suganya108/guvi
/looping/swap_first_and_last_digits_of_a_number.py
178
3.875
4
# Write a program to swap first and last digits of a number. def fun(n): c=str(n) c[0],c[-1]=c[-1],c[0] print(c) return 0 n=int(input("Enter no. : ")) fun(n)
1b60048462f876320c8b66f38add55aeabd5cadc
Suganya108/guvi
/code-kata/Absolute-beginner/Find_cube.py
90
4.09375
4
# You are given with a number "N", find its cube. num=int(input()) print(num**3,end="")
c1d0ea2431059d91d52b9e36e03edcf2192de5c2
Suganya108/guvi
/code-kata/mathematics/A*B%C.py
105
3.734375
4
# Given 3 numbers a,b,c print a*b mod c. a, b, c=[int(x) for x in input().split()] print(a*b%c,end="")
dc10394a3184462fbbd7bbd022198f63339ddb7d
Suganya108/guvi
/looping/calculator.py
671
4.03125
4
# Calculator num1=float(input("Enter the number1: ")) num2=float(input("Enter the number2: ")) ch=float(input("Enter the choice: ")) operator=round(ch) print("1.Add") print("2.Sub") print("3.Mul") print("4.Div") print("5.Exp") print(".") print(".") if(operator==1): print(num1,"+",num2,"=",num1+num2) elif(operator=...
5bc8e899f02dbf744fd6b99b69877a3e853963d5
Suganya108/guvi
/code-kata/Basics/Find_sum_is_odd_or_even.py
185
4.0625
4
# Given 2 numbers N and M add both the numbers and check whether the sum is odd or even. n, m=[int(x) for x in input().split()] sum=n+m if sum%2==0: print("even") else: print("odd")
62fc9a4d0c246882f7bccc5f62889994c27de9a3
Suganya108/guvi
/code-kata/mathematics/Find_next_immediate_greater_power_of_2.py
98
4.125
4
# Given a number N, find its next immediate greater power of 2. n=int(input()) print(n*2,end='')
0ddb4976adf8ebb2734be3285abeb85c9cca8dbb
Suganya108/guvi
/code-kata/Basics/Swap_adjacent_element.py
296
3.78125
4
# Given an array of N elements switch(swap) the element with the adjacent element and print the output. n=int(input()) l=[int(x) for x in input().split()][:n] for i in range(0,n-1,2): l[i], l[i+1] = l[i+1], l[i] for i in range(n): print(l[i],end="") if i<n-1: print(end=" ")
12b0e1f1722502f9aa796146125d687725a5a919
Suganya108/guvi
/code-kata/Strings/Reverse_all_except_1st_&_last.py
160
4.3125
4
# Given a string print reverse all words except the first and last words. s=input().split() n=len(s) for i in range(1,n-1): s[i]=s[i][::-1] print(*s,end='')
962ca1cc5943764fbc390a3a380037ffee5dd212
stmsy/deep_learning
/neural_networks/samples/activation.py
808
3.6875
4
#!/usr/bin/env python import numpy as np def identity(x: np.array) -> np.array: """Return the values of identity function.""" return x def step(x: np.array, thres: float = 0.0) -> np.array: """Return the values of stepu function following the threshold provided.""" y = x >= thres return y.astyp...
5d398c7703bf249544bc1af3df11df7390e60603
madan96/cython_tutorial
/array/numcheck.py
338
3.625
4
import numpy as np import random def check_rep(n): num = random.randint(1, n) print "Expected num is %d" % num d = np.zeros(n+1, dtype=np.int32) for i in range(n): d[i] = i+1 d[n] = num sum = 0 for i in range(n+1): sum += d[i] print sum sum_2 = n*(n+1)/2 print sum_2 num_check = sum - sum_2 print "We g...
69c09b671faa74610b97f12be20a9f156955b81c
coolstudio1678/Feature-based-Similarity-Search-for-Time-Series
/tensorFlow/ConvLayer.py~
2,931
3.546875
4
""" This file is to build a one layer CNN neural network Created by Zexi Chen(zchen22) Date: Oct 2, 2016 """ import numpy as np import tensorflow as tf #import matplotlib.pyplot as plt import math class ConvLayer(object): """ build a one layer of the CNN network """ def __init__( self, ...
927a4c8ceeb224c0962d0046ad42777f6042480f
farochocolom/Core-Data-Structures
/source/search.py
4,562
4.34375
4
#!python import math def linear_search(array, item): """return the first index of item in array or None if item is not found""" # implement linear_search_iterative and linear_search_recursive below, then # change this to call your implementation to verify it passes all tests return linear_search_recur...
501b32dd219ef83c57324aee90c2b63fcaf7e30a
farochocolom/Core-Data-Structures
/source/queue.py
4,398
4.5
4
#!python from doublylinkedlist import DoublyLinkedList # Implement LinkedQueue below, then change the assignment at the bottom # to use this Queue implementation to verify it passes all tests class LinkedQueue(object): def __init__(self, iterable=None): """Initialize this queue and enqueue the given ite...
f8eb59fa499be9a93ea571c871cad9de7ec8c077
LyleMi/Leetcode
/simplifyPath.py
384
3.5
4
class Solution(object): def simplifyPath(self, path): """ :type path: str :rtype: str """ stk = [] for s in path.split("/"): if s == "." or s == "": continue elif s != "..": stk.append(s) elif len(stk...
22120a9b029a1ca78d2d47c2c2bf5db1bc2d5917
scanasca10/Car-Trace-Tracking
/distance_analysis.py
456
3.5625
4
# -*- coding: utf-8 -*- """ Created on Fri Feb 23 19:32:13 2018 @author: canascasco """ def distance_analysis(path, non_zero_distance): same_distance = [] for element1 in non_zero_distance: for element2 in non_zero_distance: if path[element1]['Distance[Km]'].equals(path[elem...
039bd2e7bf2bd8c6d9a7b453b7e4ca6ae4e2d4a6
antiloquax/drawingpad
/drawingpad.py
6,534
4.125
4
# drawingpad.py # turtle drawing pad from turtle import * from tkinter import * def main(): pad = TurtlePad() pad.run() class TurtlePad(): def __init__(self): """Constructor that sets up some varaiables.""" # change these lines to alter the default behaviour of this program. self....
e40f5289691c2d26aa0effc18e3cd0d5fa06f620
jihunroh/ProjectEuler-Python
/ProjectEulerCommons/PalindromicNumbers.py
174
3.828125
4
def is_palindromic(n): n = str(n) length = len(n) for i in range(0, length): if not n[i] == n[length - i - 1]: return False return True
ffc56cf0367f4d06cf1052261fadd055c6332e40
jihunroh/ProjectEuler-Python
/ProjectEulerCommons/GeometricalNumbers.py
702
3.59375
4
from math import sqrt from itertools import count def generate_triangular(): for i in count(1): yield int(i* (i + 1) * 0.5) def generate_pentagonal(): for i in count(1): yield pentagonal(i) def pentagonal(i): return int(i* (3 * i - 1) * 0.5) def is_triangular(n): return ((-1 + sqrt(1 ...
c48734ed47b8f17c8570cc09195bb302c0ce23a8
pombredanne/styler
/python/tokenizer.py
14,254
3.546875
4
from core import * from javalang import tokenizer as javalang_tokenizer from token_utils import * def tokenize_with_white_space(file_content, relative=True, new_line_at_the_end_of_file=True): """ Tokenize the java source code :param file_content: the java source code :return: (whitespace, tokens) "...
b34daf521b853814fccca2cdf09e7a6a8d54fcb6
dansmetana/Random-Code
/words_per_line.py
599
3.859375
4
# -*- coding: utf-8 -*- """ Created on Wed Sep 23 16:28:20 2020 @author: dsmet """ #personal def words_per_line(filename): words = 0 count = 0 file = open(filename, 'r') for line in file: words += len(line.strip()) count += 1 average = words/count file.clo...
373533993f3f28b5b16b95a2c045f61f3b3d66f4
dansmetana/Random-Code
/calc_postage.py
736
4.03125
4
# -*- coding: utf-8 -*- """ Created on Wed Sep 23 13:03:42 2020 @author: dsmet """ postage_weight = float(input("Please enter postage weight (oz): ")) import math as math postage_weight = math.ceil(postage_weight) add_ounces= postage_weight -1 def calc_postage(postage_weight): if postage_weight<...
daf61e31d0359d70de2f6144d1631338e28ad5c5
zenith0/pytutorial
/PythagoreanTripleChecker/src/program.py
1,507
4.09375
4
''' Created on 25.02.2014 @author: stefan ''' import math def isPythagorean (a, b, c): if ((a >= b) and (a >= c)): firstSide = b; secondSide = c; hypothenuse = a; elif ((b >= a) and (b >= c)): firstSide = a; secondSide = c; hypothenuse = b; elif ((c >= a) and...
5b97d997be0b0dc9d9de96d94d9163f09896ec40
manhitv/codesignal
/Arcade/Intro/EdgeOfTheOcean.py
4,371
4.28125
4
''' Given an array of integers, find the pair of adjacent elements that has the largest product and return that product. *Example: For inputArray = [3, 6, -2, -5, 7, 3], the output should be adjacentElementsProduct(inputArray) = 21. 7 and 3 produce the largest product. ''' def adjacentElementsProduct(inputArray): a...
c46d0074cbaf4a973dbebfef64baecc29ae1d847
manhitv/codesignal
/Arcade/Python/ShowingClass.py
2,135
3.828125
4
''' Implement the missing code, denoted by ellipses. You may not modify the pre-existing code. You've launched your brand new web application not long ago, and while in beta it got beta satisfied visitors. Encouraged by such success, you decided to go ahead and push the very first stable version live. You know that eac...
4c1d855a90aa018f0e0efd88ab731418c9bff616
manhitv/codesignal
/CompanyChallenges/Asana.py
5,246
3.984375
4
''' You have some tasks in your Asana account. For each ith of them you know its deadlinesi, which is the last day by which it should be completed. As you can see in your calendar, today's date is day. Asana labels each task in accordance with its due date: If the task is due today or it's already overdue, it is labele...
e28b2a1749b036b94afdfc497ba02b1a014a0e72
manhitv/codesignal
/Arcade/Python/MeetPython.py
5,675
4.53125
5
''' Implement the missing code, denoted by ellipses. You may not modify the pre-existing code. Implement a function that, given an integer n, uses a specific method on it and returns the number of bits in its binary representation. Note: in this task and most of the following tasks you will be given a code snippet with...
8ac15baf48ff7eb223525d1ae696ea7611690e98
manhitv/codesignal
/Arcade/Python/FumblingInFunctional.py
4,622
4.3125
4
''' Implement the missing code, denoted by ellipses. You may not modify the pre-existing code. A grand Team Chess Tournament will be held at your University. Two teams, smarties and cleveries, will clash to determine whose chess skills are better. The teams have the same number of members, and the ith member of smartie...
8417b11a1b3c17b6462cd0bd45d4539d6222f5b5
manhitv/codesignal
/Arcade/Intro/EruptionOfLight.py
4,807
4.4375
4
''' A string is said to be beautiful if each letter of the alphabet appears at most as many times as than the previous letter; ie: b occurs no more times than a; c occurs no more times than b; etc. Given a string, check whether it is beautiful. *Example: For inputString = "bbbaacdafe", the output should be isBeautifulS...
f0944c9bc2986c7469517e02ade6804a1e491246
Weitao1378116505/bowen1
/python/python/day.py
15,357
3.921875
4
#!/usr/bin/python #-*- coding:utf-8 -*- #print("hello",123,1234232) #a=input('请输入密码:') #print(a) #a=1 #b=2 #print(a,b) #a,b,c=1,2,4 #print(a,b+3) #a=123.12 #c=a+b #print(c,type(c)) #a='qwesaasdwqe' #print(a[3::6 ]) #='aweqerweft' #b=a.replace('a','') #=a.split('we') #='='.join(a) #rint(type(c),c) #b='ad{a1}adaw{b2}'.fo...
4ccfdbc02a12c8c2b0f429e5b465c664d34dce1d
pinkmagicdev/SwagWorld-2
/commands/tweet.py
1,127
3.578125
4
import twitter from evennia import Command # here you insert your unique App tokens # from the Twitter dev site TWITTER_API = twitter.Api(consumer_key='api_key', consumer_secret='api_secret', access_token_key='access_token_key', access_token...
073352a94f8c5469a2f16134f53de22c08501cfa
noahfl/github-basics
/gravity.py
3,221
3.984375
4
# create your solar system animation here! import turtle import math class SolarSystem: def __init__(self, height, width): self.sun = None self.planets = [] self.window = turtle.Screen() self.window.tracer(0) self.window.setup(900, 900) self.window.bgcolor("black")...
77c4b2d22a510402fd8256553735e813454b45af
ivan-didyk/seti
/num.py
1,009
3.640625
4
import string __digs = string.digits + string.ascii_letters def basen(x : int, base : int, upprcase=False): """ Переводим `x` из десятичной в какую-то ещё :param upprcase: В каком регистры буквы - `C0FFE` или `c0ffe` """ if base <= 0: raise AttributeError('Основание системы счисления должна быть больше н...
348c06d48592135994ab01bbe0c9ec7df2d5297f
M-Smith-contact/reticulated.python
/list2.py
346
3.671875
4
mylist1 = [10, 2.3, 34, 4] mylist2 = ['dog', 'cat', 'rat', "pig", 'gif', 'monkey', "cat", 'dog', "dog"] mylist3 = mylist1 + mylist2 mylist4 = mylist2 * 2 mylist1.sort() mylist2.sort() mylist2.remove('dog') c = mylist2.count('dog') print( mylist1 ) print( mylist2 ) print( c ) mylist1.reverse() prin...
aa4bf9a9d8aec8780cc25d452fd4fe1cb1a18930
M-Smith-contact/reticulated.python
/for-loop2.py
95
3.65625
4
for i in range(5): mystr = input() num = int( mystr) print (num)
2a11551801d82ea7524df6dd75f6fcb3f6c4240d
M-Smith-contact/reticulated.python
/gui-msgbox.py
220
3.53125
4
import tkinter top = tkinter.Tk() def hello(): tkinter.messagebox.showinfo("Test", "This is to test message box!") B1 = tkinter.Button(top, text = "Say Hello", command = hello) B1.pack() top.mainloop()
ea8fd3aba6bd17ec6d6a96ee0527517b5c737f95
duanebailey/CurlingNumberSequences
/sl.py
1,965
3.75
4
"""Will generate a string of S and L using the line intercept method. First arameter is the number of digits to generate - default 100. Second parameter is offset on the y axis. Third parameter is the slope of the line - default ~.6898 (c) Adly Templeton 2015""" import sys max = 100 if len(sys.argv) > 1: if sys...
887cb1369df3e3b4adfbfbdb31be18c8bc1bcf16
hanyonghee9264/druwa
/python/problem01.py
548
4.125
4
""" 매개변수로 문자열을 받고, 해당 문자열이 red면 apple을, yellow면 banana를, green이면 melon을, 어떤 경우도 아닐 경우 I don't know를 리턴하는 함수를 정의하고, 사용하여 result변수에 결과를 할당하고 print해본다. """ def fruits(colors): if colors == 'red': result = 'apple' elif colors == 'yellow': result = 'banana' elif colors == 'green': result...
8d8d1946ae87f02a580880932e8ec5f820729ade
xiaweizi/PythonTest
/ 程序/函数/function_sorted.py
170
3.65625
4
# -*- coding: utf-8 -*- students = [('Bob', 75), ('Adam', 92), ('Bart', 66), ('Lisa', 88)] def by_name(t): return t[1] print(sorted(students, key=lambda t: t[1]))
8a7ada3d55ea530f4efaabdfd731664918b65baa
xiaweizi/PythonTest
/ 程序/基础/ListAndTuple.py
543
3.953125
4
#1 /usr/bin/env python3 # -*- coding: utf-8 -*- datas = ['a', 'b', 'c', 'd'] print(datas) print(len(datas)) print(datas[1]) print(datas[-1]) print(datas[-2]) datas.append('e') print(datas) datas.insert(1, 'a') print(datas) datas.pop() print(datas) datas.pop(1) print(datas) datas1 = [1, 2, 3] datas.append(datas1...
2030dd0ed72de2696af1d73120668876f8d39948
xiaweizi/PythonTest
/ 程序/基础/Iteration.py
290
3.515625
4
for value in range(1, 100): if value % 7 == 0: print(value) L = ['a', 'b', 'c', 'd'] for index,name in enumerate(L): print index, '-', name B = {'a':1, 'b':2, 'c':3} for value in B.itervalues(): print(value) C = B.items() C.append(1) print(C) E= [(1,2),2,3,4] E.append(5) print(E)
c3004d89382f3a2b138670b00461d4662262709e
willperring/dm-markov
/markov/common.py
349
3.75
4
import re def inputd( prompt, default ): result = input( "{0} (default='{1}'): ".format(prompt, default)) result = default if (result == "") else result if str(result).upper() == "Y": return True if str(result).upper() == "N": return False return result def normalise( string ): return re.sub(r'[^A-Za-z0-...
670209105d7296caf8b097bd95c99fc058ffc040
FilipeADF/WageMannager
/WageMannagerSystem/SalarioLiquido.py
7,430
3.6875
4
def faixa1(): desconto = (0.075 * 1100.0) return desconto def faixa2(): desconto = (0.09 * 1103.60) return desconto def faixa3(): desconto = (0.12 * 1101.80) return desconto def calcularsalarioliquido(salarioBruto): descontoINSS = 0.0 descontoIRRF = 0.0 if(salarioBrut...
506319fbec596ab6321a1a107ed9dee2633c23cf
grrtvnlw/python-102
/bonus2.py
452
4.09375
4
# number guessing game # import random module for randint func from random import randint # variables for loop counter, guess, and random number counter = 0 rand_num = randint(0, 10) # logic while counter < 5: guess = int(input("Guess a number between 0 and 10: ")) if guess == rand_num: print("You wo...
e24b351a73f14b75dbd8cfd864244a83d4c359ab
japawka/Bakery
/S01 variables/01 zmienne, id, is .py
757
3.5625
4
a = "hello PyCharm" b = a print(a, b) print(a == b) print(a is b) print(id(a), id(b)) print() b = a + "!!" print(a, b) print(a == b) print(a is b) print(id(a), id(b)) print() b = b[:-2] print(a, b) print(a == b) print(a is b) print(id(a), id(b)) print() b = a print(a, b) print(a == b) print(a is b) print(id(a), id(b)...
6c6e2d9e0b65534f067523c26033837189961025
japawka/Bakery
/S03 Klasy/28 dodawanie i ukrywanie aybutów klasy.py
1,929
3.765625
4
class Car: number_of_cars = 0 list_of_cars = [] def __init__(self, brand, model, isAirBagOk, isPaintingOk, isMechanicOk, isOnSale): self.brand = brand self.model = model self.isAirBagOk = isAirBagOk self.isPaintingOk = isPaintingOk self.isMechanicOk = isMechanicOk ...
3850313e9531fb82056ad6afa84ee41a30f68064
japawka/Bakery
/S01 variables/08 enumerat and, zip.py
1,272
3.796875
4
workDays = [19, 20, 21, 20, 22, 21] print(workDays) workDict = {a: b for a, b in zip(range(1, len(workDays) + 1), workDays)} print(workDict) enumeratedWorkDays = list(enumerate(workDays)) # bez utworzenia listy zwróci tylko 'enumerate object', # a tsk listę krotek print(enumeratedWorkDays) for a, b in enumeratedWork...
8bc0893bfd914a58c7be59b28f46b8acc691d647
japawka/Bakery
/S03 Klasy/34 Klsa jako dekorator funkcji.py
1,146
3.84375
4
import random class MemoryClass: list_of_already_selected_items = [] def __init__(self, func): #print("This is init of MemoryClass") self.func = func def __call__(self, list): #print("This is call of MemoryClass instance") items_not_selected = [i for i in list if i not in ...
e8df57c8e2ea1f0b9a907421b772af67672f041f
japawka/Bakery
/S03 Klasy/27 cake LAB.py
1,740
3.515625
4
class Cake: known_types = ['cake', 'muffin', 'meringue', 'biscuit', 'eclair', 'christmas', 'pretzel','other'] bakery_offer = [] def __init__(self, name, kind, taste, additives, filling): self.name = name if kind in self.known_types: self.kind = kind else: self...
b82fd0ed1ede6a0c7a6c2825ba6f1f6d5428baca
BholaNathSarkar/python-test-intern
/8.py
752
3.65625
4
from itertools import permutations # import itertools def permutation_subarray(a,k): # print(k) list = a.split() sum=0 p=[] n=len(list) pp=k for i in range(0,len(list)): if(i<pp): p.append(list[i]) else: p1=permutations(p) p=...
267e2df3efb8707959f75b3ccb1709c5da0eca9e
kbobs/learning-python
/squares.py
428
3.953125
4
squares = [] for value in range(1,11): square = value**2 squares.append(square) print(squares) ("\n") squares = [] for value in range(1,11): squares.append(value**2) print(squares) digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0] print("Digits = " + str(digits)) print("Min: " + str(min(digits)) + " Max: " + str(max(digi...
151de5574184d8b5c2a117bf25594f70d2519f48
kbobs/learning-python
/even_or_odd.py
314
4.1875
4
number = input("Enter a number and I'll tell you if it is even or odd: ") number = int(number) if number % 2 == 0: print("\nThe number " + str(number) + " is even") else: print("\nThe number " + str(number) + " is odd") current_number = 1 while current_number <= 5: print(current_number) current_number += 1
c1a0459aeb224b6d266afad1c74b500ea67d7fd9
Brednas/char_morph_nmt
/Network/dgm4nlp/dgm4nlp/blocks.py
10,017
3.796875
4
""" Here I have lots of code for typical building blocks. - I avoid writing a layer class whenever a Lambda layer will do. - This code is taylored for batches of sequences. :Authors: - Wilker Aziz """ from keras import layers from keras import backend as K class Generator: def __init__(self, shorter_batch='tr...
eaa54b551535a92d88f778cb5b8ccfa265bb127d
mmaina48/ProjectManagement
/basictask3.py
213
4
4
lst = [] num = int(input('How many numbers: ')) for n in range(num): numbers = int(input('Enter number ')) lst.append(numbers) print(lst) print(len(lst)) print(lst[::len(lst)-1]) # use a method
96437f24de0ce832ad2355b500616dc0364a2722
mmaina48/ProjectManagement
/tapples.py
164
4.125
4
# a tuple is a list but u canot change it daysoftheweek=("monday","tueday","wed","thue","frid","sat","sun") # daysoftheweek.index[] print(daysoftheweek.index[-1])
f3727cc229fa75ebcfc27a1194ef871e3b737040
dawidl022/hyperskill-numeric-matrix-processor
/determinant.py
2,177
3.578125
4
from copy import deepcopy #debugging examples matrix0 = [[2, 0, 4], [1, 2, 4], [4, 4, 2]] matrix1 = [[1, 7, 7], [6, 6, 4], [4, 2, 1]] matrix3 = [[1, 2, 3, 4, 5], [4, 5, 6, 4, 3], [0, 0, 0, 1, 5], [1, 3, 9, 8, 7], [5, 8, 4, 7, 11]] matrix2 = [[45, 2, 11, 5], [0, 0, 0, -4], [7, -2, 3, 2], [-4, 1, 0, 8]] matrices = ...
e8243c93036c3f3e09dd587ae7b8465d75ad04c1
gustavoaureliano/DS-lista-de-exercicios-de-revisao-2021-02-12
/ex1-03.py
143
3.65625
4
prim = int(input('Primeiro termo: ')) q = int(input('Razão da P.G.: ')) n = int(input('Número de ordem: ')) an = prim * q ** (n-1) print(an)
77857964f781a3d3d9d402a74c6310399d3fa08a
gustavoaureliano/DS-lista-de-exercicios-de-revisao-2021-02-12
/ex2-09.py
115
3.765625
4
cont = 0 for n in range(20): num = float(input('Número: ')) if num % 7 == 0: cont += 1 print(cont)
f9f8b97c2770c1e644c1c4fa359978cd52b9e2ec
DevasenaInupakutika/HPC_MidTerm_Project_Numerical_Methods
/Gauss/matrix.py
377
3.875
4
#This file consists of the matrix functions that returns matrix row, column, height, width and printing the matrix def column(m, c): return [m[i][c] for i in range(len(m))] def row(m, r): return m[r][:] def height(m): return len(m) def width(m): return len(m[0]) def print_matrix(m): for i...
fc8c14abc2770304dee05f39548340bee33d43f3
ryangchung2/ICS3U-Unit3-07-Python
/age.py
691
4.25
4
#!/usr/bin/env python3 # Created by Ryan Chung Kam Chung # Created in December 2020 # Age range def main(): # This function checks if the user is in the proper age range print("Grandma: I will only let you date my grandchild" "if you are between the age of 25 and 40!") # Input age_string ...
4b6ecf7a75a586d5969f39a0debc1a1bf5e3f5f8
davitosadze/Quiz3
/main.py
1,713
3.609375
4
import requests import sqlite3 import json from sqlite3 import Error response = requests.get("https://jsonplaceholder.typicode.com/posts") def attributes(): print(response.status_code) #STATUS OF RESPONSE E.G. (200OK, 404NOT FOUND, 405 METHOD NOT ALLOWED print(response.headers) #RETURNS RESPONSE HEADERS ...
2edbf2cf5f6f962cc35061aaacf2c2c4742ecdc2
ShaikhShakeebAhmed/DataStructures
/H_HashTableGoogleQuestion.py
615
3.71875
4
#Given a array find the first repeted element #Given an array = [1,2,3,2,4,5,6,7,8,9,0] it should return 2 inputArray = [1,2,3,2,4,5,6,7,8,9,0] def returnFirstMatch(inputarr): count = -1 inputarr.sort(reverse = True) checking = dict() print(inputarr) #>> range([start], stop[, step]) for i in range(len(inpu...
6eba3b281076b16aaf080615a2ab19ebdaa6d4e4
Ricoistmeinname/py4e
/c1_c2/ex_08_01_2.py
636
4.03125
4
# Method 2 - The Double Split Pattern with guardian while True: fname = input("Enter file name: ") try: fhand = open(fname) break except: print("The following file does not exists:",fname) continue for line in fhand: line = line.rstrip() # Guardian - Method 1 # if lin...
4438df08b8668046bd226ee879bad5472c375e80
Ricoistmeinname/py4e
/c1_c2/ex_07_02.py
860
3.984375
4
#Excercise 7.2 - Count these lines and extract the floating point values from each of the lines # and compute the average of those values and produce an output as shown below # Do not use the sum() function or a variable named sum in your solution # Use the file name mbox-short.txt as the file name fname = input("Ente...
f7f844315e111a5d2e5ed57b04b8b5e5cfed7ade
Ricoistmeinname/py4e
/c1_c2/ex_03_01.py
483
4.28125
4
#Exercise 3.1 - a program to prompt the user for hours and rate per hour using input to compute gross pay hrs = input("Enter Hours:") rate = input("Enter Rate:") h = float(hrs) r = float(rate) pay = -1 if h <= 40: pay = h * r print("Pay:",pay) else: # pay = r * 40 + (h - 40) * 1.5 * r # Method 1 reg...
893e9ab6ddf3c642c9571d967d454d0ecece2120
mwaniki9322/Password-Locker
/credentials.py
1,758
3.890625
4
class Credentials: ''' a class generates a new instance credentials ''' credentials_list=[] def __init__(self,platform,email,password): self.platform=platform self.password=password self.email=email def save_credentials(self): ''' save_credentials meth...
69f6d7e601f251dde90e79c5538fdb5981777dca
guobinhit/myleetcode
/codes/python/leetcodes/src/main/python/com/hit/basmath/interview/top_interview_questions/easy_collection/dynamic_programming/_53.py
827
3.96875
4
""" 53. Maximum Subarray Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example: Input: [-2,1,-3,4,-1,2,1,-5,4], Output: 6 Explanation: [4,-1,2,1] has the largest sum = 6. Follow up: If you have figured out the O(n) solution, ...
b546d6efbaf2c5e690420784adf863c3f85b0adc
japfohl/cs325-final-project
/joe/python/point.py
308
3.71875
4
import math class Point: def __init__(self, id_num, x, y): self.id_num = id_num self.x = x self.y = y self.visited = False def dist_to(self, point): x_dist = self.x - point.x y_dist = self.y - point.y return math.sqrt(x_dist**2 + y_dist**2)
75f5d1e89861cbbc5bc0c93546d35601a00f80e7
jackom2726/comp
/asst/1/sortcat.py
439
4.03125
4
import string def sortcat(num, *strings): """sorts list of strings from longest to shortest""" sorted_args = sorted(strings, key=lambda arg: len(arg), reverse=True) """concatenates the first num longest strings, or all of them if num == -1""" final_str = "" if num == -1: for index in xrange(len(strings)): f...
da148793f8dff1e8cc510ccb3096f4564ca7a069
BlackBoneStorm/python
/first/third.py
189
3.71875
4
quantityOranges = int(input("How many oranges? ")) priceOrange = float(input("What the price of each? ")) sumOranges = quantityOranges * priceOrange print("Please pay $%.2f" % sumOranges)
b07c8dd63fdf7fc4f9343b2929d88178b0d2f715
BlackBoneStorm/python
/blackjack/blackjack.py
668
3.765625
4
import random deck = [6, 7, 8, 9, 10, 2, 3, 4, 11] * 4 random.shuffle(deck) print("Let's play Blackjack!") count = 0 while True: choice = input("Do you need a card? y/n\n") if choice == 'y': current = deck.pop() print("You took this card: %d" %current) count += current if cou...
9c434a43a86c8ea563753d9adce24fef145c2abe
BlackBoneStorm/python
/study/6_if.py
287
3.828125
4
a = 2 if a == 3: print("hey 2") if a > 4: print("hey 3") else: print("looser") q = 10 w = True if q < 10 else False a = float(input("Введи число: ")) if a < 0: print("Neg") elif a == 0: print("Zero") elif a == 1: print("One") else: print("Pos")
a0981e47f8868007dc89fd64fadbb3ebcfd3de8b
christiaaaan/dingdang-robot-master
/skills/car.py
3,006
3.703125
4
#!/usr/bin/python # coding=utf-8 import RPi.GPIO as GPIO class Info: @staticmethod def p(message): print 'Info: ' + message # Wheel封装的单个车轮的所有可能操作 class Wheel: pins = {'a': [13, 15], 'b': [16, 18], 'c': [19, 21], 'd': [22, 24]} def __init__(self, name): self.name = name ...
e0c578e9ff7bcb8acdc86d9d03914b2b2f8edd14
ChrisNahimanan/PythonCalc
/Caculator.py
911
4.03125
4
print("Loading...") Process = 0 while Process <= int(100): print(Process, "% Complete.") Process += int(10) print("Process Finished.") print(" ") print("Opening... Calculator 2.0") print("1. Add") print("2. Subtract") print("3. Multiply") print("4. Divide") def add(x, y): ...
66c4638d738ea154caf01629122b9b1d147eb0f0
morshedmasud/100_days_with_python
/Day-3/itertools/combi_2.py
522
3.59375
4
# Go to the link to know about the problem # https://www.hackerrank.com/challenges/iterables-and-iterators/problem from itertools import combinations n = int(input()) s = input().split() k = int(input()) num = 0 den = 0 for i in combinations(s, k): den += 1 num += 'a' in i print(float(num/den)) # from ite...
efe233c7b70dfd9320dcdffe351d52dd5d454b4f
morshedmasud/100_days_with_python
/Day-7/inheritance.py
476
4.15625
4
class Vehicle: """Base class for all vehicle""" def __init__(self, name, manufacturer, color): self.name = name self.manufacturer = manufacturer self.color = color class Car(Vehicle): def __init__(self, name, manufacturer, color, year): super().__init__(name, manufacturer, c...
21bf9e8d1d482d4fc0ed0ca92c5e20aabae1de7b
cdb342/Machine-Learning-Exercises-with-Python
/code/SoftmaxRegression/SoftmaxRegression_GD.py
6,251
3.5
4
import numpy as np import matplotlib.pyplot as plt from matplotlib import animation """ 导入数据 train_X:训练集特征集合 train_y:训练集标签集合 test_X:测试集特征集合 test_y:测试集标签集合 """ train_X=np.loadtxt("./dataset/Iris/train/x.txt") train_y=np.loadtxt("./dataset/Iris/train/y.txt") test_X=np.loadtxt("./dataset/Iris/test/x.txt") test_y=np.l...
c5f6c1050c8666da09fc62ce341984ce0b6bc8b1
ArsKar2001/TestProject
/task4-28.py
815
3.984375
4
import math while bool: x = int(input('Введите координату на оси OX: ')) y = int(input('Введите координату на оси OY: ')) def area_circle(r: float): return math.pi * math.pow(r, 2) def vector_length(x0: int, y0: int): return math.sqrt(math.pow(x0, 2) + math.pow(y0, 2)) min_cir...
7dabae77c36cf1ca9d9e47f7bcf396839dcce14d
therealfantoma/Black-Hat-Python-for-Pentesters
/car_shop.py
1,388
3.890625
4
class CarShop: """Models a car salesroom. Creates and shows the car inventory, calculates profit, and removes cars from inventory when sold. """ def __init__(self, name): self.name = name self.inventory = {} self.shop_markup = 1.5 self.sale_profit = 0 self.sel_ca...