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
f90f200aa717a2977f5d6d7a51dc76f4035395bb
webturing/PythonProgramming_20DS123
/lec03-loop0/while1c.py
50
3.5625
4
x=10 while x>0: print("hello world") x-=1
c2eab50f47b843baf1b9fcf5a6120f36c9cf7e58
kanoria/Honeyword-decoder
/detectors/tokenslib/classifier.py
9,417
3.90625
4
import pprint from password_leaner import password_leaner pp = pprint.PrettyPrinter(indent=1) def isInAlphabeticalSequence(word): """ Checks if the string passed to it is in an alphabetical sequence """ if len(word) == 1: return False else: for i in range(len(word) - 1): ...
49396cb15582f4ad0ce3df93fa78360e167849cd
uniqstha/PYTHON
/Area of circle.py
125
4.03125
4
r=float(input("Enter radius")) a= 3.14*r**2 p= 2*3.14*r print (f"Area of circle is {a}") print(f"Perimeter of circle is {p}")
58cf95567369f215e445c1196a4076de3b2d3055
13323106900/1python-diyigeyue
/14day/手机号.py
337
3.8125
4
def check_phone(phone): if phone.starteswith("1") and len(phone)==11: return True else: return False phone = input("请输入手机号") result=check_phone(phone) if result == False: print("手机号是错的") phone2=input("请输入手机号") result =check_phone(phone2) if result ==False: print("手机号是错的")
df15540b753316563d8912ffac1f1fff3e67de06
oghusky/DV_Study_Hall_Monday
/lamdas_and_oop/nestedFuncs.py
2,458
4.5
4
# define a function in simple words # what are functions used for # what is the difference between a parameter and an argument # how many times can you use a function in a program # what is the difference between print() and return # ==================CHALLENGE # Write a function that on "run" asks you for input on a ...
54ce3fc26077c7b3d1aa4890532b1358d252271a
hehuanshu96/PythonWork
/dailycoding/python_UI/ComplicatedHello.py
3,124
3.53125
4
""" Hello World, but with more meat. 更复杂一点的helloworld """ import wx class HelloFrame(wx.Frame): """ A Frame that says Hello World 一个框架,显示hello world,还有其他的一些功能 """ def __init__(self, *args, **kw): # 调用父类(wx.Frame)的__init__函数 super(HelloFrame, self).__init__(*args, **kw) # create a panel in the frame pn...
c98ad559369734cb6c85e5de9b38a8a134240c6c
thxa/test_python
/python_beyond_basics/Exceptions_and_Errors/median.py
807
4.125
4
def median(iterable): """Obtain the central value of a series Sorts the iterable and returns the middle value if there is an even number of elements, or the arithmetic mean of the middle two elements if there is an even number of elements. Args: iterable: A series of orderable items. Returns: The median v...
78591e455550a1bf25df27e7d74d533fb39b43c2
cfan-guo/ECE422-Homework
/PS12/PS12Q7.py
353
3.828125
4
# Question 7 from math import * R_earth = 6378e3 R_orb = 250e3 R_total = R_earth + R_orb mu = 3.986e14 # Nm^2/kg T = (2*pi*(R_total)**(3/2.0))/sqrt(mu)/60 # period in minutes, decimal T_sec = int((T-int(T))*60) T_min = int(T) print("Orbital period: "+str(T_min)+" min "+str(T_sec)+" sec") v = sqrt(mu/R_total) print("V...
0967ab047577706f4295a338ad59e727261f2b97
ewartj/cs50_2020
/week6/mario.py
990
3.90625
4
from cs50 import get_int def main(): while True: # this do/wile loop from https://cs50.stackexchange.com/questions/32589/cs50-pset6-cash-py-not-returning-number-of-coins-used-for-change # https://www.reddit.com/r/cs50/comments/7tcnok/pset_6_need_help_with_mariopy_more_comfortable/ user_input = ...
d29a5e9173eab6aa1205a6b48be468efdd4f0b51
bulue94/Game
/game_what_is_your_quest.py
6,599
4.40625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Aug 23 17:52:46 2018 @author: chase.kusterer """ """ DocString: A) Introduction: This game is based on the movie Monty Python and the Holy Grail (1975). It consists of three stages, and also has defined functions for start, win...
1944e0318d7908f1f364e31e7de933d0c224a954
codename1995/LeetCodeHub
/python/34. Find First and Last Position of Element in Sorted Array.py
2,037
3.828125
4
import math class Solution: def searchRange(self, nums, target): # INPUT: nums: List[int], target: int # OUTPUT: the position of first target number. def leftBound(nums, target): # return the number of elements that less than target l = 0 r = len(nu...
b36503282926d73cabe8f8d0a9fa312484b25f4f
nhforman/MicromouseSimulator
/algorithm/search.py
3,338
3.859375
4
from stack import Stack from robot_wrapper import Robot, Direction from maze import Maze, Neighbors, Square class Move: def __init__(self, current_x, current_y, direction): self.x = current_x + (direction % 2) * (direction - 2) self.y = current_y + ((direction % 2)-1) * (direction - 1) self.parent_x = current_...
9f19fbb7cdcde22519a7512f3d1da0bb812471c7
abilalakin/Project-Euler
/q4-Largest palindrome product/palindrome.py
326
3.796875
4
def isPalindrome (pal): return str(pal) == str(pal)[::-1] def largest (): maxPal = 999999 minPal = 100000 print ("abc") for i in range(maxPal,minPal,-1): if isPalindrome(i): #print (i) for j in range(100,1000): if i % j == 0: div = int(i / j) if len(str(div)) == 3: #print (i) re...
965898dab26ae99a0ea65a052b28302d427e260c
nag-sa/testpython
/exam/q6.py
271
4.53125
5
#Write a program to find whether a string is pallindrome or not. The output should be true/false. #kanak #str = input("Enter string: ") str = "hello" print(str) str1 = str[::-1] print(str1) if str == str1: print("pallindrom") else: print("not pallindrom")
ff61d8820400382c2afb5abb168c38ef6956fa34
shuchenWu/git_
/src/matrix_mul.py
816
4.0625
4
# 没有必要,但是可以,just for practicing iterators from operator import mul from itertools import tee, islice class Matrix(object): def __init__(self, values): self.values = values def __repr__(self): return f'<Matrix values="{self.values}">' def __matmul__(self, other): x = zip(*(row f...
74214e35c8b9d0d63cafcd1463d02aabb800e1ed
Roy-Gal-Git/TicTacToe
/algo.py
1,670
3.625
4
def checkWinner(positionsDict): keysList = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] diagX = [0, 0] diagO = [0, 0] rowX = [0, 0, 0] rowO = [0, 0, 0] colX = [0, 0, 0] colO = [0, 0, 0] for i in range(len(keysList)): # Check if there are 3 of the same char ...
5f1f0e17e67ad738caca77d6fbc2599d4939abb9
barassah/File-Handling-in-Python
/F_handling.py
1,232
4.53125
5
#File Handling in python #creating and deleting import os #checking if file exists before creating if os.path.exists('text.txt'): #print('File Exist!') #inquire overwrite or append content #prompt for over witing of file contents i=input('Overwrite file? y/n: ') if i!='n': myfile = open('text.txt', 'w...
56d5b4e0478444fe850eade7826d9245b9225548
azafrob/fin-model-course
/fin_model_course/lectures/start_python_excel/notes.py
6,289
3.84375
4
from lectures.model import LectureNotes, Lecture, LectureResource from resources.models import RESOURCES def get_intro_and_problem_lecture() -> Lecture: title = 'Introduction and an Example Model' youtube_id = 'KL48T_XGbzI' week_covered = 1 notes = LectureNotes([ 'In the beginning of the cours...
2fe53ed2538c82ac5cb5c9d95c1f74114aa20435
srinidhik/pycharm_projects
/srinidhi/PycharmProjects/OOP/vehicle2.py
1,887
4.03125
4
class Vehicle(object): vehicleType = "" vehicleColor = "" def __init__(self,type,color): self.vehicleType = type self.vehicleColor = color def get_no_of_wheels(self): pass class Car(Vehicle): vehicleWheels = 4 def __init__(self,type,color): Vehicle.__init__(se...
5e49edfa627e7d8ce6841a2cc8c2ee34b8793a39
qiujiandeng/-
/python1基础/day03/Code/get-max-number2.py
1,044
3.953125
4
# 2.写程序,任意给出三个数,打印出三个数中最大的一个数 #laoshi a = int(input("请输入第一个数:")) b = int(input("请输入第一个数:")) c = int(input("请输入第一个数:")) #改进算法: #先假设第一个最大,用变量绑定 #进了西瓜地,看到第一个西瓜拿起来,看到第二个西瓜比第一个大,把第一个扔掉拿第二个,...第三个 zuida = a #zuida等于手,a等于第一个西瓜 if b >zuida: #第二个比手里的大,扔掉手里的,把第二个拿到手里,手上等于第二个西瓜 zuida = b if c >zuida:...
06d4824980ba599577cf110951d659521fef489e
Skluchnik/homework
/HW-03&04/Lesson-03-2-print.py
216
3.84375
4
#Каждый пишет сумму списка при помощи for и while L = [3, 5, 1] sum = 0 index = 0 list_last_index = len(L) while (index < list_last_index): sum += L[index] index += 1 print(sum)
e46d24f37a441740d591d5212a24addd93e27e5b
dbconfession78/interview_prep
/leetcode/102_binary_tree_level_order_traversal.py
1,408
4.0625
4
# Instructions """ Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example: Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7 return its level order traversal as: [ [3], [9,20], [15,7] ] """ class TreeNode...
d721aa5dacf72ae27bfee1bf10db80e774982ba4
zhou-jia-ming/leetcode-py
/problem_105.py
947
3.59375
4
# coding:utf-8 # Created by: Jiaming # Created at: 2020-03-20 # 根据一棵树的前序遍历与中序遍历构造二叉树。 from typing import List from utils import TreeNode, levelOrder class Solution: def buildTree(self, preorder: List[int], inorder: List[int]) -> TreeNode: if not preorder: return None if len(preorder) ...
c9139a930c31b7168d2c178b76820e9c680d5af6
mottola/dataquest_curriculum
/python_basics/conditional_logic.py
1,580
4.21875
4
# USING CONDITIONAL LOGIC IN PYTHON # BOOLEANS IN PYTHON - True False cat = True dog = False print(type(cat)) print(type(dog)) print(cat) print(dog) # BOOLEAN OPERATORS IN PYTHON # ___________________________ # == # != # > # < # >= # <= print(8 == 8) prin...
690e148f0458973434dd39a1a7ef16a9a4aac544
he44/Practice
/leetcode/20_0808_contest/1.py
703
3.515625
4
from typing import * class Solution: def makeGood(self, s: str) -> str: list_s = [char for char in s] good_string = False while not good_string: good_string = True n = len(list_s) for i in range(n-1): if list_s[i] != list_s[i+1] and list_s...
9544f45c08c21341077c17ebd8c337854e2544cb
Iamnetis/Nitesh
/hello world.py
99
3.71875
4
str='Hello world !!' print (str) print (str[2]) print (str[2:5]) print (str*2) print (str+ "TEST")
ea2b79d97f8261f344b6e6c10721af10016d939f
ytyc2k/MYCPP
/CCC/2017CCC_J1-J5.py
2,159
3.515625
4
# ####################################### # @ Canadian Computing Competition # # @ Junior 2017 # # @ Author : Jun Yang # # @ Time : 2020-08-28 # # ####################################### # ''' # Problem J1: Quadrant Selection # ''' # a=int(input()) # b=i...
18b4e8fdf1bf347edd4951f2583320d45b8635fc
Betrezen/SimpleCV2
/SimpleCV/Display/Base/DrawingLayer.py
12,881
3.703125
4
from Shapes import * from ...Color import Color class DrawingLayer: """ **SUMMARY** DrawingLayer gives you a way to mark up Image classes without changing the image data itself. **NOTE** This class should be kept picklable so that the it can be sent over a Pipe """ ...
beac9db2b9bd482dc933865229a84db6b5cdb5c0
LarryStanley/mathCampClass
/wave.py
105
3.796875
4
while True: n= int(input("> ")) for i in range(n,-n-1,-1): print(" "*(i**2),"*",sep="")
91ac10d81b17a59776f6e1000ac8dac7f16b5f90
FuneyYan/Python-
/hello.py
33,858
3.984375
4
import math ''' name=input('please enter you username:') print(name) a=100 if a>=1: print(0) else: print(1) print(10.0/3.0) print('i\' am \"ok\"!') #字符串原样输出 \\r\\ print(r'\\r\\') #占位符 s1=72 s2=85 r=(s2-s1)/100 print('hello,{0}成绩提升了{1:.1f}%'.format('james',r)) #占位符 print('hello,%s的成绩是%.1f' % ('james',11.22)); # 打印...
359684540bbf8117b3895bb47320036022c52817
RaymondHealy/Karahl_Codespace
/CS 1/Homeworks/hw8/sort_compare.py
2,539
4.28125
4
"""Raymond Healy""" import random as r import time as t from insertionSort import * from quickSort import * from mergeSort import * def GenerateRandomList(size, minimum, maximum): toReturn = [] for i in range(0, size-1): toReturn += [r.randint(minimum, maximum)] return toReturn ...
15fa64079ab80947c8e5e0136963ad160fa0df00
zack-ashen/noted
/noted/NoteGrid.py
7,486
3.640625
4
"""Helper functions for printing out grid of notes.json or one note. These functions assist with the printing of a grid of notes.json. Primarily manipulate a nested list object which can be ragged or note. Author: Zachary Ashen Date: June 4th 2020 """ import os import re from textwrap import fill from . import NotedI...
d19693e07f7436eb1cfc7164e74677dfca172216
Anshikaverma24/meraki-list-questions
/meraki list ques/q2.py
218
3.78125
4
# Write a code, that counts the numbers between 20 and 40 and then print its count. numbers=[50, 40, 23, 70, 56, 12, 5, 10, 7] i=0 while i<len(numbers): if numbers[i]>20 and numbers[i]<40: print(numbers[i]) i+=1
0ffdea8b5f188623511a3da2c029720320c9e45e
notwhale/FizzBuzz
/fizzbuzz.py
1,607
4.09375
4
#!/usr/env python3 """ Write a program to print numbers from 1 to 100. But for multiples of 3 print 'Fizz' instead and for the multiple of 5 print 'Buzz' and for the numbers multiple of both 3 and 5 print 'FizzBuzz'. """ import sys import time def fizz_buzz1(r_min, r_max): """ Straight solution ...
3fc47789635941d4b5215568a5e8d5612200d539
LolaSun/Tasks
/Camel to Snake.py
763
4.46875
4
""" The company you are working for is refactoring its entire codebase. It's changing all naming conventions from camel to snake case (camelCasing to snake_casing). Every capital letter is replaced with its lowercase prefixed by an underscore _, except for the first letter, which is lowercased without the underscor...
a9209700cf92a020ebf0b3825c28027d040f368d
MluskGit/Note
/py/increase.py
677
3.734375
4
#!/usr/bin/python3 from readURL import ReadURL # 增加某用户的CSDN阅读量, 发现是每天都能去增加一次 def read_blog(list_url): readUrl = ReadURL(list_url) soup = readUrl.readhtml() li_list = soup.find_all('li') for li_element in li_list: li_class = readUrl.getelement(str(li_element), 'class') if li_class == "b...
27ae0dc2f9eff4ac89d583dc50b33789095c9dec
nchdms1999/Python
/Python/4-6成员运算符.py
440
4.125
4
# in ; not in str01 = "my name is KK, I come from China" if "come" in str01: print("include") else: print("not include") name_array = ["Alice","Bob","Peter","Tomas"] name = input("Please input name: ") if name in name_array: print("The name %s is in the List!" % name) else: print("The name %s is NOT in t...
2ee9e967a8ba89af405ee0129b67b106297110f7
mulongxinag/xuexi
/L2基础类型控制语句/练习题:学习成绩.py
855
4.15625
4
# 接收用户输入的学生成绩 score=input('成绩:') score=int (score) if score< 60: passed='不及格' print(passed) else: passed='及格' print(passed) if 60<=score<70: rank='D' elif 70<=score<80: rank='C' elif 80<=score<90: rank='B' elif 90<=score<=100: rank='A' print(rank) ...
0c57d38ab22ad465e0322eba46028567039fa495
anujaverma11/-100DaysOfCode
/0035_ElectronicsShop.py
2,320
4.03125
4
#!/bin/python3 import sys def getMoneySpent(keyboards, drives, s): # keyboards = [3, 1] # drives = [5, 2, 8] # s = 622830 maxAmount = -1 for x in keyboards: for y in drives: if (x + y <= s and x+y > maxAmount): maxAmount = x+y if (maxAmount>s): maxAmount ...
4faeae492ce66e5cc0f2b92ea015b442c505e56c
jimishere/SI506-practice
/problem_sets/ps_09-2020Fall/problem_set_09.py
5,240
4.28125
4
# START PROBLEM SET 09 print('Problem set 09 \n') # SETUP import csv class Country(): """ Representation of a country Attributes: code (str): the code of the country name (str): the name of the country population (int): the population of the country meat_consumption_per_c...
76437de03673fa10258883b76a0297afa06e6260
Karpo22/Project-Euler
/Problem 8.py
771
3.546875
4
## Variables highestValue = 0 intContainer = 1 lowerBound = 0 spotHolder = 0 f = open("/Users/karp/Desktop/Numbers.rtf", "r") lines = f.read().splitlines() ## Strip only to digits then store in control string cleaned = [x for x in lines if x[:1].isdigit()] controlString = '' for x in cleaned: for i in x: ...
3c566b16d82cc04538d23f43c8c3b9af7b5a9845
animeshsahu80/Data-Structures-and-Algorithms
/Algorithm_Solutions/hash_map.py
2,377
3.953125
4
from collections import namedtuple HashMapNode = namedtuple('HashMapNode', ['key', 'value']) class HashMap: def __init__(self, bucket_count=16): self.size = 0 self.bucket_count = bucket_count self.buckets = [[] for i in range(bucket_count)] def put(self, key, value): """Inse...
46095d4b2c385effec4993cb58f997ac138424ab
DJSull93/python-oop
/webscrap/wikipedia.py
542
3.890625
4
class Wikipedia(object): def __init__(self, url): self.url = url def __str__(self): return self.url @staticmethod def main(): while 1: menu = int(input(f'0.Exit\n1.Input\n2.Print URL\n')) if menu == 0: break elif menu == 1: ...
d51df74f709e8a3e4c2594a0697e2c492460bc30
linmartinescu/Code
/bb_temperature.py
1,849
3.53125
4
""" Aurthor: Lindsay Martinescu """ from Blackbody import Blackbody def bb_temperature(wavelength, radiance, epsilon = 1e-8): tLow = 0.0 # initial low temperature tHigh = 6000.0 # initial high temperature tResult = (tHigh + tLow)/2.0 # current calculated temperature while ((tHigh - tLow) > epsilon): # while o...
07a94f2e0462d566138041a779a2df40191570a6
todorovventsi/Software-Engineering
/Python-Advanced-2021/Exam-preparation/Python_Advanced_Retake_Exam-16-Dec-2020/02.Problem_2-Letter-game.py
1,246
3.6875
4
def move_is_valid(coordinates): return True if 0 <= coordinates[0] < size and 0 <= coordinates[1] < size else False moves_mapper = { "up": lambda x, y: (x - 1, y), "down": lambda x, y: (x + 1, y), "right": lambda x, y: (x, y + 1), "left": lambda x, y: (x, y - 1), } initial_string = input() size =...
755c056515dc6a1d65818a14023d643757d0f879
oojo12/algorithms
/sort/count_sort.py
972
4.03125
4
def count_sort(arr, k): ''' This is a non-negative implementation of count sort it runs with the following complexities: time - O(K+N) space - O(K+N) Input: arr - array to be sorted k - integer space to allot to the temp storage array. It is recommeneded...
17a10d0551e47d62b70e0bccb6981cc8c973ee2c
kharrigian/emnlp-2020-mental-health-generalization
/mhlib/util/helpers.py
534
4.0625
4
def flatten(l): """ Flatten a list of lists by one level. Args: l (list of lists): List of lists Returns: flattened_list (list): Flattened list """ flattened_list = [item for sublist in l for item in sublist] return flattened_list def chunks(l, n): """ ...
e8035ecc665c887d6641216f67ac9b2f1d027f81
Ukasz11233/Algorithms
/Algorytmy/Ćwiczenia1/zad5_reverse_list.py
638
3.84375
4
class Node: def __init__(self, value = None): self.value = value self.next = None def MakeFromArray(A): first = None for el in A: p = Node(el) p.next = first first = p return first def Write(first): tmp = first while tmp is not None: print(tmp.va...
3b2f49704f8857af05d2962b6b6bc298ba572fc6
DahrielG/EvenOdd
/app/models/model.py
477
3.828125
4
sentence = "Hello" def count(sentence): sentence = sentence.replace(" ", "") sentence = sentence.replace(".", "") sentence = sentence.replace(",", "") sentence = sentence.replace("!", "") sentence = sentence.replace("?", "") sentence = sentence.replace("'", "") sentence = sentence.rep...
1ede3d16dbe9459a7efac3f4028dbffa8ddc4a0d
lindsaymarkward/CP1200InClassDemos2015
/files.py
1,042
3.796875
4
__author__ = 'sci-lmw1' # writeFile = open("data.txt", 'a') # # writeFile.write("CP1200 is such\n\n a good\nSubject!!!") # # writeFile.write("Goodbye") # writeFile.write("\nHappy!\n") # writeFile.close() # file = open("data.txt", 'r') # # text = file.read() # countLines = 0 # for line in file: # line = line.strip...
224bc22ac75d49eb241315a270d175d360c849ea
sudhanthiran/Python_Practice
/Competitive Coding/maxSubArray.py
480
3.515625
4
from typing import List class Solution: def maxSubArray(self, nums: List[int]) -> int: len_nums = len(nums) sum_nums = nums[0] temp = nums[0] for i in nums[1:]: if (temp + i > i): temp = temp + i else: temp = i if (...
37f06770c1c6ddf6c67119d879e95bbed27d47f6
zack-ashen/noted
/noted/NotedItem.py
4,553
3.734375
4
"""Noted Items class and subclasses including Notes Class and Lists Class. Author: Zachary Ashen Date: June 4th 2020 """ class _NotedItem(object): # Master class of NotedItems including NoteItem and ListItem # Invariant: title is a string def __init__(self, title): # Initializes _NotedItem ...
c6e71c6a1215eb2cda3b999f9e55e7ddadfedd51
becurrie/py-sorts
/py_sorter/sorter.py
7,533
3.921875
4
"""py_sorter.sorter: provides argument parsing and entry point main(). Any calls to the sorts methods are called from here based on the -s/--sort argument specified by the user. """ __version__ = "0.3.1" import argparse import os import timeit from random import randint from .sorts import * def parse_args(args): ...
8b210c5f155c4d4dfefc5c9769790c1203a01111
the-blackbeard/python-code
/bfs.py
1,019
4.21875
4
class Node: def __init__(self, name): self.name = name self.adjacency_list = [] self.visited = False def breadth_first_search(start_node): # FIFO: First item we insert will be taken out first queue = [start_node] # We keep iterating (considering the neighbour) until the queue is empty while queu...
13bcb68da10012c1f64fb2c6dbc14754813ba162
aljubaer/AES-Implementation
/engine/cipher_block_chaining.py
1,278
3.5
4
# -*- coding: utf-8 -*- """ Created on Sun Oct 13 16:01:11 2019 @author: hp """ from block_cipher_encryption import block_cipher_encrypt from block_cipher_decryption import block_cipher_decrypt from utility import array_xor def encrypt(message, expanded_key, number_of_rounds, iv): print('CBC Encrypt') encryp...
7456e34e998eb140942f5d714cd2430d84f4181c
birajaghoshal/uncertainties-1
/representation/mnist.py
3,795
3.703125
4
# -*- coding: utf-8 -*- """Simple feedforward neural network for Mnist.""" #%% Packages import os import shutil from absl import app import numpy as np import keras from keras.models import Sequential, Model from keras.layers import Dense, Flatten from sklearn.model_selection import train_test_split import utils.u...
7c89ce41eb74d47444d7f8bef22ff0aee2497048
SunshineHai/PythonTest
/DataStructure/mo.py
346
3.625
4
def BBsort(array): for i in range(1, len(array)): for j in range(0, len(array)-i): if array[j] > array[j+1]: array[j], array[j+1] = array[j+1], array[j] return array def writeresult(path, result): with open(path, 'w' ,encoding='utf-8') as source: ...
778ffeb74ddaae6e0d01d15ddb73219948b30722
Team-Tomato/Learn
/Juniors - 1st Year/Suvetha Devi/day4/string_rev.py
164
4.3125
4
def reverse(word): i= -1 while i>=-(len(word)): print (word[i] ,end =" ") i-=1 str = input("Enter a string to reverse") reverse(str)
6a178cf163df0fa5e59cd39318538b49dab0a22e
thisismsp78/PythonCodsLearn
/p1/RangeDemo/RangeDemo.py
210
4
4
number=int(input("Enter number : ")) if number>100 or number<0: print("Invalid !") elif number>75: print("A") elif number>50: print("B") elif number>25: print("C") else: print("D")
0a68c4b7482b395f09b33602f7d1797aa9699e50
cuiqs/pythonlearn
/dnsreverse.py
1,292
4.15625
4
#!/usr/bin/env python # Performs a reverse lookup on the IP address given on the command line import sys,socket def getipaddrs(hostname): """Get a list of IP address from a given hostname. this is a standard\ (forward) lookup""" result=socket.getaddrinfo(hostname,None,0,socket.SOCK_STREAM) return [x[4][0] for x ...
8841ad7e4cf981985bbe154bbc9677cab722573b
CharlieHoffmann/NumericalMethods
/BubbleSortCH.py
500
4
4
def Bubble(a): for j in range(len(a)-1): for k in range(len(a)-1,j,-1): print("j=",j,"k=",k); if(a[k]<a[k-1]): temp=a[k]; a[k]=a[k-1]; a[k-1]=temp; print(*a); else: print("a*"); ...
03c7f1944bceb2bd7878abb52ff4395201ecfa03
vcarehuman/tf-pose-estimation-master
/ytfgpu.py
1,958
3.765625
4
import numpy as np # #def sigmoid(x): # s = 1 /(1+np.exp(-x)) # print(s) # return s #x = np.array([1, 2, 3]) #print("Sigmoid of x is = " +str(sigmoid(x)) + "\n") # #def sigmoid_derivative(x): # s = sigmoid(x) # ds = s*(1-s) # print(ds) # return ds #x = np.array([1, 2, 3]) # #print("\n sigmoid_der...
b9bc1dd86e9796ddf1074c0ce1bb2974a7d496bc
KuroDev89/Python-Crash-Course
/dicc.py
210
3.734375
4
person={'name':'Aurelio','age':31, 'job':'Profesor'} # print(person) # print(type(person)) # print(dir(dict))#conociendo los métodos y funciones #obtener las llaves print(person.keys()) print(person.items())
884c5b9339b84174d009239ed54146266fc782aa
ayushakar1/Pycamp
/day 2/assig1.py
280
4.0625
4
def input(a,b,c,d): summ = a+b+c+d product= a*b*c*d diff = (a+b)+(c-d) random_operation = ((a+b-3)**c)//d return summ,product,diff,random_operation #returns multiple values as a result print(input(5,33,6,9)) #passes multiple arguments as input
b5e4ef7c2c9b94a29456899b56a48547d5b5a10d
demelue/easy-medium-code-challenges
/Python/ArrayManipulation/find_maximum_square.py
1,326
3.828125
4
#brute force def find_max_square(matrix): row_dim = len(matrix) col_dim = len(matrix[0]) max_sq_len = 0 for r in range(row_dim): for c in range(col_dim): if matrix[r][c] == 1: flag = True sq_len = 1 while sq_len + r < row_dim and sq_len...
83d682f5c753c15e3e6e556776b0806d68215d4d
RiikkaKokko/JAMK_ohjelmoinnin_perusteet
/exercise15/Tehtävä_L15T04.py
495
3.6875
4
while True: luku = input("Kirjoita numero") try: luku = int(luku) print('This is a int') filename1=("Integers.txt") file1=open(filename1, "w") file1.write(str(luku)) file1.close() except: try: luku = float(luku) print('This is a...
d7a4fd338e4e40bc66b7760167f59ea6a8a8b17b
vuquocm/VuQuocMinh-c4t7
/dict_hw2/tn.py
1,204
3.890625
4
# print('how many engines does an a 340 have?') # answer = { # 'A' : 2, # 'B' : 4, # 'C' : 3, # 'D' : 1 # } # for k, v in answer.items(): # print(k,v, sep=":") # rep = str.upper(input('enter your anwser')) # while True: # if rep == 'B': # print('correct') # break # else: # ...
bbcf7129700f0857cc607bc510c55b150a56c5b1
YashSaxena75/GME
/gameer.py
1,861
3.921875
4
c=None k=None y="" z="" x=None print("You have 30 points in the very starting of the game") print("Rules for the game are:") print(""" 1:If you choose any attribute u will loose 7.5 points 2:You can take back ur points from that attribute 3:You will loose th...
0235317cfab4f69d6a50a316ebb0feed1e52bcbf
EyreC/PythonCiphers
/backwards.py
483
4.25
4
import string def backwards(inputString): wordList = inputString.split(" ") #list of space-separated words in inputString backwardsList = [] #list of reversed words #Generate list of reversed words for word in wordList: newWordList=[] for index,letter in enumerate(word): ...
5825345d205a5cd2277684d0c9c41a55b97dea1f
Aasthaengg/IBMdataset
/Python_codes/p02261/s626200736.py
1,271
3.828125
4
import time import copy def BubbleSort(A, N): flag = 1 while flag: flag = 0 for j in reversed(range(1, N)): if A[j]['value']<A[j-1]['value']: A[j], A[j-1] = A[j-1], A[j] flag = 1 return A def SelectionSort(A, N): for i in range(0, N): ...
75ab452b5b19b73a743c89d58dfb892a9660f3be
tpt5cu/python-tutorial
/language/old/built_in_types/floats.py
831
3.875
4
def float_precision(): """The maximum floating point value is just under 1.08e308, which is 64-bit double precision. Any floating point value greater than that is represented by the string 'inf'.""" print(1.79e308) print(1.8e308) print(1.79e309) """The smallest positive floating point value is a...
6928daa9732d370a0d361ab941c8f6a56734955d
BrandonP321/Python-masterclass
/Dictionaries&Sets/sets.py
957
4.15625
4
# farm_animals = {"sheep", "cow", "hen", "pig"} # print(farm_animals) # # for animal in farm_animals: # print(animal) # # wild_animals = set(["lion", "tiger", "bear"]) # print(wild_animals) # # for animal in wild_animals: # print(animal) # # farm_animals.add("horse") # wild_animals.add("horse") # ...
20ca3b613852f9d5c7d06ff9ca145e5d54ca65a1
qi-zhang8/Exercises
/stringPermutation.py
198
3.59375
4
def getPermutation(s, prefix=''): if len(s) == 0: print prefix for i in range(len(s)): print("s[0:%d]"%i, s[0:i]) getPermutation(s[0:i]+s[i+1:len(s)],prefix+s[i]) getPermutation('abc', '')
2db126e208d792e7a1f0edcfa0d072b611362bdc
blakeaw/PyBILT
/pybilt/common/distance_cutoff_clustering.py
7,070
3.828125
4
"""Function to compute hiearchical distance cutoff clusters.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np from six.moves import range def distance_euclidean(v_a, v_b): """Compute the Euclidean distance between two vectors. ...
8c310ec646b3164f8fc6f210c265df590fdf4aa8
neriphy/evaluar_numeros_perfectos
/numeros_perfectos.py
748
3.78125
4
#Calculador de numeros perfectos #Creado por @neriphy import time numero = int(input("¿Que numero desea evaluar? ")) start = time.time() intentos = numero suma = 0 intentos = numero - 1 while intentos>0: if numero%intentos == 0: suma = intentos + suma print("intentos",intentos,"y suma=",suma) """elif nume...
b993d85079946b5d54b0138a16d172970974331b
piekey1994/spiderdemo
/initSql.py
700
3.53125
4
import sqlite3 conn = sqlite3.connect('test.db') print("Opened database successfully") conn.execute('''CREATE TABLE food (id varchar(50) PRIMARY KEY NOT NULL, name varchar(100) NOT NULL, href text not null, usetime varchar(10), taste varchar(50), img text not null, tec...
38dc347dd5e01a4a145f117fec8e76858bd009f9
lucasffgomes/Python-Intensivo
/seçao_06/exercicio_seçao_06/exercicio_05.py
256
4.03125
4
""" Faça um programa que peça ao usuário para digitar 10 valores e some-os. """ print("Vamos calcular a soam de 10 valores.") resultado = 0 for vez in range(0, 10): valor = int(input("Digite o valor: ")) resultado += valor print(resultado)
7d68f461be3e8144e36a2faaf0ee3f9d65edbbe8
chionglai/euler
/q032.py
2,445
3.5625
4
#!/usr/bin/env python import time import itertools as it """ q032: We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once; for example, the 5-digit number, 15234, is 1 through 5 pandigital. The product 7254 is unusual, as the identity, 39 × 186 = 7254, containing mult...
24cc718e8fea644181372537feecf9039e7b3c5f
nurack/eric-pcc-solutions
/PCC2_10.py
362
4.0625
4
#it prints the message using the variable name name = "Eric" print(f"Hello {name}, would you like to learn some Python today?") name = "\t Anurag \n Singh " print(name) print(name.lstrip()) print(name.rstrip()) print(name.strip()) #different strip functions are performed on the same variable but it is not permanent ...
ddfe0a592d2a9d801d971c7048f10f6a0e19c6ee
Moeh-Jama/Kattis-Problems
/flip.py
119
3.59375
4
numbers = input().split() i = 2 a = '' b = '' while i>=0: a += numbers[0][i] b += numbers[1][i] i-=1 print(max(a,b))
cd3591ccded132a91a48821d7a9b9b3cb77c16b4
JayantGoel001/Open-Source
/Week2/20.py
356
3.921875
4
import collections import pprint file_input = input() with open(file_input, 'r') as info: count = collections.Counter(info.read().upper()) value = pprint.pformat(count) print(value) a = file_input.split(".") if a[1] == "txt": print("it is a text file") elif a[1] == "cpp": print("it is a c++ file")...
2dcb81c7bbeba7e426829a378f9afbe12237fd5a
Elvis2597/Python_Programs
/CountChar.py
89
3.921875
4
list=input("enter the list:") str=str(list) for i in str: str=str.count(i) print str
b3547d48193d66569259bda3679dd9a9d4cecafa
MikuWRS/PythonJust4Fun
/Proyecto4_TicTacToe_IA/proyecto4.py
3,192
3.578125
4
import os tablero=[' ' for x in range(10)] c_posicion='123456789' def insertar(marca,ins_posicion): tablero[ins_posicion]=marca def p_tablero(tablero): print(" | | \n") print(" "+tablero[1]+" | "+tablero[2]+" | "+tablero[3]+" \n") print(" | | \n") print("------------------\n") prin...
921975d39894238512519cd91d3fcca833838a4b
mrsempress/Simple-Interpreter
/Python/test.py
813
3.65625
4
""" read code from "Code.txt", and then put the strings to the interpreter show the pictures of the statements """ import matplotlib.pyplot as plt import Grammar import Exceptions # Open code document print("The code is follows: ") with open("Code.txt") as fp: for line in fp.readlines(): # 删除分隔符,如\n, \r, ...
12b1ede17ae5e072c62477e430e672caf5bed798
fdouw/AoC2019
/Day04/day04.py
688
3.921875
4
#!/usr/bin/env python3 def match(num): """ count the recurrence of digits -1 if any digits are in the wrong order: filter this out 2 if any digit appears exactly twice: count these for part 1 and 2 max recurrence otherwise: count for part 1 if > 2, but filter if 1 """ s = str(num) for...
2d7b2c0e8b4798a7fa336c3c6ebc35957c5e3e68
saeidp/Data-Structure-Algorithm
/Sorting/InsertionSort.py
1,859
4.125
4
# Implement Insertion Sort # On the first pass, it compares a maximum of one item. # On the second pass, it’s a maximum of two items, # and so on, up to a maximum of N-1 comparisons on the last # pass. This is 1 + 2 + 3 + … + N-1 = N*(N-1)/2 # However, because on each pass an average of only half of # the maximum numb...
daf90277269b9dffcc8e2818c5626b62d1062398
jayyei/Repositorio
/Python/Curso-Python-3-Udemy/CursoPython/Fase 4 - Temas avanzados/Tema 11 - Modulos/Apuntes/Leccion 02 (Apuntes) - Paquetes/paquete/adios/despedidas.py
270
3.546875
4
#Este es un modulo con funciones que despiden def despedirse(): print("Adios, me estoy despidiendo, desde la funcion despedirse del modulo adios") class Despido(): def __init__(self): print("Adios, me despido desde la clase despido en el modulo adios")
d3763659b8b824588d2640a02bc7e627e96a57b3
clarissadesimoni/aoc15
/day8/day8.py
1,422
3.59375
4
data = open('day8/day8.txt').read().split('\n') def countChars1(string): i, code, memory = 0, 0, 0 hexChars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'] while i < len(string): if string[i] == '\\': if string[i + 1] == 'x' and string[i + 2] in hexCha...
c6414f3b48a4a3c2ee90f0e31b73e98337dc5144
pandey-ankur-au17/Python
/coding-challenges/week07/day04/ccQ2.py
665
3.96875
4
# Given a sorted array with Duplicates . Write a program to find UPPER # BOUND of a TARGET using Binary search Method . # Return Index corresponding to the element of the upper bound element. # Example : # Input : - arr = [1,1,1,2,2,3,3,5,5,5,7,7] , Target = 4 # Output : - 7 def Upper_bound(arr,target): n=len(ar...
6238ac26cdbe54d32de42f1f2a1b129bc5d5d5cd
codeBeefFly/bxg_python_basic
/Day09/07.datetime.py
147
3.59375
4
import datetime year = datetime.datetime.now().year month = datetime.datetime.now().month day = datetime.datetime.now().day print(year,month,day)
9d14724a55e90399dc43cc6fdf932f8044f01ad9
samuaicc/Python
/课练三十.py
953
4.3125
4
#-*-coding:utf-8-*- #输入一周内某一天的英文首字母判断这是星期几,第一个字母重复就判断第二个字母 f_letter = str(input('First letter:')) if f_letter.upper() == 'M': print('This day is Monday !') elif f_letter.upper() == 'W': print('This day is Wednesday !') elif f_letter.upper() == 'F': print('This day is Friday !') elif f_letter.upper(...
c4149bd78577535c55476234bd0bf717436cb2e3
qqizai/python36patterns
/创建型模式-单例模式.py
2,305
3.578125
4
# -*- coding: utf-8 -*- # @Author : ydf # @Time : 2019/10/8 0008 13:55 """ 单例模式 适用范围三颗星,这不是最常用的设计模式。往往只能脱出而出仅仅能说出这一种设计模式,但oop根本目的是要多例, 使用oop来实现单例模式,好处包括 1 延迟初始化(只有在生成对象时候调用__init__里面时候才进行初始化) 2 动态传参初始化 否则,一般情况下,不需要来使用类来搞单例模式,文件级模块全局变量的写法搞定即可,python模块天然单例,不信的话可以测试一下,c导入a,b也导入a,c导入b,在a里面直接print hello, 运行c.py,只会看到一次pr...
e16f6a60db6bf7d9682571965bbf910a78b5f7c0
zy199529/data_structure1
/排序/InsertSort.py
876
3.984375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Author: Lenovo # @Date: 2019-05-28 08:52:20 # @Last Modified by: Lenovo # @Last Modified time: 2019-05-28 09:53:06 # 插入排序工作原理:对于每个未排序数据,在已排序序列中总后往前扫描,找到相应位置并插入。 # 直接插入排序被分为:有序数据和无序数据 # 每次从无序数据中选择一个数据插入到有序数据中 def InsertSort(k, n): for i in range(1, n): i...
0a4602da934f3d2cbdcc17c10084fb8baf591d96
ankile/ITGK-TDT4110
/timeoppgaver/sum_table.py
234
3.5
4
def sum_table(table): sum = 0 for i in range(len(table)): for j in range(len(table[i])): sum += table[i][j] return sum my_list = [[1 for i in range(10)] for i in range(5)] print(sum_table(my_list))
b3d20eaaa79efacd8b10b943495c5cb8ba99e6a1
mitzaM/python-learning-program
/plp_1_p3.py
1,397
4.1875
4
#! /usr//bin/env python def _sort_list(l): """ Sorts a list of (key, value) pairs """ for i in range(len(l) - 1): for j in range(i + 1, len(l)): if (l[i][0] > l[j][0]): l[i], l[j] = l[j], l[i] return l def _compare_dict(dict_a, dict_b): """ Compares t...
6a30f8e41742853e1535cbdf86f296299ffc8fb0
yanliang1/Python-test
/Python-03/dict.py
567
3.71875
4
#键值对(字典)->映射 d = {} #创建 print(type(d)) print(len(d)) #添加 #d[key] = value d["red"] = 0xff0000 d["green"] = 0x00ff00 d["blue"] = 0x0000ff print(len(d)) print(d) #修改 d["red"] = 123456 print(len(d)) print(d) #移除 d.pop("red") print(d) #获取指定的值 value = d.get("green") print("value =",value) print("-"*30) #获取所有的项 prin...
85c1b5eb8d3870e882bf1d1d62e1ebdefab98d60
nishanthakur/Modified-RSA
/rsa.py
4,683
3.921875
4
import time import sys #Checking whether the user input is prime number or composite number. def check_prime(number): counter = 0 for divider in range(1,number+1): remainder = number % divider if remainder == 0: counter += 1 return counter #Selecting First prime Number(p) de...
f9dfcf505a50811077fff369a2e8e40fb1ad04f7
Likhith-krishna/python
/beginner/set4/71.py
87
3.625
4
inter=input() d=inter[::-1] if(inter==d): print("yes") else: print("no")
dcd0cd36c62f80c2e3e52c42c665620f2f8cb22d
JuanesFranco/Fundamentos-De-Programacion
/sesion-05/ejercicio 33.py
205
3.890625
4
suma=0 x=1 n=int(input("cuantas personas va a procesar")) while x<=n: altura=float(input("ingrese la altura")) suma=suma+altura x=x+1 promedio=suma/n print("la altura promedio es de",promedio)
9b5d5ade3aebf589c99dc72d7b04e1e2cd730e32
krusellp/SoftDesSp15
/toolbox/word_frequency_analysis/frequency.py
1,492
4.53125
5
""" Analyzes the word frequencies in a book downloaded from Project Gutenberg """ import string def get_word_list(file_name): """ Reads the specified project Gutenberg book. Header comments, punctuation, and whitespace are stripped away. The function returns a list of the words used in the book as a list. A...