blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 545k | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 545k |
|---|---|---|---|---|---|---|
1f561cbd24991690d041d444eae5cc96a110e06d | bronyamcgrory1998/Variables | /Class Excercises 5.py | 724 | 4.21875 | 4 | #Bronya McGrory
#22/09/2014
#Both a fridge and a lift have heights, widths and depths. Work out how much space is left in the lift once the fridge
fridgeheight= int (input("fridge height"))
fridgewidth= int (input("fridge width"))
fridgedepth= int (input("fridge depth"))
volume_of_fridge_answer= fridgeheigh... |
b5a145d5f861634da327f06d9993d0d1ae4c9eba | thespacepanda/pyrogue | /pyrogue/geometry.py | 2,121 | 3.921875 | 4 | """
pyrogue.geometry
~~~~~~~~~~~~~~~~
This module handles all of the geometric code in the game, such
as rectangles, points, and lines.
"""
class Point(object):
"""
Abstract representation of a point in 2-dimensional space,
originally used a tuple, but the added readability this gives is
... |
0aef221b23ade7877820d0416d4629222abbf757 | mariia-iureva/code_in_place | /Robot_Karel_tasks/PuzzleKarel.py | 1,023 | 3.875 | 4 | from karel.stanfordkarel import *
"""
File: PuzzleKarel.py
--------------------
Karel should finish the puzzle by picking up the last beeper (puzzle piece) and placing it in the right spot.
Karel should end in the same position Karel starts in -- the bottom left corner of the world.
"""
def main():
"""
program to... |
158386040c09b8f8111e3526bd61881034d4b6c5 | mariia-iureva/code_in_place | /diagnostics/nondecrease.py | 604 | 4.09375 | 4 | def main():
# TODO write your solution here
welcome_message()
count = play()
exit_message(count)
def play()
previous_number = float(input("Enter num: "))
count = 1
while True:
next_number = float(input("Enter num: "))
if next_number >= previous_number:
count +=1
... |
2d8881cef624299204688eee1fbe091c8f32fab0 | mariia-iureva/code_in_place | /group_coding_sections/Section2/8ball.py | 991 | 4.375 | 4 | """
Simulates a magic eight ball.
Prompts the user to type a yes or no question and gives
a random answer from a set of prefabricated responses.
"""
import random
# make a bunch of random answers
ANSWER_1 = "Ask again later."
ANSWER_2 = "No way."
ANSWER_3 = "Without a doubt."
ANSWER_4 = "Yes."
ANSWER_5 = "Possibly."
d... |
116eca58b6cb26b119d93d1d39931a2f2c4ddcf9 | Shatnerz/glad | /object.py | 7,201 | 3.6875 | 4 | import animation
from util import Rect, Vector
class AbstractObject(object):
"""All game world objects are ultimately derived from this class.
Contains a variety of useful functions used for movement and
collision detection"""
def __init__(self, pos, shape, team=1, moveSpeed = 50.0, moveDir=None):
... |
e5f4cb4e36277a22ed51d8cc66d9dd0f641e8782 | pallavi-abhijith/leetcode | /removeDuplicats.py | 403 | 3.78125 | 4 | list1 = [1, 1, 2, 3, 3, 3]
print(list1)
s = set(list1)
print(sorted(list(s)))
def removeDuplicates(nums):
if not nums:
return 0
new_number = 0
for i in range(1,len(nums)):
print("i value=",i)
if nums[i] != nums[new_number]:
new_number += 1
nums... |
b77768bc18e7226741d23502a66cacf632280be9 | AldoMaine/Solutions | /scripts/tsp/tsp_naive.py | 1,601 | 3.734375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Apr 4 13:21:19 2022
@author: aldon
"""
# traveling salesman
# problem using naive approach.
from sys import maxsize
from itertools import permutations
import pandas as pd
# implementation of traveling Salesman Problem
def travellingSalesmanProblem(graph, s):
# store a... |
90d5a193ee5985f1ad9304e502d6b2199df08058 | kuki1029/Planets | /physics.py | 1,150 | 3.609375 | 4 |
# All physics calculations are done here
import math
class physicsCalc:
convertAUtoM = 1.496 * (10 ** 11)
gravConstant = 6.67 * (10 ** (-11))
# Constructor
# Mass is in kg and distance in km
def __init__(self, solarSystem):
# We set these parameters to 1 as we aren't dealing with real wo... |
cb0392b74b7d56fa2583af01e7779cca0491366b | LofOWL/Jupyter-code-tracker | /mapping/cell_mapping/cell_mapping.py | 356 | 3.5 | 4 |
def cell_mapping(lines_mapping):
cell_x = {i:[] for i in list(set([i[0] for i in lines_mapping]))}
for line_map in lines_mapping:
from_cell = line_map[0]
map_cell = line_map[2]
if map_cell not in cell_x.get(from_cell):
cell_x[from_cell] = cell_x.get(from_cell) + [map_cell]
return cell_x
if __name__ ==... |
cc9185790da339f2ff3ab482e5948d8b5ca834a6 | gleon3/Sudoku-Project | /sudokuapp.py | 10,467 | 3.5625 | 4 | from tkinter import *
import Solver
import random
class App(Tk):
def __init__(self):
Tk.__init__(self)
self.state("zoomed")
img = PhotoImage(file='sudokuicon.gif')
self.tk.call('wm', 'iconphoto', self._w, img)
self.geometry("900x800+0+0")
# start with the sudoku "... |
009c1adc7155346cdebdf136237a9f00d6a4b4a5 | Ace139/PythonAlgorithms | /pysort.py | 1,942 | 4.125 | 4 | __author__ = 'ace139'
__email__ = 'soumyodey@live.com'
"""
This program is implementation of different sorting algorithms,
also could be imported as a module in other programs.
"""
def insertion_sort(arr):
for p in range(1, len(arr)):
key = arr[p]
c = p - 1
while c >= 0 and arr[c] > key:
... |
1d85f9e0eb064c7b90ab5612aa6d867d2d0c2ed6 | serenaraju/21_Day_Challenge | /Day_4/21_Day_4.py | 1,627 | 3.8125 | 4 | #Collections.OrderedDict() HACKERRANK Printing cumulative cost of a list of items -> dictionary
import re
track = dict()
uni_val = [input() for i in range(int(input()))]
for i in uni_val:
x = re.findall(r'\d+',i)
y = re.findall(r'(?![\s])[A-Z]*',i)
y = [item for item in y if item!='']
y = ' '.join(y)... |
9accec8cb8019f22d9e70d3a101684eb96105abf | serenaraju/21_Day_Challenge | /Day_2/21_Day_2.py | 1,174 | 4.09375 | 4 | #Basic demo of decorators
def fun1(fun):
def wrap():
print("Hey")
fun()
print("Good Day!")
return wrap
@fun1
def fun2():
print("Hi! I'm function 2")
fun2()
#Decorators with arguments
def fun3(fun):
def wrap(*args,**kwargs): #If the function in wrapper has an argument mention ... |
f1b01443deb5c185bb01700b1c3f650e1dc2bfa5 | ameet2503/pyprog | /InitialCoffeeMachine.py | 3,301 | 3.9375 | 4 | d_water = 400
d_milk = 540
d_coffee = 120
d_cups = 9
d_money = 550
def status(d_water, d_milk, d_coffee, d_cups, d_money):
print("The coffee machine has:")
print(d_water, " of water")
print(d_milk, " of milk")
print(d_coffee, " of coffee beans")
print(d_cups, " of disposable cups")
... |
6391d5543a2e8bfdb2fde31d145e04025a6f585e | qcymkxyc/JZoffer | /main/question17/book2.py | 854 | 3.796875 | 4 | #!/usr/bin/python3
# coding=utf-8
"""
@Time : 18-10-20 下午12:42
@Author : qcymkxyc
@Email : qcymkxyc@163.com
@File : book2.py
@Software: PyCharm
"""
from main.question17 import book1
def order_display(n):
"""顺序打印n位数
:param n: int
n位数
:return : list
打印结果
"""
nums = li... |
ee2aa1cfaec59588d94f7296aef4cde0ca9da8d8 | qcymkxyc/JZoffer | /main/question49/my1.py | 696 | 3.984375 | 4 | #!/usr/bin/env python
# _*_coding:utf-8_*_
"""
@Time : 19-1-28 上午10:32
@Author: qcymkxyc
@File: my1.py
@Software: PyCharm
"""
def ugly_num(order):
"""丑数
:param order: int
第多少个
:return: int
对应的数字
"""
ugly_nums = [1]
last_nums = [1]
def _find_ugly_num... |
05723ccb1861abb95ecddf360aab032619a54687 | qcymkxyc/JZoffer | /main1/question4/book1.py | 696 | 3.859375 | 4 | #!/usr/bin/env python
# _*_coding:utf-8_*_
"""
@Time : 19-1-28 上午11:25
@Author: qcymkxyc
@File: my1.py
@Software: PyCharm
"""
def find_num(matrix, num):
"""查找数
:param matrix: List[List[int]]
矩阵
:param num: int
要查找的数
:return: bool
是否存在
"""
n_row, ... |
8ce924536efad980347dadd56b3e854ee7b43e1e | qcymkxyc/JZoffer | /main/question30/book1.py | 1,049 | 3.84375 | 4 | #!/usr/bin/python3
# coding=utf-8
"""
@Time : 上午11:54
@Author : qcymkxyc
@Email : qcymkxyc@163.com
@File : book1.py
@Software: PyCharm
"""
from main.question30 import my1
class Stack(my1.Stack):
def __init__(self):
my1.Stack.__init__(self)
self.assist_stack = list()
def min(self):
... |
410cd4eae846e5f36fdf76230a5e64afd7cfaa81 | qcymkxyc/JZoffer | /main/question51/book1.py | 1,438 | 4.40625 | 4 | #!/usr/bin/env python
# _*_coding:utf-8_*_
"""
@Time : 19-1-30 上午10:49
@Author: qcymkxyc
@File: book1.py
@Software: PyCharm
"""
def _merge(nums1, nums2):
"""合并两个数组
:param nums1: List[int]
数组一
:param nums2: List[int]
数组二
:return: List[int], int
合并数组, ... |
617f106ccf931593125ac6a67bf78c644e441e82 | qcymkxyc/JZoffer | /main/question53/my1.py | 1,905 | 3.90625 | 4 | #!/usr/bin/env python
# _*_coding:utf-8_*_
"""
@Time : 19-2-2 上午10:12
@Author: qcymkxyc
@File: my1.py
@Software: PyCharm
"""
import math
def _binary_search1(nums, num):
"""二分查找
:param nums: List[int]
数组
:param num: int
数字
:return: int
待查数字的位置
"""
... |
762ed823bb288586531ccdd742c41c0defd24bc8 | qcymkxyc/JZoffer | /main/question40/heap_sort.py | 1,387 | 3.96875 | 4 | #!/usr/bin/env python
# _*_coding:utf-8_*_
"""
@Time : 19-1-1 上午11:56
@Author: qcymkxyc
@File: heap_sort.py
@Software: PyCharm
"""
def _shift(nums, i, end = None):
""""""
if not end:
end = len(nums)
if i >= end:
return False
current_num = nums[i]
left_ind... |
b0560c88d0a9f6c37e305c12f058776196848692 | qcymkxyc/JZoffer | /main/question58/my1.py | 507 | 3.71875 | 4 | #!usr/bin/env python
# -*- coding:utf-8 _*-
"""
@author:qcymkxyc
@email:qcymkxyc@163.com
@software: PyCharm
@file: my1.py
@time: 2019/2/10 11:06
"""
def reverse_sentence(sentence):
"""翻转句子
:param sentence: str
句子
:return: str
翻转后的句子
"""
words = sentence.split()
stac... |
0786cc333d457f4bed4bc6cdea7cf9f8bba12b97 | qcymkxyc/JZoffer | /main1/question7/my1.py | 1,578 | 3.953125 | 4 | #!usr/bin/env python
# -*- coding:utf-8 _*-
"""
@author:qcymkxyc
@email:qcymkxyc@163.com
@software: PyCharm
@file: my1.py
@time: 2019/1/30 14:51
"""
class TreeNode:
def __init__(self, val):
self.val = val
self.left_child = None
self.right_child = None
def pre_display(root):
"""... |
9789f1fd130938a339c561fe0223f625ded1560b | qcymkxyc/JZoffer | /main1/question3/my2.py | 376 | 3.75 | 4 | #!/usr/bin/env python
# _*_coding:utf-8_*_
"""
@Time : 19-1-24 上午11:38
@Author: qcymkxyc
@File: my2.py
@Software: PyCharm
题目二
"""
def repeat_num(nums):
"""
:param nums:
:return:
"""
num_set = set()
for num in nums:
if num in num_set:
return nu... |
20f0be5cc04de5a4261604e68044e0101e7cba3b | qcymkxyc/JZoffer | /main/question48/my1.py | 1,027 | 3.6875 | 4 | #!/usr/bin/env python
# _*_coding:utf-8_*_
"""
@Time : 19-1-27 上午10:36
@Author: qcymkxyc
@File: my1.py
@Software: PyCharm
"""
def _is_repeate(s, start, end):
"""判断是否是重复的字符串
:param s: str
母字符串
:param start: int
开始位置
:param end: int
结束位置
:return: bool
... |
76e8e3ae9b628598fb41c2b0bb60a3ad854e9db5 | qcymkxyc/JZoffer | /main/question38/my2.py | 989 | 3.59375 | 4 | #!/usr/bin/env python
# _*_coding:utf-8_*_
"""
@Time : 18-12-16 上午11:38
@Author: qcymkxyc
@File: my2.py
@Software: PyCharm
本题扩展
"""
import copy
def all_combination(s):
"""字符串的所有组合
:param s: str
字符串
:return: List[str]
所有组合的list
"""
def _combination(pre_ind... |
da4034615d249dd6cdd48300590534c74b17e9c8 | qcymkxyc/JZoffer | /main/other/DP/question3.py | 995 | 3.84375 | 4 | #!/usr/bin/env python
# _*_coding:utf-8_*_
"""
@Time : 19-1-14 上午10:01
@Author: qcymkxyc
@File: question3.py
@Software: PyCharm
给定数组arr,返回arr的最长子序列长度。比如
arr = [2,1,5,3,6,4,8,9,7],最长递增子序列为
[1,3,4,8,9],所以返回这个子序列长度为5
"""
def max_sub_len(nums):
"""最大子序列长度
:param nums: List[int]
... |
9b7b7afdc006a41f2cf091637098bd88ceb0f3f1 | qcymkxyc/JZoffer | /main1/question8/my1.py | 2,956 | 3.875 | 4 | #!usr/bin/env python
# -*- coding:utf-8 _*-
"""
@author:qcymkxyc
@email:qcymkxyc@163.com
@software: PyCharm
@file: my1.py
@time: 2019/2/1 14:37
"""
class BinaryTreeNode:
def __init__(self, val):
self.val = val
self.left_child = None
self.right_child = None
self.parent = None
... |
39a2571d83aebcf7ba0c21232241cd252ca64ea2 | qcymkxyc/JZoffer | /main1/question1/my1.py | 661 | 3.90625 | 4 | #!usr/bin/env python
# -*- coding:utf-8 _*-
"""
@author:qcymkxyc
@email:qcymkxyc@163.com
@software: PyCharm
@file: my1.py
@time: 2019/1/21 11:42
"""
matrix = [
[1, 2, 8, 9],
[2, 4, 9, 12],
[4, 7, 10, 13],
[6, 8, 11, 15]
]
def find_num(matrix, num):
"""查找该数
:param matrix: List[List[int]... |
b68f9e27938992b28dbd4796470e078c7e16047d | qcymkxyc/JZoffer | /tests/ms40_test.py | 1,081 | 3.5625 | 4 | import unittest
from main.question40 import my1, book1, heap_sort
import random
class MSTestCase(unittest.TestCase):
def setUp(self):
self.nums = list(range(20))
random.shuffle(self.nums)
def test_my1_bubble_min(self):
k = 4
min_nums = my1.bubble_min(self.nums, k)
self... |
6e618489744ffee058bef234e8aa683a189eaff5 | tmdgusya/DailyAlgorithMultipleLang | /max_n/max_n.py | 131 | 3.734375 | 4 | def max_n(lst, n=1):
return sorted(lst, reverse=True)[:n]
print max_n([1, 2, 3, 4, 5, 6])
print max_n([1, 2, 3, 4, 5, 6], 2)
|
437ce130505686a8de2c84610a395b3eb1d18316 | youxuehu/python-base | /myfristpyproject/myblog/绘图/柱状图.py | 405 | 3.578125 | 4 | import numpy as np
import matplotlib.pyplot as plt
x = np.array([1, 2, 3, 4, 5, 6, 7, 8])
y = np.array([3, 5, 7, 6, 2, 6, 10, 15])
plt.plot(x, y, 'r') # 折线 1 x 2 y 3 color
plt.plot(x, y, 'g', lw=10) # 4 line w
# 折线 饼状 柱状
x = np.array([1, 2, 3, 4, 5, 6, 7, 8])
y = np.array([13, 25, 17, 36, 21, 16, 10, 15])
plt.bar(x,... |
9268ca30fda51d0402cfaf036adac96266e2d18a | youxuehu/python-base | /py01/hello/循环.py | 260 | 3.953125 | 4 | # 循环
print('循环')
for i in '100':
print(i)
# 循环0到100
print('循环0到100')
for i in range(1, 100):
if i % 2 == 0:
break
print(i)
print('while循环')
sum = 0
num = 0
while num < 100:
sum += num
num += 1
print(sum)
|
48145de3c6adebf5844a9ce682ddf906d9d78c56 | youxuehu/python-base | /myfristpyproject/myblog/绘图/坐标轴二.py | 1,231 | 3.53125 | 4 | # -*- coding: utf-8 -*-
"""
设置坐标轴
"""
import matplotlib.pyplot as plt
import numpy as np
# 绘制普通图像
x = np.linspace(-1, 1, 50)
y1 = 2 * x + 1
y2 = x ** 2
plt.figure()
plt.plot(x, y1)
plt.plot(x, y2, color='red', linewidth=1.0, linestyle='--')
# 设置坐标轴的取值范围
plt.xlim((-1, 1))
plt.ylim((0, 3))
# 设置坐标轴的lable
# 标签里面必须添加字体... |
7613f47a14309938632d1fe0792fa52d5115abe5 | lucasgsfelix/Exerc-cios-de-PAA | /seq_seguida_alternada.py | 673 | 3.5625 | 4 |
def seq_seguida_alternada(seq):
tabela = [(0,0)] # do primeiro elemento
if seq[0] > seq[1]: # descrecente
tabela.append([0, 1])
else:
tabela.append([1, 0]) # crescente
for i in range(2, len(seq)):
if(seq[i] > seq[i-1]): # se for decrescente
tabela.append([tabela[i-1][1] + 1, 0])
elif(seq[i] < seq[i-... |
ff188f6e1fc8d3ac4d75da82d3bb2e77e4fa08c1 | TuftsRadioTelescope/srt-py | /srt/daemon/rotor_control/rotors.py | 2,820 | 3.734375 | 4 | """rotors.py
Module for Managing Different Motor Objects
"""
from enum import Enum
from .motors import NoMotor, Rot2Motor, H180Motor, PushRodMotor
def angle_within_range(angle, limits):
lower_limit, upper_limit = limits
if lower_limit <= upper_limit:
return lower_limit <= angle <= upper_limit
e... |
76b34732f8052a3e60e8d7b88308755af8274332 | lightionight/LearnPython | /SourceCode/BuildInModules/collections.py | 1,045 | 3.921875 | 4 | # _*_ coding: utf-8 _*_
# collection is python build-in models prvide so much powerful tools
'''
namedtuple
'''
# define a tuple type name
# very simialy like C / C++ enum style
from collections import namedtuple
# define a Point tuple type and set how many element Point tuple should hold on
# below is the case , sh... |
8fae52869cf75b6148a5d45fb80fe6e0a947c052 | lightionight/LearnPython | /SourceCode/BuildInModules/hashlib.py | 794 | 4.09375 | 4 | # _*_ coding: utf-8 _*_
# hashlib provide a series alogrithom about HASH
# normally like MD5, SHA1
# HASH Algorithm is a function can translate any length data for an constant length string
# AND keep string is unique.
# usually if file's HASH string is equal, we can say they are the same thing
import hashlib
md = ha... |
9ba0a9c8deed4fe2abd5439fbd97a495ddbbff1f | lightionight/LearnPython | /SourceCode/OOP/enumClass.py | 487 | 3.59375 | 4 | JAR = 1
FEB = 2
MAR = 3 # USE Captital for constant variable
# But JAR FEB MAR still can change it's data type
# python give us a Enum class for using constant
from enum import Enum
Month = Enum("Month", ("JAR", "FEB", "MAR", "APR", "MAY"))
# just like C And C++ enum element value start 1
# but you can creat subcl... |
27adb1fc3f8123c570ede9bf812de225ed72aeb4 | elenaserrano12/ejercicios1 | /python elena/bucle_1.py | 124 | 3.734375 | 4 | def bucle_1():
n=input("Hasta que numero quieres contar?: ")
for i in range(n):
print i
bucle_1()
|
a57612a005864e361ebf18274fc62a76f97618d1 | duonglong/practice | /magicalRoom.py | 2,880 | 4.15625 | 4 | # --*-- coding: utf-8 --*--
"""
You're an adventurer, and today you're exploring a big castle.
When you came in, you found a note on the wall of the room.
The note said that the castle contains n rooms, all of which are magical.
The ith room contains exactly one door which leads to another room roomsi.
Because the room... |
cc0f5d2bcf94b1e96a1ca5f41299fac04b367fba | duonglong/practice | /isPower.py | 216 | 3.71875 | 4 | import math
def isPower(n):
for i in range(2, n + 1):
k = n**(1.0/i)
if round(k,14) == int(round(k, 14)) :
return True
return False
for i in range(1, 351):
print i, isPower(i) |
1cd204b6f3b4a171e9625b8d2a3db9c04e472b84 | duonglong/practice | /acode.py | 2,098 | 4.25 | 4 | """
Alice and Bob need to send secret messages to each other and are discussing ways to encode their messages:
Alice: 'Let's just use a very simple code: We'll assign 'A' the code word 1, 'B' will be 2, and so on down to 'Z' being assigned 26.'
Bob: 'That's a stupid code, Alice. Suppose I send you the word 'BEAN' enco... |
4ef6f1a487f89a0b06299ae5d9e916b1e8f06b8a | kevinddf1/AI-Python | /PA1/8-Puzzle.py | 8,411 | 3.84375 | 4 | import sys
import math
import time
from queue import PriorityQueue
# Author: Fan Ding
# Email: ding0322@umn.edu
# UMN CSCI 5511 AI
# Prof: Andy Exley
# Date: 09/22/2020
#setup problem
input=sys.argv[1]
#Make PuzzleList from the input integer number
PuzzleList=[int(x) for x in str(input)]
ch... |
2d370c39c1e0e8ce69271161b82066a3a2df2f66 | kevinddf1/AI-Python | /PA3/othellogame.py | 13,460 | 3.796875 | 4 | # Author: Fan Ding
# Email: ding0322@umn.edu
# UMN CSCI 5511 AI
# Prof: Andy Exley
# Date: 10/06/2020
'''
othellogame module
sets up an Othello game closely following the book's framework for games
OthelloState is a class that will handle our state representation, then we've
got stand-alone functions for player, ... |
8d9986153b35182be36177a36ab7fa0614a473d3 | julianamerchant1/cmpt120merchant1 | /calc3 project.py | 3,054 | 3.59375 | 4 | #calc 3.py
# CMPT 120 Intro to Programming
# Project 3
# Author: Juliana Merchant
# edited on Nov 26, only changed hash format.
from graphics import *
# following line of code is asked for in textbook but outputs error
from button import Button
# import button.py, allowing placement of calc keys etc.
class Calculator:... |
c4b20701708d3844be14b52e6c8f7f151cb017ba | dmitriySSAU/LogAnalyzer | /patterns/information.py | 1,994 | 3.515625 | 4 | from abc import ABC, abstractmethod
from database import pattern
class Information(ABC):
"""Абстрактный класс Информация, предназначеный для работы с информацией в строке.
"""
def __init__(self, name: str):
settings = pattern.get_info_settings(name)
self._name: str = name
self._s... |
6bc4618c89cac725021f664e74ce6852b0ebd841 | KRiteshchowdary/myfiles | /primesteps.py | 371 | 3.890625 | 4 | import math
n = int(input())
for i in range(0,n):
s = input()
a = s.split()
for number in range(int(a[0]),int(a[1])+1):
max = math.sqrt(number)
if number % 2 == 0:
print ("not prime number")
else:
for divisor in range(3,1 + int(max)):
if number % divisor == 0:
print("not prim... |
fad0f3159059b1956fd62cd3e34a0de5939d3f42 | KRiteshchowdary/myfiles | /practice.py | 217 | 3.734375 | 4 | input1 = list(raw_input("list_1 :- "))
input2 = list(raw_input("list_2 :- "))
n = raw_input("clockwise shift by ")
if(input1[0] == input2[int(n)]):
print("lists similar")
else:
print("lists diferent")
|
6187ce90623f7394fbaf792025d02cb9e154d8df | KRiteshchowdary/myfiles | /relativeprime.py | 509 | 3.921875 | 4 | n = int(input('Your first number is '))
m = int(input('Your second number is '))
l = []
count = 0
count1 = 0
if n>m:
for i in range (2,m+1):
if m%i == 0:
l.append(i)
else:
for i in range (2,n+1):
if n%i == 0:
l.append(i)
for j in l:
if n>m:
if n%j == 0:
count = count+1
else:
if... |
579138fbc644da7ecde21ddea9f71c48e0eb6b8c | KRiteshchowdary/myfiles | /Numbers_order.py | 279 | 3.953125 | 4 | a = float(input('a is '))
b = float(input('b is '))
c = float(input('c is '))
if(a>b and a>c):
print('Greatest number is ',a)
elif(b>c and b>a):
print('Greatest number is ',b)
elif(c>a and c>b):
print('Greatest number is ',c)
else:
print("numbers donot set well")
|
2a3c2e06512850e14ce1232efe86a1003c56bd5e | KRiteshchowdary/myfiles | /reversenumber.py | 100 | 3.65625 | 4 | n = int(input("Enter number "))
b = 0
while n>0:
a = n%10
b = b*10 + a
n = n//10
print(b)
|
6df36cd62db80d9079b3c7ff742e1db0abfe0562 | KRiteshchowdary/myfiles | /phone.py | 222 | 3.984375 | 4 | n = int(input('your phone number is '))
if type(n) == int:
if n % 10000000000 != 0 and n.startswith()!=0:
print('your number ic correct.thank you ')
else:
print('your number is wrong.')
else:
print('sorry')
|
8c8a756fef13005c438d61aeba566ddac644166a | KRiteshchowdary/myfiles | /pro2.py | 1,414 | 3.96875 | 4 | login = {'ritesh':'Mark 1234','steve':'Stevejobs 1','elon':'Elon musk 1'}
user_id = raw_input("Username please ")
if user_id not in login:
print(" user_id not found")
else:
password = raw_input("Enter password ")
if(password == login[user_id]):
print("Access Granted")
print "1.Change ... |
e36cd8364bcea5628339683e6481484bf0a1ad01 | KRiteshchowdary/myfiles | /speed.py | 238 | 3.953125 | 4 | n = float(input('number of miles raced by the runner '))
t = float(input('time taken to complete the mile race in seconds '))
print('speed of runner is',n*5290/t,'feet per sec')
print('speed of runner is',n*1609.34/t,'meter per sec')
|
b3fbacf8e7c5a5fd61a833c04a2b4e87899dc127 | KRiteshchowdary/myfiles | /Calculator.py | 394 | 4.15625 | 4 | a = float(input('number 1 is '))
function = input('desired function is ')
b = float(input('number 2 is '))
if (function == '+'):
print(a + b)
elif (function == '-'):
print(a - b)
elif (function == '*'):
print(a*b)
elif (function == '/' and b != 0):
print(a/b)
elif (function == '/' and b==0):
print... |
0ee672d520f8a915f269215ac12d78738e46ed33 | bilun167/FunProjects | /CreditCardValidator/credit_card_validator.py | 1,036 | 4.1875 | 4 | """
This program uses Luhn Algorithm (http://en.wikipedia.org/wiki/Luhn_algorithm) and works with most credit card numbers.
1. From the rightmost digit, which is the check digit, moving left, double the value of every second digit.
2. If the result is greater than 9 (e.g., 7 * 2 = 14), then sum the digits of it (e.g... |
04888451dc58ff56807404a1e37583d6e73835a5 | tdefriess/Code-Challenges | /Lists/contains-duplicate.py | 438 | 3.640625 | 4 | # https://leetcode.com/problems/contains-duplicate/
# Difficulty: Easy
class Solution:
def containsDuplicate(self, nums: List[int]) -> bool:
# for each item in the list, if not in set, add to set, else return true
encountered = set()
for item in nums:
if item in encountered:
... |
746589741268b3bfb13cd070db5b99e2625a82e2 | Khushi761/DeliveryToday | /flaskapp/helpers/postcodeHandler.py | 1,389 | 3.671875 | 4 | from typing import List
import requests
url = "https://postcodes.io/postcodes" #url to get all the postcodes, calling an API, app on the internet where we make post request and give it buunch of postcodes
EARTH_RADIUS_IN_MILES = 3958.761
def get_distance(postcodes: List): #pass the list of postcodes that user gi... |
53d0e16b45b626b90844cec08a8cae7a921b518f | tedle/uitabot | /bot/uita/database.py | 4,530 | 3.625 | 4 | """Manages database connections and queries."""
import sqlite3
import os
import binascii
import hmac
from typing import cast, Optional
from typing_extensions import Final
import uita.auth
class Database():
"""Holds a single database connection and generates queries.
Args:
uri: URI pointing to datab... |
611faf2e75debe513985d8691b599e3a44f8d7be | MasterEndless/Information-Theory-coding-research | /Code/Huffman_encoder.py | 4,718 | 3.640625 | 4 | import math
import os
class letter_codeword(object):
def __init__ (self, letter=0, weight=0,codeword=''):
self.letter = letter
self.weight = weight
self.codeword = codeword
class leafnode(object):
def __init__ (self, letter=0, weight=0, left=None, right=None, ok = 0):
... |
ab5f15242dd2f49949ba57a7b47a7558120d7a0e | dxjoshi/linkedin-learning-python | /sorting.py | 874 | 4.09375 | 4 | def bubble_sort(inputlist):
# swap pairs of elements in order, such that after one iteration an element is in its correct place
print('Original list: ', inputlist)
for i in range(0, len(inputlist), 1):
for j in range(len(inputlist)-2, i-1, -1):
# print('i-{} | j-{}'.format(i, j))
... |
de4352cd7d651055e3204be3f1c06dfb4ba75d83 | DarlanNoetzold/P-versus-NP | /P versus NP.py | 2,233 | 4.15625 | 4 | # Simulação de tempo que o computador que está executando o programa
# levaria para calcular algumas rotas para o caixeiro viajante sem
# utilizar Otimização Combinatória
import time
# Calcula o tempo que o processador da máquina leva para fazer 10 milhões
# de adições, cada edição é o calculo de um caminho (li... |
5e726585bec2f72d42298ef0d0ab27419554f05b | monroeloop/pdxcodeguildassignments | /lists.py | 577 | 3.796875 | 4 |
numbers = [14, 24, 34, 44, 54, 64]
# rng = list(range(10))
# print(rng)
# print(len(animals))
# for a single number in total numbers in the range of 'numbers'
# len() sets the total number
# range() then sets 1 - total nu... |
80aa5fe5135b95c67ddbc0760a36b432be269811 | monroeloop/pdxcodeguildassignments | /phonebook.py | 2,631 | 3.8125 | 4 | pb = {'Monroe-Loop':
{'name': 'Mike Monroe-Loop', 'phone': '503-440-1201'},
'Loop':
{'name': 'Jackie Loop', 'phone': '208-552-1587'},
'Chevrolet':
{'name': 'Frank Chevrolet', 'phone': '541-555-5555'}
}
#
# def lookup(dictionary, na... |
e64c27ea14242038eeab3c1c2c062ce83d5b083c | willian-moura/chat_python | /client.py | 2,030 | 3.859375 | 4 | # -*- coding: utf-8 -*-
'''
Client python
Este código deve ser iniciado para conectar-se ao server já iniciado
'''
import socket
import select
import sys
# criando um socket para a conexão
# AF_INET : define a família de IP que será utilizado (AF_ de Address Family)
# SOCK_STREAM : define o tipo de conexão do socket,... |
7b9161c5406ba2dc33bc5a97bad6c1d26719d08c | ab14jain/python | /firstExample.py | 134 | 3.53125 | 4 | print("hello world to python")
another_list = ["xyz", 56, 78]
my_list = ["apple", "pear", 1, 3, another_list]
print(my_list.pop(0))
|
6730835a21f043373e774e231017986200f0dc92 | asiskc/Python_assignment_dec15 | /cube.py | 347 | 4.03125 | 4 | def cube_append(arb_list):
apnd_list = list()
for num in range(len(arb_list)):
cubed_num = pow(num, 3)
apnd_list.append(cubed_num)
return apnd_list
arbitary_list = [1, 2, 4, 4, 3, 5, 6]
print("List after cubing each elements and appending to another list : ")
final_list = cube_append(arbit... |
6e0d94465c6b3f2a38e8150ac42031e98f12cb52 | asmiyeniislamiati/metode-numerik | /latihan 3.1 metode bagidua.py | 803 | 3.84375 | 4 | Nama = ('ASMIYENI ISLAMIATI')
NIM = ('H061181012')
print(Nama)
print(NIM)
import math
def f(x):
return math.exp(x)-6*x**2*x**3
a=int(input('masukkan nilai batas bawah='))
b=int(input('masukkan nilai batas atas='))
e=float(input('masukkan nilai toleransi='))
N=int(input('masukkan jumlah iterasi='... |
50af87a7ad391f9e5c0d470cfbcf387e1b1c53e5 | vivek-gour/Python-Design-Patterns | /interviewQus/class_attribute.py | 390 | 3.53125 | 4 | __author__ = 'Vivek Gour'
__copyright__ = 'Copyright 2018, Vivek Gour'
__version__ = '1.0.0'
__maintainer__ = 'Vivek Gour'
__email__ = 'Viv30ek@gmail.com'
__status__ = 'Learning'
class abc():
print("1")
person = 'person'
def __init__(self, p=None):
print("2")
self.person = p
pass
... |
e7bac1009882291403bb8dce07263d6c958c9f98 | vivek-gour/Python-Design-Patterns | /Patterns/Creational/factory.py | 1,377 | 4.0625 | 4 | __author__ = 'Vivek Gour'
__copyright__ = 'Copyright 2018, Vivek Gour'
__version__ = '1.0.0'
__maintainer__ = 'Vivek Gour'
__email__ = 'Viv30ek@gmail.com'
__status__ = 'Learning'
from abc import ABCMeta, abstractmethod
# create an interface for Shapes
class Shape(object):
__metaclass__ = ABCMeta
@abstractme... |
d60ab5af0eef25079b21b8ae76cde80b8e7ba6da | linuxlizard/dotfiles | /kazi42.py | 1,472 | 3.5625 | 4 | #!/usr/bin/env python3
# 8-Jan-2006 davep
# generate nice random passwords
# 20200911 davep
# after a long long time, upgrade to a better way
import sys
import random
import string
default_pwlen = 14
def mkpasswords(pwlen, num_passwords):
s = string.ascii_letters + string.digits
# remove l (lowercase L) a... |
852ea728b22fde40a9b48ec8ed873fb086750a63 | dyadav4/leetcode | /Search Insert Position Solution.py | 1,212 | 3.734375 | 4 | class Solution:
def searcheleindex(self, nums: List[int], element: int) -> int:
start = 0
end = len(nums) - 1
while start <= end:
mid = (start+end)//2
if element == nums[mid]:
return mid
elif element < nums[mid]:
... |
8153b4cfc2169b781bc16d1ad06e2ca4233b3ea9 | osagieomigie/foodWebs | /formatList.py | 1,572 | 4.21875 | 4 | ## Format a list of items so that they are comma separated and "and" appears
# before the last item.
# Parameters:
# data: the list of items to format
# Returns: A string containing the items from data with nice formatting
def formatList(data):
# Handle the case where the list is empty
if len(data) == ... |
5b5bdc1422c305868389baeb1417be13cff9808b | codernayeem/python-cheat-sheet | /10_magic_methods.py | 5,895 | 4.1875 | 4 | # Details : https://rszalski.github.io/magicmethods/
# __init__(), __str__() etc. are magic functions
# magic methods starts and ends with __.
# There is many more magic methods :
class Point:
def __init__(self, x=0, y=0, z=0):
# Construct the object
self.x = x
self.y = y
self.z = ... |
339967af72507042b728f6034a46b3d61df98853 | codernayeem/python-cheat-sheet | /13_module_&_package.py | 1,757 | 4.0625 | 4 | # A module is a file containing some python code
# A package is a folder where can be some modules
# importing module
from a_module import get_factorial, get_sum
# from a_module import * : import all things from a_module
# import a_module : import a_module and use module name as a prefix of all the thin... |
6539b33d137c632c5e304bb60051d6889d23bcc1 | codernayeem/python-cheat-sheet | /8_with_satement.py | 861 | 3.921875 | 4 | # the with satement is used to release extra things
# without 'with'
fl = open('8_with_satement.py', 'r')
print("File opened")
data = fl.read()
fl.close()
with open('8_with_satement.py', 'r') as fl:
# fl.__enter__() : called at the satrt of with satement
# fl.__exit__() : called at the end of with satem... |
a033cde3c9bc3cbc6f3c03e2e3d6ca4d1a255353 | Shivani2012/LearningPython | /webscraping/data_generator.py | 6,946 | 3.6875 | 4 | """
data_generator.py
functions to create random (US) names and (UK) addresses for mock contact lists of any size
"""
import pymongo as mgo
from random import randint, seed, choice
def generate_names(size=100):
"""
generate_names creates a list of length size of random names from a database of popular first ... |
3b71b870b59136999ad3a0f259216f7dd699a6ff | lfelipev/Neural-Network | /perceptron.py | 1,117 | 3.71875 | 4 | # Predicts an output value for a row given a set of weights
def predict(row, weights):
activation = weights[0]
for i in range(len(row)-1):
activation = activation + weights[i+1] * row[i]
return 1.0 if activation >= 0.0 else 0.0
# Estimate Perceptron weights using stochastic gradient descen... |
504d7e7a303b436ee7ae71fb892ef881365668c4 | soledb94/data-analysis-pipeline | /source/dataset.py | 518 | 3.75 | 4 | import pandas as pd
def dataSet():
data=pd.read_csv("input/clean.csv")
return data
def information(df):
data_max=int(df.value.max())
data_min=int(df.value.min())
info=f"The min value for the month was {data_min} µg/m³, and the max value, {data_max} µg/m³"
return info
def mean_information(df)... |
34a25e0660c94d00080a5637ff73e10bfdde2d66 | Ivernys-clone/maths-quiz1 | /questions/questions_v2.py | 1,347 | 3.828125 | 4 | import random
def get_range():
while True:
num = input("\nPlease enter number of questions you would like to play:")
print("Shows questions")
try:
num = int(num)
except ValueError:
print("===... |
1da15a33c3bd0063791cf1e8d60b8c728b0af745 | anil-4-real/RockPaperScissors | /RockPaperScissors.py | 1,887 | 4.03125 | 4 | import random
def play():
items = ["rock", "paper", "scissors"]
counter = 0
compScore = 0
playerScore = 0
tieCount = 0
while True:
comp = random.choice(items)
playerInput = input("\nEnter your choice Rock, Paper, Scissors or Enter Q to quit: ").lower()
if ... |
cff58f411f735e2185532baa38ff00838591da95 | ChNgineer/ESC180 | /lab5/lab5.py | 1,842 | 3.6875 | 4 | import time
class Node:
def __init__(self, data, right=None, left=None):
self.data = data
self.right = right
self.left = left
def __str__(self):
return str(self.data)
class BinarySearchTree:
def __init__(self, root):
self.root = root
def insert(self, node, cu... |
fc5560073789863afa0453542c18eb01f39a4a8d | aabishkaryal/exercism-python | /grade-school/grade_school.py | 1,760 | 3.84375 | 4 | from typing import List
from dataclasses import dataclass
class School:
def __init__(self):
self.students: List[Student] = []
def add_student(self, name: str, grade: int) -> None:
"""
Add student to the school at grade
"""
print(self.students)
new_student = S... |
c1033cfcd44dda42337ebc71f5717e6089355fdf | aabishkaryal/exercism-python | /meetup/meetup.py | 969 | 3.796875 | 4 | from datetime import *
from calendar import *
MeetupDayException = Exception
days = ["Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday", "Sunday"]
position = ["1st", "2nd", "3rd", "4th", "5th"]
def meetup(year, month, week, day_of_week):
if (week in position):
d = date(year, mon... |
ce06c19ba42ba54a8b6a75abfee3808e081faa1d | aabishkaryal/exercism-python | /anagram/anagram.py | 652 | 3.890625 | 4 | from typing import Dict, List
def find_anagrams(word: str, candidates: List[str]) -> List[str]:
original_candidates = candidates
word, candidates = word.upper(), [x.upper() for x in candidates]
anagrams = []
for i, x in enumerate(candidates):
if (isAnagram(word, x)):
anagrams.appen... |
ab5c5f58c34814eef07eea82b4b20e018aec2746 | aabishkaryal/exercism-python | /collatz-conjecture/collatz_conjecture.py | 240 | 3.984375 | 4 | def steps(n: int, current_steps: int = 0) -> int:
if n <= 0:
raise ValueError("number cannot be less or equal to zero")
if n == 1:
return current_steps
return steps(n/2 if n % 2 == 0 else 3*n+1, current_steps+1)
|
133d8cfe38a65dac1661313e3b620595a98c3846 | aabishkaryal/exercism-python | /say/say.py | 2,380 | 3.78125 | 4 | positions = ["", "", "thousand", "million", "billion", "trillion"]
single_digit_num_to_words = {'0': '', '1': 'one', '2': 'two', '3': 'three',
'4': 'four', '5': 'five', '6': 'six', '7': 'seven', '8': 'eight', '9': 'nine', }
teen_numbers = {'11': 'eleven', '12': 'twelve', '13': 'thirteen',... |
76420ad4194b8f6e1521ab9a522703a4d3d424bf | rwilmar/Python-DL-Tests | /test_preprocImage.py | 1,924 | 3.53125 | 4 | import numpy as np
import cv2
def preproc(input_image, height, width):
image = cv2.resize(input_image, (width, height))
image = image.transpose((2,0,1))
image = image.reshape(1, 3, height, width)
return image
def pose_estimation(input_image):
'''
Given some input image, preprocess the image s... |
38b10b95d1d3c15d30cfc01cebd2312d806ef28f | SadeeshKumarMN/python-autobots | /challenges/test_challenge7.py | 2,941 | 3.578125 | 4 | """
*****************
Challenge#7
******************
Go to copart.com
Look at the Makes/Models section of the page
Create a two-dimensional list that stores the names of the Make/Model as well as their URLs
Check that each element in this list navigates to the correct page
"""
import sys
import traceback
from pprint im... |
e63d3dfce1a7b5c4f1d245cb3aafe47e172b7652 | juditacs/dsl | /storage/RBM.py | 8,710 | 3.53125 | 4 | from __future__ import print_function
import numpy as np
class RBM:
def __init__(self, num_visible, num_hidden, learning_rate = 0.1):
self.num_hidden = num_hidden
self.num_visible = num_visible
self.learning_rate = learning_rate
# Initialize a weight matrix, of dimensions (num... |
2aca0f756cf7a787167f2ecf64a151523c613364 | ParaworldJ/leetcode | /009-回文数.py | 377 | 3.640625 | 4 | import math
def isPalindrome(x):
if x<=10:
return 2>3
elif x>=0 and x<10:
return 2<3
a=str(x)
if len(a)%2==0:
i=math.floor(len(a)/2)
if a[: i]==(a[: i:-1]+a[i]):
return 2<3
if len(a)%2==1:
i=math.floor(len(a)/2)
if a[: i]==a[: i:-1]:
... |
f519d6c3f7fcb8c423b2467da8e3765a762f93f6 | margueriteblair/Intro-To-Python | /intermediate-expressions.py | 230 | 3.5 | 4 | sval = '123'
type(sval)
ival = int(sval)
type(ival)
print(ival + 1)
nam = input('Who are you? ')
print('Welcome', nam)
# elevator convention application
inp = input('European floor? ')
usf = int(inp) + 1
print('US Floor', usf) |
d87ae28da2b3a113e2891241fddd47595525417f | margueriteblair/Intro-To-Python | /more-loops.py | 1,001 | 4.125 | 4 | #counting in a loop,
zork = 0
print('Before', zork)
for thing in [9, 42,12, 3, 74, 15]:
zork = zork+1
print(zork, thing)
print('After', zork)
count = 0
sum = 0
print('Before', count, sum)
for value in [9, 42,12, 3, 74, 15]:
count = count + 1
sum = sum + value
print(count, sum, value)
print('After... |
9224f571c9c93452c679d8420ec1316ac95cbe86 | MoraAndrea/controller-drone-ui | /controller/UserGuiResources/logger.py | 3,792 | 3.578125 | 4 | import queue
import logging
import tkinter as tk
from tkinter.scrolledtext import ScrolledText
from tkinter import ttk, VERTICAL, HORIZONTAL, N, S, E, W
logger = logging.getLogger(__name__)
values = ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']
class QueueHandler(logging.Handler):
"""Class to send logging rec... |
5801cdfe78131b2e2bd6ad9abf28346c9a4ecdc1 | vic012/Alura-python-intro-oo | /conta.py | 2,098 | 4 | 4 | #Começando OO
class Conta:
#A função que inicia automaticamente
#Chamamos de construtor
def __init__(self, numero, titular, saldo, limite):
#self é a própria referencia do objeto criado na memória
#Atributos privados
self.__numero = numero
self.__titular = titular
self.__saldo = saldo
self.__... |
c41272f3890e8d974ab410ee720c8c6470539726 | min7180/cnu_kiosk | /choice_menu1.py | 1,970 | 3.953125 | 4 | # 1.햄버거 단품 메뉴 선택하는 메서드
def choice_burger():
print('=========================================================')
print('BURGER MENU')
print('1.치즈버거: 3,500원')
print('2.불고기버거: 3,000원')
print('3.새우버거: 2,500원')
print('=========================================================')
... |
e612e0ed1467980f7f1fc75997c0b4d1d7614240 | kelvinluime/data-structures-with-python | /Stack.py | 495 | 3.984375 | 4 | class Stack:
def __init__(self):
self.__list = []
def __str__(self):
result = "Here is a stack: "
for item in self.__list:
result += str(item) + ", "
return result
def push(self, item):
self.__list.append(item)
def pop(self):
self.__list.pop... |
294f2179411592f52b5193c41359667cc9a3b0fe | Baeth/CeV-Python | /Desafio031.py | 485 | 3.609375 | 4 | # Ler distância de uma viagem em Km. Calcular o preço da passagem em R$0,50 apra viagens até 200Km e 0,45 para maiores.
import locale
locale.setlocale(locale.LC_ALL, '')
v1 = float(0.5)
v2 = float(0.45)
d = float(input('Distância da viagem em Km: '))
if d <= 200:
pf = (d * v1)
pf = locale.currency(pf)
print... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.