blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
525d6a69c5a2ea74e78e43af87a899e39d598f57
lborg019/py-netcentric
/hw2/http-server/HTTPServer.py
5,190
3.828125
4
########################################################################## """ HTTPServer.py HTTPServer in Python [STUDENTS FILL IN THE ITEMS BELOW] STUDENT: Lukas Borges COURSE NAME: [CNT4713] Netcentric Computing SEMESTER: Spring 2016 ...
9b8271faadd33f72f8123ed7dcf2a1d4388507a3
TheAragont97/Python
/Actividades/Relacion 2/ejercicio 9/ejercicio_9.py
544
4.15625
4
diccionario={} carac=input("Ingrese el dato nuevo para el diccionario: ") dato=input("Ingrese el valor del dato: ") diccionario[carac]=dato print(diccionario) op=input("¿Quiere seguir añadiendo datos? S/N :").upper() if op=="S" or op=="N": while op=="S": carac=input("Ingrese el dato nuevo para el diccionari...
ded07d00c939c506517453cd9dd0d663ea836a01
robintecho/Python
/Co1/14nmultiple.py
52
3.6875
4
n = int(input('Enter n: ')) s=n+n*n+n*n*n print(s)
c9a6308bb58449d081812657c641f8285cd625b2
hnmahamud/Unix-Problem-Solving
/Python/Code/5/main.py
1,241
4
4
# Dictionary of 10 elements std_dic = { 'sayeed': 75, 'sakib': 70, 'shaon': 90, 'pranto': 38, 'hasib': 79, 'anik': 80, 'evan': 35, 'rafi': 82, 'pial': 83, 'masud': 40 } # Extract the value of key contains from std_dic and append to num_list # Then sort the num_list with Ascendi...
f16bbb16a231b27b0b793f10f33cffed079928e3
mgokani/RH
/test_printpairs.py
678
3.609375
4
"""@author: Mirav Gokani Unit tests for print_pairs.py """ import print_pairs as ps import unittest class TestPairs(unittest.TestCase): def test_negativenumbers(self): """Test a combination of positive and negative numbers""" result = ps.pairs([-4, 4, 0, -2, 0], 0) self.assertEqual(result[...
f009cfa22ca6d4034c7bdb0f15dda19e66480b96
sheilsarda/CV_Fundamentals
/spring20_Solutions/hw2-sols/Part_2/line_intersection.py
657
4
4
import numpy as np def line_intersection(l1, l2): """ Compute the intersection of two line Input: l1: array of size (3,) representing a line in homogenous coordinate l2: array of size (3,) representing another line in homogenous coordinate Returns: pt: array of size...
eed2adcdf014261a4888ea6041dfa4ebb248ae77
Alicho220/python_practice
/python practice/set.py
453
3.96875
4
# collection with no duplicate.. # if you have a list and want no duplicate of element just convert to a set # we cannot index a set numbers = [1,1,1, 2,2,2,4,5,6,7,6] numbers1 = set(numbers) numbers2 = {1,4,10,50} print(numbers1) # you can add, remove # numbers1.add() # numbers1.remove() # len(numbers1) # union of...
e8bc86da72d39b2f73eb6971ebfe5899553a1c37
tmtmaj/PYTHON
/SECTION_03/set2.py
288
4.125
4
s1 = set([1,2,3]) s2 = {1, 2, 3} print(s1) # {1, 2, 3} print(s2) # {1, 2, 3} # 특징 1. 중복을 허용하지 않고, 순서를 유지 하지 않는다. s1 = set('Hello') print(s1) # 특징 2. 배열 연산자를 사용해서 요소 접근 안됨 print(s1[0])
fd9e589c78389a84e8c7e32a3cf446d80854fb67
tmngomez/DBN-Campus-Workshops-codebase-
/Lambda/calculator_test.py
2,747
3.90625
4
import calculator import unittest from unittest.mock import patch from io import StringIO import sys class TestCalculator(unittest.TestCase): @patch("sys.stdin", StringIO("not numbers\nsome 1 or 2 numbers\n1,2,3,4,5,6\n2,2\n")) def test_get_input(self): """ this checks that if if any ite...
9679d2046e09fd33ea53daa11879b85b24cbca4b
ralic/aws_hack_collection
/101-AWS-S3-Hacks/searchabucket_casesensitive.py
429
3.59375
4
#!/usr/bin/python """ - Author : Nag m - Hack : Search for a bucket with bucket name which is case sensitive - Info : Search for a bucket named * 101-S3-aws """ import boto from boto.s3.connection import OrdinaryCallingFormat def searchabucket(): bucket = conn.get_bucket("101-S3-aws") print bucket if _...
ed5d20adf680bcacc1ecddc6886d87edb22d369e
WSU-RAS/ras2
/src/adl_error_detection/src/adl/robot_sensor_translation/convert_points.py
2,262
3.578125
4
#!/usr/bin/env python import math from typing import Tuple, List a_default = 0.999198 b_default = -0.052252 c_default = 1.056307 d_default = 0.080343 e_default = 1.005433 f_default = 1.052456 def convert_point(point, a=a_default, b=b_default, c=c_default, d=d_default, e=e_default, f=f_default): ...
a0fff79398db5b6fe912bb2f692b4141b8dd3f47
carlosalbferreira/curso-Udemy-Python-iniciante-ao-avancado
/Salario15%aumento.py
154
3.703125
4
s =float(input('Digite o seu salario: R$')) s1 = s*15/100 print('O salário com 15% de aumento será de R${}'.format(s+s1)) # Salário com aumento de 15%
b5a3d6a0da987102df1b77bf1fe5483b3640e1b3
ginajoerger/Data-Structures
/Assignment 3 - Recursion/Question6_tree.py
837
4.46875
4
import turtle def draw_tree(branchLen,t): ''' @branchLen: Length of this branch. Should reduce every recursion. Starting length is 100. @t: Instance of turtle module. We can call turtle functions on this parameter. Figure out the tree pattern, and display the recursion tree. You may have to play/t...
6c0ddd37baccbc7255632fe58f0ff72e92d94bf3
xylover/BS-
/BS代码示例-8.py
740
4.03125
4
html = """ <html><head><title>The Dormouse's story</title></head> <body> <p class="story"> Once upon a time there were three little sisters; and their names were <a href="http://example.com/elsie" class="sister" id="link1">Elsie</a>, <a href="http://example.com/lacie" class="sister" id="link2">Lacie</a> and <a href...
ead8e665a225ac64b916cc2ea3e0743813289dcb
tberhanu/elts-of-coding
/BST/closest_entries_in_3_sorted_arrays.py
1,405
3.828125
4
def find_closest_entries_in_three_sorted_arrays(sorted_arrays): """ Tess Strategy: Time: O(N) w/r N is the maximum array length of the three arrays Page 211 uses bintrees.RBTree(), check it out. """ a, b, c = sorted_arrays[0], sorted_arrays[1], sorted_arrays[2] smallest_gap = float("inf...
b318f7a181f487bf6abbea2bfeff5a9477952100
HimaniSoni/CtCI
/8.3 Magic Index.py
595
3.609375
4
def magicIndex(arr): first = 0 last = len(arr)-1 while first <= last: mid = (first+last)//2 if arr[mid] == mid: return mid elif arr[mid] > mid: last = mid-1 else: first = mid+1 return False print(magicIndex([1, 2, 2, 3, 6, 9, 15, 21])...
f9d25b58defcfd01ef54cfa8687f1ff3d72ad1a1
aaveter/curs_2016_b
/7/gens.py
676
3.8125
4
# Генераторы lst = range(1000000) # создает список в python 2 lst = list(range(1000000)) # создадим список в python 3 lst[100] = 'hi!' gen = range(1000000) # создает генератор в python 3 #lst = [0, 1, 2 ...., 999999] #gen[100] = 'hi' for a in gen: print( a ) # - не создают массив в памяти, а вычисляют н...
e748645915206c4067d83d0c749133b46a4c7968
jxie0755/Learning_Python
/LeetCode/LC238_product_of_array_except_self.py
2,489
3.515625
4
# LC238 Product of Array Except Self # Medium # Given an array nums of n integers where n > 1, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i]. # Note: Please solve it without division and in O(n). # Follow up: # Could you solve it with constant space c...
eb68d005b874156194a759e152563ec368dbf35e
RawandKurdy/snippets
/22_hashcode_pizzza/pizzza.py
1,948
3.8125
4
import os # More Pizza # Google Hash Code 2020 # Practice Problem # In Python def fileOperation(fileName, flag): path, op = "", "" if flag == "a": path = f"./output/{fileName}.out" op = "Writing To" elif flag == "r": path = f"./input/{fileName}.in" op = "Reading From" ...
10cd9181b7bdbb9c5e898401099350e7a319ec19
ShukurDev/Algorithms
/python_algorithms/#1 - Task/max.py
281
3.734375
4
a,b,c = map(int,input().split()) if a>b: if a>c: print(f"{a} eng katta son.") else: print(f"{c} eng katta son.") elif a<b: if b>c: print(f"{b} eng katta son.") else: print(f"{c} eng katta son.") else: print(f"{c} eng katta son.")
8e656ae9c9e7be5c01b244129d12f848b0b422f2
maguedon/codingup
/2016/desamorcage_explosif.py
234
3.6875
4
#python3.6.3 # numSerie = '317010' numSerie = '449149' middle = int(len(numSerie)/2) u = numSerie[0:middle] n = numSerie[middle:len(numSerie)] u = int(u) n = int(n) for i in range(n): u *= 13 u = str(u)[-3:] u = int(u) print(u)
8a75540b3347022ab3ebac5c8f6b9e39bd7b6907
theemilyzhang/15-112_TP
/Player.py
3,036
3.953125
4
import Balloon import Tower from mathFunctions import * import random class Player(object): def __init__(self): self.hp = 20 self.coins = 150 self.towers = [] self.bullets = [] self.cacti = [] self.placingTower = None self.placingCactus = None self.il...
b70882e118f3c2706f4562bef5f19dff03242d41
jose-m-marrero/MDTanaliza
/MDTa_interface.py
78,655
3.59375
4
#!/usr/bin/env python #-*- coding: utf-8 -*- import os import sys from Tkinter import * from Tkinter import Tk, Frame, BOTH import Tkconstants, tkFileDialog from tkMessageBox import showerror, showinfo, askyesno import numbers """ * Copyright (C) 2009-2017 Jose M. Marrero <josemarllin@gmail.com> and Ramon Ortiz <ra...
81ac2f9c4c26d2305517baa4a160a6ec5157543b
PatrickNyrud/projects
/other/test.py
870
3.53125
4
import lyricwikia import re from PyDictionary import PyDictionary import enchant dictionary=PyDictionary() # name = "Barack (of Washington)" # name = re.sub('[\(\)\{\}<>]', '', name) # print(name) artist = "Lil pump" song = "Gucci gang" def run(): lyrics = lyricwikia.get_lyrics(artist, song) d = enchant.Dict("en_...
6ed1b150d53e200047c99a0103894feaca812702
gb08/30-Day-LeetCoding-Challenge
/binary_tree_diameter.py
1,158
4.25
4
""" Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may not pass through the root. """ # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): ...
91b969c1eeff25b086293bc8217938794567808a
InduPriya-pokuri/Python_Advance_Topics
/Python Advanced Workshop/files/list_comprehension.py
449
3.96875
4
'''n=int(input("Enter range:")) li=[] for i in range(1,n+1): num=int(input("Enter number:")) li.append(num) print(li) print("minimum elemnent ", min(li)) print("max element :", max(li)) s=0 for ele in li: s+=ele print("sum value is ",s) print("sum of the list ",sum(li)) if li.sort()!=None: ...
e6b52b09c2bebe8304b27f5f2c9f077ba14e8039
AdamZhouSE/pythonHomework
/Code/CodeRecords/2333/60602/261884.py
1,250
3.71875
4
def quickSort(list): if(len(list)>1): count=1; x=list[0]; leftList=[]; rightList=[]; while(count<len(list)): if(int(list[count])>=int(x)): rightList.append(list[count]); else: leftList.append(list[count]); co...
f4fd2c67348e172ae83a40e0c8ced65e0deec606
LokiGadd/Python
/26.py
2,204
4.09375
4
# Problem 26 ''' My friend John and I are members of the "Fat to Fit Club (FFC)". John is worried because each month a list with the weights of members is published and each month he is the last on the list which means he is the heaviest. I am the one who establishes the list so I told him: "Don't worry any more, I ...
d695275eeaab7e4e737567704ed466460a357eb3
zcl0405/vip10test
/面向对象/1.py
1,914
3.96875
4
# class washer():#定义类 # def wash(self): # print('我会洗衣服') # haier1=washer()#创建对象 # print(haier1) # haier1.wash()#haier对象调用实例方法,创建对象的过程也叫实例化对象 # class washer(): # def print_info(self): #类的里面获取实例属性 # print(f'haire1洗衣机的宽度是{self.width}') # haier1 = washer()#创建对象 # haier1.width = 500#添加实例...
ceb203c13a3fe912077532290b4a8c27c1707855
Oceavos/PythonCourses
/Korean_ver/2_Datatypes/Step_9_Dictionary_functions.py
1,060
3.53125
4
이번에는 딕셔너리 자료형에서 사용하는 함수들에 대해 알아보자. - 딕셔너리의 Key만 모아서 리스트로 리턴 (keys) >>> dic = {'name' : 'SeongJin-Hong', 'gender' : 'male'} >>> dic.keys() dict_keys(['name', 'gender']) # dict_keys 란 이름의 객체를 리턴해줌 - 딕셔너리의 Value만 모아서 리스트로 리턴 (values) >>> dic = {'name' : 'SeongJin-Hong', 'gender' : 'male'} >>> dic.values() dict_va...
583d2d49508b5cd2cd18f6e791e3e6f13fb0a434
osmaoguzhan/topSort
/topSort.py
1,157
3.6875
4
#Code has been taken from Geeksforgeeks and updated from collections import defaultdict import time class myGraph: def __init__(self,verts): self.graph = defaultdict(list) self.V = verts def edge(self,u,v): # adding an edge self.graph[u].append(v) def topSortSub(self,v,visited,queue): visited[v] = ...
10f91a0fd19d2eddb344b5a7028683a2dfe0b42c
maubarrerag/python-exercises
/advanced-python-concepts/Demos/sorting_sort_method.py
973
4.5625
5
# Simple sort() method: colors = ['red', 'blue', 'green', 'orange'] colors.sort() print('Colors sorted', colors, '-'*70, sep='\n') # The reverse argument: colors.sort(reverse=True) print('Colors sorted in reverse order', colors, '-'*70, sep='\n') # The key argument: colors.sort(key=len) print('Colors sorted by length...
1c4b1c09a147479aff3412ba352579e88d8c1bda
erickapsilva1/desafios-python3-cev
/Desafios/066.py
373
3.828125
4
# programa que leia vários n. inteiros, só vai parar com 999 # ao final, tem que mostrar a soma desconsiderando a flag n = int(input('Digite um número: ')) cont = 0 soma = 0 while n != 999: cont += 1 n = int(input('Digite um número: ')) if n == 999: break soma += n print('Saindo...') print('A ...
829d335cfa700d8900ddacee56b0b84e4d1ce94b
gsk120/ibk_python_progrmming
/mycode/3_string/yesterday_count.py
658
3.9375
4
""" yesterday.txt 파일을 읽어서 yesterday 단어가 몇번 나오는지을 count 해보기 open mode r : read, w: write rb : read binary, wb: write binary a : append """ def file_read(file_name): with open(file_name, "r", encoding='utf-8') as file: lyric = file.read() return lyric read = file_read("yesterday.txt") print(read) n_...
0cfa47b60866d55a896ebb31b34882a141d17f61
MrHamdulay/csc3-capstone
/examples/data/Assignment_8/mjlkhw001/question4.py
2,263
4.09375
4
# Palindromic Primes # Khwezi Majola # MJLKHW001 # 04 May 2014 import question1 #Import for use of palindrome checker import math #Import for limiting the checking of prime numbers import sys #Import to increase recursion limit sys.setrecursionlimit (30000) #Increase recursion limit def palin_primes(n, m): ...
a1dc16f3dbaa17143808c998fc3690ff159fcee8
rodcoelho/flask-chatbot
/createdb.py
387
3.75
4
import sqlite3 connection = sqlite3.connect('db/entries.db') cursor = connection.cursor() cursor.execute(""" CREATE TABLE users( pk INTEGER, name VARCHAR(32), PRIMARY KEY(pk)) ;""") cursor.execute(""" CREATE TABLE tweets( pk INTEGER, userID INTEGER, tweet VARCHAR, response VARCHAR, FOREIGN KEY(userID) REFERENCES use...
52bed69c128d6d6e9348ea29abdfbed8521255f2
nagireddy96666/Interview_-python
/practice/prepare/dict/dictswaap.py
165
4.03125
4
def swap(d): k = d.keys() v = d.values() z = zip(v,k) print dict(z) z1 = zip(k,v) print dict(z1) d = input("enter the dict values:") swap(d)
f126a0c0d3bce18bb99ae77ba4d0223fb6d82372
adiraj47/Python_Udemy
/List_Range_Tuple_Section_5/more_tuples.py
154
4
4
even = [2, 4, 6, 8, 10] odd = [1, 3, 5, 7, 9] numbers = [even , odd] print(numbers) for i in numbers: print(i) for j in i: print(j)
35d965366fa0333abbe2f0ec526b76006413e5ab
kantegory/studying
/Multimedia-Tech/03. jpeg-python/huffman.py
1,591
3.8125
4
import heapq from collections import Counter, namedtuple class Node(namedtuple("Node", ["left", "right"])): def walk(self, code, acc): self.left.walk(code, acc + "0") self.right.walk(code, acc + "1") class Leaf(namedtuple("Leaf", ["char"])): def walk(self, code, acc): code[self.char]...
075c3abd77cead11df004ca7b5e73967f9352a83
sotojcr/100DaysOfCode
/PythonLearningStep1/05function.py
1,002
3.953125
4
#function # def helloFun(): # # print('Hello Function!') # # print('Hi') # return 'Hello Funciton' # def fun2(greeting, name ='You'): # return '{}, {}'.format(greeting, name) # print(helloFun()) # print(fun2('Hi')) #allowing us to accept an arbitary number of positional keyword arguments # def fun3(*args, **kwa...
a69ac4a9cab9db8ced8f9a84ca9be7d454e7c590
haley-harris/csc221
/hw5/part3/password.py
722
3.9375
4
import re def get_user_password(): password = input('Type a password: ') return password def test_password_strength(): password = get_user_password() # matches at least one lowercase letter, uppercase letter, digit, and special char password_regex = re.compile(r'(?=^.{8,}$)(?=.*\d)(?=.*[a-z])...
e52a0417b800f71bb95e8b870778ac1d9fb90ffd
copperstick6/Python-Projects
/Python-Projects/messingWithFunctions.py
593
3.84375
4
def function1(): print("I like turtles") function1() #print statement tries to print the return, but there is none, so it prints #none print function1() #not invoking the function with the parenthesis prints the #memory location of the object, as all functions are stored #as an object wihin python print function1...
8e94057e6cb452cfb8117eb5c7146c70546324a7
madeibao/PythonAlgorithm
/PartB/py是否由重复的子字符串构成.py
696
4.15625
4
给定一个非空的字符串,判断它是否可以由它的一个子串重复多次构成。给定的字符串只含有小写英文字母,并且长度不超过10000。 示例 1: 输入: "abab" 输出: True 解释: 可由子字符串 "ab" 重复两次构成。 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/repeated-substring-pattern 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 class Solution: def repeatedSubstringPattern(self, s: str) -> bool: retu...
aacbe90159a43d06fa50edd42d3c1dc50f6ded95
Isthares/Small-Python-Projects
/Conversion-Calculator/screen.py
8,407
4.0625
4
# File Name: screen.py # Author: Esther Heralta Espinosa # Date: 02/20/19 # Description of the program: Conversion Calculator # This class contains functions that are related to displaying something on the screen # or asking the user to enter some kind of data # ---------------------------------- Libraries ----------...
7827351c66f94086305a2fd91812d320bfdca6e5
abhi55555/dsPrograms
/Dynamic Programming/ugly_numbers.py
364
3.921875
4
# program to find ugly numbers(numbers with only prime factors 2,3,5) upto n. def reduce(num, x): while(num % x == 0): num = num / x return num def ugly(n): count = 1 for i in range(2, n): i = reduce(i, 2) i = reduce(i, 3) i = reduce(i, 5) if i == 1: ...
f4157ba7c8485c7abaa719e71c87ba3389750dad
pah-dev/curso_python
/funciones/decoradores.py
757
3.75
4
# a, b, c # a(b) -> c formula de decoradores # formula a recibe a funcion b y retorna funcion c def decorador(funcion): def nueva_funcion(): print("Podemos agregar codigo antes") funcion() print("Podemos agregar codigo despues") return nueva_funcion @decorador def funcion_a_decorar()...
c388abd56e6d66944bfcdf93d322b9788536e3ae
mcguiremw/prime_check
/src/is_prime.py
1,620
4.40625
4
import argparse from math import sqrt import sys def check(n): """Check if a number is prime, return True if it is False otherwise. Args: n -- the number to check for primeness """ if n == 1: return True elif (n % 2 == 0) and (n != 2): return False else: for x in r...
7caed6af61f104a3e0832a8fadc0f4a75778eb15
lan-tianyu/python3
/CookBook-Learning/code/chapter3/test-3-2.py
441
3.515625
4
a = 4.2 b = 2.1 print(a + b) import math from decimal import Decimal, localcontext a = Decimal('4.2') b = Decimal('2.1') print(a + b, a + b == Decimal('6.3')) print('-' * 50) a = Decimal(1.7) b = Decimal(1.2) print(a / b) with localcontext() as ctx: ctx.prec = 3 print(a / b) with localcontext() as ctx: ...
5b7d0f3f62e4cc590c7db46f10c071e2814d4149
MSharique/competitive_codes
/TWOVSTEN.py
162
3.6875
4
t = int(input()) while t>0: t-=1 num = int(input())%10 if num==0: print("0") elif num==5: print("1") else: print("-1")
fa26018430388028041567a0138e795f6cedd18f
qkreltms/problem-solvings
/BOJ/괄호의값/3회차-stack.py
1,108
3.5625
4
def f(): stack=[] for c in s: if c==')': r=0 if not stack: return 0 while True: t=stack.pop() if t=='(': if r: stack.append(2*r) else: ...
b52a116f8990e6d083f19a4ca6ba2f119efc63de
jwlauer/MS5803_Logger
/pressure.py
4,695
3.875
4
def MS5803(i2c, power_pin=None, ground_pin=None): """ A micropython function for reading pressure and temperature from an MS5803 sensor. The function assumes that the MS5803 is hooked up according to instructions at the `cave pearl project <https://thecavepearlproject.org/2014/03/27/adding-a-ms580...
48a124c129dcd782fcc4d47f189decb740fbfde2
liqian7979/algorithm016
/Week_07/Trie.py
1,655
4.125
4
# @Author : debian-liqian # @Email : liqian@infinities.com.cn # @Time : 20-10-29 下午3:55 # @File : Trie.py # @Software : PyCharm """ 208. 实现Trie (前缀树) 实现一个Trie (前缀树),包含 insert, search 和 startsWith 这三个操作。 示例: Trie trie = new Trie(); trie.insert("apple"); trie.search("apple"); // 返回 true tri...
8a20ee352924876b8b7685ecbd96d5fa4b1bfb1a
Navuzasshu/Act_3
/Act_3.py
3,089
4.125
4
#This is a program that gives the user a limited breakfast selection. delivMes='It will be delivered shortly. Enjoy!' #delivMes = delivery message. Will be used repeatedly, therefore it was stored in a variable. rejectMes='Your choice is not available at the moment. If you want a special order, please visit the count...
88a778f6ac35154a4a09c337d586e17d7aac4359
swapnil-tiwari/programming
/printsubsetsum.py
676
3.609375
4
stack=[] def printsubsetsum(sets,sub,n,sum): # print(elem) if(sum==0): for each in sub: print (each, end=" ") print() return if(n==0): return # res = (printsubsetsum(sets,n-1,sum) or (stack.append(sets[n-1]) and printsubsetsum(sets,n-1,sum-sets[...
576c0552b68614b8eb12440fb228a56aab204a02
vitorAmorims/python
/dicionario_loop.py
546
4.5
4
thisdict = { "brand": "Ford", "model": "Mustang", "year": 1964 } for x in thisdict: print(x) # Imprima todos os valores do dicionário, um por um: for x in thisdict: print(thisdict[x]) # Você também pode usar o values()método para retornar valores de um dicionário: for x in thisdict.values(): print(x) #...
58aea3f621bd062cce83316ed654d980b48bbcc7
lowrybg/SoftuniPythonFund
/dictionaries/student_academy.py
446
3.53125
4
n = int(input()) my_dict = {} for _ in range(n): name = input() grade = float(input()) if name not in my_dict: my_dict[name] = [] my_dict[name].append(grade) filtered = {} for key, value in my_dict.items(): av_grade = sum(value)/len(value) if av_grade >= 4.5: filtered[key] ...
df2f36e15e49ee1196837e9a28d150efeac030b8
linika/Python-Program
/code43.py
309
4
4
# count the vowel in each number vowel="aeiou" ip_str=input("Enter the string") ip_str=ip_str.casefold() count={}.fromkeys(vowel,0) # here in fromkeys we are constructing new dictinary where all the vowels are keys and intialize value as 0 for char in ip_str: if char in count: count[char]+=1 print(count)
147e08b938d321076b9f43711c8194566a5a4671
harishtallam/Learning-Python
/Learn_Python_by_Udemy_Navin/3_Math/5_assignment.py
591
4.3125
4
## List any 5 funtions from math module and how it works? import math print(math.sqrt(4)) print(math.floor(3.2)) print(math.ceil(3.2)) print(math.degrees(1)) # converts radians to degrees print(math.fabs(2.13)) # returns absolute value of the float """ Write a code to find the cube of the number. Take input from the ...
b018f5a27cd18418bd8c4570f8267e6eff5be0cf
njenga5/python-problems-and-solutions
/Solutions/problem92.py
295
4.125
4
''' Question 92: By using list comprehension, please write a program to print the list after removing the value 24 in [12,24,35,24,88,120,155]. Hints: Use list's remove method to delete a value. ''' values = [12, 24, 35, 24, 88, 120, 155] values = [x for x in values if x != 24] print(values)
5499110ab50d4a11ed5463f011178055aecc1502
linag99/Proyecto
/cris.py
940
3.53125
4
#MiPong# from tkinter import* def pad1Arriba(r): c.move(pad1, 0, -10) def pad1Abajo(r): c.move(pad1, 0, 10) def pad2Arriba(e): c.move(pad2, 0, -10) def pad2Abajo(e): c.move(pad2, 0, 10) def moverBall(): x1, y1, x2, y2 = c.coords(ball["obj"]) x = (x1+x2)//2 y = (y1+y2)//2 dx = 4 i...
ab510abcf925e780b8ec8b0867419f3a59ebeb16
Padma-Dhar/Python_assignments
/black_jack/black_jack.py
3,343
3.671875
4
# from art import logo # import random # class blackjack_player: # def __init__(self): # self.blackjack_cards_drawn = [] # self.end_game_parameter=0 # self.lost=0 # self.sum_of_card_value=0 # self.card_value={"J":10,"Q":10,"K":10,"A":11} # for i in range(1,11): # ...
a545d73cfd2e26f29484b2a7e611986da2ba0b03
turanbulutt/ThirdClassAssignments
/Scripting/ServerAndClientCoding/server.py
3,796
3.640625
4
import datetime import socket import threading threadLock = threading.RLock() class ClientThread(threading.Thread): # custom class extending the Thread class def __init__(self, clientAddr, clientsock): # constructor for ClientThread threading.Thread.__init__(self) # calling base class constructor Thre...
8b2f0ce3c46f80ccdb65d434383860445ad28187
Juan-Chen-BNUZ/algorithm-study
/Test/test-29.py
568
3.625
4
# -*- coding:utf-8 -*- """ 题目描述 输入n个整数,找出其中最小的K个数。例如输入4,5,1,6,2,7,3,8这8个数字,则最小的4个数字是1,2,3,4,。 """ class Solution: def GetLeastNumbers_Solution(self, tinput, k): if k > len(tinput): return [] tin = sorted(tinput) res = list() for i in range(0, k): res.appen...
56e9ac27af978ad10077a35c7af6aadbd960f1e0
wangyendt/LeetCode
/Easy/14. Longest Common Prefix/Longest Common Prefix.py
530
3.8125
4
# !/usr/bin/env python # -*- coding: utf-8 -*- # author: wang121ye # datetime: 2019/8/28 22:38 # software: PyCharm class Solution: def longestCommonPrefix(self, strs: list) -> str: if not strs: return '' ret = strs[0] while strs: s = strs.pop() for i in range(min(le...
170b03b10232c13c78943636cefbacafe4cda4be
Yuehchang/Python-practice-files
/Introducing_Python/Chap2_numstrvar.py
2,501
3.84375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue May 30 21:57:41 2017 @author: changyueh """ type() #瞭解()的物件類型 # / 浮點除法 => 7/2 => 3.5 # // 整數除法 => 7/2 => 3 (捨去) # % 餘數 => 7/2 => 1 a -= 3 <==> a = a - 3 #兩個式子是一樣的 a += 3 <==> a = a + 3 a *= 3 <==> a = a * 3 divmod() #可以回傳商及餘數 page 25 #基數 二進位 0b/0B...
fccba4e01ad566e184e5d163f52d2bcb7839174c
Vith-MCB/Phyton---Curso-em-Video
/Cursoemvideo/Exercícios/exer36 - Empréstimo.py
314
3.859375
4
valcasa = float(input('Valor da casa: ')) sal = float(input('Salário: ')) anos = float(input('Quantidade de anos: ')) prest = valcasa/(anos * 12) if prest > sal * 1.3: print('Empréstimo negado!') elif prest == sal * 1.3: print('Empréstimo aprovado NA TRAAAAVE!') else: print('Emprestimo liberado!')
0ac93e2bc791451ccd9c104718498da651e186f2
DmitryIvanov10/MetodyNumeryczneI
/Tasks/Lista10/task2.py
482
3.890625
4
# Lesson10, Task2 # import cos from math import cos # import own module import numerical_methods as num # set initial data a = -1 b = 1 def f(_x): return cos(2 * cos(_x)**(-1)) # calculate and print results integral = num.simpson(f, a, b, 3) print("I = {} for n = 3".format(integral)) print () integral = nu...
12a1792b0510f40f52988688b2179788e2b8d949
PrimoWW/mooc
/add_digits.py
610
4.21875
4
""" Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example: Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one digit, return it. """ def add_digits(num): """ :param num: int :return: int """ next_num = num ...
afc337ddb683636cd770fa48fa88213a8e5bd6a9
SamratAdhikari/Ethical-Hacking-Python
/Password cracker/Password Cracker.py
1,485
3.90625
4
# Password Cracker import hashlib, pyperclip def main(): myPass = str(input("Enter the password/passhash: ")) pass_mode = str(input("[E]ncrypt or [D]ecrypt: ")) if pass_mode.upper().startswith("E"): encryptHash(myPass) elif pass_mode.upper().startswith("D"): decryptHash(myPass) else: print(...
5a2284a34993b18ea278047eca702c643ee98b43
sufyjakate/Mario-Princess
/princess_save.py
694
3.703125
4
def PrincessPath(n, grid): for idx, row in enumerate(grid): if 'p' in row: princess = (idx, row.index('p')) if 'm' in row: mario = (idx, row.index('m')) # negative row difference implies UP # negative col difference implies LEFT drows = princess[0] - mar...
00fe8b198e8cf153a2ada8b8236033e9f801856b
mradoychovski/Python
/PAYING OFF CREDIT CARD DEBT/bisection_search.py
863
4.25
4
# Uses bisection search to find the fixed minimum monthly payment needed # to finish paying off credit card debt within a year balance = float(raw_input("Enter the outstanding balance on your credit card: ")) annualInterestRate = float(raw_input("Enter the annual credit card interest rate as a decimal: ")) monthlyInt...
0fde2f9f07c9997cef61ab99b9ff03140a373f28
OctavioThomsen/LexerParser
/LexerParser/Automata_numeros.py
1,847
3.875
4
#Variables auxiliares TRAP_STATE = -1 RESULT_TRAP = "RESULT_TRAP" RESULT_ACCEPTED = "ACCEPTED" RESULT_NOT_ACCEPTED = "NOT ACCEPTED" numeros = ["0","1","2","3","4","5","6","7","8","9"] #Función transición def delta(state, caracter): #{q0, ["0",...,"9"], q1f} if state == 0 and caracter in num...
4663f2a44681e3730212682b1d30fc87e12a2183
allenwhc/Algorithm
/Company/Facebook/IncreasingTripletSequence(M).py
1,141
3.78125
4
class Solution(object): """ Brute force solution Time complexity: O(nk), n is length of nums, k is length of subset whose best case is O(1) and worst case is O(n) Extra space: O(1) """ def increasingTriplet(self, nums): """ :type nums: List[int] :rtype: bool """ if not nums or len(nums)<3: return Fal...
334f482ea6e98d0b7de665fa89eef7601b9b3f22
lealobanov/Year3-COMP3487-Bioinformatics
/bio_expectation_maximization.py
12,898
3.796875
4
import sys import numpy as np import pandas as pd import matplotlib.pyplot as plt import math pd.set_option("display.max_rows", None, "display.max_columns", None) #Run-time instructions and output formatting #The command line prompt accepts 3 arguments: alphabet length, number of states, and an observed input sequen...
8a9ef66ca67a9f251ccd5f5340545c84adf755ef
DarMorar/Dawson_Python_Programming
/Chapter6/6.1.py
736
3.9375
4
""" Доработайте функцию ask_number() так, чтобы ее можно было вызывать еще с одним параметром - кратностью (величиной шага). Сделайте шаг по умолчанию равным 1. """ def ask_number(question, low, high, multiplicity=1): """Функция просит ввести число из диапазона""" response = None while response not in ran...
7869fa76162c6b7ffa31256edfd0393f85968bdf
Knoxxx-404/amanirshad.github.io
/sum_of_array.py
382
4.25
4
# Python 3 code to find sum # of elements in given array def _sum(arr,n): # return sum using sum # inbuilt sum() function return(sum(arr)) # driver function arr=[] # input values to list arr = [12, 3, 4, 15] # calculating length of array n = len(arr) ans = _sum(arr,n) # display sum print ('Sum of...
400422f4dcf4b8edebffabc10b2932cdff485986
carlos1134/python
/programa de calculo.py
1,396
4.09375
4
'''Escribir un programa para calcular f(x) = ((x^2 + 1)^0.5) − 1 g(x) = x^2/[((x^2 + 1)^0.5) + 1] para la sucesion 8^−1, 8^−2, 8^−3. . . , 8^−10. Aunque f = g la computadora produce resultados distintos,cual es m´as confiable? ''' import math def f(x): return math.sqrt(math.pow(x, 2)+1)-1 def g(x): re...
0c1d632857c90962088ba0a44729684a85e4ee1d
nkbhan/Spectral_Runner
/main/Obstacle.py
1,650
3.703125
4
""" Obstacle.py contains the class for the obstacles in the game """ import pygame import Colors class Obstacle(pygame.sprite.Sprite): @staticmethod def init(): Obstacle.size = 75 Obstacle.vy = 7 Obstacle.pinkImage = pygame.image.load("Images/pinkObstacle.png").convert_alpha() ...
2ecc063dcd86afbe46d49d5e85e4512c4ae7fa3f
adamvh/caesar-cipher
/decrypt-message.py
1,476
3.796875
4
""" Name: Adam Hudson Date: 2018-07-12 Program Name: decrypt-message.py Description: This program will receive a text file and decrypt the message using the caesar-cypher method. The decrypted message will output to the terminal. """ # Declair imports impo...
0702888c98fc07cc48a6f74bd9cbf708bfccfdde
boknowswiki/mytraning
/lc/python/0067_add_binary.py
926
3.5
4
# string # time O(n) # space O(n) class Solution: def addBinary(self, a, b) -> str: x, y = int(a, 2), int(b, 2) while y: x, y = x ^ y, (x & y) << 1 return bin(x)[2:] class Solution: def addBinary(self, a: str, b: str) -> str: a_len = len(a) b_len = len(b) ...
d16ad5c898122f21fe43fcce9801fb08c3cf056e
amolsmarathe/python_programs_and_solutions
/2-Basic_NextConceptsAndNumpy/3-Functions_Basics.py
2,481
4.4375
4
# Functions can be created to perform certain tasks # Functions can return nothing, or may return single or multiple values # Function is to be DEFINED and then CALLED # Types of arg- Formal (defined in function) and Actual (given while calling a function) # Types of Actual arg- Position, keyword, default, variable le...
5474fc354fe6537e9aee3955705de44462ddcc07
jsm209/lugmere-s-loss
/encounterGroup.py
369
3.609375
4
# EncounterGroup keeps track of a group of encounters. It is able to store encounters, # and retrieve random encounters. import random class encounterGroup: def __init__(self): self.encounters = [] def add(self, encounter): self.encounters.append(encounter) def get_random_encounter(sel...
0f02f68206617afb2655ed694a1d247dd6a3b91c
JamesNgai/qtbot
/utils/dict_manip.py
1,054
3.5
4
import json from nltk.metrics import edit_distance as ed def get_closest(word_dict, word): """ returns the key which matches most closely to 'word' """ # stores keys and their edit distance values distance_dict = {} for key in word_dict: distance_dict[key] = ed(key, word) # return key w/...
56f6e82e3db7ae91ffe0ad09a56e363ff8d80948
mozzherina/cherimoya
/event.py
1,172
3.640625
4
from abc import ABC, abstractmethod from typing import List from constants import * class Event(ABC): """ Event is base class providing an interface for all subsequent (inherited) events, that will trigger further events in the trading infrastructure. """ def __init__(self, event_typ...
a2e152e09ee76827469dd796f819987373bd4473
JoshRU13/Project-105
/105.py
460
3.765625
4
import math import csv with open('data.csv',newline='')as f: reader=csv.reader(f) data1=list(reader) data=data1[0] def mean(data): m=len(data) total=0 for x in data: total=total+int(x) mean=total/m return mean square=[] for i in data: a = int(i)-mean(data) a= ...
7c12bdf3a21e9d2cdc759b91e28b5dad68170bda
MurluKrishna4352/Python-Learning
/palindrome_check def function.py
418
4.03125
4
# def p[alindrome def palindrome_check(word): if word == word[::-1]: return 1 else: return 0 input_list_no= int(input("Enter number of elements you want in your list : ")) list_1 = [] for i in range(input_list_no + 1): list_elements = input("Enter element" , str(i + 1) ...
8efde4beb616e355b7f191139120cdd8e9458b68
pewosas/DuongHieu-C4T6
/list-intro.py
230
4
4
color_list = ["red", "purple", "blue", "orange", "teal"] while True: new_color = input("New_color?") color_list.append(new_color) print("* " * 10) for color in color_list: print(color) print("* " * 10)
0435975b01e1a9698ee0f37c11e900055f0da990
cyang812/leetcode
/20-isValid.py
1,351
3.75
4
# -*- coding: utf-8 -*- # @Author: cyang # @Date: 2020-09-22 19:49:00 # @Last Modified by: cyang # @Last Modified time: 2020-09-22 20:47:44 def isValid(s): c1 = s.count('(') c2 = s.count(')') c3 = s.count('[') c4 = s.count(']') c5 = s.count('{') c6 = s.count('}') print(c1, c2, c3, c4, c5, c6) if c1 != c...
62daebb185af4bfeb27d0d85bc3ec13c9f52b27b
AdamZhouSE/pythonHomework
/Code/CodeRecords/2068/60654/253820.py
95
3.75
4
a= int(input()) b = int(input()) if a*b >0: print(a//b) else: print(a//b + 1)
ccaf5123dc1613be15a4e8d46109bcda85efe318
MichelleZ/leetcode
/algorithms/python/minimumInitialEnergytoFinishTasks/minimumInitialEnergytoFinishTasks.py
495
3.546875
4
#! /usr/bin/env python3 # -*- coding: utf-8 -*- # Source: https://leetcode.com/problems/minimum-initial-energy-to-finish-tasks/ # Author: Miao Zhang # Date: 2021-05-26 class Solution: def minimumEffort(self, tasks: List[List[int]]) -> int: n = len(tasks) tasks.sort(key = lambda x: (x[1] - x[0]),...
7c4c593bb4dd93be1ad42d83d0eb38bc3a3a3fed
ordinary-developer/education
/py/m_lutz-programming_python-4_ed/code/ch_03/10-redirecting_streams_to_python_objects/teststreams.py
372
3.5625
4
"read numbers till oef and show squares" def interact(): print('Hello stream world') while True: try: reply = input('Enter a number>') except EOFError: break else: num = int(reply) print("{} squared is {}".format(num, num ** 2)) print...
813cef8156751c1c858ef39f7f93e2f030904dcb
govardhananprabhu/DS-task-
/Extra.py
1,230
4.09375
4
""" H-5 Given two sorted arrays. There is only 1 difference between the arrays. The first array has one element extra added in between. Find the index of the extra element. Explanation: The first array has an extra element 9. The extra element is present at index 4. In des First line contain two space integer...
e5f1a7c0d33100f373dd67b9668b1252293e661a
Leownhart/My_Course_of_python
/Exercicios/ex067.py
552
4.0625
4
'''67 - Faça um programa que mostre a tabuada de vários números, um de cada vez, para cada valor digitado pelo usuário. O programa será interrompido quando o número solicitado for negativo.''' cont = 0 while True: n = int(input('Quer ver a tabuada de qual valor? ')) print('\033[34m=\033[m'*35) if n <= 0: ...
5705e7444c6d33f95a82d3bfb76500e980eb2ef1
mike-jolliffe/Learning
/leet_268.py
560
3.78125
4
class Solution(object): def missingNumber(self, nums): """Find number missing from array :type nums: List[int] :rtype: int """ # Generate a set for reference, from 0 to n ref_set = set(range(0, len(nums) + 1)) # Return the diff of the sets return list(...
98b4343b21d76144aa82b4745b046c91b61af09c
aatherton/project4
/py_output.py
5,322
3.5
4
# coding: utf-8 # In[1]: # import modules import pandas # In[2]: # declare variables data = pandas.read_json("purchase_data.json") data.append(pandas.read_json("purchase_data2.json")) data.head() # # Playercount # In[3]: print("Total Players: " + str(len(data["SN"].value_counts()))) # # purchasing analys...
bde4780839b308dddbf4b73d94e1220078c7e32c
kristophercasey/Ransomware
/payload/generator/message.py
3,274
3.6875
4
from tkinter import * TITLE_MESSAGE = "Your files have been encrypted!" INFO_MESSAGE = "Your files have been encrypted. If you wish to recover them, you need to pay {}$ worth of Bitcoin "\ "and follow the payment instructions. If you don't pay the ransom within {} hours the access to your files " \ ...
69d955821edadda5fa188e2507f894ff6ff119e0
AndrejusAnto/tvwatch
/series.py
12,267
3.53125
4
#!/usr/bin/env python # coding: utf-8 from threading import Thread from datetime import datetime from typing import Union import imdb import json import os import copy import sys import logging tod = datetime.today() listtod = [tod.year, tod.month, tod.day] ia = imdb.IMDb() convertmonths = { 1: "January", 2: "Feb...
cb7ec5a8c46a0546a2bcc121089208703be9f8ad
at-bradley/python_Main
/Sublime/TIY6b.py
2,381
3.9375
4
print ("\n") #6-3 p.102: from pprint import pprint #Stackoverflow. programming_words = { 'list': 'Items enclosed in [] brackets.', 'list_comprehension':'A simpler way to construct lists.', 'tuple':'A list of immutable objects, enclosed in () brackets.', 'pep 8':'Style guide...
4ac0cb071c5b70181f5d00fd568b6018a20f4d23
juraj-kajaba/MITx_6_00_2x
/Item.py
1,527
3.59375
4
from functools import total_ordering import sys #I used decorators for getters and setter just to practise them. I know they should not have them as I can acess them directly in Python @total_ordering class Item: def __init__(self, name, weight, value): self._weight = weight self._value = value ...
ad9a1c16c133627450dee835fabb62830b9a823d
JakubKazimierski/PythonPortfolio
/AlgoExpert_algorithms/Hard/KnapsackProblem/test_KnapsackProblem.py
915
3.84375
4
''' Unittests for KnapsackProblem.py March 2021 Jakub Kazimierski ''' import unittest from KnapsackProblem import knapsackProblem class test_KnapsackProblem(unittest.TestCase): ''' Class with unittests for KnapsackProblem.py ''' def setUp(self): ''' Sets up input. ...