blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
237d4b5597562a6fd1daef1fab074a8e496ada5e | pawwahn/python_practice | /regular_exp_search_concepts_1/search_word_positions.py | 531 | 3.765625 | 4 | import re
content = """This method either returns None
(if the pattern doesn’t match), or a re.MatchObject that
contains information about the matching part of the string.
This method stops after the first match, so this is best suited
for testing a regular expression more than extracting data."""
search_word =... |
49b160f0a772354389d62ef9b54f1c5e6143c30b | gunit84/Code_Basics | /Code Basics Beginner/ex13_modules.py | 483 | 3.953125 | 4 | #!python3
"""Learning Modules... """
__author__ = "Gavin Jones"
import sys
import functions as f
# Add the current directory to your Python Systems PATH so it can locate the file aka Module
sys.path.append("D:\PycharmProjects\Projects\Projects_Learning\Code Basics")
squareArea = f.calculate_square_area(5)
triangl... |
33829702bf31d0136782224dc51c7ceb568c14d0 | dante092/Mega-Bus-Web-Crawler | /citicodes.py | 2,927 | 3.5 | 4 | """ Small Script to find citi destinations codes for MEGABUS"""
from urllib.request import urlopen
from bs4 import BeautifulSoup
number = 89 # First city.
while True:
try:
url = 'http://us.megabus.com/JourneyResults.aspx?originCode={0}&destinationCode=143&outboundDepartureDate=4%2f16%2f2016&inboundDepart... |
ae322d5dab25616f4bad2fb1cc085166136a5a60 | gin2010/work | /data_train/basic1.py | 404 | 3.734375 | 4 | # -*- coding: utf-8 -*-
# File : 01-basic1.py
# Author: water
# Date : 2019/7/31
for i in range(1,4):
email = input ('email:')
index = email.find("@")
if index>0:
name = email[:index]
email_sort = email[index+1:]
print(f'邮箱名:{name} 类型:{email_sort}')
break
else:
... |
8e32ecc9c3a4799548dca4e8f887bd79ed139984 | dchapp/blind75 | /python/17_letter_combinations_of_a_phone_number.py | 938 | 3.5625 | 4 | num_to_letters = {
'2': ['a', 'b', 'c'],
'3': ['d', 'e', 'f'],
'4': ['g', 'h', 'i'],
'5': ['j', 'k', 'l'],
'6': ['m', 'n', 'o'],
'7': ['p', 'q', 'r', 's'],
'8': ['t', 'u', 'v'],
'9': ['w', 'x', 'y', 'z'],
}
class Solution:
def letterCombinations(self,... |
a648c7badc895501112ac747aef0bc9fb6011c28 | anjali-kundliya/Hactoberfest-2022 | /Python/Graph Algorithms/DFS.py | 1,669 | 3.953125 | 4 | '''
The purpose of the algorithm is to mark each vertex as visited while avoiding cycles.
Algorithm:
* We will start by putting any one of the graph's vertex on top of the stack.
* After that take the top item of the stack and add it to the visited list of the vertex.
* Next, create a list of that adjacent node of th... |
1fc5b807a370eaf2c85357e1b7abdf3dc3801bc8 | Yoshioki311/Python-basics | /trim.py | 303 | 3.828125 | 4 | # Trims a given word with extra spaces
def trim(s):
if s == '':
return s
else:
i = 0
j = len(s) - 1
while s[i] == ' ' and i < len(s) - 1:
i += 1
while s[j] == ' ' and j > 0:
j -= 1
j += 1
s = s[i:j]
return s |
894e96cb347e1df6c79f4acb38b758d472cae769 | BrianMillsJr/alan | /learning/learn.py | 7,008 | 3.828125 | 4 | import nltk
import re
import alan
"""
This file handles learning tasks for alan.
A task is something that can be dictated by the user and Alan turns that dictation into python code.
Note:
You need to add Alan's main directory to your python path for this script to work due to importing alan.
Example comm... |
bcb61861490db4e81d6c98c98cfb6ea1099a9aa4 | 2ashishs/LearningPython | /pyNotes.py | 4,166 | 4 | 4 | Points to note in Python
Python,
is simple to use
allows you to split your program into modules that can be reused in other Python programs
is an interpreted language, which can save you considerable time during program development
enables programs to be written compactly and readably
is extensible: it is easy to... |
989b95b86a60078d41a5d50488531ea4a64d1138 | DuyguCiftci/lettergrade | /lettergradecalculator.py | 845 | 4.1875 | 4 | text = """
Letter Grade Calculation
"""
print(text)
num1 = int(input("Type your first midterm score: "))
num2 = int(input("Type your second exam score: "))
num3= int(input("Type your final exam score: "))
result = (num1*0.3)+(num2*0.3)+(num3*0.4)
print(result)
if result>=90:
print("Your letter grade is AA,excell... |
f449a89aaffc6e2395a1855dab842d8d5cced229 | RoboPlusPlus/Div-Python--JW | /HowTos/Import funcs/funcpy.py | 917 | 3.53125 | 4 |
#Takes two iterables, and makes a dictionary with them.
#If the two dicts are of different lenghts, the dict will be ass long as the shortest of the inputs
#inputs may be any combination of tuple, set, string or list.
def two_iters_dict(key_iter, value_iter):
dic={}
if len(key_iter) < len(value_iter):
... |
78b28dab5d2c7b79020ff93b17bbc4e0d73eefbd | Ankele/python_code | /algo/test_quick_sort.py | 845 | 3.953125 | 4 |
# -*- coding:utf-8 -*-
def quick_sort(li):
n = len(li)
if n < 2:
return
_quick_sort(li, 0, n-1)
def partition(li, left, right):
tmp = li[left]
while left < right:
while left < right and tmp <= li[right]:
right -= 1
li[left] = li[right]
while left < ri... |
dbc4fde14b7035af0ea55ea3019ab6144b2452cd | KShih/workspaceLeetcode | /python/Mathwork_MaxValAmongShortestDisInAMatrix.py | 579 | 3.765625 | 4 | """
Given a grid with w as width, h as height.
Each cell of the grid represents a potential building lot and we will be adding "n" buildings inside this grid.
The goal is for the furthest of all lots to be as near as possible to a building.
Given an input n, which is the number of buildings to be placed in the lot,
det... |
b685e5091b6eec6dda0f14772c0729821911faea | Jonnylazzeri/hangman | /script.py | 1,054 | 4 | 4 |
import random
import hangman_words
import hangman_art
stages = hangman_art.stages
logo = hangman_art.logo
word_list = hangman_words.word_list
word = word_list[random.randint(0, len(word_list) - 1)]
word = list(word)
empty_word = ['_' for i in range(len(word))]
lives = 6
print(logo)
print(stages[lives])
print(' '.j... |
7130bea7baad8b27931ecb239c2b3e7bda67beec | SafonovMikhail/python_000403 | /000403_01_10_ex03_Div.py | 580 | 3.921875 | 4 | #000403_01_10_ex03_Div.py
a = int(input())
b = int(input())
if b != 0:
print(a/b)
else:
print("Деление невозможно, b = ", b)
# дополняем условие: просим еще раз ввести "b" (если произошел случай "else", просим еще раз ввести "b")
if b != 0:
print(a/b)
else:
# print("Деление невозможно, b = ", b)
b =... |
69d6c052d5c8669417bccb0f1509379e29b59abe | jacquelineramos8/567HW01 | /HW01_JacquelineRamos.py | 3,667 | 4.15625 | 4 | """
Author: Jacqueline Ramos
Assignment: HW01
Description: The code below receives triangle side input using the if __name__ == '__main__' function and classifies that triangle as:
equilateral, isosceles, scalene, right, or not a triangle. I left the code intentionally with bugs to demonstrate how
p... |
579c079561564841a91084ed9134ee971bd34e22 | BornRiot/Python.Udemy.Complete_Python_BootCamp | /methods_and_functions/scribbles/transform.py | 326 | 3.953125 | 4 | """This is my module docstring"""
# https://bit.ly/2CiRBog
the_list = [1,3,5,7,9,11,13,15,17,19,21]
the_tuple = tuple(the_list)
y = list(enumerate(the_tuple))
print("Here is Y:", y)
print(the_tuple)
for i, v in enumerate(the_tuple):
print("Here is the non enumerate", the_tuple[i])
print(type(the_tuple))
print(the_t... |
62fafbe7e3b9d8f717103844722f6d774d12bb6c | tlxxzj/leetcode | /19. Remove Nth Node From End of List.py | 610 | 3.78125 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def removeNthFromEnd(self, head: ListNode, n: int) -> ListNode:
h1, h2 = head, head
while n != 0:
n -= 1
h2 =... |
3b5f48d1b8ed72cb82509f52c86c3d3c5a53d220 | Yirogu/EasyPython | /python zajecia AI/zaj1/zad3.py | 953 | 3.609375 | 4 | import random
import statistics
import numpy
numbers = []
for x in range(0, 30):
randomNumber = random.randrange(100)
numbers.append(randomNumber)
print ("Wektor: ",numbers)
minimum = min(numbers)
maximum = max(numbers)
print ("Min: ", minimum)
print ("Max: ", maximum)
newNumbers = sorted(numbers)
print ("P... |
61c71a9b429f7d7f42e48e26b070b0d80204e363 | liviaasantos/curso-em-video-python3 | /mundo-1/ex013.py | 267 | 3.703125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun May 30 19:45:35 2021
@author: Livia Alves
"""
salário = float(input('Qual é o seu salário? R$'))
print('O funcionário que recebia R${:.2f}, com aumento de 15%, passará a receber R${:.2f}'.format(salário, salário*1.15))
|
114bded8d8bc98a945976ff5adcd890e393b0421 | taitujing123/my_leetcode | /333_largestBSTtree.py | 1,721 | 4.25 | 4 | """
给定一个二叉树,找到其中最大的二叉搜索树(BST)子树,其中最大指的是子树节点数最多的。
注意:
子树必须包含其所有后代。
示例:
输入: [10,5,15,1,8,null,7]
10
/ \
5 15
/ \ \
1 8 7
输出: 3
解释: 高亮部分为最大的 BST 子树。
返回值 3 在这个样例中为子树大小。
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/largest-bst-subtree
著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注... |
fd88625209ceb6fd6d80e07d70eca2b27cdd7cee | 17BTECO36/Tejeswini-kolekar | /program.py | 68 | 3.796875 | 4 | a=input("enter a value")
print(a)
int a,b,c;
a=10
b=20
print(c=a+b)
|
8bebab64cc70a010eca0112826864f4eb29d0bd2 | NirajPatel07/Data-Structures-Python | /Binary Tree/BinaryTree.py | 4,880 | 4.03125 | 4 | #Binary Tree Traversal
#1. Depth First Search
#2. Breadth First Search
#
#Depth First search is futher classified as
#1.1 PreOrder Traversal
#1.2 PostOreder Traversal
#1.3 InOrder Traversal
class stack(object):
def __init__(self):
self.items=[]
def push(self, value):
self.items.a... |
f01618ea94ce90c88c3a525ca0701452d9b38b59 | MuhiaKevin/Data-Structures-and-Algorithims | /Algorithims/Sort/bubblesort/bubblesort.py | 747 | 4.28125 | 4 | def bubblesort(array):
listlen = len(array)
swapped = True
while swapped:
swapped = False
for i in range(listlen - 1):
if array[i] > array[i + 1]:
temp = array[i] # save the current element of t... |
405d442ca55d9fd8a68a82dfbe3ce3ce7b848e4a | CCW22/Projects | /velocity_maker/combinations_std.py | 686 | 3.84375 | 4 | import itertools
import numpy as np
def lowest_std_comb(list_of_values, n):
"""
When a list is inputted, returns the lowest std calculation of a combination of 3 items
"""
list_of_std = []
y = list(itertools.combinations(list_of_values, n))
#print(y)
y = [t for t in y if 0 not in ... |
c602339a6b868133afa95a9937f7a953443e5817 | ZayJob/OS-and-N | /Tasks/task1/task1.py | 761 | 3.765625 | 4 | import os
def search_files(search_dir, search_assignment):
result = []
for root, dirs, files in os.walk(search_dir):
for file_name in files:
if file_name.endswith(search_assignment):
result.append(file_name)
return result
def dump_to_file(result, file_to_write):
if... |
5dc7e4a56d290c3c7f5e9474d0b0a4960a70e837 | Glitchad/test | /Primes/Prime - Final.py | 515 | 4.125 | 4 | # define input variable
inputNum = int(
input("This program checks whether an integer is a prime. Please enter a number: ")
)
isPrime = None
if inputNum > 2:
for item in range(2, inputNum):
if (inputNum % item) == 0:
print(item, "*", inputNum // item, "=", inputNum)
isPrime = Fa... |
2c7c1680effdeb6e2c94835de1a9fd3e5ea8b155 | varunbpatil/udemy_algorithms_python | /bst/bst.py | 2,218 | 3.828125 | 4 | class Node():
def __init__(self, data):
self.data = data
self.leftChild = None
self.rightChild = None
def traverse_inorder(self):
if self.leftChild:
self.leftChild.traverse_inorder()
print(self.data)
if self.rightChild:
self.rightChild.t... |
6a235270d14c37ae74c560ed3f9ad82f3d9c4e3a | Himanshu-jn20/PythonNPysparkPractice | /Practise_beginner/list.py | 275 | 4.03125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Sep 18 11:38:22 2020
@author: Himanshu
"""
numbers=[2,4,5,120,3,122]
print(len(numbers))
num2=numbers
print(num2)
lnum=numbers[0]
for num in numbers:
if lnum < num :
lnum=num
print(lnum)
|
8dd25ec3d9550ec6e3e0fcb253eddf8e6dc05303 | amanprodigy/cab-booking | /cabs/models/address.py | 827 | 3.671875 | 4 | from enum import Enum
class Country(Enum):
INDIA, USA = 'IND', 'USA'
class State(object):
def __init__(self, name: str, state_code: str, country: Country):
self.name = name
self.state_code = state_code
self.country = country
def __repr__(self):
return self.state_code
c... |
cf36d6217d9081a3f9d4bc309d462c228246fb86 | liudaoqiangtj/fuzzy-spoon | /python进阶.py | 3,605 | 3.796875 | 4 | #! /usr/bin/env python
# -*- coding:utf-8 -*-
#函数名和变量没有什么区别,只不过函数名是指向函数的变量名
from math import sqrt
def add(x,y,f):
return f(x)+f(y)
print(add(4,9,sqrt))
z = lambda x,y:x+y
import re
def format_name(s):
st0 = re.sub(r'.*',s[0].upper(),s)
st = re.sub(r'.*',s[1:].lower(),s)
return st0+st
print(list(map(format_name,['... |
5aeacfe2ec0ec3213f96f632e1af30abf4da0f72 | abugasavio/mitx600.1x | /week1/05ps2.py | 339 | 3.609375 | 4 | s = 'jmeocobdobvjbb'
bob_count = 0
for index, letter in enumerate(s):
if letter == 'b':
try:
o, b = s[index + 1], s[index + 2]
except IndexError:
pass
else:
if o == 'o' and b == 'b':
bob_count += 1
print('Number of times bob occurs is: '... |
9a639c345411ddd7ed6160403ad0373451c9305b | andrew-walsh-dev/practice-algorithms | /Algorithmic Interview Prep/longest_substring.py | 320 | 3.90625 | 4 | def longest_substring(str):
unique = ""
length = 0
for char in str:
if char not in unique:
unique += char
else:
#peel off the part of unique with the duplicate
unique = unique[unique.index(c)+1:] + c
length = max(length, len(unique))
return length
|
9ba56e95f6168350755dd97f6f2a0e1098bb9bde | UdhaikumarMohan/Strings-and-Pattern | /freq of char/sec_most.py | 809 | 4.03125 | 4 | # Write code to find the second most repeated word in a given sentence
def sec_rep(String):
freq = {}
Sentence = String.split()
for a in Sentence:
if a in freq:
freq[a]+=1
else:
freq[a]=1
max=0
sec_max=0
word=0
sec_max=0
li=[]
for a i... |
ee3d1d44f91ea6582ec28114874e68a49187100f | itb-ie/step-by-step-gui | /sixth.py | 1,233 | 3.890625 | 4 | import sys
import tkinter as tk
from tkinter.ttk import *
from ttkthemes import ThemedTk
def get_text():
entered_text = et_text.get()
lb2.config(text=entered_text)
# create a window, make it prettier, add functionality
window = ThemedTk(screenName="This is a title", theme="radiance")
# with ttk we need ... |
cbb6f4f7886ea6283d223a4de56e7701efea18c5 | nchristina2001/School-Projects | /Quadratic.py | 650 | 4.0625 | 4 | import math
def qudeq(a, b, c):
d = b ** 2 - 4 * a * c
if d >= 0:
print("The equation has real solutions")
x_2 = (-b - math.sqrt(b ** 2 - 4 * a * c)) / (2 * a)
x_1 = (-b + math.sqrt(b ** 2 - 4 * a * c)) / (2 * a)
print("x_1 = ", x_1)
print("x_2 = ", x_2)
... |
ad74e86a636f68a32f3f55f62aed0a3ab76588e6 | kdyskin/AdventOfCode | /2020/11/seatsPart2.py | 4,356 | 3.515625 | 4 | def readInput():
text_file = open("input.txt", "r")
lines = text_file.readlines()
#start with 0 -> charging outlet
input = []
for line in lines:
row = []
for c in line.strip():
row.append(c)
input.append(row)
text_file.close()
return input
def changeSeat(... |
2249d5730e30d42ced6342065c1e1831a46e99dc | Sultansharav/08-31 | /Дасгалууд/d14.py | 895 | 4.09375 | 4 | # Өгөдсөн n тоо анхны /prime nubmer/ тоо мөн үү?
# анхны тоо гэж зөвхөн 1 болон өөртөө хуваагддаг эерэг тоог хэлнэ
'''
num = 11
# If given number is greater than 1
if num > 1:
# Iterate from 2 to n / 2
for i in range(2, num//2):
# If num is divisible by any number between
... |
3e179717f18781cc23993c9db7831dc982fe3628 | stickhog/non-programmers_tutorial_for_python_3 | /password1.py | 337 | 4.21875 | 4 | # asks for a name and a password
# checks them and determines if user is allowed in
name = input("Name?")
password = input("Password?")
if name == "Howard" and password == "douche123":
print("Welcome Howard")
elif name == "Spongebob" and password == "patrick":
print("Welcome Spongebob")
else:
print("I don'... |
2dd8bcd97c9fc5030214d933c55c38f49e2b0a35 | konjakuc/python | /python-basic/经典算法案例/杨辉三角/杨辉三角test.py | 519 | 3.515625 | 4 | def triangles1(n):
a=[1]
print(' '*(n-1)+"1")
while len(a)<=n-1:
ar = [0] + a + [0]
a = [ar[x-1] + ar[x] for x in range(1,len(ar))]
for j in range(n-len(a)):
print(" ",end="")
for i in a:
print("%-2d"%i,end=" ")
print()
triangles1(8)
print(... |
16e50eb7ceebc68c8fca010b9ed9558ed53968f4 | isaaq1235/multipage_streamlit | /data.py | 1,479 | 3.828125 | 4 | import streamlit as st
def app(car_data):
st.header("Car Price Dataset")
with st.expander("Car Price Data"):
st.dataframe(car_data)
st.subheader("Columns Description:")
if st.checkbox("Show summary"):
st.table(car_data.describe())
beta_col1, beta_col2, beta_co... |
e5e87b0ab8bfec3e9adcd0005af65f43bda3b8b3 | diningphills/eulerproject | /problems/01~09/4/dy.py | 476 | 3.5625 | 4 | def GetRadixList(n):
list = []
if n < 10: return [n]
else:
radix = n % 10
list = GetRadixList(n/10)
list.append(radix)
return list
def isPalindrome(list):
for i in range(0, len(list)/2):
if list[i] != list[-(i+1)]: return False
return True
biggestPalindrome = 0
for i in range(100, 1000):
for j in ra... |
8f2d0c8da7fd42d38a91ec095c1660de76acf975 | abditaresadabela/holbertonschool-higher_level_programming-1 | /0x07-python-test_driven_development/5-text_indentation.py | 1,128 | 4.46875 | 4 | #!/usr/bin/python3
"""
prints text in special format
"""
def text_indentation(text):
"""prints a text with 2 new lines after each of these characters: . ? :
Args:
text (str): a string
Raises:
TypeError: if text is not a string
"""
new = ""
substring = ""
temp = [] * 2
... |
3ee6b6c0ca91b80db5e04f64223a2c289c25385c | HonourZhan/python_train | /sort algorithm/bubble sort.py | 740 | 3.515625 | 4 | from time import perf_counter
def bubble_sort_op(sequence):
for i in range(len(sequence)-1,0,-1):
flag=True
for j in range(i):
if sequence[j]>sequence[j+1]:
sequence[j],sequence[j+1]=sequence[j+1],sequence[j]
flag=False
if flag==True:
break
return sequence
def bubble_sort(sequence):
for i in ran... |
663d3a58a3f2c11cd2c96af665014b3dd2b14158 | yzl232/code_training | /mianJing111111/Google/ugly_numbers_Design an algorithm to find the kth number such that the only prime factors are 3,5, and 7.py | 2,724 | 3.828125 | 4 | # encoding=utf-8
'''
Design an algorithm to find the kth number such that the only prime factors are 3,5, and 7
'''
#G家最近考过
class Solution: #思想简单。 就是每次比较3, 5, 7的倍数哪个最小。 然后每次更新pointer
def primeN(self, n): #用了3个pointer来记录
c3 = c5 = c7 = 0
ret = [1]
for i in range(n):
m = min(re... |
f27f0cd95d853c6a397104c8df1a00b53dc41ecc | stormshadowcr7/python-sample-for-jenkins | /pyeg.py | 65 | 3.5625 | 4 |
for i in range(1,6):
print ("The loop number is: " + str(i)) |
211789bddd83b39afb76eaed515e5b944c7b06bb | dieg0palma/IntroPython | /string.py | 1,172 | 4.375 | 4 | # -*- coding: utf-8 -*-
# Para concatenar strings, usa-se o sinal de + :
ladoA = "Diego";
ladoB = "José";
nome = ladoA + " " + ladoB + "\n";
# Através da operação len, é possível checar o tamanho de uma string:
contar = len(nome);
print (contar);
# Há a possibilidade de se exibir certa posição de um item ... |
5ea440dba1e6d2ffafb7d588904b1bebef35e826 | RohanPankaj/FibonacciSequence | /CraigReverseFib.py | 367 | 3.515625 | 4 | # Code by Craig (The best)
# Copyright © 2019, Craig A Kelley, All Rights Reserved
# Free for commercial use
# Story boarded by Sai
def fSeq(n):
a = 0
b = 1
i = 0
while not (a == n):
i += 1
ph = a
a = b
b = ph + b
if (a > n):
print("Error")
... |
293c8d665dacf4206e365d9539fda51ec19ad132 | sidduGIT/Hacker-Rank- | /numpy_maths.py | 2,687 | 4 | 4 | '''
Basic mathematical functions operate element-wise on arrays. They are available both as operator overloads and as functions in the NumPy module.
import numpy
a = numpy.array([1,2,3,4], float)
b = numpy.array([5,6,7,8], float)
print a + b #[ 6. 8. 10. 12.]
print numpy.add(a, b) ... |
c542dc69a1a65ebf0e25b06702add34ac69fa2ec | colinchambachan/GroceryMayhem | /main.py | 16,363 | 4.0625 | 4 | ##
# Grocery Collector game for CPT
#
# @author Colin Chambachan
# @course ICS3U
# @date June 8th, 2020
"""
Sample Python/Pygame Programs
Simpson College Computer Science
http://programarcadegames.com/
http://simpson.edu/computer-science/
Explanation video: http://youtu.be/4W2AqUetBi4
"""
import pygam... |
091ca401d76fb2a7b95edb4d85e5e03b302bb325 | aakashjha001/helloworld | /dictionary.py | 640 | 3.8125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Jan 10 22:05:57 2019
@author: Aakash Jha
"""
#attributes of a song with dictionary
dictionary={}
dictionary["Genre"]="Pop"
dictionary["Artist"]="Shawn Mendes"
dictionary["Year"]=2017
print(dictionary)
def fun(key,value):
if key in dictionary:
i... |
839ee05f1596027f2541940995707fec59e3892a | Dustin461/projects | /various/iap_5_iteration.py | 12,511 | 4.375 | 4 | #! /usr/bin/env python2
"Interactive Python Part 5: Iteration and Repetition"
import random
from lib import cImage as image
def wandering_turtle():
"""Modify the walking turtle program so that rather than a 90 degree left or
right turn the angle of the turn is determined randomly at each step.
Modify the... |
51d481305b8cb97611cb7a1a426f69337ee144e8 | Sathyasree-Sundaravel/sathya | /Program_to_print_all_the_permutations_of_the_string_in_a_separate_line.py | 256 | 3.9375 | 4 | #Program to print all the permutations of the string in a separate line
from itertools import permutations
a=list(input())
p= permutations(a)
L=[]
for i in list(p):
s=''
for j in i:
s+=j
if s not in L:
L.append(s)
print(s)
|
7d386fb87918811363f8852540f0a1ecd5602fca | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_199/3442.py | 1,069 | 3.53125 | 4 | import csv
count = 1
length = 0
data = []
with open('problem_1_input.txt', 'rb') as csvfile:
reader = csv.reader(csvfile, delimiter= ' ')
for row in reader:
if count == 1:
length = row[0]
else:
data.append(row)
count += 1
def flip(array, start_index, num_flip):
#print "array: ", array, ... |
22966d059bd2a8a436c8c65500b0136e36e3ace4 | davidadamojr/diary_of_programming_puzzles | /recursion_and_dynamic_programming/child_steps.py | 682 | 4.4375 | 4 | """
A child is running up a staircase with n steps, and can hope either 1 step,
2 steps, or 3 steps at a time. Implement a method to count how many possible
ways the child can run up the stairs.
"""
def count_ways(number_of_steps):
"""
The total number of ways of reaching the last step is therefore the
su... |
73be1dfa59ad0d9871cc35badbb68d12fb5fb1b5 | Milstein-Corp/exercises | /reorder-log-files/main.py | 1,267 | 3.5625 | 4 | # Definition for singly-linked list.
def exam(x):
a = x.split(" ")
identifier = a[0]
firstentry = a[1]
if firstentry.isdigit():
metric = tuple([True])
else:
# metric = (False, len(a)) + tuple(a[1:]) + tuple(identifier)
metric = (False, len(a), a[1:]) + tuple(identifier)
... |
abe1211d505721bce3bf37cd5633cf31097c56d7 | DarshanaPorwal07/Python-Programs | /%Calc.py | 532 | 4.03125 | 4 | total=int(input("enter the total marks:"))
sub1=int(input("enter the marks of 1st subject:"))
sub2=int(input("enter the marks of 2ns subject:"))
sub3=int(input("enter the marks of 3rd subject:"))
sub4=int(input("enter the marks of 4th subject:"))
sub5=int(input("enter the marks of 5th subject:"))
marks_obtained... |
02bf22a8b39ccd9e273780c22e32dfc7251031a4 | Susmit141/tusk | /pss.py | 536 | 3.8125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Jul 20 00:56:04 2019
@author: SUSHMIT
"""
def is_palindrome_v1(s):
""" (str) -> bool
Return True if and only if s is a palindrome.
>>> is_palindrome_v1('noon)
True
>>> is_palindrome_v1('dented')
False
"""
def reverse(s):
... |
4cdadd8f921a93b36e8e88a078ec5319d78c2ff4 | rodolphorosa/desafio-intelie | /schemaFacts.py | 7,765 | 3.75 | 4 | class SchemaFacts:
"""
This class provides the tools to visualize and manipulate facts and schema.
The constructor input comprises two lists of tuples: schema and facts.
"""
def __init__(self, schema, facts):
self.__schema = schema
self.__facts = facts
@staticmethod
def __re... |
0e1703d1b0dee1492b2626faffc82f691130a605 | anishLearnsToCode/python-workshop-7 | /day_1/complex_list.py | 249 | 3.9375 | 4 | a = [True, False, 10, 3.14, 'hello', [1, 4, 5, 6, 7, 100, -45], print, range(1, 10, 2)]
# print(a[5])
# numbers = a[5]
a[6]('hello', end='-----')
print()
b = print
b('this is also print', end=' hello there')
# for item in a[5]:
# print(item)
|
cffce6cbbdbe718964df1ac741fdda974f8f1fe7 | duoarc/basecamp_basic_tasks | /tech_trial/Task_3.py | 1,087 | 4.375 | 4 | #! /usr/bin/env python3
import Task_2
def list_primes(list_of_num):
"""
Returns a list of prime numbers
Parameters:
list_of_num (list): List of positive integers
Returns:
list_prime (list): List of prime numbers in list_of_num
"""
# Check if the list of int... |
f41651b02602482dbc0fdeded16b2eb3497a4640 | chukgu/Algorithm | /LeetCode/344_Reverse String.py | 323 | 3.78125 | 4 | class Solution:
def reverseString(self, s: list[str]) -> None:
"""
Do not return anything, modify s in-place instead.
"""
s.reverse()
print(s)
if __name__ == "__main__":
s = Solution()
s.reverseString(["h","e","l","l","o"])
s.reverseString(["H","a","n","n","a","h... |
ec1f8a73ab4bd037fa2b2a05b0f39079f5799e14 | MariaBet/EstudosPython | /aulas/Classe/Desafio/banco/conta.py | 488 | 4 | 4 | from abc import ABC, abstractmethod
class Conta(ABC):
def __init__(self, agencia, conta, saldo):
self.agencia = agencia
self.conta = conta
self.saldo = saldo
def depositar(self, valor):
self.saldo += valor
self.detalhes()
def detalhes(self):
print(f'Agênci... |
0abe64186ac98b3f7fc9c1542e085f41c7a07d92 | mcole22266/pythonTutorial | /Exercise02-Strings/strings.py | 2,138 | 4.3125 | 4 | #----------------------------------------------------------------------
#
# Problem 1
#
# In Robert McCloskey’s book Make Way for Ducklings, the names of the
# ducklings are Jack, Kack, Lack, Mack, Nack, Ouack, Pack, and
# Quack. This loop tries to output these names in order.
#
# prefixes = "JKLMNOPQ"
# suffix = "a... |
fc4c783cc026f19ce5f2e40c154c11d052d8e1ed | RyanUkule/Python_Demo | /01.py | 119 | 3.84375 | 4 | # -*- coding: UTF-8 -*-
# Python
num = input('请输入数字:')
if num == 1:
pass
else:
print('not equal to 1')
|
55c2f96a64984a2df8962f5dc65136172df188ef | Zufru/Blackjack__ | /project_2.py | 2,494 | 4 | 4 | import random
suits = ('Hearts', 'Diamonds', 'Clubs', 'Spades')
ranks = ['Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight',
'Nine', 'Ten', 'Jack', 'Queen', 'King', 'Ace']
values = {'Two': 2, 'Three': 3, 'Four': 4, 'Five': 5, 'Six': 6, 'Seven': 7, 'Eight': 8,
'Nine': 9, 'Ten': 10, 'Jack': 11, '... |
9072d786fa2326cd7995ac3dcd4cba060c96ba11 | Castaldo/US-Mortgage-Analysis | /Data/Pre_Processing.py | 804 | 3.515625 | 4 | import pandas as pd
Mortgage = pd.read_csv('Data/Unprocessed/hmda_2017_nationwide_all-records_labels.csv')
Mortgage = Mortgage[(Mortgage['loan_purpose_name'] == 'Refinancing')]
Mortgage = Mortgage[(Mortgage['action_taken'] <= 3)]
Mortgage.drop(Mortgage.columns[[0, 1, 2, 3, 5, 7, 9, 10, 11, 14, 15, 16, 18, 26, 28, 32... |
4c77444af8e976b71936c870895662e017499650 | bindingofisaac/projecteuler | /python/problem_15.py | 199 | 3.828125 | 4 | """
Lattice Paths
Number of paths from (0,0) to (a,b) -> (20, 20) = (a+b)!/(a!*b!)
"""
def fac(n):
ans = 1
for i in range(2, n+1): ans = ans*i
return ans
print (fac(40))/(fac(20)**2)
|
640fe33acec1444f949e67eb5c1b28a84212992e | InonCohen/Mtm | /ex3/gradesCalc.py | 4,941 | 4.09375 | 4 | #### PART 1 ####
# final_grade: Calculates the final grade for each student, and writes the output (while eliminating illegal
# rows from the input file) into the file in `output_path`. Returns the average of the grades.
# input_path: Path to the file that contains the input
# output_path: Path to the file that wil... |
5775ebf5a84658fc28aaba65a548a0db3e8a1ef5 | bettinson/programming-assignments | /235assignment1.py | 652 | 3.765625 | 4 | #Matt Bettinson
#10138240
def algorithmA(lis, target):
for x in lis:
if x == target:
return True
return False
def algorithmB(lis, target):
sortedLis = quickSort(lis)
def quickSort(lis):
less = []
equal = []
greater = []
size = len(lis)
if size > 1:
pi... |
fabfb3f5e9d6c7f2bc2368f84ce0b5773147b19b | enmalik/Spam-Filter | /src/filter.py | 3,392 | 3.9375 | 4 | """
filter.py has several functionalities: all, indie or range.
all: the filter returns a list of tuples containing the email id (email name)
as well as its classification (ham or spam) for all emails in the files/emails directory.
indie: the filter returns a list of tuples containing the email id (email name)
as w... |
7c5e2d0ad5d36eab2e5c8808738de7b5b5739c08 | chloeward00/CA117-Computer-Programming-2 | /labs/main_words_041.py | 827 | 3.703125 | 4 | import sys
import string
def builddictionary():
dictionary = {}
for line in sys.stdin:
thewords = line.lower().strip().split()
for aword in thewords:
aword = aword.strip(string.punctuation)
if aword == '':
continue
if aword not in dictionary:
... |
f7c332f14e479dadb8b3d758dfdf15d015fa3616 | zhouyzhao/Python_Test | /Python2_test/ex33.py | 261 | 4.0625 | 4 | # -*- coding: utf-8 -*-
# ex33.py
i = 0
number=10
numbers = []
while i < number:
print "At the top i is %d " % i
numbers.append(i)
i= i+1
print "Numbers now:", numbers
print "At the bottom i is %d" %i
print "The numbers:"
for num in numbers:
print num |
659287c9503355a52338d1ee40cb41113b69093f | antonio00/blue-vscode | /MODULO 01/AULA 11/rascunho.py | 593 | 3.515625 | 4 | galera = list()
dados = list()
totalMaior = TotalMenor = 0
for c in range(0,3):
# dados = list() pode ser usada assim tambem em substituicao do dados.clear
dados.append(str(input('Nome: ')))
dados.append(int(input('Idade: ')))
galera.append(dados[:])
dados.clear() # apos add dados em galera, limpa ... |
62932fbbe566ec8e8222ead01b97b5af654f9548 | gaurava45/PythonProjectRepo | /revision1.py | 1,377 | 3.5 | 4 | #print numbers 1 to n in one line
# [print(i, end = " ") for i in range(1, int(input("upto?:")) + 1)]
# print([i for i in range(1, int(input("upto?:")) + 1)])
print(r"C:\Users\harry\Desktop")
print("C:\\Users\\harry\\Desktop")
# Oh soldier Prettify my Folder
# path, dictionary file, format
# def soldier("C://... |
84153f583e7368b7fb3ea7f4cb2d359699d25b89 | Akbhobhiya/Algorithms-DSA | /lab0/prob4.py | 579 | 4.125 | 4 | n=int(input('Enter the size of Array:'))
list=[]
for i in range(n):
a=int(input())
list.append(a)
def bubble(list):
for i in range(n):
for j in range(n):
if list[j]>list[i]:
x=list[i]
list[i]=list[j]
list[j]=x
def selection(list):
for i in range(n):
p=list[i]
for j in range(n):
if list[j]>li... |
8e3b0c763f9508b0a82b412e02eac1cbe7adf0b2 | DmitryAristarhov/lesson_9 | /main.py | 1,330 | 3.546875 | 4 | # -*- coding: utf-8 -*-
import card_game_fool as fool
game=fool.Game()
print(game.hello()) # Приветствие - отобразит текст "Добро пожаловать в игру".
print(game.command_commands()) # Список команд.
print('Козырь: ', end='')
print(game.command_trump(), end='') # Козырь - отобразит последнюю карту колоды задающую коз... |
4846ab559e6fc65a635ad390608f89720ba88328 | fnov/learn_python3 | /specialist/homework/home7-07.py | 1,002 | 3.71875 | 4 | #!/usr/bin/python
#На вход подаётся целое число N - количество строк подаваемых на вход.
#Далее, подаются N строк из слов. Если слов в строке несколько, они разделяются пробелом.
#Для каждого слова напечатайте его количество. Список слов выведите по частоте.
#Пример ввода
#9
#hi
#hi
#what is your name
#my name is bond... |
fc1fd46b3af4c7221b1b09c3bc182674fb1d0069 | kevinislas2/Iprep | /python/heaps/wave.py | 1,796 | 3.546875 | 4 | class MinHeap(object):
def __init__(self):
self.heap = list()
def push(self, value):
self.heap.append(value)
self.heapify(len(self.heap)-1)
def heapify(self, i):
continueFlag = True
while (i > 0 and continueFlag):
if(self.heap[i] < self.heap[(i-... |
3aa6e99e7fe394d9cf26d1326c474daadca9c11e | diegun99/proyectos | /listas.py | 422 | 3.84375 | 4 | #lista vacia
lista_vacia = []
#lista con elementso
lista_numeros = [1,3,5]
#imprimir listas
print(lista_vacia)
print(lista_numeros)
print(lista_numeros[0])
#solicitaremos una posicion
#probando try catch except
try:
print(lista_numeros[10])
except IndexError as err:
print("ha ocurrido un error", err)
... |
48af51eecf446f14e5d145e4882877d9ca9c245d | AniketCS10/first_git_project | /cube_list.py | 554 | 3.796875 | 4 | # n = int(input("Enter the number of elements for list:"))
# a = []
# b = []
# sum = 0
# for i in range(1, n + 1):
# el = int(input("Enter element:"))
# a.append(el)
# sum = el * el * el
# b.append(sum)
# print("list elements",a)
# print("cube of list elements",b)
# faulty program
# nums = [1, 2, 5, 1... |
c896d12a9fdfc9849cfb5dae02e5cda16f5030a3 | TD0401/pythonsamples | /src/io/myacademy/pythontut/66.py | 354 | 4.03125 | 4 | #Create an English to Portuguese translation program.
#The program takes a word from the user as input and translates it using the following dictionary as a vocabulary source.
d = dict(weather = "clima", earth = "terra", rain = "chuva")
#Expected Result
#Enter word: earth
#terra
#Sol
i = input("Enter word: ")
i.st... |
77d457edeb1e34616469ced4b682d9fe5d196506 | BlancaRiveraCampos/Project_Euler | /Pb02_fibonacci.py | 266 | 3.515625 | 4 | #Find the sum of the even numbers in the Fibonacci sequence between 1 and 4M.
fib_list = [1, 2]
def fib(list_f, i):
x = 0
y = 2
while x < i:
x = list_f[-1] + list_f[-2]
if x % 2 == 0:
y = y + x
list_f.append(x)
return y
print(fib(fib_list,4000000))
|
2e36be4d4eee398f8a6939ef6c2ec2713420b6e2 | akurilov92/coding-test-django | /letter_digit/api/letter_case_permutation.py | 1,719 | 4.28125 | 4 | import itertools
from typing import List, Tuple
def generate_upper_lower_pairs(input_string: str) -> List[Tuple[str, str]]:
"""
Given an input string ("ab"), return a list of pairs of the form (c.lower(), c.upper()) for every c in input_string.
"""
return [
(c.lower(), c.upper()) if c.isalpha(... |
2eceb382c507eef37b05df29d944ba68fe62a802 | sanchitkalra/Classes | /more_on_loops/assignment_number_pyramid.py | 588 | 3.625 | 4 | size = int(input())
for k in range(1, size):
flag = False
x = 0
for j in range(k-1, 0, -1):
if j == size-1:
continue
print(" ", end = "")
for j in range(k, size+1):
if j == k == size:
flag = True
continue
print(j, end = "")
x =... |
0017cd9d7f3f3d8706cfef26cc17d4c16146f4f2 | Alan3058/python-study | /src/cypher/randomPassword.py | 624 | 3.65625 | 4 | '''
Created on 2017年8月16日
随机密码生产
@author: liliangang
'''
import random
class RandomPassword:
def __init__(self, length=8):
self.factor = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ~!@#$%^&*()_+=-'
self.length = length
def next(self, length=0):
length = length if leng... |
645b9db944025a7cb9a81505b184ba6503119c84 | ajrichards/notebook | /archive/python/working_with_generators.py | 287 | 3.53125 | 4 |
import numpy as np
from itertools import islice
x = np.arange(0,100)
def split_every(n, iterable):
i = iter(iterable)
piece = list(islice(i, n))
while piece:
yield piece
piece = list(islice(i, n))
for chunk in split_every(5, x):
print(chunk)
|
27c5e988090e247bb8ccab8b4bb859cb75855bf2 | rewingchow1/LeetCode | /Python/TwoSum.py | 454 | 3.53125 | 4 | def twoSum(nums, target):
for i in range(0, len(nums), 1):
sum = None
if nums[i] < target:
for j in range(0, len(nums), 1):
if nums[j] < target:
sum = nums[i] + nums[j]
if sum == target:
break
... |
3664e6a814dd950adc45a67115493c49a80ff456 | RavinderSinghPB/data-structure-and-algorithm | /bst/Print leaf nodes from preorder traversal of BST.py | 814 | 3.671875 | 4 | def leafNodePre(bst,size):
leaves = []
nodes = [bst[0]]
for pos in range(1, size - 1):
if bst[pos] > bst[pos + 1]:
nodes.append(bst[pos])
else:
found = False
while len(nodes) and nodes[-1] < bst[pos]:
found = True
nodes.pop... |
1b8350375ce5463bdaa3001f2645e6c1aca14f05 | santoshsr19/Python-DS | /Array/arraysort.py | 1,257 | 4.125 | 4 | def sort012(arr,n):
return arr.sort()
#{
# Driver Code Starts
#Initial Template for Python 3
if __name__ == '__main__':
t=int(input())
for _ in range(t):
n=int(input())
arr=[int(x) for x in input().strip().split()]
sort012(arr,n)
for i in arr:
print(i, end=' ... |
7da1605bb366ed1284afc1558d16319d26fe7f9f | lefty06/pgm06 | /python_code/argparse/argsparse_tutorial.py | 8,934 | 3.921875 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
#to avoid error: syntaxError: Non-ASCII character '\xc2' in file
import argparse
'''
parser.add_argument('-s','--serie',help='Store a simple value',required=True)
By default all argument are optional except if you mention required=True
-s or --serie can be used and must be fo... |
4ea266d4f4c18efbba4204d7301652f8966c18a5 | Kegs30/sheepwolves.github.io | /Development/Animation/Animation.py | 3,262 | 3.671875 | 4 | # -*- coding: utf-8 -*-
"""
Animation practical output
The code that follows builds on the "Communications.py" file
Additional code that follows has in part been modified from that of
https://www.geog.leeds.ac.uk/courses/computing/practicals/python/agent-framework/part8/index.html
https://www.geog.leeds.ac.uk/courses... |
4422c0f11178dc73a539b8a153b0241e7a7b43bd | bruteforce1/cryptopals | /set2/ch09/implement_pkcs7.py | 1,612 | 4.3125 | 4 | #!/usr/bin/python3
"""
A block cipher transforms a fixed-sized block (usually 8 or 16 bytes)
of plaintext into ciphertext. But we almost never want to transform a
single block; we encrypt irregularly-sized messages.
One way we account for irregularly-sized messages is by padding,
creating a plaintext that is an e... |
34f32303fb4e85ef516b860de53ef3eb347ec8f7 | gsbhardwaj27/datastructure-algorithms-related-problems-python | /coursera_algorithms_part2/week1/hamiltonian_path_DAG.py | 1,943 | 3.625 | 4 | # Digraph: Design a linear-time algorithm to determine whether a
# digraph has a vertex that is reachable from every other vertex,
# and if so, find one.
import unittest
from digraph import DiGraph
class HamiltonPathDag:
def __init__(self, g):
self.g = g
self.done = [False]*self.g.V
self... |
fa95eda673239625f2e3cde410cfe1d28f8549c5 | minus-plus/ocr_project | /classification/testInvert.py | 544 | 4.28125 | 4 |
def arrayInvert(array):
"""
Inverts a matrix stored as a list of lists.
"""
result = [[] for i in array]
for outer in array:
for inner in range(len(outer)):
result[inner].append(outer[inner])
return result
def testInvert():
count = 1
l = []
for i in range(0,3):
... |
1fa65db1a79db44510a476e0e030636df2602e93 | carv-silva/cursoemvideo-python | /Mundo01/exercsMundo01/ex031.py | 521 | 3.984375 | 4 | ''' Faca um programa que pergunte a distancia de uma viagem em km.Calcule o preco da passagem cobrando R$0.50
por km para viagens de ate 200km e R$0.45 para viajens mais longas'''
dist = float(input('Entre com a distancia da viagem em Km: '))
'''if dist <= 200:
t = dist * 0.50
print(f'O preco total é: R${t:.... |
d2f3ca9424cdbf042c68c0b08a085ee90abd366a | Dioclesiano/Estudos_sobre_Python | /Exercícios/ex080 - Organizando Lista.py | 2,586 | 4.3125 | 4 | '''
Crie um programa onde o usuário possa digitar cinco valores numéricos e cadastre-os em uma lista,
já na posição correta de inserção (sem usar o sort()). No final, mostre a lista ordenada na tela.
lista = []
for c in range(0,5):
n = int(input('Digite um valor » '))
if c == 0:
lista.append(n) # C ... |
dece306105ff7939c9dea206d64f92fc2f86f8b7 | msingh55-asu/madhaterz | /user_int.py | 1,410 | 3.671875 | 4 | from subprocess import call
import os
print("Hello, How are you? Let us make Cloud Computing great again! ")
return_typ = input("Please enter return type expected ")
func_name = input("Please enter the file name ")
fobj = open(func_name, 'w')
fobj.write("import sys\n")
fobj.write("print( \'Number of arguments:\', len... |
e0bb0c48cf5be2359ea5c0f79e05bc635b700783 | Ayur12/python_basic | /Home_works/les_1/task_3.py | 204 | 3.671875 | 4 | user_number = input('Введите число: ')
user_number_2 = user_number + user_number
user_number_3 = user_number_2 + user_number
print(int(user_number) + int(user_number_2) + int(user_number_3))
|
52b1f389ca074c96f513dc7556f0542799a80341 | JoshuaBelden/hacking-ciphers | /transpositionDecrypt.py | 624 | 3.53125 | 4 | import math
def main():
message = 'Cenoonommstmme oo snnio. s s c'
key = 8
plain_text = decryptMessage(key, message)
print(plain_text + '|')
def decryptMessage(key, message):
ncols = math.ceil(len(message) / key)
nrows = key
shades = (ncols * nrows) - len(message)
plain_text = [''] * n... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.