blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
e68dea6c5620f5fdcb0b46f916f2fb5b9ca72540
MrNullPointer/AlgoandDS
/Udacity_NanoDegree/Recursion_revisited/Intro.py
637
3.921875
4
def power_of_2(input): if input <= 0: return 1 output = power_of_2(input - 1) return 2 * output def sum_of_integers(input): if input <= 0: return 0 return input + sum_of_integers(input - 1) def sum_array(array): if len(array) <= 0: return 0 first_elem = array[0] ...
0f4ac3d796e581f45a53da2b9a217ea22f2b3ca5
Gauri69Gupta/python
/file.py
1,042
3.71875
4
print("Question1") n=int(input("Enter the number of lines: ")) with open("1.txt", "r") as text_file: contents = text_file.readlines()[-n:] for line in contents: print(line) print('*'*10) print('\n') print("Question2") file=open("1.txt","r+") wordcount={} for word in file.read().split(): if word n...
0c017617ba8c27d9a7848d376ba17e0005d8e08c
Fuddlebob/CGAAPIMM
/transform/mirror.py
1,047
3.5625
4
from . import abstractTransform from helper import * import cv2 import numpy as np import random class mirrorTransform(abstractTransform.abstractTransformClass): def name(): #short form name for the transform return "Mirror" def description(): #return a brief description of what the transform doe...
29fa4d91b9e3c4def2e17f0927f0c32b5ffc5929
vain01/pythonlearning
/grammar/continue_7_7.py
288
3.984375
4
running = True while running: s = input('输入字符串:') if s == 'exit': running = False if s == 'quit': break if len(s) < 3: print('Too small') continue print('输入的长度足够') else: print('循环结束') print('结束')
7d31bc9626ef38efc837f3d97cae423213abe7fe
RubeusH/Python_Learning
/Chapter-02/Programming-Exercises/programming-exercise-2-08.py
309
3.78125
4
TIP = 0.18 TAX = 0.07 total_amount = float(input("How much is the total: ")) tip = TIP * total_amount tax = TAX * total_amount print("GRAND TOTAL = $" + format(total_amount+tip+tax,'.2f'), "\n\tPURCHASE = $" + format(total_amount, '.2f'), "\n\tTIP = $" + format(tip,'.2f'), "\n\tTAX = $" + format(tax,'.2f'))
874d55111c478dbdef223547238e8300e1590848
harshit3012/AI_Lab
/Lab 1/ticTacToe.py
4,242
3.515625
4
import random import colorama from colorama import Fore, Style board = [' ' for _ in range(10)] user_char = '' comp_char = '' def printBoard(board): global user_char, comp_char print("\033c", end="") print(Fore.GREEN + 'Tic Tac Toe! \n') print(Fore.WHITE + f'Your player : {user_char}') print(f'Co...
06207118a538a9fdaa5042bee37639d741d1a777
preetkd/Mile7
/Package4Image.py
1,697
3.59375
4
# Downloading Zip file from URL from urllib.request import urlopen from zipfile import ZipFile import re # Function to Unzipfile defining upload path def FileDwnLdFun(path): zipurl = path # Download the file from the URL zipresp = urlopen(zipurl) # Create a new file on the hard drive tempzi...
265e7b26d9866f09b8da9342e0683841100d7e0a
jiyiyun/programing
/python3/follow_laoqi/part4_Classes/class_Inheritance.py
389
3.875
4
__metaclass__ = type class Person: def speak(self): print "This speak is in class not inheritance" def setHeight(self): print "old calss 216 cm" def weight(self): print "weight is old class 60 kg" class man(Person): def setHeight(self): print "The height is new 199,not father_class" if __name__ == "__m...
36c583032a301779b7a8f71bd2ef9c7727c51130
feverrro/Python
/sorting.py
976
3.53125
4
# li = [9,1,8,2,7,3,6,4,5] # s_li = sorted(li, reverse=True) # print('Sorted Variable:\t', s_li) # li.sort(reverse=True) # print('Original Variable:\t', li) # tup = (9,1,8,2,7,3,6,4,5) # s_tup = sorted(tup) # print('Tuple\t',s_tup) # di = {'name': 'Corey', 'job': 'programming', 'age': 'None', 'os': 'Mac'} # s_di = so...
6ac3da8f43f1900e3393fb0a6f8e8edd4b3c7c93
Nzadrozna/main
/labs/04_conditionals_loops/03_06_while.py
185
4.0625
4
''' Use a "while" loop to print out every fifth number counting from 1 to 1000. w ''' # start at one then go up by 5 till 1000 # n = 0 while n < 1000: n = n + 5 print (n)
10c7208d814939c47c571e3f2ef6d6782f526484
chrisglencross/advent-of-code
/aoc2021/day2/day2.py
866
3.796875
4
#!/usr/bin/python3 # Advent of code 2021 day 2 # See https://adventofcode.com/2021/day/2 import re with open("input.txt") as f: lines = f.readlines() def follow_commands(lines, forward, depth): p, d, aim = 0, 0, 0 for line in lines: match re.search("^([a-z]+) ([0-9]+)$", line.strip()).groups(): ...
ee26fd79baf700f7cf201916352f41c9874eb835
mdjukic/repos
/q_python_scripts/return2.py
1,148
4.09375
4
# Returning values # like python's built-in str() function, which returns a string # representation of the value specified as its argument by the caller # custom functions from __future__ import print_function import os import sys from datetime import datetime def main(args): num = str(raw_input('Enter an Intger:') ...
870b8f2dbe5a2803e2e61fa49aa5bd8b7384dfc3
AdarshRazor/Cracking_Coding_Interview
/Codes and Implementation/Chapter 2 - Linked Lists/2.KthtoLast.py
1,285
4.0625
4
import os os.system('cls') class Node: def __init__(self,data): self.data=data self.next=None ''' find the kth to last element of a singly linked list. ''' class LinkedList: def __init__(self): self.head=None def appendnode(self,data): New_Node = Node(data) if...
a789d39572bbd832bfb9e9a7caa545f245cf1322
maxoyed/CQU_2021_Spring_Python018
/题库/第六章练习(分支、循环)/编程题/18.加密数据.py
173
3.578125
4
raw_number = [int(i) for i in list(input())] password = [(i + 5) % 10 for i in raw_number] password.reverse() password = [str(i) for i in password] print(''.join(password))
e8d0f7b265e5966e4d495f63f269d7dc53cef6d3
zcg741/leetcode
/python-leetcode/src/string/titleToNumber.py
718
3.515625
4
# 给定一个Excel表格中的列名称,返回其相应的列序号。 # # 例如, # # A -> 1 # B -> 2 # C -> 3 # ... # Z -> 26 # AA -> 27 # AB -> 28 # ... # # # 示例 1: # # 输入: "A" # 输出: 1 # # # 示例 2: # # 输入: "AB" # 输出: 28 # # # 示例 3: # # 输入: "ZY" # 输出: 701 # # 致谢: # 特别感谢 @ts 添加此问题并创建所有测试用例。 # class Solution: def titleToNumber(self, s...
051972eda0f011b6344b0accd76bc4baa79f455e
tr0ublye/strukturnoe
/lab3/5.py
119
3.59375
4
import math n=int(input("vvedi n: ")) m=int(input("vvedi m: ")) s=sum(i*i for i in range(n, m+1)) print (s)
627a4dd615278850dee1f2052907ae5072aee276
Myles-Trump/ICS3U-Unit4-03
/main.py
930
4.5
4
#!/usr/bin/env python3 # Created by: Myles Trump # Created on: May 2021 # This program uses a while loop to solve the power of ever number # up to the inputted number def main(): # this function uses a while loop to solve the power of ever number # up to the inputted number # this is to keep track o...
044c8140323d0dcc1fe8190c0beccb2e68823c3a
maxwell-carmichael/chess_ai
/MinimaxAI.py
4,537
3.625
4
# Maxwell Carmichael, 10/10/2020, Modified from CS76 Material import chess import math import random class MinimaxAI(): def __init__(self): self.depth = 3 # Constant self.nodes_visited = 0 # will reset after each move. self.random_factor = 0.1 # the percent chance that an as-good move ove...
7e1bf8ced55312d987b87c316ff68d3647457e8f
Nehanavgurukul/list
/palindrome1.py
227
4.03125
4
first_list=[1,2,3,4,5,4,3,2,1] last_list=[] i=len(first_list)-1 while(i>=0): last_list.append(first_list[i]) i=i-1 if(first_list==last_list): print("it is palindrome") else: print("it is not palindrome")
a5f98a800bd485f463f73f9259bb42eba217fd8c
PriyanSiva/pong-game
/pong.py
1,410
3.796875
4
import turtle wn = turtle.Screen() wn.title("pong") wn.bgcolor("black") wn.setup(width=800, height=600) wn.tracer(0) # Paddle A paddle_a = turtle.Turtle() paddle_a.speed(0) paddle_a.color('white') paddle_a.shape('square') paddle_a.shapesize(stretch_wid=5, stretch_len=1) paddle_a.penup() paddle_a.goto(-350, 0) # Padd...
043b958842f998dbfa9dfb5efe5a634923a29058
tutuba13/Python-Summary
/Map, Filter, Zip and Reduce/Zip(put together two iterables for example two lists).py
513
4.5625
5
print("Zip Function") print("Put together two iterables, for examples: link two lists together") first_list = [1, 2, 3] second_list = (9, 6, 3) # It can put lists, tuples, sets together third_list = [7, 10, 8] print(list(zip(first_list, second_list, third_list))) print("Sorting with the second element") a=[(0,2),(9,9...
971a83f9a8277f35199c048fcdf7ec3b0da5cec6
wererLinC/Python-Learning
/python基础/06_sort.py
416
3.78125
4
# sort cars = ['bmw', 'audi', 'toyota', 'qiaoke'] print(cars) cars.sort() print(cars) # reverse = True cars = ['bmw', 'audi', 'toyota', 'qiaoke'] print(cars) cars.sort(reverse = True) print(cars) # sorted cars = ['bmw', 'audi', 'toyota', 'qiaoke'] print(cars) print(sorted(cars)) # reverse cars = ['bmw', 'audi', ...
c0895a46cc272b0a44ad45b627c8fbc4465f9eaa
GingerWWW/python
/多态.py
658
3.609375
4
class Vehicle: def __init__(self, number='12345', admin='Xiaoming'): self.number=number self.admin=admin def load(self,origin, destination): print(origin) class Track(Vehicle): def load(self, weight, origin, destination): print('载货重量:%s,出发地:%s,目标地:%s'%(weight,origin,...
db88287e1c5352afc2d6d5cc68dba9fdef8a3c29
sivakumargsk/python-programs
/sorting algorthims functions.py
1,924
4.28125
4
def selection_sort (a): for i in range (len (a)): mini = i for j in range (i, len(a)): if (a[j] < a[mini]): mini = j temp = a[i] a[i] = a[mini] a[mini]= temp return a def insertion_sort (a): for i in range (len (a)): if (a[i] < a[...
594701cce3d2c2e7f5586eb058522f993c95d3d2
Zichuanyun/go-shuati
/chunlin/98.py
1,149
3.8125
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def isValidBST(self, root): """ :type root: TreeNode :rtype: bool """ (isValid, _...
eda8434966532cc89b6c679c35424fd6e6455fbf
sanchit-ahuja/cppcode
/PythonCode/blank.py
862
4.0625
4
#Create a sequence from 100 to 999 three_dig_seq = range(999, 99) # and an empty list for the palindromes list_palindromes = [] # loop twice over the number sequence for n1 in three_dig_seq: for n2 in three_dig_seq: # Get the product number = n1 * n2 # Transform it in string number...
d3cc9d16f82db744ffbae2c7085035e743c00bde
pbskumar/GraphSearches_py
/uninformedSearches.py
14,534
4.125
4
import pprint from copy import deepcopy class Graph: """ Graph Class represents all variations of the Graph Data Structure in the form of a dictionary Weighted/Uniform paths, Directed/Bi-directional Graphs Ex: Directed path from node 'A' to 'B' with path cost 'c' is represented as follows: ...
91d6de231249af2f23d696ce983df04476ceb273
SlaviSotirov/HackBulgaria
/week_0/day_1/sum_dig.py
213
3.921875
4
def sum_of_digits(n): sum = 0 n = abs(n) while n: sum += int(n) % 10 n = int(n) / 10 return sum def main(): print (sum_of_digits(12)) if __name__ == '__main__': main()
d86353a283122471c0d22ec6abeb79e375eb69d9
Sen2k9/Algorithm-and-Problem-Solving
/leetcode_problems/207_Course_Schedule.py
2,279
4.09375
4
""" There are a total of numCourses courses you have to take, labeled from 0 to numCourses-1. Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair: [0,1] Given the total number of courses and a list of prerequisite pairs, is it possible for yo...
baed068c4294cab0942444b6d3df70dff2ed3228
aerialboundaries/python_practice
/automate/7-Project3-Strip.py
393
3.859375
4
#!/usr/bin/env python # Project 7-3 Strong Regex Version of the strip() Method import re testWord = 'aabbcc-abc-aabbcc' def spritRegex(word, remove=' '): stripRegexL = re.compile(r'(^[' + remove + ']*)') stripRegexR = re.compile(r'([' + remove + ']*$)') result = stripRegexL.sub('', word) result = s...
52e03e7e317d293e03a3f2156bf1487431132bfa
green-fox-academy/sara2585
/week02/day-2/copy_file.py
631
3.734375
4
# Write a function that copies the contents of a file into another # It should take the filenames as parameters # It should return a boolean that shows if the copy was successful def copy_file(copyfromfile,copytofile): try: f1 = open(copyfromfile, "r") f2 = open(copytofile, "w") contents =...
1caa0140a669e118b24fe7cf4b6ad4e0a5a15ceb
alinedsoares/api-biblioteca
/clientes.py
464
3.5
4
import encargos class Cliente: def __init__(self, id_cliente, id_livro_emprestado): self.id_cliente = id_cliente self.id_livro_emprestado = id_livro_emprestado clientes = Cliente(0, 22) if clientes.id_livro_emprestado is not None: #TODO: O RETORNO ESTÁ CONFLITANDO COM A ESTRUTURA CON...
98c05f524f363ba2ae850eef7e0d7c76f1c559f3
lcxstar/Hello-World
/1.tkinter基础学习/1.1设置窗口大小及位置.py
812
3.921875
4
# GUI(Graphical User Interface)意为图形用户界面,tkinter 提供的该功能 # Tk的功能是设置主窗口 from tkinter import Tk # 显示窗口 my_window = Tk() # 标题 my_window.title('我的窗口') # 设置窗口居中 # (1)获取当前屏幕大小 screen_width, screen_height = my_window.maxsize() # (2)设置窗口的大小 width = 480 height = 480 # (3)geometry函数只能识别字符串,所以对数据进行封装 align_str = '%dx%d+%d+%d'%(w...
98cb595b32ef616efe03b08e69ba316aaed0e3db
shinkai-tester/python_beginner
/Lesson6/tic_tac_toe2.py
777
3.546875
4
FieldSize = 3 field = [['*' for i in range(FieldSize + 1)] for k in range(FieldSize + 1)] command = input() while command != 'Stop': x, y = [int(i) for i in input().split()] if x > len(field) - 1 or y > len(field) - 1: print('Такой координаты не существует!') else: if fi...
d8fa6fc536ed8bfe88a9375f48d387116134969a
pradyumnakr/Python_code
/newtonraphson.py
350
3.734375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Jan 26 22:59:53 2018 @author: pradyumna """ epsilon=0.01 y=30 guess=y/2.0 numGuesses=0 while abs(guess*guess -y)>=epsilon: numGuesses+=1 guess=guess-(((guess**2)-y)/(2*guess)) print("numGuesses= "+str(numGuesses)) print('square root of ' +str(...
5fe69a19cdc598650bdbf922afc0b43f76482e36
KDiaCodes/ict2018
/primenumber.py
453
3.6875
4
import os num = int(input("Enter a number: ")) if num > 1: for i in range(2, num): if (num % i) == 0: print(num,"is not a prime number") print(i,"times",num//i,"is",num) break else: print(num, "is a prime number") else: print(num, "is not a prime ...
afa7db62ad284d15173bbf293a95310d9fefe408
anilkohli98/My-Assignments
/Data_stru/rotatingLinkedList.py
1,475
3.875
4
class node: def __init__(self,data): self.data=data self.next=None class DoublyLinkedList: def __init__(self): self.head=None self.tail=None def CountLenRecur(self,temp): if temp is None: return 0 else: return 1+self.CountLenRecur(temp.next) ...
d9615cdcc7a75a401e8ed36f6e162f2f6f48067b
BearachB/Hello_World
/Week 2/Lab 5/lab5_q1.py
133
3.765625
4
mark = int(input("Please enter your grade:")) if mark >= 40: print("This is a pass") elif mark <40: print("This is a fail")
9ed94697edab9d58f8f7da5a8a27de21b244fb5d
AlexNedyalkov/Python-OOP-2020
/attributes_and_methods_03/exercises/gym_04/project/trainer.py
753
3.859375
4
""" Class Trainer Upon initialization the class will receive the following parameters: name:str. The class should also have an id (autoincremented starting from 1). Implement the __repr__ method so it returns the info about the trainer in the following format: "Trainer <{self.id}> {self.name}" Create a static method ca...
5dc13b3e122461e9514506ba03bc6fa880078e98
ivan-filonov/online-challenges
/codeeval/moderate/lowest-common-ancestor.py
903
3.59375
4
#"""Sample code to read in test cases: tree = [30, 8, 52, 3, 20, -1, -1, -1, -1, 10, 29] def p(x): res, i = [x], tree.index(x) while i > 0: i = (i-1)>>1 res.append(tree[i]) return res def lca(s): v1,v2=[int(ss) for ss in s.split()] # print(v1,v2) p1,p2=p(v1),p(v2) # print(p1,p2...
73804fa20ff1108e54c6cc6504053e4b5bf48a71
sujin1561/fiveneck
/ㅠ핑퐁.py
3,634
3.734375
4
import pygame # 1. pygame 선언 pygame.init() # 2. pygame 초기화 # 3. pygame에 사용되는 전역변수 선언 WHITE = (255,255,255) BLACK = (0, 0, 0) size = [400, 300] screen = pygame.display.set_mode(size) done = False clock = pygame.time.Clock() # 4. pygame 무한루프 def runGame(): global done ## 게임판 크기 screen_w...
421370cff155d13ff74a9ba3513c0836aa4c4e87
RomanLopatin/Python
/Algorithms/HW_3/task_3_6.py
939
3.984375
4
"""coding=utf-8 3.6. В одномерном массиве найти сумму элементов, находящихся между минимальным и максимальным элементами. Сами минимальный и максимальный элементы в сумму не включать. """ import random arr_size = 10 range_min = 0 range_max = 100 ind_max = 0 ind_min = 0 arr = [random.randint(range_min, range_max) fo...
847c2801c5cfb4bc839c7bd59ec0cd364979440c
cerebnix/Projects
/__init__.py
414
3.640625
4
''' l= list(range (1,31)) l = input("Enter text") print (l * 2) for line in open ('test.txt'): print (line) f = open ("test.txt") for line in f.readlines(): print(line) import sys print(sys.copyright, '\n\n', '\n sys.platform', sys.platform, '\n sys.path', sys.path, '\n sys.modules', sys.modules) ''' stri...
cee102724632f5cec1f82e77fac37e82296e57b9
Sunhick/hacker-rank
/Algorithms/Implementation/python/ExtraLongFactorials.py
184
3.859375
4
#!/bin/python import sys n = int(raw_input().strip()) def factorial(n): if ( n == 1 ): return 1 else: return ( n * factorial ( n - 1 )) print factorial(n)
72859f810a0ed02079e1f47c35e2db93738f3870
rafaelperazzo/programacao-web
/moodledata/vpl_data/303/usersdata/289/81958/submittedfiles/testes.py
96
3.984375
4
n = int(input("Digite um número: ")) while(x<=100): if n%2==0: print(x) x += 1
a5f741a9697e8580b24ba6dd0b18537ef80dc548
gabriellaec/desoft-analise-exercicios
/backup/user_066/ch149_2020_04_13_19_19_50_853685.py
925
3.984375
4
dependentes = int(input('Insira o número de dependentes ')) salario_bruto = int(input('Insira a salario bruto ')) if salario_bruto<=1045.00: contribuicaoINSS=0.075*salario_bruto elif salario_bruto<=2089.60: contribuicaoINSS=0.09*salario_bruto elif salario_bruto<=3134.40: contribuicaoINSS=0.12*salario_bruto ...
9c174c95d938d98cb6887b7e0fdeb6290ce86ae8
kamilczerwinski22/Advent-of-Code
/main_files/year_2015/day_9/year2015_day9_part2.py
1,902
3.953125
4
# --- Part Two --- # The next year, just to show off, Santa decides to take the route with the longest distance instead. # # He can still start and end at any two (different) locations he wants, and he still must visit each location exactly # once. # # For example, given the distances above, the longest route would be ...
6a4e7eb5f53c3fab66cc5cca0cf58ebc90e015e6
troyleak/RPGMaker
/app/character_gen/skills.py
1,857
3.765625
4
class Skills(): def __init__(self): self.skills = { 'acrobatics': 0, 'appraise': 0, 'bluff': 0, 'climb': 0, 'craft_a': 0, 'craft_b': 0, 'craft_c': 0, 'diplomacy': 0, 'disable_device': 0, '...
728363b1ea914d06af349336f0630c984614db43
chengchaoyang/my-leetcode-record
/linked-list/0024-swap-nodes-in-pairs.py
842
4.03125
4
""" 给定一个链表,两两交换其中相邻的节点,并返回交换后的链表。 你不能只是单纯的改变节点内部的值,而是需要实际的进行节点交换。 示例: 给定 1->2->3->4, 你应该返回 2->1->4->3. 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/swap-nodes-in-pairs 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 """ # Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x ...
66113d7bc3597a332c8628d99927e638ce58b368
Lee-Park-Bae-Project/Algorithm
/problems/boj/2644/bbumjun.py
810
3.5
4
from collections import deque n = int(input()) a, b = map(int, input().split()) m = int(input()) relation = {} for i in range(m): parent, child = map(int, input().split()) relation.setdefault(parent, {}) relation.setdefault(child, {}) relation[parent].setdefault(child, {}) relation[child].setdefault...
d982bf6dd6845b93159e6aed6a599103a59774a8
getstock/GETSTOCK
/getstock/accounts/register.py
2,901
3.78125
4
import csv data = [] t = "!@#$%^&*()_-=+-" with open('accounts.csv') as file: csv_reader = csv.reader(file, delimiter = ',') for row in csv_reader: data.append(row) def lower_letter(s): have = 0 for ch in s: if ('a' <= ch and ch <= 'z'): have += 1 return have def upper_le...
419d27a4647704eeb7b4d24aad082d1a0ebf796e
ryancarmes/findchar-python
/findchar.py
211
3.75
4
list_one = ["Hello", "Lamp", "Moto", "Nurse", "Dolly"] x = 0 char = "ll" newlist = [] for x in range(0, len(list_one)): if list_one[x].find(char) != -1: newlist.append(list_one[x]) print newlist
3a5c3c4c66888688f157b115ea5ae48dcf3385d4
Liu-Zhijuan-0313/pythonAdvance
/lianxi/day0216/queue03.py
626
3.6875
4
# 进程通信,两个进程同时操作队列,有读有写 # 进程池下共享Queue,使用Manager创建队列 from multiprocessing import Pool from multiprocessing import Manager import time # 向队列里放数据 def writep(q1): while True: q1.put(0) time.sleep(2) # 一直等待队列里有数据 def readp(q1): while True: r = q1.get() print(r) if __name__ == '__...
a0df8246243dca4e382355f4e18f349c81422be5
DennisCkw/Python-Coursera
/10.Tuple.py
588
4.4375
4
#Tuples are like list but are immutable(cannot be changed). # - cannot sort, append, add in tuples. # - tuple is a reduction of list. # But they are more efficient, less processing time and less memory. # Tuples are preferred when making 'temporary variables' over lists. #Multi assign x, y = (3, 4) print(x, y) #Tup...
629eb51d134daba1140ac1a1bd810c709af0c514
ninepillars/trunk
/example/pythonexample/bookexample/lession_3/lession_3_4.py
936
3.875
4
# coding: utf-8 ''' Created on 2011-12-2 @author: Lv9 ''' import copy; a = [1, 2, 3, 4, [5, 6]]; b = a; b[0] = '1'; print(a, a is b);#当a和b引用指向同样的对象的时候 更改a同时也会更改b b = list(a); b[0] = 1; print(a, a is b);#执行浅copy后 重新创建了一个对象 但是仅仅是对第一层进行了简单的copy 保存了a列表中元素的引用 b[4][0] = '5'; print(a, a is b);#...
47e506eb4997480026d2635e19c020423328935d
AlessyJay/Python-practice-2021
/practice25.py
94
3.578125
4
list1 = ['ant','bird','cat','dog','eagle'] list1[0] = 'ape' list1.append('fish') print(list1)
16b8804e5b85e8b92893d49a8c8e2f929e9fed84
UmutKoca/azimuth
/azimuth.py
2,003
4.4375
4
print(""" Convert grads to degrees, find zone and calculate azimuth angle """) import math X1 = float(input("Please enter X1 coordinate: ")) Y1 = float(input("Please enter Y1 coordinate: ")) X2 = float(input("Please enter X2 coordinate: ")) Y2 = float(input("Please enter Y2 coordinate: ")) def check_zone(X1,X2,Y...
c46623ee5d065470bb630733d0c585f3887a87b2
codesigned4/AdvancedPython
/4) Usage of Github API/githubAPI.py
1,530
3.5
4
import requests class Github: def __init__(self): self.apiURL="https://api.github.com" self.token="dkljfPOEOkjdjfmcmaqwekd956" def getUser(self,username): response=requests.get(self.apiURL+"/users/"+username) return response.json()#json import edip json.loads() methodunu ku...
3d0cfce32961d3c13f2331db9e00c8e4edb9fcdf
haoknowah/OldPythonAssignments
/Gaston_Noah_NKN328_Hwk18/Ch06_005_permutation.py
1,590
4.03125
4
try: from itertools import permutations except ImportError as exc: print(exc) def permutation(word): ''' permutation()=finds permutations of an input word returns a list of the permutations ''' try: return ["".join(char) for char in permutations(word)] except: print("...
09bd05740d57ea01694e0db75ac5228e4c777b43
testdemo11/test2_pratice
/pratice_lesson5_selenium/test_wait.py
1,210
3.640625
4
#直接等待 #time.sleep(2) #隐式等待,轮询查找(default 0.5s),全局等待 #self.driver.implicitly_wait(2) #显式等待 WebDriverWait 配合until,until_not(),判断进行等待 from time import sleep from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions from selenium.webdriver.support....
6f67128f5afe61ef495661dc3d3194796bcf9288
NHopewell/coding-practice-problems
/Algorithms/leetcode/strings/repeatedSubstringPattern.py
1,471
3.734375
4
""" Problem: given a string, check if it can be constructed using substring appended multiple times Examples: Input: "abab" Output" True ------------- Input: "aba" Output: False ------------- Inputer: "abcabcabcabc" Output: True """ import pytest d...
92eb5468109689e8227fe97abf8acf3c97a7323f
donhwi94/NomadCoders_WebScrapper_with_Python
/Code_Challenge/Day Four Blueprint/main.py
883
3.90625
4
import os import requests start = True def answer(): while True: a = input("Do you want to start over? y/n ") if a == "n" or a == "N": print("K bye!") return False elif a == "y" or a =="Y": os.system('clear') return True else: print("That's not a valid answer.") whi...
746366ad91cb782b4bed8c4cee17e0d92d75f486
zeraien/advent_of_code_2020
/dimo/day3.py
772
3.703125
4
import math def load_file(name="day3.txt"): map_list = [] with open(name,'r') as f: map_list = f.readlines() return [l.strip() for l in map_list] def traverse(map_list, x_step=0, y_step=1): counter, x=0,0 wrap_point = len(map_list[0]) for idx in range(0, len(map_list), y_step): line = map_list[idx] if lin...
2961a6913819dcfb6f430f9cf3ed7d90c82857f5
AnubodhKarki/Nim
/Nim.py
6,231
3.984375
4
#Nim import random import math def Menu(): quit = False bad_choice = True while bad_choice == True: print('\nNIP MENU:') print('~~~~~~~~~~~~') print('1 : play against an AI') print('2 : rules') print('3 : quit') Choice = raw_input("What would you like to do...
3f09efbf3c305a9fbb41dd09cd4d4a94b998ee9e
louisbemberg/python_notes
/py4e/2-conditionals.py
568
4.03125
4
if 2 + 2 == 4 : print("quick mafs") if type("Loulou") == type("Bemberg") : print("Both of these are strings!") if 6 < 9 : print("One line if statement woohoo!") if 10 < 5 : print("inside the if block") print("not inside the if block") age = 17 if age < 18 : print("You cannot drink alcohol, here's a coke...
9fd606cd0bf82bd2df096e0ad467273cc848b810
Brom-nn/PythonCourse
/Practice/EvgeniySyatoykin/2.1.py
154
3.640625
4
inta=0; print("Введите ") input(a) def fun(a, b): if a > b: print(f"max number={a}") else: print(f"max number{b}")
0116fa0608352979c9a7667fb4f0abda4573f812
viniciusmartins1/python-exercises
/ex013.py
209
3.65625
4
salario = float(input('Qual é o salário do funcionário: R$ ')) reajuste = salario * 1.15 print('Um funcionário que ganhava R$ {}, com 15% de aumento, passa a receber R$ {:.2f}!'.format(salario, reajuste))
2ef24b19bd050ee4c6d8be772ea0b9685507cab8
jhonfa94/python
/8_Encasulamiento/1_encapsulamiento.py
1,467
3.96875
4
''' El encapsuplamiento es practicamente el no permitir que se pueda acceder a los atributos de forma directa, sino que se pueda acceder a traves de metodos, Para definir un atributo de forma privada para que no sea accedido desde cualquier lugar, se hace a través del doble guion bajo(__) Para ellos se crea los metod...
5e8a776b0e7713f7eec1307281a628cd1b631bc6
shalgrim/advent_of_code_2020
/python/day13_1.py
591
3.53125
4
from math import prod ARRIVAL_TIME = 1003681 LINE_TWO = '23,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,37,x,x,x,x,x,431,x,x,x,x,x,x,x,x,x,x,x,x,13,17,x,x,x,x,19,x,x,x,x,x,x,x,x,x,x,x,409,x,x,x,x,x,x,x,x,x,41,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,29' BUSES_IN_SERVICE = [int(bus) for bus in LINE_TWO.split(',') if bus != 'x'] if __n...
1dd4547e8e5d1250bbf4514a25236b40aacf7853
Hschan2/Opentutorials
/Python/Python/python/func.py
618
4.03125
4
#!python print("Content-Type: text/html; charset-utf-8\n") ''' a = 1 b = 2 c = 3 s = a+b+c r = s/3 print(r) ''' ''' #average 함수 코드 def average() : a = 1 b = 2 c = 3 s = a+b+c r = s/3 print(r) average() ''' ''' #average 함수 코드 응용, 괄호에 변수를 넣어 더 쉽게 사용 (매개변수, parameter) def average(a,b,c) : s = a+b+c r = s/3 pri...
aafcf34641e0be7cb6f67176ea8d487405f4a772
ntsdwkr/Python
/ncr.py
231
3.640625
4
# ncr using function def fact(n): ans = 1 for i in range(1, n+1): ans = ans * i return ans def ncr(n, r): return fact(n)//(fact(r)*fact(n-r)) n = int(input()) r = int(input()) ans = ncr(n, r) print(ans)
a5f8cf2de38a252d3e9c9510368419e5a763cf74
TheFibonacciEffect/interviewer-hell
/squares/odds.py
1,215
4.28125
4
""" Determines whether a given integer is a perfect square, without using sqrt() or multiplication. This works because the square of a natural number, n, is the sum of the first n consecutive odd natural numbers. Various itertools functions are used to generate a lazy iterable of odd numbers and a running sum of them,...
a6b4a196de4ccf74fcbed58c3c69bc7bac34bf2c
amosniu/Python_CRMDSJ
/第二章.py
3,137
3.609375
4
#coding=gbk #2-1 message = 'Ұ̣Ұpython' print(message) #2-2 message = 'pythonϲıԣѧǿ' print(message) #2.3ַ #2.3.1ʹ÷޸ַСд #ĸΪд name = 'ada lovelace' print(name.title()) #ĸȫΪд name = 'Ada Lovelace' print(name.upper()) #ĸΪСд print(name.lower()) #2.3.2ϲ(ƴ)ַ first_name = 'amos' last_name = 'niu' full...
0ddf8389cb42e7d18641a5b4d74ebb594d6edff7
zv2051/Study
/MIT_600/fibonacciRecursion.py
433
4.09375
4
#!/usr/bin/python3 #################################################################### # # proc fibonacci by recursion # #################################################################### var = int(input("Enter a Number:")) def fibonacciRe(var): assert type(var) == int and var >=0 if var == 0 or var == 1...
011af88a76fc4c0bc12a4c900d46f84d1ceb6df0
jammy-bot/atom-test
/2-py.py
674
3.796875
4
#------------------------------------------------------------------------------- # Name: 2-py # Purpose: test file for atom-plus # # Author: jbot # # Created: 12/04/2019 # Copyright: (c) jammy-bot 2019 #------------------------------------------------------------------------------- length_list = ...
272c357360c8070dd5a383ad9d1e9197454ba401
caylavgonzales/ITMGT-25.03-Submissions-Cayla-Gonzales-Section-A-
/202386_GONZALES_CAYLA_HANDLINGFILES.py
1,776
3.859375
4
products = { "americano":{"name":"Americano","price":150.00}, "brewedcoffee":{"name":"Brewed Coffee","price":110.00}, "cappuccino":{"name":"Cappuccino","price":170.00}, "dalgona":{"name":"Dalgona","price":170.00}, "espresso":{"name":"Espresso","price":140.00}, "frappuccino":{"name":"Frappuccino"...
cbb789854cfcee1aa9f31347c505a8c582b304e7
VakinduPhilliam/Python_Time_Machine
/Python_Datetime_Time_Delta.py
1,777
4.125
4
# Python Datetime # datetime Basic date and time types. # The datetime module supplies classes for manipulating dates and times in both simple and complex ways. While date and time arithmetic is supported, the # focus of the implementation is on efficient attribute extraction for output formatting and manipulation....
b2227b0448249064574b1c4fda4bf1514a2bf375
limiyou/Pyproject
/1python基础/class4 list and dict/demo07_tuple.py
333
4.0625
4
""" 元组 元组和列表相似 元组是不可变的,只能获取;列表是可变的(增加,修改) 元组表示:() 列表表示:[] """ tp=(3,4,5) print(tp) print(type(tp)) #空元组 tp=() print(tp) #TODO: 一个元素的元组,在元素后面一定要加, tp=(1,) print(tp) #查找 print(tp[0])
17a7805435ebdad80573f3ab8cb4628ae48d23f7
abhiram11/NLP-and-Multi-Layered-Neural
/tensorflow/deepnet.py
3,762
3.6875
4
import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets("/tmp/data/", one_hot=True) #one element is hot (ON), rest all are cold (OFF) n_nodes_hl1 = 500 n_nodes_hl2 = 500 # number of nodes for hiddden layers n_nodes_hl3 = 500 # the numbers can be random, no...
614f942da599ff50d2b8608b07f4f8a5a1cb218e
RaviMudgal/AlgoAndDataStructures
/recursion/SumList.py
338
3.875
4
def listSum(numList): sum = 0 for i in numList: sum += i return sum print (listSum([1,2,3,4,])) # listSum using recursion def listSumRecursion(numList): if len(numList) == 1: return numList[0] else: return numList[0] + listSumRecursion(numList[1:]) print(listSumRecursion([...
6d18b7343951327484d14f41c920fc6de550d572
Darlley/Python
/LIVRO_CursoIntensivoPython/Capitulo_3/ex07.py
1,387
3.78125
4
#3.7 – Reduzindo a lista de convidados: Você acabou de descobrir que sua nova #mesa de jantar não chegará a tempo para o jantar e tem espaço para somente #dois convidados. #• Comece com seu programa do Exercício 3.6. Acrescente uma nova linha que #mostre uma mensagem informando que você pode convidar apenas duas pessoa...
b5c40939b75e212648e3f19d0adbc03cd688c490
Taoge123/OptimizedLeetcode
/LeetcodeNew/DynamicProgramming/LC_361_Bomb_Enemy.py
5,061
3.90625
4
""" Given a 2D grid, each cell is either a wall 'W', an enemy 'E' or empty '0' (the number zero), return the maximum enemies you can kill using one bomb. The bomb kills all the enemies in the same row and column from the planted point until it hits the wall since the wall is too strong to be destroyed. Note: You can o...
103f2674ed5700000edda2737a2f6df0a801e4b0
d391/UBB--Formal-Languages-and-Compiler-Design
/lab6/Grammar.py
2,243
3.59375
4
class Grammar: def __init__(self, _nonterminal_symbols, _terminal_symbols, _productions, _start_terminal): self.nonterminal_symbols = _nonterminal_symbols self.terminal_symbols = _terminal_symbols self.productions = _productions self.start_terminal = _start_terminal @stat...
e5862f062f63daa9d44276bcfe9172a6e46b3077
jtsit/checklists
/excel-json-converter.py
3,317
3.6875
4
#this is the concept in python. import csv # to read csv file import xlsxwriter # to write xlxs file import ast # you can change this names according to your local ones csv_file = 'data.csv' xlsx_file = 'data.xlsx' # read the csv file and get all the JSON values into data list data = [] with open(csv_file, 'r') as...
2dbf6f8e09c0c5e3056a8407953b198db446348a
utksezgin/GTU-Homeworks
/Daily Coding Problems/Stack.py
1,245
4.28125
4
# This problem was asked by Amazon. # Implement a stack that has the following methods: # • push(val), which pushes an element onto the stack # • pop(), which pops off and returns the topmost element of the stack. If there are no elements in the stack, then it should throw an error or return null. # • max(), which ret...
bc7cfe416b5b89b9428923c9f577a47126dafdf7
ErmanoClaude/Algorithms
/SymmetricDifference.py
782
4.28125
4
""" A function that takes two or more arrays and returns an array of the symmetric difference (△ or ⊕). """ def sym(*args): """Return Unique Values between Arrays into one array """ sym = []; value = args[0][0] for array in args: #iterate over tuple of arrays for value in array: #iterate over values in e...
7dc777a03f0b40171a7e4b423e77c534fa603df0
webstorage119/Iris_pattern_classification
/CNNModels/GoogLeNet/util/dataloader.py
4,396
3.59375
4
''' (x_train, x_test) : uint8 array of RGB image data with shape (num_samples, 3, 32, 32) or (num_samples, 32, 32, 3) based on the image_data_format backend setting of either channels_first or channels_last respectively. (y_train, y_test) : uint8 array of category labels (integers in range 0-9) with shape (num_samples,...
9d0230ccdfed81a0b5a617e6abc84f333e7246ca
Ruturaj4/leetcode-python
/easy/to-lower-case.py
376
3.84375
4
#Implement function ToLowerCase() that has a string parameter str, #and returns the same string in lowercase. class Solution: def toLowerCase(self, str: str) -> str: upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" lower = "abcdefghijklmnopqrstuvwxyz" temp = dict(zip(upper, lower)) retu...
a79fdd3b6be3765e0266986b7d72bebade4fb65a
iamanogre/capitalone_OSCARS
/capitalone.py
4,304
3.625
4
""" CapitalOne Challenge Due 3/10/2015 Author: Gary Hoang """ import csv import string import operator from states import states_to_letters, letters_to_states # nominees MAP = {'birdman': "Birdman", 'whiplash': "Whiplash", 'sniper': "American Sniper", 'budapest': "The Grand Budapest Hotel", 'imitation'...
d5becd9c56bb2ab8fd73ebacc7d1d8f494ab50ee
dtliao/Starting-Out-With-Python
/chap.4/08 p.162 ex5. hard.py
593
4.375
4
years=int(input('Enter number of years:')) year=0 total_months=0 total_rainfall=0 average_rainfall=0 month_rainfall=0 for years in range(years): print('For year', years+1, ':' ) for month in range(12): month_rainfall=float(input('Enter the inches of rainfall for the month:')) total_months+=1 ...
28e0eaa23ab1ab3484ef394601ffbf1b07fe1d84
mackowia/bootcamp
/basic/zjazd I/while.py
450
3.921875
4
a = 0 while a < 10: print ( 2 ** a ) a += 1 a = 0 b = 0 while b < 10000: print ( b ) a += 1 b = 2 ** a a = 1 while a < 10: print ( 2 ** a) a += 1 a = 0 while a < 100: print(f"{a}^2 = {a ** 2}") a+=1 suma_temperatur = 0 dzien = 1 while dzien < 8 : suma_temperatur += float (in...
b92ce495aa97e6715b9d19385e8f24e81566f13e
ShangruZhong/leetcode
/Linearlist/36.py
992
3.71875
4
""" 36. Valid Sudoku @author: Shangru @date: 2015/09/30 """ class Solution(object): def isValidSudoku(self, board): """ :type board: List[List[str]] :rtype: bool """ def isValid(x, y, tmp): for i in range(9): if board[i][y] == tmp: ...
29e26446572fbca3cf3bf3969c78d21b11447514
ThalesLeal/python
/URI/URI 1006.py
250
3.890625
4
# -*- coding: utf-8 -*- def media (A,B,C): return (A * 0.2)+(B * 0.3)+(C * 0.5) def main(): A = float(input("")) B = float(input("")) C = float(input("")) print("MEDIA = %2.1f" % media(A,B,C)) if __name__ == '__main__': main()
05da8da042444d88e1134d70eb85a68082e4dac6
Antilos/llgram
/llgram/rule.py
954
3.546875
4
class Rule: def __init__(self): """ """ self.left = "" self.right = list() self.first = set() self.action = None def __repr__(self): return f"{self.left} -> {' '.join(self.right)}" def __str__(self): return f"{self.left} -> {' '.join(self.rig...
8782c17f9c8740cc744594b888ce740f1ae57ec5
Nutner/mod02acelera
/func1rnivel.py
320
3.546875
4
def normal(x): return x def cuadrado(y): return y*y def cubo(x): return x**3 def sumaTodos(limitTo,f): resultado = 0 for i in range(limitTo + 1): resultado += f(i) return resultado if __name__ == "__main__": print (sumaTodos(100,normal)) print (sumaTodos(3,cuadrado))
d8fbc755a27a42c631663891970d67a5ccf2a3b2
iturricf/clusteris
/clusteris/timer.py
679
3.5625
4
# -*- coding: utf-8 -*- from timeit import default_timer as timer class Timer(object): def __init__(self): self.times = [] self.start = 0 self.end = 0 def AddTime(self, description): t = timer() self.times.append((description, t)) if (description.lower() == "...
7381c75df418ec000814aed230ba6ba7f06334a5
anks321/numpy
/numpy.py
424
4
4
import numpy as np #Accessing / Chnaging a=np.array([[1,2,3,4,5,6],[7,8,9,10,11,12]]) print(a) #getting specific element (r,c) print(a[1,5]) #Getting a spcefic row print(a[0,:]) #Getting a specefi column print(a[:,3]) # Getting every other element of first row print(a[0,1:6:2]) #Changing element a[1,5]=1...
c49786a218257cbb4d24eb5bcecb0ea59c0037c4
q759729997/qyt_nlp_collections
/文本相似度/jaccard_distance.py
738
3.890625
4
def calculate_jaccard_distance(words1, words2): """计算jaccard距离""" # 转换为set集合 words_set1 = set(words1) words_set2 = set(words2) # 计算交集与并集 union_len = len(words_set1.union(words_set2)) # 两个集合的并集 intersection_len = len(words_set1.intersection(words_set2)) # 两个集合的交集 return 1 - inte...
9d50c5d6c6c40e6d8d46bc9ded80c13774bc985a
latata666/newcoder
/leecode/lec_322_coinChange.py
1,114
3.640625
4
# -*- coding: utf-8 -*- # @Time : 2020/6/15 10:56 # @Author : Mamamooo # @Site : # @File : lec_322_coinChange.py # @Software: PyCharm """ 给定不同面额的硬币 coins 和一个总金额 amount。编写一个函数来计算可以凑成总金额所需的最少的硬币个数。 如果没有任何一种硬币组合能组成总金额,返回 -1 输入: coins = [1, 2, 5], amount = 11 输出: 3 解释: 11 = 5 + 5 + 1 """ import functools class Solution: ...
7c4f99a4575011edc4bdb9340f35694d3a1061eb
Babkock/python
/6 - Functions/Module6/validate_input/validate_input_in_functions.py
1,010
4.25
4
#!/usr/bin/python3 """ Tanner Babcock October 1, 2019 Module 6, topic 4: Functions with variable parameter lists """ """ This function prints the test name and test score. It asks for user input if the score is not in the valid range. :param test_name: The name of the test taker :param test_score: The score of the t...