blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
91cc7fc79cbe78c9984d75c3f31df75fd9b657f9
duanzw88/thmoas
/thomas/pre/p-4-55.py
301
3.828125
4
#-*- coding:utf-8 -*- #设y1=ln(ax) y2=ln(x) y3=y1-y2 #a:对a=2,3,4,5,画y1 y2的图形 #b:画y3图形 #c: import numpy as np import matplotlib.pyplot as plt x = np.arange(1,10,0.1) a = 2 y1=np.log(a*x) y2=np.log(x) y3=y1-y2 plt.plot(x,y1,c='r') plt.plot(x,y2,c='g') plt.plot(x,y3,c='b') plt.show()
f3d339796b63805916f57b7fc2be460240256ed4
aakib7/python
/Basic/Chapter7.py
2,964
4.21875
4
# dictionary creation user = {"name" : "Aaqib", "age" : 24, "Id" : "sp19-bse-087"} user1 = dict(name = "aaqib", age = 21, id = "sp19-087") print(user) print(user1) # Access data from dictionary print(user["name"]) print(user["age"]) print(user["Id"]) print(user1["name"]) print(user1["age"]) print(user1["id"]) # dict...
24dfdb767ba6cc4860333cdfc2fa943e5785bb8c
xirain/realpython-test
/sql/hw_sql_2.py
1,136
3.53125
4
# Join import sqlite3 with sqlite3.connect("cars.db") as connection: c = connection.cursor() c.execute("DROP TABLE IF EXISTS orders") c.execute("CREATE TABLE orders(make TEXT, model TEXT, order_date DATE)") orders = [('Fords', 'A', '2012-01-01'), ('Fords', 'B', '2013-06-06'), ('Fords', 'C', ...
d5360b197dec40c50cfdca05efbec06456c0d09f
8secz-johndpope/avatarify-fast
/facial_landmark/alignment.py
1,472
3.53125
4
import numpy as np import math import cv2 def align_face(image_array, landmarks): """ align faces according to eyes position :param image_array: numpy array of a single image :param landmarks: dict of landmarks for facial parts as keys and tuple of coordinates as values :return: rotated_img: numpy...
d725ca1a6cfe52eaf3694328419d6b7a235ed7ee
manuhana/praxis-academy
/novice/excercise/standard_library.py
109
3.90625
4
import math radius = input() radius_2 = int(radius) ** 2 circle_area = math.pi * radius_2 print(circle_area)
0fe0c05b251bbefc5f0c25c87ebfabfe7da877cd
antoshkaplus/CompetitiveProgramming
/ProjectEuler/001-050/12.py
1,423
3.875
4
""" The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be: 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... Let us list the factors of the first seven triangle numbers: 1: 1 3: 1,3 6: 1,2,3,6 10: 1,2,5,1...
e6aa0c03b3bc30c12bfdfeff635ab210ce3e8b05
lobdol/softserve_course
/Reversing Words in a String.py
455
4.5625
5
#You need to write a function that reverses the words in a given string. A word can also fit an empty string. If this is not clear enough, here are some examples: #As the input may have trailing spaces, you will also need to ignore unneccesary whitespace. #Pushynskyy Kostya reverse('Hello World') == 'World Hello' rev...
a58187c246e0e52fdb783e2c04f93585d78da101
Vignettes/PythonBootcamp
/Section_12_Lists/slicing.py
1,319
4.40625
4
### Allows you to take part of a list based on given indexs ### # makes a new list using slices of your old list. #some_list[start:stop:step] # start is starting index, stop stopping index, step the intervals # The indext to copy from first_list = [1, 2, 3, 4] first_list[1:] #[2, 3, 4] first_list[3:] # [4] # If ...
402e536512fec254c6e3726d106c160fdd066ba0
RobinWenqian/classic_machine_learning
/SingleLevel_BP_Network.py
699
3.796875
4
import numpy as np #sigmoid function def nonlin (x,deriv=False): if(deriv==True): return x*(1-x) return 1/(1+np.exp(-x)) #input dataset X = np.array([[0,0,1],[0,1,1],[1,0,1],[1,1,1]]) #output dataset y=np.array([[0,0,1,1]]).T #seed random numbers np.random.seed(1) #initialize weights randomly with m...
07fb51234acbd4e2240e23d14219cbf8bc534344
callmeed/pypasser
/qb_rating.py
772
3.671875
4
import sys if len(sys.argv) < 6: print "One or more arguments missing" sys.exit("Required arguments: attempts completions yards tds interceptions") def rating(attempts = 0, completions = 0, yards = 0, tds = 0, interceptions = 0): if attempts == 0: return 0.00 a = (completions / attempts - 0.3) * 5 b = (yar...
2192068c8ce9dd31ef497d66f8d3632efd4d6f66
yashbagla321/Mad
/computeLineThroughTwoPoints.py
618
3.796875
4
print 'Enter x and y coordinates of point1 then point2' x1 = float(input()) y1 = float(input()) x2 = float(input()) y2 = float(input()) def computeLineThroughTwoPoints(x1, y1, x2, y2): if x1 == x2 and y1 == y2: print 'Error, Please give 2 distinct points' return(0,0,0) else: ...
61401679f467cbe71c81f17af8668d3b918f771f
luisfsantos/Hashcode2018
/src/python/algorithms/knapsack.py
865
3.515625
4
# A Dynamic Programming based Python Program for 0-1 Knapsack problem # Returns the maximum value that can be put in a knapsack of capacity W def knapSack(W, wt, val, n): K = [[0 for x in range(W + 1)] for x in range(n + 1)] keep = [[0 for x in range(W + 1)] for x in range(n + 1)] # Build table K[][] in bot...
e3fbfbc66b368e877a3d5973156cdbf83aa3f3eb
async-dime/DQLab-DataAnalyst
/01 Python for Data Professional Beginner/Python for Data Professional Beginner - Part 2/01 Collection Manipulation dengan Python/10 praktek.py
738
3.640625
4
''' Tugas: Dari variabel keuangan, aku akan menghitung rata-rata pengeluaran dan pemasukanku selama 9 bulan terakhir. Semoga keuanganku sehat-sehat saja. ''' # Data keuangan keuangan = { 'pengeluaran': [2, 2.5, 2.25, 2.5, 3.2, 2.5, 3.5, 4, 3], 'pemasukan': [7.8, 7.5, 9, 7.6, 7.2, 7.5, 7, 10, 7.5] } # Perhitungan rat...
3765c5f46182021cbb2579386183ffa6a0753b40
Alex-Cel/UskoKruM2010_Python
/Curso/lambda.py
449
4.125
4
# Son funciones anónimas que sirven para abreviar o resumir una función normal, # para convertirla en una expresión más simple. """ def sumar(n1, n2): return n1 + n2 print(sumar(12,15)) """ # Toda función lambda se puede convertir a una función normal, no viceversa. sumar1 = lambda n1, n2: n1 + n2 print(sumar1...
457bd2089699030bf177e45566a8b0346e5ecdf4
lynnanni/Netflix-SDET-project
/Modules/Pages/HomePage.py
2,930
3.75
4
from Modules.Pages.BasePage import Page from Modules.Library.locators import HomePageLocators as locators class HomePage(Page): """ This is the main URL you visit to test: http://computer-database.herokuapp.com/computers """ def __init__(self, driver, url="http://computer-database.herokuapp.com/comput...
6594451dd811d04901faa0cfa7706d9a9f877bfb
128keaton/Spring-2020-COMP-4040
/quiz8/question3.py
710
3.671875
4
# question3.py # kbrleson # COMP 4040 import sys correct_username = 'johndoe' correct_password = 'secret1234' authenticated = False def authenticate(username, password): return username == correct_username and password == correct_password if sys.version_info < (3, 0): sys.stdout.write("Sorry, requires Python 3.x,...
17dc157758252c89cf39dcd8dad174176f32823e
padamcs36/Introduction_to_Python_By_Daniel
/Chapter 6 Functions/Scope Of varaible inside the method.py
658
4.09375
4
print("Example 1") def funciton(x): print(x) x = 3.4 #x, y are local variable can only be accessible inside the function y = 4.5 print(y) x = 2 #Global variable can be accessible inside the function. y = 3 funciton(x) print(x, y) print("Example 2") def f(x, y = 1, z = 2): return x + y...
2915b8d7f3e13571a19e5ace52f813b147391c37
Avalineai/PythonProjects
/whileloop.py
662
3.828125
4
num1= [8, 19, 148, 4] num2= [9, 1, 33, 83] list3 = [] for i in num1: for j in num2: mult = i*j list3.append(i*j) print(list3) num4= [8, 19, 148, 4] num5= [9, 1, 33, 83] mult2 = [] for i in num4: for j in num5: mult2.append(i*j) print(mult2) numbers = [11, 32, 33, 15...
d9d36661c594863cac30b3e6d04ecd7681274a55
mattsharpe/ProjectEuler
/python/002.py
401
3.53125
4
calculated = [0,1] def fibonacci(n): if n<=len(calculated): return calculated[n-1] else: next = fibonacci(n-1)+fibonacci(n-2) calculated.append(next) return next limit = 4000000 current = 0 count = 1 answers = [] while current < limit: current = fibonacci(count) if cu...
ef7d4d4f5a7ac9744a94354ef5c119d797d1168c
miracle3070/github-practice
/Q6.py
51
3.640625
4
li = [1,3,5,4,2] li.sort() li.reverse() print(li)
714cac23886cab76e3483a39f93dde5262e62866
artainmo/python_bootcamp
/day00/ex01/exec.py
447
4.28125
4
from sys import * def reversed_string(a_string): return a_string[::-1] # It works by doing [begin:end:step] - by leaving begin and end off and specifying a step of -1, it reverses a string. argv.reverse() i = 0 while i < len(argv): argv[i] = reversed_string(argv[i]) argv[i] = argv[i].swapcase() i += 1...
58ef2103e7c1fc2c8e14c95df890e353830fa717
awzsse/Keep_Learning_ML
/python就业班/python-05/09-共享全局变量的问题.py
744
3.84375
4
import time import threading # 先定义一个全局变量 g_num = 0 def test1(num): global g_num for i in range(num): g_num += 1 print("---in test1 g_num=%d" % g_num) # 获取全局变量,不用加global def test2(num): global g_num for i in range(num): g_num += 1 print("---in test2 g_num=%d" % g_num) def main(): t1 = threading.Thread...
8a248a5211f066237fd1270227dd1e23c679a690
JohnnyAIO/Python
/Fisica.py
158
3.75
4
distance = float(input("Ingrese la distancia: ")) vec = int(input("Ingrese la velocidad: ")) time = vec/distance print("Total del tiempo: %5.2f " % time)
c6aa00b7d6bddb624b2984a0bba72620cbdc0b43
HYDFKI7/integrated-mk
/Model/farm_decision/dp_demo.py
4,741
3.5625
4
# following 11.3 from AMP-Chapter-11.pdf # stages are years # state is number of plants # decision is number to construct # return/utility is cost # the key innovation of dynamic programming (as oppposed to simple recursion) is to only evaluate each subproblem once ''' return/cost of decision d_n \in D_n (permissibl...
42ca811f25ae6c0c46b855ed07ff411019e4c75f
Swapnil367/code-series-10days-running-beginner
/acronym maker python code.py
108
3.765625
4
s1 = str(input("Enter string: ")) s2 = s1.split() x = " " for i in s2: x = x+str(i[0]).upper() print(x)
7833ae011ebb7e34f8525d8d5dd92a0ccde6fd2c
karthigabanu/python_programs
/factorial.py
170
4.25
4
#Program to find factorial of a number def fact(n): if n == 1: return 1 else: return n*fact(n-1) n = int(input("enter a number:")) print(fact(n))
e464c0b726f3c2ae21d6225bc691c74f720b880f
marri88/python-base
/STRINGS/prob27.py
487
3.546875
4
q = ['a': 1, 'b' : 2, 'c': 3, 'd': 4, 'e': 5] w = 'Здравствуйте [a]', 'Прекрасная профессия [1]' for w in q: print(w) # Создайте Dictionary с 5 элементами где ключи это их имена, а значение их профессия. # С помощь цикла for пройти вывести на экран строку: # "Здравствуйте <Имя> Прекрасная профессия <Профессия>"
e34aa71ae3b0af87153cd14da26f14d6ccf2cff3
eliashow/cs1411
/project_1/project_1.py
4,560
4.46875
4
##Elias Howell | 11/1/2019 | Project #1 ## ##Program solves a predetermined maze, a list of lists; '#' represents walls, ' ' represents a path. ## 'S' is the starting point of the maze and 'E' is the end ## ##Algorithm: ## 0)Get the starting location for the given maze using getStartPoint() ## 1)Get the ending locati...
207d942c399d0ff5077309e19b143e86a77c6b48
zhuzihope/WenzhuLiu
/Animation Paint Board/Design/demo.py
25,057
3.640625
4
# Wenzhu Liu + wenzhul + section L # This is the main class which makes the paint board work well. # We could draw like pencil, pen, and dropper. It also includes eraser, images # and the method how to draw a regular line. # What's more, we could put some images on the canvas and make them move # in different directi...
1dd2316f0e064719c582684bff739f90544bd8e5
fujiisoup/pdffigure_extractor
/digitizer/geometry.py
454
3.8125
4
import numpy as np def distance2(x, x0, x1=None): """ Obtain the distance between a path x0-x1 and x. """ x0 = x0 - x if x1 is None: return x0 @ x0 x1 = x1 - x dx = x1 - x0 if dx @ x0 < 0.0 and dx @ x1 > 0.0: # x is inside x0 and x1 x_sum = x0 + x1 retur...
6f66de8ac5ba44a5484dceb25329f35c15978be5
jambellops/hRank
/itertools/S_max_moded.py
1,609
3.71875
4
''' You are given a function f(x) = x^2. You are also given K lists. The i^th list consists of N_i elements. You have to pick one element from each list so that the value from the equation below is maximized: S = (f(x_1) + f(x_2) + ... + f(x_k)) % M X_i denotes the element picked from the i^th list . Find the maximiz...
6d39da3a2a868af5a39ce7694f53cde1fe9fbde3
yamini219/PYTHON-LOGICAL-PROGRAMS
/Printing alphabets.py
189
3.90625
4
num=int(input("Enter the number:")) space=num-1 for i in range(num): for j in range(space-i): print(end=" ") for j in range(i+1): print(chr(98+j-1),end=" ") print("\r")
4d8318385ed2190edccd8274c0e757ca68212081
Siqi-Ren/Algorithm-in-Python
/Fib2.py
442
3.90625
4
""" This programme use search in memory method to solve fibonacci number """ from collections import defaultdict total = defaultdict(int) def fib(k): assert k > 0, "k is greater than 0" if k in [1, 2]: return 1 global total if k in total: result = total[k] else: result = fib(...
8ba50b1f2d1ec09fa0ed667c9a18c07774936375
mjhea0/learn-tdd-the-hard-way
/ex12_test.py
545
3.796875
4
import unittest from ex12 import Prompting class TestPrompting(unittest.TestCase): def setUp(self): age = raw_input("How old are you? ") height = raw_input("How tall are you? ") weight = raw_input("How much do you weigh? ") self.create = Prompting(age,height,weight) def te...
0d4a64ecc3338f5b0f4f2dc591c2ebdfd16adf60
Plasmoxy/DevMemories
/Python/scripts122014/object/employee.py
640
3.75
4
#python class Employee: empCount = 0; def __init__(self, name, salary): self.name = name; self.salary = salary; Employee.empCount += 1; def displayCount(self): print("Total Employee %d" % Employee.empCount); def displayEmployee(self): print("Name : " + self.name + ", Salary : " + str(self.salary) ); ...
5624e23f5ce027748bb5034f3b555e3cfb54103e
UWPCE-PythonCert-ClassRepos/SP_Online_PY210
/students/CCSt130/lesson03/string_lab_ex3-3.py
8,901
4.125
4
# -*- coding: utf-8 -*- """ This code contains the answers to 6 different string-related tasks. """ """ Lesson03 :: String Lab Exercise 3.3 @author: Chuck Stevens :: CCSt130 Created on Sat Jun 1 18:53:03 2019 """ """ Menu """ import random if __name__ == "__main__": def main(): """ Main contains the...
838438b3ba1d3400e643e639c1b6ed5c7462e2ff
hayabalasmeh/pythonisms
/tests/test_pythonism.py
805
3.546875
4
from pythonismm.pythonisim_linked_list import LinkedList,Node def test_str(): num = LinkedList() num.insert(4) num.insert(5) num.insert(6) actual = str(num) assert actual == 'The LinkedList Representation is : {6} -> {5} -> {4} -> + NULL' def test_get_item(): num = LinkedList() nu...
af3441c3ba77c94a7d84d5c515c7142c5e07320b
pinku4/Python
/Assignment 5.py
302
3.8125
4
from random import randint def main(): n=raw_input('enter a lengthof the random numberto be generated') m=random_with_N_digits(n) print m def random_with_N_digits(n): range_start=10**(n-1) range_end=(10**n)-1 o =randint(range_start,range_end) return o main()
9f98ea3a312aaf0fb519fc8b94053c413f93210c
DeshErBojhaa/sports_programming
/leetcode/450 Delete Node in BST.py
1,217
3.734375
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def deleteNode(self, root: TreeNode, key: int) -> TreeNode: def predessor(cur): cur = cu...
372817d028d48a2d2059c4f33d2cfdaa1acc247a
inrixx/python_work
/test.py
183
3.5
4
class Person(): def __init__(self,name): self.name = name self.a = 800 def hello(self): print('myange is ',self.name) p = Person("bill") p.hello() print(p.name) print(p.a)
0cf4ce0d4bb9b938218e5a6a657edbc19b587c6c
SS4G/JP2020
/algo/31.py
627
3.671875
4
class Solution: def nextPermutation(self, nums: List[int]) -> None: """ Do not return anything, modify nums in-place instead. """ #nums if len(nums) == 1: return else: op_flag = False for i in range(len(nums) - 2, -1, -1): ...
986c6fb34b9403e145bc58b703da74d9fe8c9f58
junaidkpm1998/FULL-STACK-ICT
/python/username_password.py
442
3.65625
4
fileobj=open("login.txt","w") fileobj.write("ictak\n") fileobj.close() fileobj=open("login.txt","a") fileobj.write("1234") username=raw_input("enetr user name") password=raw_input("enter ur password") fileobj=open("login.txt",'r') uname=fileobj.readline() passw=fileobj.readline() print(username) uname==uname.rstrip("\n...
c39204863ed6fcad5ca5b80256dbf0fcae26470a
zfreedman/udacity_mlnd_mock_interview
/question5.py
2,064
4.03125
4
class Node: """ Implementation of a singly linked list node. """ def __init__(self, data): self.data = data self.next = None #Note there's no need to implement a linked list class if I just need to iterate through #a list of nodes. This problem is trivial def make_fake_ll(data_l...
8f361ba880c1f7e2d244ab965d0ba1503f98b531
rahulrajb/python-assessments
/9th program.py
443
4.40625
4
#!/usr/bin/env python # coding: utf-8 # In[1]: #9. Write a Python function that accepts a string and calculates the number of uppercase letters and lowercase letters. x=input("enter string ") count=0 count1=0 for i in range(len(x)): if((x[i].islower())==True): count+=1 elif((x[i].isupper())==True): ...
a9f773b29d84967d3b970d9427e654f0dfae215d
Aanchalsenapati/PythonForEveryone
/PYAssignment 13a.py
946
4.25
4
#Extracting Data from XML #In this assignment you will write a Python program somewhat similar to https://py4e.com/code3/geoxml.py. #The program will prompt for a URL, read the XML data from that URL using urllib and then parse and extract the comment counts from the XML data, compute the sum of the numbers in the fil...
149333f8518419437f5560fedd73b9b076f26b18
girinabin/test
/q1.py
381
3.859375
4
# num1 = int(input('enter number')) # num2 = int(input('enter number')) # def sum(a,b): # return a+b # print(sum(num1,num2)) # def altotal(*args): # total = 0 # for i in args: # total +=i # return total # print(altotal(3,4,5)) # def altotal(*args): # total = 0 # for i in args: # ...
ee8edff8e3339ed8f4ed4d50aaa15530496d8e57
Greece4ever/pythematics
/basic.py
2,819
4.15625
4
""" Module containing some basic Math operations-functions: ** product(*args) # Returns the product of specified numbers ** comaSplitNumber(num : int or float) #Returns a human readble string splitting a large number with commas ** isNumber(arg) -> bool #Returns a boolean on wheter an argume...
ce94ef8b49f3956c3affec1e5e300c01b68f618b
nishpatel512/Python-Project-
/Signup.py
3,428
3.890625
4
import tkinter as tk import datetime import sys import os now = datetime.datetime.now() signup = tk.Tk() signup.geometry("1000x500+200+50") we=tk.Label(signup,text="WELCOME TO EXTREME BANKS!!",font=("Helvetica",25)) we.pack() i=tk.Label(signup,text="What is your name?",font=("Helvetica",15)) i.place(x=0,y...
53d82adce930cd7db287781196aa2b311163a712
carvey/AdventofCode2020
/day1/sum2020.py
540
3.609375
4
import sys from functools import reduce from itertools import combinations entries_fle = open(sys.argv[1]) combination_size = int(sys.argv[2]) entries = entries_fle.read().strip().split('\n') entries_fle.close() entries = [int(entry) for entry in entries] combinations = combinations(entries, combination_size) sums...
77a86cab71e89a5d40408a35a8c2bff67e099c2b
ogama8/adventofcode2015
/day5/part1.py
629
3.546875
4
import sys doubles = ['aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh', 'ii', 'jj', 'kk', 'll', 'mm', 'nn', 'oo', 'pp', 'qq', 'rr', 'ss', 'tt', 'uu', 'vv', 'ww', 'xx', 'yy', 'zz'] bad = ['ab', 'cd', 'pq', 'xy'] f = open('input.txt', 'r') nice = 0 for line in f: vowels = 0 double = 0 good = 1 for c ...
a140a287689dfeca042621a97465e7299c50686b
Fathima7391/PYTHON-LAB
/leapyear.py
197
4.1875
4
year=int(input("Enter the year to be checked:")) if (year%400==0 or (year%100!=0 and year%4==0)): print("The year is a leap year !") else : print("The year is not a leap year !")
cb0fc0c158e2d42ab57c58ca1e668955bfd26d01
FOSS-UCSC/FOSSALGO
/algorithms/ar-slpsrt/python2/sleep_sort.py
423
3.828125
4
from time import sleep from threading import Timer def sleepSort(values): sortedList = [] def add(x): sortedList.append(x) maxVal = values[0] for value in values: if maxVal < value: maxVal = value Timer(value, add, [value]).start() sleep(maxVal+1) return sortedList lst ...
453a81b22cae1a60af237b7dbcdcd91dc8cb2c14
yli166/lintcode
/majority element II.py
1,821
3.9375
4
class Solution: """ @param nums: A list of integers @return: The majority number occurs more than 1/3 """ #这种投票法先将第一个数字假设为众数,然后把计数器设为1,比较下一个数和此数是否相等,若相等则计数器加一,反之减一。然后看此时计数器的值,若为零,则将当前值设为候选众数。 #这么苛刻的限制条件只有一种方法能解了,那就是摩尔投票法 Moore Voting,这种方法在之前那道题Majority Element 求众数中也使用了。 # 题目中给了一条很重要的提示,让我们先考...
f0dc52f4088fe5348f95d200ff3515da2c480456
yzl232/code_training_leet_code
/Word Pattern.py
1,238
4.0625
4
''' Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str. Examples: pattern = "abba", str = "dog cat cat dog" should return true. pattern = "abba", str = "dog cat cat fish...
2a563812ace3f00af5fc0295b2b1fe1f23c3a30f
ramonvaleriano/python-
/Livros/Introdução à Programação - 500 Algoritmos resolvidos/Capitulo 4/Exercicios 4a/Algoritmo218_Para45.py
242
3.8125
4
# Program: Algoritmo218_Para45.py # Author: Ramon R. Valeriano # Descritption: # Developed: 02/04/2020 - 21:34 # Updated: current = 12 for e in range(current): name = input("Enter with your name: ") name = name.upper() print(name[0], "\n")
8884b1f7afde238e77f990e6b2c3a812a3fe9a66
alexcarcar/WebLayout
/app/src/main/assets/jsexamples/py/ch11/examples.py
2,461
3.875
4
# Basics (p 121) eng2sp = dict() print eng2sp # {} eng2sp['one'] = 'uno' print eng2sp # {'one': 'uno'} eng2sp = { # stored in a different order... 'one':'uno', 'two':'dos', 'three':'tres' } print eng2sp # {'three': 'tres', 'two': 'dos', 'one': 'uno'} print eng2sp['two'] # dos try: print eng2sp['four'] except Exce...
0f0e4b88b26e2dd59ec0e57b9aa8450d10ced378
ravi4all/PythonMorningReg_10-12
/01-BasicPython/07-ForLoop.py
113
3.734375
4
a = [1,2,3,4,5,6,7,8,9] for i in a: print(i,"is the value") b = 'Hello' for j in b: print(j)
438e5b1e10aaaee48aea63dcd85174229a08fb93
n18020/programming-term2
/src/basic-c3/inzei.py
611
3.765625
4
#印税を計算する関数 def calc_royalty(price, sales, per): rate = per / 100 #印税率(ここでは10)を100で割る ro = int(price * sales * rate) #定価と発行部数と印税率をかけて、それを整数にする return ro #ユーザから情報を入力してもらう i = input('定価は?') price = int(i) i = input('発行部数は?') sales = int(i) i = input('印税率(パーセント)は?') per = float(i) #結果を表示する v = calc_royal...
0fac96a4de1c80d8bb294f504b1c79e569521330
Abhiii5540/Python-programs
/input.py
132
3.765625
4
a = input("Enter a number: ") a = int(a) # Convert a to an Integer(if possible) print(type(a)) b = input("Enter a name: ") print(b)
41dfce64eb50f999e39cecf7c30b01a36ffb18cb
mahim007/complete-python
/Python Basics/Touple.py
328
3.8125
4
my_touple = (1, 2, 3, 4, 5, 3) print(my_touple) print(my_touple.index(3)) print(my_touple.count(3)) name = 100 my_data = { name: 'mahim', 'age': 25, True: [1, 2, 3], (1, 2, 3): (1, 2, 3, 4, 5) } print(my_data[(1, 2, 3)][0:3]) new_touple = my_touple x, y, z, *others = new_touple print(x, y, z) print(...
48fac62e8f85e76dd9611f5296f5b7d419cd8e6d
CUGshadow/Solution_to_Daniel_Liang_python_exercises
/chapter4/4.4.py
261
3.734375
4
import random number1, number2 = random.randint(0, 99), random.randint(0, 99) answer = eval(input("What is the sum of " + str(number1) + " and " + str(number2) + " : ")) print("The sum", number1, "+", number2, "=", answer, "is", number1 + number2 == answer)
9b5678c56657d58cf9d2a74391329fbb2049d29a
chenxy3791/leetcode
/No1027. Longest Arithmetic Subsequence.py
2,072
3.796875
4
# -*- coding: utf-8 -*- """ Created on Sat Apr 22 10:15:46 2023 @author: chenxy 1027. Longest Arithmetic Subsequence Given an array nums of integers, return the length of the longest arithmetic subsequence in nums. Note that: A subsequence is an array that can be derived from another array by deleting some or no el...
6a55b9b347f57a797a0673dc447e0dcf22d2be44
Gitus-Maximus/Skills
/python_basics/Trójkąty.py
1,269
3.671875
4
import math op = "t" #Deklarujemy i inicjujemy zmienną pomocniczą while op != "n": #dopóki wartość zmiennej jest inna ni n wykonuj pętle dane = input("Podaj 3 boki trójkąta (oddzielone przecinkami): ") lista = [] #definiujemy pustą listę for x in dane.split(","): lista.append(int(x)) a, b, c...
04e01fdff98d8e97859862a1163c557c6b9ba51b
alexandralevacheva/laboratornye
/sortirovki.py
1,911
3.796875
4
from random import randint a = [] for i in range(15): a.append(randint(0, 15)) print("1) Сортировка пузырьком") print("2) Сортировка вставками") print("3) Сортировка Шелла") print("4) Быстрая сортировка") print("Выберите вид сортировки:") vid = input() print("Изначальный вид списка - ", a) def ...
8152f9245993a484c75f3b92d31591eba850b2a1
collinwzw/APS1080
/A1/A1.py
4,743
3.5625
4
import gym import numpy as np gym.envs.register( id='FrozenLakeNotSlippery-v0', entry_point='gym.envs.toy_text:FrozenLakeEnv', kwargs={'map_name' : '4x4', 'is_slippery': False}, max_episode_steps=100, reward_threshold=0.74 ) # Create the gridworld-like environment env=gym.make('FrozenLakeNotSlipper...
f6f02170a57bcfa2268164ab4007063b44eef7cf
GerryMijarry/dino_vs_robots_project
/Battlefield.py
2,631
3.671875
4
from fleet import Fleet from herd import Herd import random class Battlefield: def __init__(self): self.fleet = Fleet() self.herd = Herd() def run_game(self): self.display_welcome() self.battle() self.display_winners() def display_welcome(self): print("Welc...
6402f0d53dadc89aa91cfda4c44b699fc653f84f
draju1980/Hello-World
/fun_list_avg.py
264
4.21875
4
#Write a function that accepts a list of integers and returns the average. #Assume that the input list contains only numbers. def list_avg(mylist): sum=0 for item in mylist: sum=sum+int(item) result=(sum/len(mylist)) return result
9b8690aa821b1a1c78d519446248b7257acadec0
pola5pola5/edu90_python
/atcoder002.py
1,537
3.5
4
""" 長さ N の正しいカッコ列をすべて、辞書順に出力してください。 ただし、正しいカッコ列は次のように定義されています : () は正しいカッコ列である S が正しいカッコ列であるとき、文字列 ( +S+ ) は正しいカッコ列である S,T が正しいカッコ列であるとき、文字列 S+Tは正しいカッコ列である それ以外の文字列はすべて、正しいカッコ列でない 4 ()() (()) """ # 小さい制約は全探索 # 二進数に置き換える(bit全探索) # ・(と)の数が同じ # ・全てのiについて左からi文字目までの時点で(の数が)の数以上 # 上記2点を満たすのが必要十分 def hantei(S: str) -> boo...
6934796d978067d665a6ad6ee0a8b95cce5c4c34
KurinchiMalar/DataStructures
/Sorting/MaxRepeatedElement.py
4,250
3.8125
4
#Complexity Analysis Chart - http://bigocheatsheet.com/ #Naive n*n solution --> for every element i, go through i+1 to end and increment counter. #Sorting Solution from HeapSort import Heap ob = Heap() def get_max_repeated_element_SortAndScan(Ar): max_counter = -1 ob.heapList = Ar ob.HeapSort(0,len(Ar)-1) ...
ddde332d84d9c6160dfe5cf101bbcc6248787543
nawonda/Leetcode-Solution
/2_Array(Math)/M.3Sum.py
775
3.65625
4
''' Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. For example, given array S = {-1 0 1 2 -1 -4}, (-1, 0, 1) (-1, -1, 2) ''' def tree_sum(A): if len(A) < 3: return A.sort() solution =...
f235f9f6cb222cb11bc71b921db30b55e61e8a49
befreeman/advent-of-code-2016
/day1/do_puzzle_one.py
466
3.9375
4
""" Complete the puzzle! """ from puzzle_one import Navigate # create the navigator! nav = Navigate() # for each direction in the data file for direction in open('puzzle_one_data.txt', 'r').read().split(' '): distance = int(direction[1:-1]) if direction[0] == 'R': nav.travel_right(distance) else:...
dac31bf3799d89403c89713da954d4b377d0961e
daniel-reich/ubiquitous-fiesta
/6kseWBaSTv6GgaKDS_0.py
157
3.78125
4
def next_letters(s): if not s: return 'A' elif s[-1] == 'Z': return next_letters(s[:-1]) + 'A' else: return s[:-1] + chr(ord(s[-1]) + 1)
f44b71e94ff52e814b62ef6ecc7c1b1d097607dd
renato04/sudoku
/sudoku_row.py
602
3.625
4
class SudokuRow(list): def __init__(self, size = 0, values = None): if values is None: list.__init__(self, [0] * size) else: list.__init__(self, values) def is_repeated(self): for i, val in enumerate(self): if self.count(i + 1) > 1: ...
b6667b44425b2dfeef08c0b6633b3f1ccb4d7c16
vernittyagi/General-Algorithms
/Bubble_sort.py
634
4.1875
4
# Program for Bubble sort #defining the function def sort(num): for i in range(len(num)-1,0,-1): for j in range(i): if num[j] > num[j+1]: temp = num[j] num[j] = num[j+1] num[j+1] = temp num= [55,58,69,35,147,25] #To test this for random input arra...
dd5bfb9af4191a8da8a0b3b54cbc6b19161694fc
zhoujf620/LeetCode-Practice
/Python/283.move-zeroes.py
1,596
3.65625
4
# # @lc app=leetcode id=283 lang=python # # [283] Move Zeroes # # https://leetcode.com/problems/move-zeroes/description/ # # algorithms # Easy (55.49%) # Likes: 2554 # Dislikes: 91 # Total Accepted: 562.1K # Total Submissions: 1M # Testcase Example: '[0,1,0,3,12]' # # Given an array nums, write a function to mov...
96b7de161899783b6bff841400056ea113a30df1
54shady/py3
/chapter3/guess_number.py
558
3.90625
4
#!/usr/bin/env python import random secretNumber = random.randint(1, 20) print('Guess a number in [1, 20]') # Ask the player to guess 6 times for guessesToken in range(1, 7): print('Take a guess[%d].' % guessesToken) guess = int(input()) if guess < secretNumber: print('> %d' % guess) elif gu...
ac2778eddf52c5e0d52ccd30465491729a726f6e
timothyyu/python-practice
/python_for_everybody/ch4_ex7_computegrade.py
761
4.5625
5
# Excercise 4, Ch. 4 Pg. 55, Python For Informatics v3 # Rewrite the grade program from the previous chapter using a function # called computegrade that takes a score as its parameter and returns # a grade as a string score = input("Enter a numeric grade from 0 to 100: ") def computegrade(score): score = float(s...
30bf0eb88547da29927c40f5fe8328ec245e4b7d
dojo-se/descubra-o-assasino
/assassino.py
4,809
3.875
4
# coding=utf8 # Esqueleto de código Python para uso no Dojo-SE # Escrito por Wagner Luís de Araújo Menezes Macêdo <wagnerluis1982@gmail.com>. # # Para executar os testes, chame o interpretador Python com esse arquivo como # parâmetro. Ex: python <caminho_do_arquivo> import unittest import random from testemunha impo...
82a4c5141ebbc1ef651392662028a7e8080f4c89
anmapie/advent-of-code
/2020/day1/day1.py
3,452
4.09375
4
# --- Day 1: Report Repair --- # After saving Christmas five years in a row, you've decided to take a vacation at a nice resort on a tropical island. Surely, Christmas will go on without you. # The tropical island has its own currency and is entirely cash-only. The gold coins used there have a little picture of a star...
91f40442e62b37c1d9fc0c8bac755c19054e88ec
zhengjiani/pyAlgorithm
/leetcode/prac14.py
960
3.671875
4
# -*- coding: utf-8 -*- # @Time : 2019/5/27 14:46 # @Author : zhengjiani # @Software: PyCharm # @Blog :https://zhengjiani.github.io/ """ 字符串的最小表示法的概念。我们需要求一个字符串的循环同构体中最小字典序的那个。 比如bcda的循环同构体有bcda,cdab,dabc,abcd,其中最小表示法是abcd。 """ #字符串的最小表示法 def find_min(s): i = 0 #起始指针 j = 1 #指向第一位 k = 0 #匹配长度 siz...
f8e47f3c865e48d1e0261ebf3a7a012c6860ca20
cleitonkn/CursoemVideo
/Desafio024.py
406
4.03125
4
# crie um programa que leia o nome de uma cidade e diga se ela começa #ou não com o nome "SANTO". # primeiro modo ( Curso em video) cid = str(input('Em que cidade você nasceu? ')).strip() print(cid[:5].upper() == 'SANTO') # segundo modo ( Meu) a = str(input('Digite o nome da sua cidade: ')).strip() b = a.upper() c = ...
56aff0499981f4dd969f147676bfc710301f5cd8
AnwarKoromah/210CT-CW
/Week 4.py
1,156
3.90625
4
a = input("Please enter a list: ") lis = list(a) low = int(input("Please enter your low number: ")) high = int(input("Please enter your high number: ")) eList = [] def searchAlgorithm(lis, high, low, eList): stop = False for i in range(low, high+1, 1): eList.append(i) for a ...
b78c0929a3c461dba49a68e3c5b2b061d56428f9
duanmao/leetcode
/809. Expressive Words.py
790
3.640625
4
class Solution: def expressiveWords(self, S: str, words: List[str]) -> int: def stretch(t, w): # t as target ptr = 0 count = 0 for i, c in enumerate(t): if (ptr < len(w) and c == w[ptr]): ptr += 1 else: ...
e68569049940e4831c51076fba0cd036523aa552
Hrishikesh-3459/leetCode
/prob_2a.py
1,676
3.609375
4
class ListNode: def __init__(self, x): self.val = x self.next = None def addTwoNumbers(l1, l2): l1_list = [] currentNode = l1 while True: l1_list.append(currentNode.val) if(currentNode.next == None): break else: currentNode = currentNode....
ec7d30e415761da751fb76b86617148c0bb00d75
Whiteyingshan/pythonClass
/Exercise 1/6-8.py
430
3.671875
4
def Freq(line): dic = dict() for i in line: if dic.__contains__(i): dic[i] += 1 else: dic.update({i: 1}) n = len(dic) num = 0 print(n) for i in sorted(dic): num += 1 if num == n: print("{} = {}".format(i, dic[i]), end='') ...
6878420b97d3ade2dcdd8065ebb161e3262777a4
Shreiya/coderama
/week1-python/lists.py
675
3.90625
4
my_list = [1, 2, 3, 4, -3] my_list = list([3, 4, 5]) my_list = list() my_list.append(7) print my_list print len(my_list) b = [8] c = my_list + b print c c.append(3) print c c.insert(1, 1000) print c #slice me up print c[1:] print c[1:3] print c[-1] #since no colon, it'll only return an element print type (c[-...
49adf3b60ef83dd9c4416b1fbb179c752641ea6d
bigtone1284/hackerRank
/find_point.py
1,064
3.765625
4
"""======================================================================================================================== Problem statement Given two points P and Q, output the symmetric point of point P about Q. Input format: The first line contains an integer T representing the number of testcases (T <= 15) Ea...
a141390a16af10771e21f3b6b0b828f5b5454758
UWPCE-PythonCert-ClassRepos/SP_Online_PY210
/students/mattcasari/lesson01/logic-2/round_sum.py
238
3.796875
4
#!/usr/bin/python # -*- coding: utf-8 -*- def round_sum(a, b, c): return round10(a) + round10(b) + round10(c) def round10(num): if 5 <= (num % 10): return num + 10 - (num % 10) else: return num - (num % 10)
6c7a7be02dd3ead48352501781412a385ad139f4
jeniia/Python_Basic_SoftUni_2021
/Conditional Statements/Lab/P07Toy_Shop.py
714
3.59375
4
trip_price = float(input()) puzzles_count = int(input()) dolls_count = int(input()) teddy_bears_count = int(input()) minions_count = int(input()) trucks_count = int(input()) profit = (puzzles_count * 2.60) + (dolls_count * 3) + (teddy_bears_count * 4.10) + (minions_count * 8.20) + ( trucks_count * 2) total...
e96490230af1624df3e3da25085ed22a3fb6af24
jinseok9338/PopulationModel
/animal.py
16,634
3.5
4
from random import choice, randint,getrandbits from map import Map class Animal: class_counter = 0 def __init__(self,map): self.hunger = 0 self.thirst = 0 self.day = 0 self.age = int(0/365) self.sex = bool(getrandbits(1)) self.sexual_drive = 0 self.map = ...
7e49b3938f834465be5a6f21ce93237531d982eb
Yucheng7713/CodingPracticeByYuch
/Easy/844_backspaceStringCompare.py
388
3.765625
4
class Solution: def backSpacing(self, s): result = [] for l in s: if l != '#': result.append(l) elif l == '#' and result != []: result.pop() return ''.join(result) def backspaceCompare(self, S, T): return self.backSpacing(S)...
1a4b0a31016ee19c394e8ac026aaa5a544836173
FGPortales/PythonCourse2
/Funcionalidades_avanzadas/funciones_generadoras.py
726
4
4
def main(): """Funcines Generadoras""" # my_list = [numero for numero in [0, 1, 2, 3, 4, 5] if numero % 2 == 0] # print(my_list) # my_list = [numero for numero in range(0,6) if numero % 2 == 0] # print(my_list) def pares(n): for numero in range(n+1): if numero % 2 == 0: ...
aa1ad7444f47a617ec5f4b818cc846e8b0bba1e8
MaertensArthon/BP_Personal
/Oef_02.py
432
3.546875
4
#Oef 02 Aantal seconden dagen = input("Geef het aantal dagen op: ") uren = input("Geef het aantal uren op: ") minuten = input("Geef het aantal minuten op: ") seconden = input("Geef het aantal seconden op: ") dagen = int(dagen) uren = int(uren) minuten = int(minuten) seconden = int(seconden) Totaal = dagen*24*60*60 +...
34ab8e21c0f54b04567d16b322cde3fb2162d1bf
sundogrd/tensorflow_end2end_speech_recognition
/utils/training/learning_rate_controller.py
2,454
3.578125
4
#! /usr/bin/env python # -*- coding: utf-8 -*- """Decay learning rate per epoch.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function class Controller(object): """Controll learning rate per epoch. Args: learning_rate_init: A float value, the...
d9d9d57c1c491e680c6467aeb1cc2ebbc9a211b0
supriadi-yusuf/python-GUI
/extends/stacking.py
335
3.515625
4
import tkinter layar = tkinter.Tk() layar.title("window utama") layar.geometry('400x400') lb1 = tkinter.Label(master=layar,text='contoh', relief='raised') lb1.grid(column=0,row=0) lb2 = tkinter.Label(master=layar,text='selamat malam', relief='raised') lb2.grid(column=0,row=0) layar.after(5000,lambda:lb1.lift()) la...
e60e0afbe8cec0f8adc72775201aeee444b9e267
Evantopian/Python1n2_HS
/labs/hourly/main.py
198
4
4
Hours = float(input("How many hours did you work?")) Pay = float(input("What is your hourly pay?")) Total = float(Hours*Pay) print (("You get paid $")+ str(Total) + (" in ")+str(Hours)+ (" hours."))
d51c609eed6f88536736b45bc2afefc62f0e7d24
Tigge/advent2019
/days/day2.py
1,799
3.609375
4
from itertools import product def parse_input(f): return list(map(int, f.read().split(','))) def solve(initial_program): prepared_program = apply_noun_verb(initial_program, 12, 2) test_program = run_program(prepared_program, 0) input_pair = search_for_output(initial_program, 19690720) return [g...
1b12fd38653f3f89b2125053102f93b97ef36950
tmorriso/Computer_Science
/Recitations/PowerFactor.py
614
4.09375
4
# Thomas Morrison # August 28, 2015 # Assignment 1 Part 2 # Power Factor Problem import math kW = int(input("Enter the real power:")) # Real Power kVAr = int(input("Enter the reactive power:")) # Reactive Power pF = kW/(math.sqrt(math.pow(kW,2)+math.pow(kVAr,2))) #power factor final = round(pF,4)*100 print ("The...
0738cfb0ae2fb7e436521eab2734e1b480ac5155
soar1966/PythonTWII_1101026
/Python基本語法/Test07.py
413
4.0625
4
if __name__== '__main__':#主程式開始 x = True y = False z = False if not x or y: print(1) elif not x or not y and z: print(2) elif not x or y or not y and x: print(3) else: print(4) print("not x or y:=>",not x or y) print("not x or not y and z:=>", not x or...
8d7d55237031e141071ae84f5f86300a56d49bc9
angelm1974/PythonOlsztyn
/D1/wprowadzanie_danych.py
310
3.625
4
import math # wyświetlenie pytania i pobranie danych do zmiennej a a = input("Podaj swoje imię: ") print(f'{a} - jest fajnym gościem!!!') # wyświetlenie odpowiedzi promien = float(input('podaj promień:')) # print('pole kola wynosi: ', 3.14*promien**2) print(f'pole kola wynosi: {math.pi*promien**2}')