blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
35fdd7501a04f8d9c35cb2fa844937e5ed062d7a
divyanshumehta/graph-algo
/bfs.py
747
3.953125
4
from collections import defaultdict class Graph: def __init__(self): self.graph = defaultdict(list) def addEdge(self,u, v): self.graph[u].append(v) def BFS(self,s): visited = [False] * len((self.graph)) queue = [] queue.append(s) visited[s] = True ...
214e59ccda73904fc0518a0614631fd996a8d4cc
xulei717/Leetcode
/45. 跳跃游戏II.py
1,514
3.703125
4
# -*- coding:utf-8 -*- # @time : 2020-01-17 09:52 # @author : xl # @project: leetcode """ 标签:困难、贪心算法、数组 题目: 给定一个非负整数数组,你最初位于数组的第一个位置。 数组中的每个元素代表你在该位置可以跳跃的最大长度。 你的目标是使用最少的跳跃次数到达数组的最后一个位置。 示例: 输入: [2,3,1,1,4] 输出: 2 解释: 跳到最后一个位置的最小跳跃数是 2。 从下标为 0 跳到下标为 1 的位置,跳 1 步,然后跳 3 步到达数组的最后一个位置。 说明: 假设你总是可以到达数组的最后一个位置。 来源:...
61ebc71a0a737843a3862835146f28849e68179e
namkiseung/python_BasicProject
/python-package/question_python(resolved)/chapter4_conditional_and_loops(완결)/i_odd_even.py
539
4.21875
4
# -*- coding: utf-8 -*- def odd_even(x): """ 정수를 전달받아서 그 수가 짝수면 'even'을, 홀수면 'odd'를 반환하는 함수를 작성하자 sample in/out: odd_even(2) -> 'even' odd_even(1000) -> 'even' odd_even(777) -> 'odd' """ # 여기 작성 if x % 2==0: return 'even' else: return 'o...
6e1fcb2967c122b1b078d8c3a5c34c15a9c6a25d
Tarun-Sharma9168/Python-Programming-Tutorial
/gfgpart220.py
1,066
3.625
4
''' ###### # ##### # ### ### ##### # # # ### # ##### #### ##### ###### ### # # #### # ##### #### # Author name : Tarun Sharma Problem Statement: use of the ...
0a7cea01a2cedadcf3690b72ffd04380198c20b3
bio-tarik/PythonUnitTesting
/pytest/Proj02/test_class.py
530
3.578125
4
""" Learning unit testing on Python using py.test. Tutorial: docs.pytest.org/en/latest/getting-started.html#our-first-test-run """ class TestClass(object): """ Generic test class """ def test_one(self): """ Tests if the string 'this' contains 'h' """ string = "...
80378660ae773aa71593ae59b38372520baf663f
jitudv/python_programs
/prm2.py
98
3.765625
4
var=input("enter the no \t ") var2=input("enter the 2nd no") print("addition is= %d"%((var+var2)))
d54feb625dcdbab60409ced5068ad46d50b004c0
jackmoody11/project-euler-solutions
/python/p017.py
1,828
3.765625
4
letters = {1: "one", 2: "two", 3: "three", 4: "four", 5: "five", 6: "six", 7: "seven", 8: "eight", 9: "nine", 10: "ten", 11: "eleven", 12: "twelve", 13: "thirteen", 14: "fourteen", 15: "fifteen", 16: "sixteen", 17: "seventeen", 18: "eighteen", 19: "nineteen", 20: "twenty", 30...
12cc5ef3a624905bc1aa900526727544e7222539
amine0909/FunnyReplacer
/change.py
252
3.5
4
# script python, just to rename all images name # i'm a little bit lazy :p import glob import os list = glob.glob("./pics/*.*") print(list) for i,filename in enumerate(list): #print(filename) os.rename(filename,"./pics/{0}.jpg".format(i))
8bc64bb7045c38ecfd338eb6380863f3b0c07608
lucasdmazon/CursoVideo_Python
/pacote-download/Exercicios/Aula17.py
588
3.765625
4
num = [2, 5, 9, 1] num[2] = 3 num.append(7) sorted(num, reverse=True) num.insert(2, 2) if 4 in num: num.remove(4) else: print(f'Não achei o numero 4') #num.pop(2) print(num) print(f'Esta lista tem {len(num)} elementos') valores = [] valores.append(5) valores.append(9) valores.append(4) for c, v in enumerate(v...
5bb3f01f31167aa154acdfe9dd8483409ffc0e4f
vincenthanguk/TicTacToe-Python
/tictactoemodules.py
3,855
3.90625
4
import random def display_board(board): print(' | |') print(' ' + board[1] + ' | ' + board[2] + ' | ' + board[3]) print(' | |') print('-----------') print(' | |') print(' ' + board[4] + ' | ' + board[5] + ' | ' + board[6]) print(' | |') print('-----------') print(' ...
874e9f13c8a50fbe7f906adbcaaaf3cf81e1454e
yennanliu/CS_basics
/leetcode_python/Array/find-the-celebrity.py
7,195
3.9375
4
""" 277. Find the Celebrity Medium Suppose you are at a party with n people labeled from 0 to n - 1 and among them, there may exist one celebrity. The definition of a celebrity is that all the other n - 1 people know the celebrity, but the celebrity does not know any of them. Now you want to find out who the celebri...
29473ad7178fee18cc9fcf8d1492c33dd5613e20
WuAlin0327/python3-notes
/python基础/day7/购物车作业.py
1,570
3.75
4
goods = [ {"name": "电脑", "price": 1999}, {"name": "鼠标", "price": 10}, {"name": "游艇", "price": 20}, {"name": "美女", "price": 998}, ] shopping_cart = {} lump = [] sum = 0 shopping = True user = input("请输入用户名:") password = input("请输入密码:") wage = int(input("请输入本月工资:")) print("-----商品列表-----") for index,i in enumerate(goo...
edc057d74877ef4c732ed5640193bfb542739981
MikeDev0X/PythonPracticeEcercises
/convertidor a cm.py
792
3.828125
4
def feet(): feet=int(input('Feet: ')) if feet<=0: print('Error') else: print ('cm: ',feet*30.48) def inches(): inches=int(input('Inches: ')) if inches<=0: print('Error') else: print ('cm: ',inches*2.54) def yards(): yards=int(input('Yards: '))...
941210ba99a6b19b57d90b401cabc1bfff29ba08
davidmcclure/lint-analysis
/lint_analysis/core/utils.py
452
3.765625
4
import re import os import scandir def scan_paths(root, pattern=None): """Walk a directory and yield file paths that match a pattern. Args: root (str) pattern (str) Yields: str """ for root, dirs, files in scandir.walk(root, followlinks=True): for name in files: ...
1b008231a583dab78b26d94b216ed02483a6c7f7
xixijiushui/Python_algorithm
/algorithm/14-sortOddAndEvenNum.py
446
3.5
4
def recordOddEven(pData): if pData == None or len(pData) == 0: return start = 0 end = len(pData) - 1 while start < end: while start < end and pData[start] & 0x1 != 0: start += 1 while start < end and pData[end] & 0x1 == 0: end -= 1 if start < e...
13c851856e954ed682ae4f12d4b3bc047fe404c7
ajritch/DoublyLinkedList
/Node.py
265
3.953125
4
class Node(object): def __init__(self, value, prev = None, next = None): self.value = value self.prev = prev self.next = next #method to display the node def printNode(self): print "Value:", self.value, "|", "Next:", self.next, "|", "Prev:", self.prev
ee529f30bc053eda2bf2a980743a088f269251e2
ankitkumarr/AdventOfCodeSolutions
/Day5/solution2.py
609
3.515625
4
def rule1(st): for x in range ((len(st)-1)): if rule1test (st[x:x+2], st, x)==True: return True return False def rule1test(st1, st2, y): for x in range (len(st2)): if (x< ((len(st2))-1)) and x!= y and x!=y-1 and x!=y+1 : if st2[x:x+2]==st1: return True return False def rule2(st): for x in rang...
d2d5c415bdb478397756373992c417d1bd17c1c0
BossDing/Interview-example
/其他/字符串的排列/Permutation.py
547
3.734375
4
# -*- coding:utf-8 -*- #输入一个字符串,按字典序打印出该字符串中字符的所有排列。 #例如输入字符串abc,则打印出由字符a,b,c #所能排列出来的所有字符串abc,acb,bac,bca,cab和cba。 import itertools class Solution: def Permutation(self, ss): # write code here if(ss==''): return [] li=list(itertools.permutations(list(ss),len(ss))) for i i...
05ade5232e2b47fcdaa2956056c1917f16fd1d5e
BirAnmol14/My-Python-Learning
/Automation Codes/Regex/RegExAdv.py
2,213
3.53125
4
#Regex advanced # ? character -> optional my appear once or never import re batreg=re.compile(r'bat(wo)?man') #this means the wo group can apperaer 0 or one times in the pattern mo=batreg.search('Adventures of batman') print(mo.group()) mo=batreg.search('Adventures of batwoman') print(mo.group()) mo=batreg.search('Adve...
c31350118e9a2a900b8a48623f0753c954a18c5c
karolwk/tictactoe
/tictactoe.py
9,959
3.640625
4
import random import copy class StaticMethods: @staticmethod def check_field(cords, board) -> bool: # Check for "X" or "O" in specified field if board[cords[0]][cords[1]] in ("X", "O"): return True else: return False @staticmethod def avail_spots(board)...
d261169c5ecdecc6eccbdf3bbd95f7846954e1b8
kojicovski/python
/exercises/ex018.py
245
4.15625
4
from math import sin, cos, radians, tan degree = int(input('Type a value in degree :')) print('Value of sin {:.4f}, cos {:.4f} and tg {:.4f} of {} degree'.format(sin(radians(degree)), \ cos(radians(degree)), tan(radians(degree)), degree))
6e4c1d8f83d99baf4c030cea3f9bdb29b062c00f
KangKyungJin/Poker_hackathon
/cards.py
1,452
3.75
4
import random #class card to create card objects class card: def __init__(self,suit, val, numericVal): self.suit=suit self.val= val self.numericVal=numericVal def displaycardinfo(self): return(f"{self.val}{self.suit}") def returnVal(self): if self.val == "Ace": ...
23f1a63c1c676e67efbc0cba54116de481cd0fd5
benjaminrall/uno
/display.py
24,268
3.671875
4
import turtle def update(): turtle.update() def resetFirst(): turtle.tracer(0,0) turtle.speed(0) turtle.ht() turtle.pu() def reset(): turtle.clear() def write(x, y, size, text): turtle.color("white") turtle.fillcolor("white") turtle.pu() turtle.goto(x,y) turtle.write(text...
a7e1384c179cd458abef9eb9eb42ea9a0a2d4793
GianlucaTravasci/Coding-Challenges
/Advent of Code/2020/Day 3/solution3.py
613
3.5
4
with open('input.txt', 'r') as file: map_lines = file.read().splitlines() line_length = len(map_lines[0]) def way_tree_counter(right, down): tree_counter = 0 for i in range(0, int(len(map_lines) / down)): step = i * right if map_lines[i * down][step % line_length] == '#': tree...
4ba42df9e051ece562b5d6f9d4b537ad8da1bb28
vineetpathak/Python-Project2
/reverse_alternate_k_nodes.py
965
4.21875
4
# -*- coding: UTF-8 -*- # Program to reverse alternate k nodes in a linked list import initialize def reverse_alternate_k_nodes(head, k): count = 0 prev = None curr = head # reverse first k nodes in link list while count < k and curr: next = curr.nextnode curr.nextnode = prev prev = curr ...
6cd26e15abb228d8ae218504dcd89472ebff7401
AdrienCeschin/sauvegarde-formation
/python_training/vagrant/sapin.py
514
4
4
nb_lines = int(input('Please enter the height of the tree, int and positive values only: ')) distance = ' ' branch = '^' if nb_lines>0: n=0 while n != nb_lines: tmp_line = '' tmp_distance = distance*(nb_lines-1-n) tmp_branch = branch*(2*n+1) tmp_line = tmp_distance + tmp_branch...
b463750c73e5cdd0586379a091a84c977182a2d9
Rushikesh8421/Python-projects-2
/Grocery Billing application.py
894
3.953125
4
""" Project By: Rushikesh Patil; Description: A grocery billing application to display and sum total bill using Python; """ def sum_single(quantity, price): return price*quantity; mylist = []; suma = 0; new_item = "y" while new_item == "y": print("...Guruprasad Grocery...") item = input("Ente...
8fe42c20049a4d1590f99ecec25de72cb5a95f62
IronE-G-G/algorithm
/leetcode/101-200题/139wordBreak.py
2,029
3.828125
4
""" 139 单词拆分 给定一个非空字符串 s 和一个包含非空单词列表的字典 wordDict,判定 s 是否可以被空格拆分为一个或多个在字典中出现的单词。 说明: 拆分时可以重复使用字典中的单词。 你可以假设字典中没有重复的单词。 示例 1: 输入: s = "leetcode", wordDict = ["leet", "code"] 输出: true 解释: 返回 true 因为 "leetcode" 可以被拆分成 "leet code"。 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/word-break 著作权归领扣网络所有。商业转载请联系官方授权,非...
477a1f977f2f2225622e4c0f1c1e492fc59bde49
himangi6550/student-data
/test2.py
421
3.75
4
import sqlite3 MySchool=sqlite3.connect('schooltest.db') curschool=MySchool.cursor() for i in range(1,5): mysid=int(input("enter id:")) myname=input("enter name:") myage=int(input("enter age:")) mymarks=float(input("enter marks:")) curschool.execute("insert into student(StudentID,name,ag...
dd1ecb055c5c4234ae5c1766efb4315afa9db215
Zorro30/Udemy-Complete_Python_Masterclass
/Using Tkinter/tkinter_button_command.py
225
3.828125
4
#On Click listener from tkinter import * root = Tk() def doSomething(): print ("Button is been clicked!") button1 = Button(root, text = "Click here!", command = doSomething) button1.pack() root.mainloop()
5f256b2646576b1f8c3a49c07e498305b0fd6f59
JOHNTESFU/python
/exercice 8.py
867
4.09375
4
def say_hi(name, age): print("hello " + name, "you are " + str(age)) say_hi("john" , 33) say_hi("mike" , 23) print("--------------------------") def cube(num): return num*num*num result= cube(10*10) print(result) print("----------------------------") is_male = True is_tall = True if...
7e9138ddef64d39a390cc480b0e2bf4cbc2cc2be
AileenXie/leetcode
/written-examination/0823iqiyi_wsf/01.py
1,394
3.78125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2020/8/23 4:06 PM # @Author : aileen # @File : 01.py # @Software: PyCharm class Solution: def func(self,string,words): if not words: return string dic = {} dic_len = {} for word in words: dic.setdefault(word[0],[])...
472f41f9d8b86bd1f3d74e40df84cbe780063a56
yaolizheng/leetcode
/166/fraction.py
545
3.578125
4
def fraction(n, d): res = '' if n / d < 0: res += '-' if n % d == 0: return str(n / d) table = {} res += str(n / d) res += '.' n = n % d i = len(res) while n != 0: if n not in table: table[n] = i else: i = table[n] r...
700b79e970f6dbc27004911bb7b8b2ed1537c9ee
hemal507/python
/reverseOnDiagonals.py
715
3.578125
4
def reverseOnDiagonals(matrix): l=len(matrix)/2 pos=len(matrix)-1 for x in range(l) : matrix[x][x] , matrix[pos][pos] = matrix[pos][pos] , matrix[x][x] pos -= 1 pos=len(matrix)-1 for x in range(l) : matrix[pos][x] , matrix[x][pos] = matrix[x][pos] , matrix[pos][x] pos -= 1 return matrix #print(reverseOn...
1451daf71d99d11b76b8d2581e80e7bcff6cb36f
irtefa/skoop
/classifiers/wordcountclassifier.py
803
3.78125
4
""" WordCount classifier -- scores a doc based on word count """ from classifier import Classifier import string class WordCountClassifier(Classifier): # constructs a word count classifier based a given input word def __init__(self, options): keyword = options['keyword-word'] self.keyword = ...
124eb9acffee943f3d0a93042373b475cbf2837d
thegapro/CSPC4810-Assigments
/pythonquestion.sh
435
3.703125
4
#!/usr/bin/env python3 import pandas as pd df = pd.read_csv('2007.csv') delay = df[['ArrDelay']][df['Origin'] == 'SFO'].head(3) print("a, The first 3 of the arrival delay for the flights that depart from SFO are: \n",delay) top = pd.DataFrame(df['Dest'].value_counts().head(3)) top = top.reset_index() top.columns = [...
b9ff5b4754da25a26d736cb5dda5361ac1e85cfe
muhammadqasim3/Python-Programming-Exercises
/2_Odd_Even.py
200
4.15625
4
number = int(input("Enter the number you want to check: ")) if number % 2 == 0 and number % 4 == 0: print("Even and Divisible by 4") elif number % 2 == 0: print("Even") else: print("odd")
291e6cc0b65e5c66b5aebcb471519cb7247fdb02
Lekanda/master-python
/07-Ejercicios/ejercicio8.py
276
3.828125
4
""" TANTO POR CIENTO: Con dos numeros dados. El total y el % a sacar """ num=int(input("Dame el numero total: ")) tanto=int(input("Dame el %: ")) resultado=0 cienparte=0 cienparte=num/100 resultado=cienparte*tanto print(f"El {tanto}% de {num} es: {resultado}") print("\n\n")
971c3ad295e7a85387538cfd412e05f21ed13594
kasthuri2698/python
/naturalnumber.py
154
3.609375
4
number=input() number=number.split() num1=int(number[0]) num2=int(number[1]) sum=0 z=input().split() for i in range(num2): sum=sum+int(z[i]) print(sum)
61fba2eb691dbcc608145126470647c50a3a3b2f
python-cmd2/cmd2
/examples/decorator_example.py
4,375
3.515625
4
#!/usr/bin/env python # coding=utf-8 """A sample application showing how to use cmd2's argparse decorators to process command line arguments for your application. Thanks to cmd2's built-in transcript testing capability, it also serves as a test suite when used with the exampleSession.txt transcript. Running `python d...
86a576383c9febd6a8b5a47e5c9889b54b24f5ec
zhanghuaisheng/mylearn
/Python基础/day002/06 运算符.py
1,316
3.640625
4
# 1.比较运算符 """ > < >= <= == != """ # 2.算术运算符 """ + - * / // 整除,向下取整(地板除) ** 幂 % 取余,取模 """ # print(5 / 2) #2.5 # print(5 // 2) #2 # print(5 ** 2) #25 # print(5 % 2) #1 # 3.赋值运算符 """ = += -= *= /= //= **= %= """ # a = 10 # b = 2 # b += 1 #b = b + 1 # a -= 1 #a = a -1 # a *= 2 #a = a *2 # a /= 2 #a = a / 2 # a /...
e3c584f5a4fd3a22abe27ceb800ce311c8d29c82
adamlwgriffiths/PyMesh
/pymesh/md5/common.py
2,357
3.609375
4
import math def process_md5_buffer( buffer ): """Generator that processes a buffer and returns complete OBJ statements. Empty lines will be ignored. Comments will be ignored. Multi-line statements will be concatenated to a single line. Start and end whitespace will be stripped. """ d...
725f84647af17d9c670ab18011ff2a4f8dac09f9
gabealvarez11/BrownianMassMeasurement
/Gabe/expectedMass.py
274
3.609375
4
# -*- coding: utf-8 -*- """ Created on Mon Jul 23 14:44:22 2018 @author: alvar """ import numpy as np def expectedMass(diameter): density = 2000 #kg / m^3 return density* 4./3*np.pi*np.power(diameter / 2, 3) diam = 2.01*10**(-6) #m print expectedMass(diam), "kg"
f2ff9d4871f43e99d46ae73f9d74fd836bb715ed
PauloAlexSilva/Python
/Sec_14_iteradores_geradores/a_iterators_iterables.py
666
4.71875
5
""" Iterators e Iterables Iterator: - É um objeto que pode ser iterado; - Um objeto que retorna um dado, sendo um elemento por vez quando uma função next() é chamada. Iterable: - Um objeto que irá retornar um iterator quando a função iter() for chamada. nome = 'Paulo' # É um iterable mas não é um itera...
071d438f2e8c0e9dd2b239f13b52d86073c7e7ab
clintKunz/Data-Structures
/binary_search_tree/binary_search_tree.py
1,563
4.03125
4
class BinarySearchTree: def __init__(self, value): self.value = value self.left = None self.right = None def __str__(self): return f'value: {self.value}' def insert(self, value): # check if the new node's value is less than our current node's value if value < self.value: # check if...
2127aeaa1ef3c8fa4c82f20c11353e6578fbe040
wusanshou2017/Leetcode
/using_python/154_findmin.py
278
3.5625
4
from typing import List import random # [2,2,2,0,1] class Solution: def findMin (self,nums:List[int])-> int: l =0 r = len (nums)-1 while l<r: mid =(l+r)//2 if nums[mid]<nums[r]: r=mid elif nums[mid]>nums[r]: l=mid+1 else: r-=1 return nums[l]
4202367baaac485691b433056e60821abe12279b
Tanjim-js-933/python-practice
/odd_even.py
147
4.21875
4
string = input("please give a number: ") num = int(string) if num % 2 == 0: print("it is a even number") else: print("it is a odd number")
de25eefc225ba5a51098c5a7a8b765ce9243d826
bschs1/IBM_data_science
/Scripts/numpy_aprendendo_01/numpy02_arrays_2D.py
3,713
4.65625
5
import numpy as np import matplotlib.pyplot as plt #O que vou ver nessa aula? #Criação de arrays 2D #Indexing e Slicing de Arrrays 2D #Operações básicas em Arrays 2D #[start:end:step] -> ARRAY SLICING # Slicing in python means taking elements from one given index to another given index. # # We pass slice...
98f95eb588c72a99ec6605fd2bdea716d8c2fc73
Rohan2596/Mytest
/FunctionalPrograms/eucldist.py
583
4.09375
4
import math import random # a= int(input("enter the a ")) # b= int(input("enter the b ")) # z=a*a + b*b # print(z) # sq=math.sqrt(z) # print("Distance is ",sq) # output: ################### # enter the a 89 # enter the b 8 # 7985 # enter the a 4 # enter the b -4 # 32 # Distance is 5.656854249492381 x=random.randint(-...
3b3465e8390d8a611ead939e0fb02ad9650496cc
ryanatgz/data_structure_and_algorithm
/jianzhi_offer/09_旋转数组的最小数字.py
1,312
3.75
4
# encoding: utf-8 """ @project:Data_Structure&&Algorithm @author: Jiang Hui @language:Python 3.7.2 [GCC 7.3.0] :: Anaconda, Inc. on linux @time: 4/2/19 9:34 PM @desc: 把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转。 输入一个递增排序的数组的一个旋转,输出旋转数组的最小元素。 例如数组{3,4,5,1,2}为{1,2,3,4,5}的一个旋转,该数组的最小值为1。 NOTE:给出的所有元素都大于0...
9e0fa3e63448b8ea0938d82b24498b93513ce4a2
KanagatS/PP2
/TSIS5/Part 1/10.py
119
3.546875
4
#count of each word in file from collections import Counter f = open('test.txt', 'r') print(Counter(f.read().split()))
00bbe2b68ea1165995e35b099ffdd1623899b2be
ZekeMiller/euler-solutions
/solutions/026_decimal_repititions/fraction_repititions.py
652
3.546875
4
def genPrimes( max ): primes = [2] for i in range( 3, max, 2 ): for k in primes: if i % k == 0: break primes += [ i ] return primes def multOrder( g, n ): i = 1 while g ** i % n != 1: i += 1 return i def calcPeriod( val ): if val % 2 ...
922a500936f04c63242f8e083d4202de5fe7ccf2
Jayesh598007/Python_tutorial
/Chap3_strings/10_prac5.py
204
3.5
4
# practise for escape sequence letter = "Dear Jayesh, this python course is nice!, Thanks!" print(letter) formatted_letter = "Dear Jayesh,\nThis python course is nice!,\nThanks!" print(formatted_letter)
f6d4ae478877058cf938677b2596e29b8ac626a7
NataFediy/MyPythonProject
/hackerrank/math_find_angle.py
662
4.40625
4
#! Find the value of angle in degrees # Input Format: # The first line contains the length of side AB. # The second line contains the length of side BC. # # Output Format: # Output the value of angle in degrees. # # Note: Round the angle to the nearest integer. # # Examples: # If angle is 56.5000001°, then output 57°. ...
977b2b396f19bd0b61ca5b13d334c7796d66c73c
Yogesh6790/PythonBasic
/com/test/final/testclassfile.py
523
3.546875
4
class TestClass: def __init__(self, x=0, y=0, z=0): self.x = x self.y = y self.z = z @property def x(self): return self._x @x.setter def x(self, val): self._x = val @property def y(self): return self._y @y.setter def y(self, val): ...
4f3f8f7bd519d2ff47babcc67f414415cf6568b7
gurram444/narendr
/hareesh.py
844
4
4
n=int(input("enter number:")) #find powers of number i=int(input("power of number:")) j=n**i print(j) sentense='narendrabsccomputers' #find all vowels and their count in sentense vowel=['a','e','i','o','u'] for i in vowel: if i in sentense: print(i,sentense.count(i)) list=[2,3,4,1,4,6,9,12,23...
21c6f0e5ee45ea0f36a5db0623d3b59e352c3950
vvweilong/OpenCVproj
/getSetPixel.py
865
3.546875
4
#!/usr/bin/env python # coding=utf-8 import cv2 import numpy as np # 读取图像 oImg = cv2.imread("pic.jpg") # 方法一: # # 为了看效果 采用 for 修改了一条线 # for i in range(100, 200,1): # # 获取某个像素点 # for j in range(100,200,1): # # 这里进行的是值拷贝 修改 px 对象 对 oimg 没有影响…… # px = oImg[i, j] # # 修改该像素的 rgb 值 ...
3cdb6a30c5859af87dfdc63887c3b64765e59965
ChristinaEricka/LaunchCode
/unit1/Chapter 08 - More About Iteration/Chaapter 08 - Exercise 01.py
602
4.21875
4
# Write a function print_triangular_numbers(n) that prints out the first n # triangular numbers. A call to print_triangular_numbers(5) would produce # the following output: # # 1 # 3 # 6 # 10 # 15 def print_triangular_numbers(n): """Print out the first <n> triangular numbers""" su...
5927eb63d34ae2aa4199fc71324c4f6d44030472
rajrahul1997/Code-Practice
/pattern/pattern3.py
543
3.6875
4
'''Program to print pattern below 0 101 21012 3210123 432101234 if (N=4) is given by user here three loop of j is running 1st one is printing space 2nd loop is ruuning from j(i,0,-1) and printing value of left side to zero 3rd loop is ruuning from j(0,i+1) an dprinting value of right side to zer...
9615920dca520c085b93739cc2a1fe54d305ad19
varun1414/Xformations
/Scrappers/to_csv.py
467
3.625
4
import csv def convert(data,name): csv_columns = ['comp','date','result','teams','score','formation'] dict_data = data csv_file = name try: with open(csv_file, 'w') as csvfile: writer = csv.DictWriter(csvfile, fieldnames=csv_columns) writer.wri...
126f60d2d6f41a89012223cc1ff1875fa1bdef63
dyrroth-11/Information-Technology-Workshop-I
/Python Programming Assignments/Assignemt2/3.py
1,024
3.84375
4
#!/usr/bin/env python3 """ Created on Thu Apr 2 07:38:27 2020 @author: Ashish Patel """ """ Write a Python program to replace dictionary values with their sum. Example: Input: {'id' : 1, 'subject' : 'math', 'V' : 70, 'VI': 82}, {'id' : 2, 'subject' : 'math', 'V' : 73, 'VI' : 74}, {'id'...
35377ec521580c40343d95eaad24a78e801b3bd0
alegde/data_structures_and_algorithms
/cs_algorithms/stack.py
503
3.703125
4
class Stack: def __init__(self): self.my_stack = [] def _is_empty(self): if len(self.my_stack) == 0: return True else: return False def push(self, value): self.my_stack.append(value) def pop(self): if self._is_empty(): retu...
c524dfb4f742a99dad781be013df79d3e58694c7
stephalexandra/u3l5
/u3l5/problem6.py
168
3.546875
4
firstname = "Albus" lastname = "Dumbledore" fullname = firstname + " " + lastname print(firstname + " " + firstname) print(lastname + " " + lastname) print(fullname)
8f0c78bdb2b1dc230dec9be38e5f45199b5293b9
csJd/oj-codes
/leetcode/179.largest-number.py
1,268
3.734375
4
# # @lc app=leetcode id=179 lang=python3 # # [179] Largest Number # # https://leetcode.com/problems/largest-number/description/ # # algorithms # Medium (26.29%) # Likes: 1138 # Dislikes: 147 # Total Accepted: 138.4K # Total Submissions: 525.7K # Testcase Example: '[10,2]' # # Given a list of non negative integer...
8ef9db967e753b1641ab78da6a010bb4e7b16960
nathanielb91/SeleniumPractice
/SearchAmazonForBattletoads.py
856
3.6875
4
""" This code loads Chrome, searches amazon.com for a video game, and prints out the product names along with their price """ from selenium import webdriver driver = webdriver.Chrome() driver.implicitly_wait(30) driver.get('https://www.amazon.com') # get the search textbox search_field = driver.find_element_by_id('tw...
f186a4634f4f7c10416619491a4252cddd3f3fae
krocki/ADS
/leetcode/007_reverse_int.py
585
3.671875
4
# -*- coding: utf-8 -*- # @Author: Kamil Rocki # @Date: 2017-01-31 15:39:44 # @Last Modified by: Kamil Rocki # @Last Modified time: 2017-01-31 15:39:46 class Solution(object): def reverse(self, x): """ :type x: int :rtype: int """ res = 0 if x < 0: ...
12bcadc8452d3f237b5bd1200f0b0f9734fe06db
hzhnb/python2
/037-算数运算1.py
182
3.734375
4
print(type(len)) a = int(123) b = int(456) print(a+b) # class New_int(int): def __add__(self, other): return int(self)+int(other) n = New_int(2) m = New_int(3) print(m+n)
ffa6eba669d02fee03c0ca5f22578141c30ab698
Nathalia1234/Python
/Python_7_PontoFlutuante/ponto_flutuante.py
518
4.1875
4
num = 10 dec = 10.5 texto = "ola" print() print("Concatenação de inteiros") print("O valor é:", num) print("O valor é: %i" %num) print("O valor é: " + str(num)) print() print("Concatenação de números float") print("Concatenação de decimal: ", dec) print("Concatenação de decimal: %.2f" %dec) print("Concatenação de decim...
c60d9965fa077ea029a11f992eef6d238132ab8e
Shikhar99-lab/Python-CDLine-Database-Apps
/ProjYou.py
2,961
3.78125
4
import sqlite3 as lite # functionality goes here class DatabaseManage(object): def __init__(self): global con try: con = lite.connect('videos.db') with con: cur = con.cursor() cur.execute("CREATE TABLE IF NOT EXISTS video(Id INTEGER PRIMA...
aa96840769442733fb84b5b06d602b981fa0f948
Sarang-1407/CP-LAB-SEM01
/CP Lab/Lab2/4.py
380
4.15625
4
# Lab Project by Sarang Dev Saha # LAB_02 QUE_04 # Take a list of 10 nos. and remove 3rd to 6th elements and change the value of last element with a number taken from the user. list=[0, 1,2,3,4,5,6,7,8,9] #Deleting 3,4,5 and 6 from the list del list[3:7] #printing the omitted list print(list) # Entering input at th...
670597fd7ac549513473899a7a56f4c03ca86d0b
juliagolder/project-2
/Yahtzee.py
4,404
3.515625
4
#juliagolder #5/23/18 #Yahtzee.py from random import randint def printRoll(dice): #prints out list of dice print(dice) def printCard(scoreL): #prints out scorecard print('1: Aces -', scoreL[0]) print('2: Twos -', scoreL[1]) print('3: Threes -', scoreL[2]) print('4: Fours -', scoreL[3]) prin...
64ecb937173646821e241e4d79d7ca3c585552a1
anya92/learning-python
/2.Lists/nested_lists.py
613
4.1875
4
nested_list = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] # accessing items print(nested_list[0]) # [1, 2, 3] print(nested_list[-1]) # [7, 8, 9] print(nested_list[1][1]) # 5 # looping through a nested list for i in nested_list: for j in i: print(j) # nested list comprehensions print([[num for num in range(1...
32ff106056221e63c1d89f2d88f6af10658fa2a4
r25ta/USP_python_1
/semana4/fatorial.py
181
3.96875
4
def main(): print("Fatorial") n = int(input("Digite o valor de n:")) fat=1 while (n > 0): fat = fat * n n = n - 1 print(fat) main()
3aceca8ec2a3d395ef3f166a44d08a004ec2f7f9
justinnnlo/leetcode-python
/290 Word Pattern.py
1,322
4.1875
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" should ...
c22c629fbfc70ae7db320660770c26a50be36fb7
lixiaoya0313/pythonbox
/execise_004.py
902
4.03125
4
#import turtle #t = turtle.Turtle() #t.speed(0) #t.color("pink") #for x in range(100): # t.circle(x) # t.left(93) #input("Press <enter>") # coding: utf-8 print('我是能减乘除的计算器~') while True: def add(x, y): return x + y def subtract(x, y): return x - y def multiply(x, y): retur...
1dc15c12d2ad74c01ad8827f162f24620383efdf
ebunsoft/pythontask
/loop.py
84
3.78125
4
#Loopingin Python sum = 0 for i in range (1, 11, 3): sum = sum + i print(sum)
f4ccc900d319f6ea65acd48dd4d8a50bc8f5b265
Tomgauld/python-year11
/YorN.py
202
3.859375
4
def answer (Y,N): input("Y or N?") if answer == ("Y"): print("Valid entry") if answer == ("N"): print("Valid entry") else if print("Invalid entry")
2629e5db23acc2a7c1ad73a340bb320740c9765e
datAnir/GeekForGeeks-Problems
/Greedy/activity_selection.py
1,176
3.96875
4
''' https://practice.geeksforgeeks.org/problems/n-meetings-in-one-room/0 There is one meeting room in a firm. There are N meetings in the form of (S[i], F[i]) where S[i] is start time of meeting i and F[i] is finish time of meeting i. What is the maximum number of meetings that can be accommodated in the meeting room? ...
14e466e7c55721e1d47f54fe7aa58af61c014e9a
DwyaneTalk/ProgrammingLanguage
/PythonCookbook/Chapter1/Chapter1_3.py
708
3.546875
4
# FileName : Chapter1_3.py ''' 保留最后优先个历史记录 关键点: collections.deque with *A as *B:将*A赋值给*B,并在前后会执行*B对象的__enter__()和__exit()__ yield: 指定函数为生成器函数,作用是将序列的结果依次返回节省空间 ''' from collections import deque def search(lines, pattern, history = 5): previous_lines = deque(maxlen = history) for line in lines: if pattern in line: ...
5816597123107c61466f3ed205e612815e55e909
preetsimer/assignment-6
/assignment-6.py
673
3.859375
4
#question 1 def area(r): a=4*r*r*3.14 print("The area of sphere is ",a) n=int(input("Enter radius of sphere: ")) area(n) #question 2 s=0 for num in range(1,1001): for i in range(1,num): if num%i==0: s=s+i if s==num: print(num) s=0 #question 3 n=int(input("Enter a n...
5d29193af663c95bc73bc1c23159e68e18dae2b4
ivenpoker/Python-Projects
/Projects/Online Workouts/w3resource/Basic - Part-II/program-50.py
1,680
4.28125
4
#!/usr/bin/env python3 ################################################################################## # # # Program purpose: Finds a replace the string "Python" with "Java" and the # # string "Java" with "P...
97073c12cf795d02974022556cb0109c97239542
clacroi/MTH6412B
/queue.py
1,379
3.96875
4
class Queue(object): """Une implementation de la structure de donnees << file >>.""" def __init__(self): self._items = [] @property def items(self): return self._items def enqueue(self, item): "Ajoute `item` a la fin de la file." self.items.append(item) def de...
25f6c8157a790a0e74b75e7dff2acb722223c7b6
Nanutu/python-poczatek
/module_4/zad_130/homework_1/main.py
623
4.28125
4
# Stwórz odpowiednik klasy Apple jako named tuple. # # Stwórz instancję takiej krotki, a następnie wypisz zawarte w niej dane na trzy sposoby: # # a) korzystając z nazw # b) odwołując się do kolejnych indeksów # c) za pomocą pętli from collections import namedtuple Apple = namedtuple("Apple", ["species_...
54d9d1e8db127cf8e082e1f8decb34e16146ff5c
jeon-jeong-yong/pre-education
/quiz/pre_python_11.py
254
3.71875
4
"""11. 최대공약수를 구하는 함수를 구현하시오 예시 <입력> print(gcd(12,6)) <출력> 6 """ def gcd(a, b): i = min(a, b) while True: if a % i == 0 and b % i == 0: return i i -= 1 print(gcd(12, 6))
3b9d8fa76bdfb51811a9c3d1da11d70c914f85cb
Takemelady/CP3-Pattarasri-Piti
/Excercise21_Pattarasri_P.py
1,248
3.53125
4
from tkinter import * import math def leftClickButton(event): bmiResult = float(textBoxWeight.get())/math.pow(float(textBoxHeight.get())/100,2) if bmiResult <= 18.5: a = "ผอมเกิน" elif bmiResult <= 22.9: a = "ปกติ" elif bmiResult <= 24.9: a = "น้ำหนักเกิน" elif bmiResult <= ...
b98261817f3d2962cf0fba64a03b40f0879823e5
mateusisrael/Estudo-Python
/Assuntos Diversos/Testando Funções/5 - Retorno de Valores.py
315
3.921875
4
# Retorno de Valores # Toda função é capaz de retornar valor. '''def soma(): return 10 print(soma())''' '''def soma(x, y): return x*y print(soma(10, 20))''' def soma(x, y): num = x * y return num # return faz com que a função pare após o valor ser retornado print(soma(10, 20))
b429a209b02a82aa7e58e5e4bfc8e53cf3a3f759
hnz71211/Python-Basis
/com.lxh/exercises/37_difference_set/__init__.py
279
3.84375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 返回集合 {‘A’,‘D’,‘B’} 中未出现在集合 {‘D’,‘E’,‘C’} 中的元素(差集) set1 = {'A', 'D', 'B'} set2 = {'D', 'E', 'C'} set3 = set1.difference(set2) set4 = set1 - set2 print(set3) print(set4)
113a4543d90c66dac33bb1a1b8dcc2a576501568
yongtao-wang/leetcodes
/algorithms/lists.py
96,692
3.828125
4
# -*- coding: utf-8 -*- class Interval(object): def __init__(self, s=0, e=0): self.start = s self.end = e class Lists(object): def twoSum(self, nums, target): """ # 1 Given an array of integers, return indices of the two numbers such that they add up to a specific tar...
058d5277dcc28c95054d6ffe25e42f40b5ec8dbd
MistaRae/week_02_day_03_pub_lab
/tests/food_test.py
396
3.59375
4
import unittest from src.food import Food class TestFood(unittest.TestCase): def setUp(self): self.food_1 = Food("Pie", 2.50, 10, 10) def test_food_setup(self): self.assertEqual("Pie", self.food_1.name) self.assertEqual(2.50, self.food_1.price) self.assertEqual(10, self.f...
acb4ea2a050f484cf9dd12e6459e66f6e2e59325
jamanddounts/Python-answers
/4-8.py
97
3.578125
4
a = input("Input First Name:") b = input("Input Last Name:") print(a+b) #any letter works btw :)
02dc3a901c01b82a690e0a2e7c637ba99d65e844
haerba/SAD
/HangMan/Hangman_Visualizer.py
2,834
3.71875
4
''' Created on 9 Mar 2019 @author: haerba ''' class Hangman_Visualizer(object): def __init__(self, name): self.name = name self.wrong_letter_strings = [] self.correct_letter_strings = [] self.hanged_man = [] self.charge_HangedMan() def print_currentS...
63f33acfd4983a8d927424754bb2a458e728a787
quangnhan/PYT2106
/Day10/fuc/bai2/shop.py
2,172
3.5625
4
from products import Product from database import Database class Shop: def __init__(self, name, products, money): self.products = products self.name = name self.money = money def show_all_product(self): for item in self.products: print(f"amount: {item['amount']}\t ...
a0d4a8084a84705a4a8151e568e040528c5c3987
pyh3887/Tensorflow
/py_tensorflow/pack/tf3/케라스20_이미지분류.py
3,093
3.515625
4
# CNN(Convoluation) # convolution : feature extraction 역할 import tensorflow as tf from tensorflow.keras import datasets,layers,models import sys (x_train,y_train),(x_test,y_test) = tf.keras.datasets.fashion_mnist.load_data() print(x_train.shape, ' ', y_train.shape) # (60000, 28, 28) (60000,) print(x_test.shape...
bc11cec9c380b4f15ccd108ea244ab415f8abbfc
titf512/FPRO---Python-exercises
/overlap_segments.py
531
3.78125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Feb 14 09:14:10 2021 @author: teresaferreira """ def overlaps(segments): lst=[] sett=set() for i in range(len(segments)): a=[x for x in range(segments[i][0],segments[i][1]+1)] lst+=[a] for k in range(len(lst)): f...
37599fcdc322912d59d16638459d3e7637c04dbd
Sharan1425/pythonProject1
/venv/Palindrome.py
126
4.0625
4
n = input("Please enter the input: ") if n == n[::-1]: print(n,"is a palindrome") else: print(n,"is not a palindrome")
4541b293c58dbd978594a745b239a0b16e98a87e
scls19fr/openphysic
/python/oreilly/cours_python/solutions/exercice_12_04.py
731
3.59375
4
#! /usr/bin/env python # -*- coding: Latin-1 -*- class Satellite: def __init__(self, nom, masse =100, vitesse =0): self.nom, self.masse, self.vitesse = nom, masse, vitesse def impulsion(self, force, duree): self.vitesse = self.vitesse + force * duree / self.masse def ener...
488693d68288ed23463eb962318831c356bc6e17
leehm00/pyexamples
/Python概述/面向对象/创建类的实例成员(方法).py
680
3.828125
4
# _*_ coding.utf-8 _*_ # 开发人员 : leehm # 开发时间 : 2020/6/22 10:15 # 文件名称 : 创建类的实例成员(方法).py # 开发工具 : PyCharm # 与函数类似,第一个参数必须是self且必须是包含此参数 class Geese: """大雁类""" def __init__(self, beak, wing, claw): # 构造方法只能有一个 print('大雁类') # 判断init是否执行了 print(beak, wing, claw) def fly(self, state='可以飞'):...
a09c6287e6141315348816462ff6fdc63097b4e6
Zgurskaya/geekbrains_python
/lesson_3/homework_3/home_7.py
907
4.34375
4
""" Продолжить работу над заданием. В программу должна попадать строка из слов, разделённых пробелом. Каждое слово состоит из латинских букв в нижнем регистре. Нужно сделать вывод исходной строки, но каждое слово должно начинаться с заглавной буквы. Используйте написанную ранее функцию int_func(). """ def int_func(st...
d79844e0d0df3392592a6d500296b6ffcf73cba8
greatteacher/lesson2part1
/not4u/pincode.py
363
3.734375
4
line=input('введите свой пинкодище ') a=type(line) if a !=str: print('O no no no') t1=input('введите свой пинкод ') t1=str(t1) t2=input(' повторишь свой пинкод? ') t2=str(t2) if t1 == t2: print('попал') else: print('попробуй в другой раз, у тебя получится')
73a6a886e5c0d9ccc1d5e8e4a4621c7ae5239f81
avadhootkulkarni/learn_python_hard_way_exercises
/ex14.py
712
3.703125
4
from sys import argv script, user_name, age = argv prompt = 'Answer - ' print "Hi %s, I'm the %s script." % (user_name, script) print "I'm gonna ask you a few questions" print "Do you like me, %s" % user_name likes = raw_input(prompt) print "Where do you live, %s" % user_name lives = raw_input(prompt) print "What c...