blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
0e5735b7e6c7038487a859e871f5133584916d40
hyperion-mk2/git
/jumpgame1.py
411
3.5625
4
class Solution(object): def canJump(self, nums): """ :type nums: List[int] :rtype: bool """ l=len(nums) s=0 for i in range(l): s=max(s,i+nums[i]) if s>=(l-1): return True if i==s: break ...
8379d21b7aa4c339107ecab50ec35f04df582a41
rainly/scripts-1
/cpp2nd/e9-2.py
296
3.8125
4
def ex9_2(): ''' print the first N lines of file ''' filename = raw_input('pls enter your filename:') num = int(raw_input('how many lines do you want print:')) f = open(filename) index = 0 while index < num: print f.next(), index +=1 f.close()
a554b9fe96ccabb6e234f5c1eb8b12b5ab467e8c
ericf149/Practice_Projects
/coin_toss.py
425
3.796875
4
# -*- coding: utf-8 -*- """ Created on Tue Feb 16 20:13:04 2021 @author: Eric """ from math import factorial as fac def binomial(n,k): if k==0: return 1 Bino = fac(n) // fac(k) // fac(n-k) return int(Bino) prob = binomial(100,60) / 2**100 def coinProb(n,k): sums = [] for i in range(k,n): ...
b57534de1517b308cf8ed9ae42eb6fd24c55127c
anshuldante/ai-ds-ml-practical
/essential-math-for-machine-learning-python-edition/Exercise Files/iteration1/trials.py
398
4.1875
4
import pandas as pd import matplotlib.pyplot as plt # Create a dataframe with an x column containing values from -10 to 10 df = pd.DataFrame ({'x': range(-10, 11)}) # Add a y column by applying the solved equation to x df['y'] = (3*df['x'] - 4) / 2 #Display the dataframe print(df) plt.plot(df['x'], df['y'], color='...
292307d7151aff58c940e88402e18e3b961f7ceb
Inimesh/PythonPracticeExercises
/4 Function exercises/Ex_89.py
1,673
4.3125
4
## A function that will capitalise letters, like in a predictive text app. # The letters to be caapitalised: "i" with a space either side, the first # character in the string and the first non-space character after ".", "!", or # "?". The function returns the corrected string. Main() program reads the # string, capital...
e5243092faee9e758b6b3d45d51e194ef4e9f843
moontree/leetcode
/version1/1349_Maximum_Students_Taking_Exam.py
4,417
3.6875
4
""" ========================= Project -> File: leetcode -> 1349_Maximum_Students_Taking_Exam.py Author: zhangchao ========================= Given a m * n matrix seats that represent seats distributions in a classroom. If a seat is broken, it is denoted by '#' character otherwise it is denoted by a '.' character. Stud...
b22320e352ec7e2a27922b7b40100b551c2b4490
ww35133634/chenxusheng
/ITcoach/xlrd_xlwt处理数据/第9章 Python函数技术/9.6 匿名函数写法及应用/9.6.1.py
624
3.5625
4
# d=lambda :'test' # print(d()) # print((lambda :'test')()) # # # d1=lambda x,y,z:x+y+z # print(d1(3,5,6)) # print((lambda x,y,z:x+y+z)(54,2,13)) # d2=lambda x,y,z=100:x+y+z # print(d2(y=200,x=600)) # print((lambda x,y,z=100:x+y+z)(34,23)) # d3=lambda x,*y:x(y) # print(d3(sum,5,23,7,1)) # print((lambda x,*y:x(y))(le...
ee00ebd9d4c7e1dfeb5bc47a4c9a3bce9363e836
djpandit007/mini-metro
/station.py
372
3.59375
4
from enum import Enum, unique @unique class ShapeEnum(Enum): CIRCLE = 1 SQUARE = 2 TRIANGLE = 3 class Station(object): def __init__(self, shape): try: self.shape = ShapeEnum[shape.upper()] except KeyError: print("Shape '" + shape + "' not found in ShapeEnum") ...
0a0b64ac70a00289ad3b31eaddf4d236c20a0279
jiangjiane/Python
/pythonpy/third_xiti3.py
291
3.921875
4
#第三部分习题 #第三题 D={'a':1,'b':2,'c':3,'d':4,'e':5} print('origin D: ',D,'\n') Ks=list(D.keys()) Ks.sort() print('sort D: ') for k in Ks:print(k,D[k]) print('\n') print('sorted D: ') ks=D.keys() for k in sorted(ks):print(k,D[k]) print('\n') for k in sorted(D):print(k,D[k])
4fb862a1adda1daa3d3997e1d62a6088a81d2351
p0leary/cs1301x
/5-2.py
4,171
4.375
4
#Write a function called string_search() that takes two #parameters, a list of strings, and a string. This function #should return a list of all the indices at which the #string is found within the list. # # # #You may assume that you do not need to search inside the # #items in the list; for examples: # # # # string...
6a7f038240b615b16b63ebfef5e80fdd796ea4af
juandelima/Password-validation---Python
/password_validation.py
2,086
3.65625
4
#CREATED BY JUAN VALERIAN DELIMA #the algorithm is made by juan def create_lists(kata): new_arr = [] for kata1 in kata: for huruf in kata1: new_arr.append(huruf) return new_arr def sorting_huruf(password): arr = create_lists(password) for index in range(1, len(password)): current_...
3aa0552dc1a61f5422a2acbb85009d49a575e772
jlouiss/CS50
/pset7/houses/roster.py
607
3.65625
4
from sys import argv, exit import cs50 def main(): if (len(argv) != 2): exit(1) db = cs50.SQL("sqlite:///students.db") result = db.execute("SELECT first, middle, last, birth FROM students WHERE house = ? ORDER BY last, first", argv[1]) for student in result: first = student["first"] ...
f589fc4c9761b52ad16487580a8b5975c39ed4b8
wmy-one/python-project
/variableDemo.py
608
4.09375
4
# -*- coding:utf-8 -*- #python语言的变量使用 ''' python语言的变量不用声明数据类型,可以直接赋值,既,给变量赋什么类型的数据, 变量的数据类型就是什么数据类型;赋值后,python的变量指向该数据所在内存单元的地址, 当重新给变量赋值时,该变量又指向了新的数据所在的内存单元的地址。可以使用id()函数 查看变量指向的内存单元的地址 ''' a = 12 b = 13 print 'a= ',a, id(a) print 'b= ',b, id(b) a=b print 'a= ',a, id(a) print 'b= ',b, id(b) a=15 b=16 print 'a= ',a,i...
38821832b76a0efa68b5b48b0176ed767cc25e4e
chjlarson/PythonPractice
/Arrays/ArrayPairSum/pairSum.py
800
3.78125
4
# Given an integer array, output all the unique pairs that sum up to a specific value K. def pairSum(arr, k): # Return if the length of the array is less than 2 # Edge case if len(arr) < 2: return # Sets for tracking seen = set() output = set() for num in arr: ...
28139eefa5ca456be8a2f4c0bc6454509e53ffa0
N-eeraj/perfect_plan_b
/in_list_for.py
175
3.9375
4
import read lst = read.ReadList() key = read.Read(str, 'Key to Search') for i in lst: if i == key: print(key, 'is in the list') exit() print(key, 'is not in the list')
4f0c115c9ced0b927829d3c9c0b1f4c364607cc1
vansh-kapila/DSA_Class_Codes
/python/selectionSort.py
384
3.78125
4
if __name__=="__main__": n = int(input("Enter the size of the array -> ")) arr=list(map(int,input("Enter the elements -> ").strip().split())) print("Before sorting ->",arr) for i in range(n): idx=i for j in range(i,n): if arr[j]<arr[idx]: idx=j arr[i],...
1e3789c0183bca06b8d8091e830b449a4d55e375
Aftabkhan2055/Machine_Learning
/python1/od.py
131
3.65625
4
n=int(input("enter the no")) i=1 while i<=20: print("table",n,"*",i,"=",n*i) i=i+1
a8202dcf57405eae7d017617f40887be331f39ab
fbarenys/Frogger-git
/Cars.py
1,577
3.703125
4
from tkinter import * class Vehicle: def __init__(self, x, y, speed=5): self.x = x self.y = y self.speed = speed def move(self): self.x+=self.speed def stopMove(self): self.x=self.x class Car(Vehicle): width=30 height=20 def __init__(self,x,y,speed=5):...
d746560e8bfb227e3b1c671637479daaa75a5ff6
EMI322585/ILZE_course
/PYTHON/oop.py
1,311
3.8125
4
from datetime import datetime class BasketballPlayer: def __init__(self, first_name, last_name, height_cm, weight_kg, points, rebounds, assists): self.first_name = first_name self.last_name = last_name self.height_cm = height_cm self.weight_kg = weight_kg self.points = point...
ab7179425d164a7021c3a7ae8e935860a9972ff5
Raushan-Raj2552/URI-solution
/2143.py
244
3.796875
4
while True: a = int(input()) if a == 0 : break if a > 0 : for i in range(a): b = int(input()) if b%2 == 0: print(2*b-2) else: print(2*b-1)
4a54e9e0d69feefe825c8736bb44b7ba2cb99ba9
DrewStock/python-intro
/00_python_class/PythonClass_DaysAlive.py
497
4
4
Name = raw_input ('Name: ') print "Hello " + Name + "! We are going to find out how long you have been alive!" Age = int(raw_input('How old are you?: ')) print "You are " + str(Age) + " years old." Months = Age * 12 # 12 is the number of months in a year Days = Age * 365 # 365 is the number of days in a year p...
7586b227b2e3892b5df73bfadf37d9e6fc110ead
phelpsh/pythonQs
/elements.py
2,385
4.34375
4
# Find the element in a singly linked list that's m elements from the end. # For example, if a linked list has 5 elements, the 3rd element from the end # is the 3rd element. # The function definition should look like question5(ll, m), # where ll is the first node of a linked list and m is the "mth number from...
5c0984cc0b0a40f72149458f3ac64e11e1f7080b
LEXW3B/PYTHON
/python/exercicios mundo 1/ex005/ex007.py
516
4.25
4
#faça um programa que leia uma frase pelo teclado e mostre.(quantas vezes aparece a letra 'a'),(em que posição aparece a primeira vez),(em que posição ela aparece a ultima vez). frase = str(input('digite uma frase: ')).upper().strip() print('a letra A aparece {} vezes na frase'.format(frase.count('A'))) print('a primei...
f35633d99c0b3f1be15fbb829d30d8d5fba0a801
shrewdmaiden/Clue
/Rooms/Rooms.py
2,263
4.25
4
__author__ = 'gregory' class Room(object): '''All rooms have greeting, instructions, direction_choice, direction instructions, room instructions, and room name. Dictionary that lists direction and corresponding room.''' current_room = '' def __init__(self,room_name): self.greeting = "You are...
57d56f035ad8ff0917702f10cb08387acaf40fb8
rafaelperazzo/programacao-web
/moodledata/vpl_data/31/usersdata/132/9653/submittedfiles/atividade.py
305
3.71875
4
# -*- coding: utf-8 -*- from __future__ import division import math n=input('digite a quantidade de pontos:') i=1 while(i<=n): x=input(' digite o valor de x:') y=input(' digite o valor de y:') if x>=0 and y>=0 and x**2+y**2<=1: print('SIM') else: print('NAO') i=i+1
7dd00f700ba8abfa77321e8f53f97bf8d95565ef
bgbutler/PythonScripts
/Exercises/soundsBalls.py
3,229
3.546875
4
# Sound # Bouncing Sounds # This program draws a ball that makes sounds when it bounces # off the side of the canvas. import simplegui import math import random # Global Variables canvas_width = 400 canvas_height = 400 sound_a = simplegui.load_sound("http://commondatastorage.googleapis.com/codeskulptor-assets/wee...
91921a01967dd9dfe2d7e1a97e5b344e67d78e1f
loveplay1983/python_study
/21_oop/class_instance/class_method/pets/pets.py
521
4.09375
4
class Pets: """ The following code will cause problem when calling about() method since python interpreter cannot distinguish which class instance is about to call. The correct version can be done by classmethod """ name = 'Pets name' @staticmethod def about(): print(...
e2bcdec61e0812a8c6abffb2b31072161ae2cf88
spongebob03/Playground
/baekjoon/Bronze/b_10947.py
172
3.78125
4
import random lotto=list() for i in range(0,6): r=random.randrange(1,45) if r not in lotto: lotto.append(r) for i in lotto: print(i,end=' ')
3d29aec9fdbc5c1aa7844a528c04f95d7b3c10ae
Luciana1012/Intech
/Term 5 - algorythms/Testing.py
3,662
4.40625
4
import unittest def sum(array): """ This function will display the sum of all elements added together. Input: array (list) array of numbers Output: return the sum of all numbers in array. """ sumValue = 0 for element in range(0,len(array)): sumValue += array[element] ...
7cbb29af35d5df3e29b4e8994fa50743146ebf84
deft727/FlaskRestApiWithETL-script
/script.py
988
3.5
4
import requests import json import sqlite3 with sqlite3.connect("mydatabase.db") as conn: cur = conn.cursor() cur.execute('''CREATE TABLE IF NOT EXISTS users ( id INTEGER PRIMARY KEY, first_name TEXT, last_name TEXT)''' ) count=0 while count!=100: ...
482a380dcf09d4d3e29565a27299cc38cdcdafce
kzeidlere/patstavigie-darbi
/patstavigais_darbs_2/main.py
1,190
4.3125
4
import random wins = 0 loses = 0 while wins < 3 and loses < 3: computer_choice = random.randint(1, 3) if computer_choice == 1: computer_turn = 'Rock' elif computer_choice == 2: computer_turn = 'Paper' elif computer_choice == 3: computer_turn = 'Scissors' print('Enter 1 fo...
0e99ca72b873dca476964849dfc825f4726abedd
khanmaster/oop_4_pillars
/python.py
411
3.59375
4
from snake import Snake class Python(Snake): def __init__(self): super().__init__() self.large = True self.lungs = True def _change_skin(self): # hidden methods are created by using _ return " python sheds skin while growing up" cobra = Python() print(Python._change_skin(self...
35c9398f8db843fef05a0867e48e70242b4c7ff9
Jasonzy1015/python-5
/爬虫/Include/spider入门1/endecode.py
211
3.546875
4
#编码解吗模块 import urllib.request as urllib2 import urllib.parse word={"name":"张三"} word2=urllib.parse.urlencode(word)#编码操作 print(word2) word3=urllib2.unquote(word2)#解吗操作 print(word3)
a57b54748c0aab780dd02805ff39be7ed157b05f
JennieOhyoung/interview_practice
/rpn_evaluator.py
2,548
4.0625
4
""" Implement a RPN evaluator. It should be able to evaluate the following strings and answer with the corresponding numbers: "1 2 +" = 3 "4 2 /" = 2 "2 3 4 + *" = 14 "3 4 + 5 6 + *" = 77 "13 4 -" = 9 And should provide an error message for the following types of errors "1 +" (not enough arguments) "a b +...
b3942d4422a17c333e9c1a627e9988df8b578493
zeyi1/Wallbreakers
/Week 1/Simple String Manipulation/validPalindrome.py
985
4.03125
4
""" Procedure: Use two pointers (left, right) to point to the beginning and end of the string. Loop until left >= right, at each iteration keep moving the pointers until they reach an alphanumeric character and making sure left < right holds true. If the character at left does not match the character at right, then it ...
c5ad949fed9b52e1cf742c49cb8a7c326fae01ea
15zhazhahe/LeetCode
/Python/111. Minimum Depth of Binary Tree.py
1,240
3.71875
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution1: def minDepth(self, root): """ :type root: TreeNode :rtype: int """ ans = [-1] def dfs(no...
f80c39565bd2f779f3cb22a8ec398411d93ddd0c
Cronvall/Calculator
/CalculatorGUI.py
2,573
3.890625
4
# package calculator from tkinter import * from Calculator import * # A graphical user interface for the Calculator # # **** NOTHING TO DO HERE **** class CalculatorGUI: @staticmethod def calculator_program(): gui = CalculatorGUI() gui.start() def __init__(self): ...
2347eff9af41d632c5f8557baba723950abcfd95
yegeli/month2
/day03/buffer.py
365
3.65625
4
""" 缓冲区示例 """ # f = open("file",'w') # 普通缓冲 常用 # f = open('file','w',1) # 行缓冲 换行自动刷新 f = open('file','wb',10) # 设置缓冲区为10字节 while True: data = input(">>") if not data: # 直接回车结束循环 break f.write(data.encode()) # f.flush() # 手动刷新缓冲 f.close()
1537a8508d017b2b17d039640ab01e7050f2a21d
guyman575/CodeConnectsJacob
/semester1/lesson10/shapestuff.py
1,470
4.125
4
from abc import ABC, abstractmethod from math import pi # Shapes # get the perimeter/circumfrence # get the area # print a summary of the shapes dimensions class AbstractShape(ABC): def __init__(self): super().__init__() @abstractmethod def getPerimeter(self): pass @abstractmet...
eaae0e4c728281050e69e82bd957f24e80fea651
oldcast1e/Python
/Python Lecture/daily task/1.19/t2.py
545
3.578125
4
""" (두 자리 수) × (두 자리 수)는 다음과 같은 과정을 통하여 이루어진다. 8 3 (1) x 7 4 (2) -------- 3 3 2 (3) 5 8 1 (4) -------- 6 1 4 2 (5) (1)과 (2)위치에 들어갈 두 자리 자연수가 주어질 때 (3), (4), (5)위치에 들어갈 값을 구하는 프로그램을 작성하세요. [입력예시] 83 74 [출력예시] 332 581 6142 """ n1 = int(input()) #83 n2 = int(input()) #74 R1 = n2%10 #4 ...
79c1bd051741a236a5ee0bcca504fe953e5d4a36
AndreySperansky/ALGORITHMS
/Lesson_4_examples/fibo_calc/fibo_recur_anoth_memo.py
402
4
4
"""Фибо с рекурсией и упрощенной мемоизацией""" import sys import timeit #sys.setrecursionlimit(10000) #print(sys.getrecursionlimit()) def f(n, memory=[0, 1]): if n < len(memory): return memory[n] else: r = f(n-1) + f(n-2) memory.append(r) return r n = 8 print(timeit.timei...
98af31b797f940f1363a87fc228a360252ed753e
justega247/python-scripting-for-system-administrators
/bin/exercises/exercise-3.py
1,644
4.25
4
#!/usr/bin/env python3.7 # Building on top of the conditional exercise, write a script that will loop through a list of users where each item # is a user dictionary from the previous exercise printing out each user’s status on a separate line. Additionally, # print the line number at the beginning of each line, starti...
90b054d869d8ffff6bd0f5c2e45241001ecd8369
fahad92virgo/deepy
/deepy/layers/chain.py
1,899
4.09375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from layer import NeuralLayer class Chain(NeuralLayer): """ Stack many layers to form a chain. This is useful to reuse layers in a customized layer. Usage: As part of the main pipe line: chain = Chain(layer1, layer2) model....
3540563de662cf7273f422e38adb7781ae309115
RyanKeys/Ableton-Voice
/voice_detection.py
1,599
3.5
4
import speech_recognition as sr import autogui import pyautogui start_prompt = 'Ableton Voice V.1.0\nReady for a command:' commands = ["test", 1, 1] command_output = 'N/A' # Creates an instance of Recognizer(), detects voice input r = sr.Recognizer() # receives audio from users first mic mic = sr.Microphone() with ...
8db08369e141d2d50282624394bee58fb7298200
bartoszmaleta/3rd-Teamwork-week
/splitter_words.py
214
4.1875
4
my_string = 'ala ma kota' my_string_splitted = my_string.split() print(my_string_splitted) for word in my_string_splitted: print(word) for word in my_string_splitted: print(len(word), end=' ') print()
ee0d184417eba59c7db50597eb216abdd4e5153d
bnatunga/Algorithm
/summation.py
245
3.796875
4
#sums all the numbers between 1 and N (inclusive). def sum_num(N): sum_ = 0 for n in range(N + 1): sum_ += n return sum_ print(sum_num(15)) #Gauss summation rule def sum_gauss(N): return N*(N+1)//2 print(sum_gauss(15))
ae2bea8b5de4ab55beb25abce474015c118e62fc
nguyendaiky/CS114.L21
/WeCode Assignments/Tuan 3.1/DuyetTheoChieuRong.py
1,043
4.09375
4
class node: def __init__(self, val): self.data = val self.left = None self.right = None def insertTree(self,val): if self.data: if val < self.data: if not self.left: self.left = node(val) else: ...
a7f4eef2b9c391dab85c0dd0433df4f214e07f9a
shuowoshishui/python100texts
/python 100texts/35.py
390
3.71875
4
"""有一个已经排好序的数组,现输入一个数,要求按原来的规律将他插入到数组中。""" if __name__ == '__main__': a = [1, 2, 5, 6] num = int(input("输入:")) if num > a[len(a) - 1]: a[len(a)] = num else: for i in range(len(a) - 1): if num < a[i]: a.insert(i, num) break print(a)
b0db5ed72b0b63835a095a2c297679109b51d2dc
yodigi7/kattis
/JuryJeopardy.py
3,128
3.640625
4
def outputMaze(maze): for i in maze: holder = '' for j in i: holder += j print(holder) holder = '' def addBot(array): width, height = getWidthHeight(array) row = [] answer = [] answer.append(row) for i in array: answer.append(i) for i in r...
ed5a5c9cfba9ba40b18a5597d0495db44367ce6f
laxmanlax/My_python_practices
/leetcode/Problems/PalindromicSubstrings.py
822
4.25
4
""" Given a string, your task is to count how many palindromic substrings in this string. The substrings with different start indexes or end indexes are counted as different substrings even they consist of same characters. Example 1: Input: "abc" Output: 3 Explanation: Three palindromic strings: "a", "b", "c". Example ...
ca07dc8237dabc45eb5646cb4073d214bb9d7212
pangyouzhen/data-structure
/tree/199 rightSideView.py
751
3.671875
4
# Definition for a binary tree node. from typing import List from base.tree.tree_node import TreeNode class Solution: def rightSideView(self, root: TreeNode) -> List[int]: def collect(node, depth): if node: if depth == len(view): view.append(node...
d899f3f471bb956735551972976b03b976d707db
mcardosog/Hacker-Rank
/Minimum Loss
1,293
3.5
4
#!/bin/python3 import math import os import random import re import sys # Complete the minimumLoss function below. class Tree: def __init__(self,value): self.leftChild = None self.rightChild = None self.value = value def AddValue(self, value, minMaximum): if value<self.value: ...
459f7db2cc51233d6e45ab8718fab5a95468022b
Yaro1/Exercism-python
/anagram/anagram.py
215
3.625
4
from collections import Counter def find_anagrams(word, candidates): word_counter = Counter(word.lower()) return [i for i in candidates if Counter(i.lower()) == word_counter and word.lower() != i.lower()]
74bc3ad8ac73031cc66ea1e03b16359476ac1889
Nikoolaid/summer2019connect4
/finalFolder/wip.py
11,709
3.703125
4
# Color of Playing Tiles def chooseColor(player): choose_color1 = str(input( player + ", what color do you want? \n")) if choose_color1 == "white": choose_color1 = str(input( player + ", please choose a different color: \n")) return choose_color1 def mkBoard(): boa...
553b80d1e5e3d8dcb14e51a675865fb21c856e13
zhou613/CS-177-Pete-A-Maze-Game
/project2.py
13,719
3.8125
4
from graphics import * from random import * # # project2.py # Xiaoyu Zhou, 0028388913 # This program includes a game that allows the users to imput # their names and complete a maze game. The top four users with # lowest scores would be displayed. # # Game Panel def first_stage(): win = GraphWin('Game Panel...
1ccfad4e7b2afb33f71bb4fef6f31730d629a471
Zulkarnine1/Data-Structure-Algorithm-Python-Collection
/DS Implementations/BinarySearchTree.py
4,160
3.796875
4
class Node: def __init__(self, x): self.left = None self.right = None self.val = x class BinarySearchTree: def __init__(self): self.root = None def insert(self,x): new_node = Node(x) if not self.root: self.root = new_node else: ...
96baab89a41576027d83a991191ed78afe3f238b
lucasfreire017/Desafios_Python
/Exercício Python #115 - Cadastro de pessoas - B/lib/interface/__init__.py
812
3.734375
4
def leiaInt(msg): """ Função para a leitura de valores tipo int :param msg: valor a ser processado :return: valor convertido para int """ try: number = int(input(msg)) except (ValueError, TypeError, UnboundLocalError): print('\033[31mERRO! O valor digitado é inválido, digite ...
3e750585aa9927965eb0d390de93f784e684a20e
ramyasutraye/python--programming
/beginner level 1/primeornot.py
142
3.609375
4
n=raw_input() n=int(n) a=0 if n>1: for i in range(2,n): if(n%i)==0: a=1 break else: a=2 if a==1: print "no" else: print "yes"
3d32f2b9953f4ea36270e874ff35f51bfc44d756
yindan01/yindan
/animal.py
454
3.53125
4
##定义类 class Dog: #毛色,黑色,四条腿 #会吃,会叫,会水 ##属性 color="black" leg=4 ##方法,在类的方法中,是使用def关键字定义 ##def定义的在类外叫做函数function,在类内,叫做method def eat(self): print("狗在吃") def voice(self): print ("狗在叫") #类的实例化 print(Dog.color) print(Dog.leg) Dog().eat() Dog().voice()
2e0e5ef285496cbe54c3d4168d707962ffbb90cb
jackrapp/python_challenge
/PyBank/main.py
1,717
3.625
4
#import modules import csv import os budget_data = os.path.join("budget_data.csv") profit = 0 months = 0 value = 0 increase = 0 decrease = 0 #pull data from csv file in git hub folder with open(budget_data, newline="") as csvfile: records = csv.reader(csvfile, delimiter = ",") next(records) #calculate #...
8b17cb5eea460045ab563e859007f86c8e476688
Hasil-Sharma/Spoj
/m_seq.py
491
3.796875
4
from math import sqrt g_dict = {} f_dict = {1:8,2:8} def F(n): if n in f_dict: return f_dict[n] else: f_dict[n] = 8 + pow((n-2)/(1.0*n),2)*F(n-2) return f_dict[n] def G(n): if n in g_dict: return g_dict[n] else: g_dict[n] = sqrt(8*(pow(n,2)-pow((n-1),2))+pow((n-2),2)*F(n-2) - pow((n-3),2)*F(n-3) + 1.0)/...
8574c99aa44e92d5a8e69fac0691db8d057c5662
v1nnyb0y/Coursera.BasePython
/Coursera/Week.2/Task.41.py
366
3.84375
4
''' Номер числа Фибоначчи ''' digit = int(input()) number = 2 first = 0 second = 1 if (digit == 0): print(0) elif (digit == 1): print(1) else: while (second < digit): temp = second second += first first = temp number += 1 if (second == digit): print(number - 1) ...
4978d37f17bb9c95fd0078fb327785224f93706a
baby5/HackerRank
/Algorithms/Sorting/QuickSort2.py
468
3.53125
4
#coding:utf-8 n = int(raw_input()) ar = map(int, raw_input().split()) def quick_sort(ar): if len(ar) <= 1: return ar p = ar[0] equal = [p] left = [] right = [] for x in ar[1:]: if x < p: left.append(x) else: right.append(x) left1 = quick_so...
18a377e9832db62a4f0be9fe5ed11929eed940dd
wyifan/pythonlearning
/compute/bisection.py
465
3.765625
4
x = 25 epsilon =0.01 numGuess = 0 low = min(0.00,x) high = max(1.0, x) ans = (high+low)/2 while abs(ans**3 -x)>=epsilon: print 'low:',low,"high:",high,"ans:",ans numGuess+=1 if ans**3< x: low = ans else: high= ans ans = (high+low)/2.0 print "Numguess:", numGuess print ans, "is clos...
02f341a5b4bd7ee57ff9f0aaa366520cbd028ecb
pTricKg/python
/python_files/untitled/list_comprehension.py
1,365
4.09375
4
## List Comprehension ## makes list of even squares of 1 to 10 even_squares = [x**2 for x in range(1,11) if x % 2 == 0] print even_squares ## makes list of cubed number divised evenly by 4 cubes_by_four = [x**3 for x in range(1,11) if (x**3) % 4 == 0] print cubes_by_four ## list slicing ## [start:end:stride] stri...
2bdbe8794b38b7fccc52fb60fc9ea013ffe7fa5e
RyanIsBored/unit4
/rectangle.py
146
3.671875
4
#Ryan Jones #3/9/18 def rectangle(length,width): print('The area is',length*width) print('The perimeter is',length*2+width*2) rectangle(3,4)
06009d3d34daa3e4c7db77bb5bd0e39adcfce3d8
Ram-95/python_notes
/Inheritance_and_subclasses.py
1,862
4.28125
4
# Inheritance and Subclasses class Car: # class variables car_type: str = 'Hatchback' price_inc: int = 1.05 no_of_cars: int = 0 def __init__(self, brand: str, model: str, price: int): # Instance variables self.brand = brand self.model = model self.price ...
d12e330df1eeffb9f7a09064bcc58c384ad9f94d
MagiRui/machine-learning
/visualization/pandasvisual/pandas_visual.py
288
3.515625
4
# coding=utf-8 # author:MagiRui import matplotlib.pyplot as plt import pandas as pd import numpy as np df = pd.DataFrame(np.random.randn(10,4),index=pd.date_range('2018/12/18', periods=10), columns=list('ABCD')) # 数据 索引 列 print(df) ds = df.plot() # 折线图 plt.show()
551d8d0c2f5e0fa3483084f26c4af2e47a4c5250
richistron/PythonCabal-richistron
/Clase_1/if.py
289
3.90625
4
x = 'hfhfh' if int(x) = x: if x < 0: x = str(x) print ('Negative changed to zero', x) elif x == 0: print ('Zero') elif x > 0: print ('Single') else: print ('Not a found option') else: print ( x, '... Is not an intiger' )
57632c2a34616c41a683122cee51ed8dfac513e4
jakesjacob/FDM-Training-3
/Exercises/8_user_info.py
787
4.1875
4
# get full name # get dob # return users age # say users age on next birthday from datetime import datetime def getName(): firstName = input("Please type your first name: ") secondName = input("Please type your second name: ") firstNameCap = firstName.capitalize() secondNameCap = secondName.capitali...
3442c5e70926f125fd6a5831b2c3ca1aac64b475
Sakib18110/Digital-Diary
/DigitalDiary.py
3,026
3.8125
4
import pymysql as db import os conn=db.connect("localhost","root","","digital_diary") cur=conn.cursor() def insertrecord(): name=input("Enter the name of your frined: ") address=input("Enter the address of your friend: ") contact=input("Enter the contact no. of your friend: ") email=input("Enter...
34a62c5d46dd16c777341800d6b2753d817fca05
tetrabiodistributed/project-tetra-display
/filter_rms_error.py
4,707
3.859375
4
import numpy as np import matplotlib.pyplot as plt def filter_rms_error(filter_object, to_filter_data_lambda, desired_filter_data_lambda, dt=0.01, start_time=0.0, end_time=10.0, skip_initial=0...
f8a762e69a8ba68687aa075adc84b28812b5e6b8
paul-schwendenman/advent-of-code
/2018/day01/day01.py
594
3.78125
4
from itertools import accumulate, cycle def part1(frequencies): return sum(int(frequency) for frequency in frequencies) def part2(raw_frequencies): frequencies = accumulate(cycle(int(f) for f in raw_frequencies)) history = set() for frequency in frequencies: if frequency in history: ...
eece6515529bc683a42922201a1418d0d46e50b8
SongJialiJiali/test
/leetcode_844.py
592
3.578125
4
#leetcode 844. 比较含退格的字符串 class Solution(object): def backspaceCompare(self, S, T): """ :type S: str :type T: str :rtype: bool """ return self.backspaceString(S) == self.backspaceString(T) def backspaceString(self,Str): ''' 求退格后的...
c76137546716f769c3f2b78b4ee5083bab380c34
adammachaj/python-vending-machine
/collector.py
1,052
3.609375
4
import item class Collector(item.Item): """Soda collector""" def __init__(self, code, price = 2.0): self.code = code self.price = price self.quantity = 5 self.items = [] def __str__(self): if not self.items: rep = "<empty>" + "\tCena: " + str(self.pric...
051bca102944c6047be7d477a46d78974c66fe53
pokerSeven/leetcode
/71.py
680
3.625
4
# _*_ coding: utf-8 _*_ __author__ = 'lhj' __date__ = '2017/10/18 22:11' class Solution(object): def simplifyPath(self, path): """ :type path: str :rtype: str """ left = 0 for i in range(len(path)): if path[i] == "/": left = i + 1 else: break path = path[left:][::-1] left = 0 for i i...
d19b1fdca8efc92c59b9620817ba256cbe051539
fitrepoz/SSW-567
/HW01/hw01.py
1,074
4
4
import unittest def classify_triangle(a, b, c): if a == b == c: return 'equilateral' elif a == b or a == c or b == c: return 'isosceles' elif a*a + b*b == c*c: return 'right' else: return 'scalene' def main(): print('') print('Now lets check our sample in...
a55aa82e219b0b660c2a15fe43b7a3d3261614c5
meenapandey500/Python_program
/Revision/emp_constructor.py
672
4.03125
4
class Employee: def __init__(self): #__init__() constructor function : it is call automatic in main #or anywhere when create the object of class in main program or anywhere self.__Emp_no=101 #private variable self.__Emp_name="Meena Pandey" #private variable self.__Salary=67000 ...
9e553fd8bd78e84c2bc056193104072f23c51cb8
BrantLauro/python-course
/module01/ex/ex025.py
131
4.1875
4
name = str(input('Type your complete name: ')).strip().upper().split() print(f'Does your name have "POTTER"? {"POTTER" in name}')
ced8bf5c9b3fb0fcecd90bb87bb9c5ab59a0462a
suruisunstat/leetcode_practice
/1038. Binary Search Tree to Greater Sum Tree.py
988
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 bstToGst(self, root): """ :type root: TreeNode :rtype: TreeNode """ def inorder(root,s=...
9abc642667805de5af01cbd3078d6b52a62f90b3
psycomarcos/cursointensivodepython
/2.3.py
587
4.34375
4
# Armazene o nome de uma pessoa em uma variável e apresente uma mensagem a essa pessoa. nome = "Marcos" print("Alô, " + nome + ", você gostaria de aprender um pouco de Python hoje?") # // outras formas de fazer que não está no livro // # separando strings e variaveis com uma virgula print("Alô,", nome, "você gostaria ...
c46a62b74f133d49c50f0f15118a498822d79bbc
KasturiPatil/Mini-Python-Projects
/ATMMachine.py
2,010
4.09375
4
while True: pin = int(input("Enter account pin:")) if pin > 1000 and pin < 9999: print("1-View Balance 2-Withdraw 3-Deposit 4-Exit") break else: print("Invalid Pin Entered.") class Account: def __init__(self,balance = 0): self...
00f45fe6ae16e41bab5b53902fccc99ebf206420
bit-bots/bitbots_vision
/bitbots_vision/scripts/extract_from_rosbag.py
5,940
3.625
4
#!/usr/bin/env python3 import os import cv2 import rosbag import argparse import numpy as np from cv_bridge import CvBridge from sensor_msgs.msg import Image def yes_or_no_input(question, default=None): # type: (str) -> bool """ Prints a yes or no question and returns the answer. :param str quest...
10586c683f02a3df1e84da33480f0527306f741a
pratyushmb/Prat_Python_Repo
/Venkat_training/class_constructor.py
744
3.8125
4
class TscEmp: """This is a template creating tsc emp""" empCount = 0 # Constructor assigning values to instance variables. def __init__(self, name, salary, role): self.name = name self.salary = salary self.role = role TscEmp.empCount += 1 def displayCount(self): ...
4b1f90521c2c33e2b13d9764bd752aec7d799866
madamiak/advent-of-code
/2016/days7-25/test_puzzle10.py
3,808
3.515625
4
from unittest import TestCase from puzzle10 import Puzzle10 class TestPuzzle10(TestCase): pass def setUp(self): self.test_object = Puzzle10() def test_distribute_value(self): self.test_object.solve("value 5 goes to bot 2") self.assertEqual(self.test_object.get_bot_with_values([5...
2c84c68b31667d90b1d29b53af13b8757f527355
darkraven92/DD1310
/Lab1/Uppgift4.py
679
3.9375
4
import math def find_cubes(n): solutions = [] for a in range(1, math.floor(n**(1/3))+1): for b in range(a, math.floor(n**(1/3))+1): if a**3 + b**3 == n: solutions.append((a,b)) if len(solutions) == 2: return solutions return solutions ...
2b42cd4ae6925ea39b94393e46f139b964de639f
ahmad0711/PracticeOfPython
/01_basic.py
851
4.21875
4
'''# This is single Line Comment "Again This is a Comment" print("Ahmad Chaudhry") '''This is a MultiLine comment''' print('''Hello How are you and what are you doing right now''') # Arithmetic Operators a = 30 b = 30 print ("This is the sum of 30 + 30 is ", a+b) #compersion operaotre c = (14>7) d = (15<6...
c87b37e57107090990169352855e0384d5e00359
SethMiller1000/Portfolio
/Foundations of Computer Science/Lab 13- More While Loops.py
2,388
4.125
4
## More repetition with while loops- Lab 13: CIS 1033 ## Author: Seth Miller ## Loop 1- finds sum of all integers from 10 to 20 including 10 and 20 integer = 10 sum = 0 while ( integer <= 20 ): sum = sum + integer integer = integer + 1 print( "Sum of integers 10 to 20:", sum ) print() ## Loop 2-...
d97b4aff2646515f2a4399fa7c75b2ae2102e6fd
satyajit98/python_test
/add.py
95
3.84375
4
a=int(input("Enter first number")) b=int(input("Enter second number")) sum=a+b print("sum",sum)
d6b26a832f952e9183ce9ab13fb9fa0f081ec226
hghimanshu/CodeForces-problems
/bose/python/arrays/TimeMap.py
831
3.640625
4
class TimeMap: def __init__(self): self.time_map = {} def set(self, key,value,timestamp): if self.time_map.get(key): self.time_map[key].update({timestamp:value}) else: self.time_map.update({key:{timestamp:value}}) def get(self, key,timestamp): ...
674a55163057ebd490db005751673994f553c6a2
panpanshen1/vip5
/异常处理.py
1,244
3.84375
4
# def calc(a,b): # try: # print(a/b) # except ZeroDivisionError: # #如果被除数是0的话,抛出异常 # print('被除数不能是0') # a=int(input('输入一个除数')) # b=int(input('输入被除数')) # # calc(a,b) # try: # print(name) # #只打印print # except NameError: # print('未定义') # def calc(a,b): # try: # print...
1d5588f0628f4a8e4143b0669a56962079ca1232
Vagacoder/Python_for_everyone
/P4EO_source/ch05/worked_example_5/growth.py
1,677
4.21875
4
## # This program creates bar charts to illustrate exponential growth or # decay over long periods of time. # from matplotlib import pyplot def main() : showGrowthChart(1000.0, 1.0, 500, 50, "Bank balance") showGrowthChart(100.0, -0.0121, 6000, 500, "Carbon decay") ## Constructs a bar chart that shows the cum...
c966cde609243af443c51b66bafcf7ec29557e16
prologuek/python
/text.py
209
3.59375
4
import numpy data = [[1, 2], [3, 4], [5, 6]] x = numpy.array(data) print (x) print (x.dtype) print (x.ndim) # 打印数组的维度 print (x.shape) # 打印数组各个维度的长度。shape是一个元组
2615db66781d31f318108638447528f147cb21e0
pyq111/Rikao
/Zhoukao1/demo2.py
269
3.8125
4
import random list1=[] list2=[] list3=[] for i in range(50): a=int(random.randrange(-10,10)) list1.append(a) print(list1) if list1[a]>0: list2=list1 list2.append(a) print(list2) elif list1[a]<0: list3=list1 list3.append(a) print(list3)
88f84d3134f89dc0d06d37dc9b94f178aab083b1
Nadeemk07/Python-Examples
/Arrays/rotation_count.py
248
3.65625
4
def rotate(arr, n): min = arr[0] for i in range(0, n): if (min > arr[i]): min = arr[i] min_index = i return(min_index) arr = [15, 18, 2, 3, 6, 12] n = len(arr) print(rotate(arr, n))
d4748e77aad02a17b3e75ec4965331e6dcd39ad6
katerinasarlamanova/Katerina
/zadatak 1/z5.py
253
3.796875
4
# -*- coding: utf-8 -*- a = int(raw_input("Unesite prvi broj: ")) b = int(raw_input("Unesite drugi broj: ")) c = int(raw_input("Unesite treci broj: ")) s = (a + b + c) / 3.0 print ("Sredina unetih brojeva je %.3f" %s) # %.3f zaokruzava na 3 decimale
177362dad92d340b904cfe6c612f00bb8666ca38
day1127/ICSstuff
/listFunc.py
2,024
4.46875
4
""" create a python program called listFunc.py that contains the following functions 1. shuffleList(list) done 2. bubbleSort(list) done 3. selectSort(list)done 4. insertSort(list)done 5. quickSort(list)done """ # listFunc.py # Day Burke # March 9, 2021 finshed march 10, 2021 # stored on my github at li...
9b5db7119c9043ea44ba5d183c8d8f7fcd94cecb
egarcia410/digitalCraft
/Week1/9-turtleExercises/exercise1/pentagon.py
222
3.921875
4
import turtle def pentagon(): turtle.Screen() turtle.color('pink') turtle.shape('turtle') for num in range(0, 5): turtle.forward(100) turtle.left(72) turtle.exitonclick() pentagon()
691f4dbd3cf5a6d0381856293f163b9475bc709c
JamesSmith1202/softdev-work05
/utils/work03.py
1,497
3.609375
4
#Work03 #James Smith and Ish Mahdi import random global d d = {} #CORE FUNCTIONS ============================================================================= #returns a list of the csv file lines. def open_read(csvFile): csv_file = open(csvFile, 'r') return csv_file.readlines()[1:len(csv_file....
3c7d79253766f598236c308892b85ff04bac5cde
martinbaros/competitive
/HashCode/solution.py
517
3.546875
4
roads = {} positions = {} cars = {} D,I,S,V,F = [int(s) for s in input().split()] for line in range(S): start,end,name,time = [str(s) for s in input().split()] start,end,time = int(start), int(end), int(time) roads[name] = [start,end,time] for car in range(V): inp = [str(s) for s in input().split()] ...