blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
fb031e5fd8d06533bce87f74e7bccd07998faa05 | kunglaw/python-learning | /1.basic/looping-condition.py | 361 | 3.734375 | 4 | import datetime
def print_time():
print("Task Complete")
print(datetime.datetime.now())
print("")
people = ["Aries", "Dimas", "Yudhistira"]
index = 0
# while index < 10:
# print("index => ", index)
# index += 1
i = len(people)-1 # 3
# print(i)
while i >= 0:
# print(" i => ", i)
prin... |
f0d5c51d9850f5a80a138933caf0f9881e3270a9 | mwolffe/my-isc-work | /advanced_python/read_weather.py | 644 | 3.5 | 4 | import netCDF4
import numpy as np
def read_header(file):
"""Reads the header of a simple CSV file and returns header as a dictionary"""
with open(file) as file:
Header = {}
i = 0
while i < 3:
line = file.readline() #reads a line of the file
line = line.str... |
51fdde699f82a369c78cd25ef37fe8a12e360570 | mwolffe/my-isc-work | /python/word_loop.py | 245 | 3.890625 | 4 | s = "I love to write python"
#split string s into list of words
split_s = s.split()
print(split_s)
for word in split_s:
if word.lower().find("i") > -1:
print("I found I in " + word)
else:
print("No i's were found :(")
|
a8eb89aa12734ea4262c9f616119f4a7b6e34695 | dandani-cs/classic_cs_problems | /2_search_problems/2_1_dna_search/listing2-1.py | 829 | 4 | 4 | """
Searching for DNA nucleotides
"""
from enum import IntEnum
from typing import Tuple, List
Nucleotide = IntEnum("Nucleotide", ("A", "C", "G", "T"))
# Codon = Tuple[Nucleotide, Nucleotide, Nucleotide]
# Gene = List [Codon]
def str_to_gene(s):
gene = []
for i in range(0, len(s), 3):
if (i + 2) >= len(s):
... |
2c4ae47ef936b50d710eff9b0699f67b9b5ab7e6 | dandani-cs/classic_cs_problems | /1_small_problems/1_2_trivial_compressions/listing10.py | 1,440 | 3.5625 | 4 | """
Compressing data with self created class
Using genetic coding as example
"""
class CompressedGene:
def __init__(self, original):
self._compress(original)
def _compress(self, original):
self.bit_string = 1
for nucleotide in original.upper():
self.bit_string <<= 2
if nucleotide == "A":
self.bit... |
b90d03d85c582d0b3b3f63b432e61293adf09123 | TomaszMichalski/python-course | /Projekt/main.py | 17,781 | 3.859375 | 4 | import re
binary_operators = "|&^>="
unary_operators = "!"
#Get distinct list of variable names in expression
def parse_var_names(e):
result = re.findall(r'[a-zA-Z_]\w*', e) #variable may contain alphanumeric characters, but must start with a letter or underscore
return list(set(result))
#Get expression side... |
447015eed5717f79dcfa2ef3cd529fb38ed27a29 | OlivierPaulo/PW-DSBC | /Automate The Boring Stuff/section10/regex2.py | 194 | 3.796875 | 4 | import re
phoneNumRegex =re.compile(r'\(\d\d\d\)-\d\d\d-\d\d\d\d')
mo = phoneNumRegex.search('My number is 425-555-9090')
print(f"{mo.group()}")
print(f"{mo.group(1)}")
print(f"{mo.group(2)}")
|
064bff92e094fe20a6d8743ceddb967496ce1ef7 | lyreal666/pythonNotes | /bims/_itertools.py | 1,754 | 3.578125 | 4 | #!/usr/bin/env python3
# -*- coding:utf-8 -*-
import itertools
__author__ = 'Ly'
'''-----------------无限迭代器----------------------'''
iter0 = itertools.count(1)
# for i in iter0:
# print(i)
iter1 = itertools.cycle('abc')
# for i in iter1:
# print(i)
iter2 = itertools.repeat('abc')
'''---... |
db1b81c80cb1ba29f74a3de015782494b7ffa7fe | fabriciomatos1/Desafios-Python | /desafio15.py | 1,962 | 3.734375 | 4 | #Desafio 15
def criarlinha():
print("~"*30)
ctn=''
while ctn != 0:
nome=str(input("Digite o seu nome: "))
precos=[]
for i in range(0,1):
valor,valor1,valor2=["A ="],["B ="],["C ="]
for j in range(0,1):
valor.append("R$ 2.98"),valor1.append("R$ 3.90"),valor2.... |
e0f65e364ad46d2af2ad4924c7bb941aa047f094 | fp-computer-programming/cycle-5-labs-p22jdiao | /lab_6-1.py | 138 | 3.703125 | 4 | # Author: JD 10/29/2021
string = "flibbertigibbet"
a = string.find("t")
print(a)
b = "I wish, I wish, I was a fish.".split()
print(b) |
624a48196690bc918be9df6a40871aaa038ce5f4 | KiViSoft/AdventOfCode2018 | /day5/day5.py | 940 | 3.796875 | 4 | POLYMER = []
# part 1
def is_opposite(left, right):
return abs(ord(left) - ord(right)) == 32
def add_char_to_polymer(character):
global POLYMER
if len(POLYMER) != 0 and is_opposite(character, POLYMER[-1]):
POLYMER = POLYMER[:-1]
else:
POLYMER.append(character)
with open('input.txt... |
8af147c476f3646a9ed8193390efda20b07e588f | AhmedElatreby/guessing-game | /test.py | 603 | 3.796875 | 4 | import random
from words import words
def Game():
guess = words [random.randint(0, 4)]
prompt = input("please select either please, apple, orange, pear, tree : ")
if prompt == guess :
result = "Well done \"{}\" is the right answer.".format(guess)
print (result)
else :
print(... |
8b3560b0d118c9042b4e244a6f8e4b87759a9b51 | caitlinkimbrell/datamining | /HW_04_Baik_Kimbrell/HW_04_Baik_Kimbrell_Program.py | 3,039 | 3.640625 | 4 | import BirdBathFunction_424_v420 as bb424
import BirdBathFunction_431_v420 as bb431
def helper(func):
"""
Using three different increments, find how much tilt, roll, and twist of the birdbath
yields maximum water-holding ability.
:param func: an unknown convex function of birdbath
"""
curr_bes... |
f8243b8857fe6b94cea91162fe06728d31c40935 | digitalmachines/cs-module-project-hash-tables | /hashtable/hash_table_2.py | 1,193 | 3.703125 | 4 |
def my_hash(s):
string_bytes = s.encode()
total = 0
for b in string_bytes:
total += b
return total
# choose some big random number, usually prime
# loop over the bytes of our string, and do something weird
# return the weird result
# "something weird" mean with the bits, which you'll... |
fbe42529f15c1e478b63c5103e1990dc4e7d164c | popcorn9499/counterTools | /counterDown.py | 718 | 3.828125 | 4 | import json
fileName = "test.txt"
def fileSave(fileName,config):
print("Saving")
f = open(fileName, 'w') #opens the file your saving to with write permissions
f.write(config) #writes the string to a file
f.close() #closes the file io
def fileLoad(fileName):#loads files
print(open(fileName, 'r').r... |
27946aef5e266cc45b25b2e1b965ec09c6ab1a75 | robertvandeneynde/parascolaire | /progra_fichier.py | 1,102 | 4.0625 | 4 | #!coding: utf-8
## ÉCRIRE
# L'ouvrir en mode "écriture" (w = write)
# si le fichier n'existe pas, il sera crée
# si le fichier existe, il sera vidé
f = open('hello.txt', 'w')
# écrire une str (chaîne de caractère)
f.write("Salut")
# pour passer à la ligne, écrivez le caractère ascii 13 : passer à la lig... |
d6c23e07dc4f951250ca6b1dfd7895711e66e151 | phlaf39/sudoku-first-projet | /Facile.py | 2,272 | 3.625 | 4 | from Grille import afficherGrille
from Carre import sudokuGrilleFacile
from Carre import sudokuGrillefini
def partieFacile():
inputLigne = 0
inputColone = 0
inputNumero = 0
print('Voici la grille de la partie facile ! commencons...')
etatDePartie = True
while etatDePartie is True:
gril... |
613733e929e3b2ab6191239ebe585795ea75473c | osbetel/LeetCode | /gf2-1.py | 1,377 | 3.71875 | 4 |
def answer(s):
# input string will be like s = ">------<"
# output = 2. So imagine every tick, the arrows move in the direction they're facing by one space
# if two arrows cross, they'll salute. Each arrow salutes once, so one pair of crossing arrows
# salutes twice. Thus we can determine a solution b... |
0005ca1355ce8924e77501961c15c060bdb29ce7 | osbetel/LeetCode | /problems/lc345 - Reverse Vowels of a String.py | 603 | 4.34375 | 4 | # Write a function that takes a string as input and reverse only the vowels of a string.
#
# Example 1:
#
# Input: "hello"
# Output: "holle"
# Example 2:
#
# Input: "leetcode"
# Output: "leotcede"
# Note:
# The vowels does not include the letter "y".
def reverseVowels(s):
vowels = ["a","e","i","o","u","A","E","I",... |
dbe93214e55249a7cc3a365f96d8e47ef7143116 | osbetel/LeetCode | /problems/lc389 - Find the Difference.py | 621 | 4.03125 | 4 | # Given two strings s and t which consist of only lowercase letters.
#
# String t is generated by random shuffling string s and then add one more letter at a random position.
#
# Find the letter that was added in t.
#
# Example:
# Input:
# s = "abcd"
# t = "abcde"
# Output:
# e
# Explanation:
# 'e' is the letter that w... |
6a6800d61094f2a28459cc50b784586c1dd19153 | osbetel/LeetCode | /problems/lc189 - Rotate Array.py | 252 | 3.90625 | 4 |
def rotate(A: [int], k):
# reversing array technique?
A = list(reversed(A))
A[:k] = list(reversed(A[:k]))
A[k:] = list(reversed(A[k:]))
return A
a = [1,2,3,4,5,6,7]
print(rotate(a, 4))
# end goal of [4,5,6,7,1,2,3]
|
bbc1709f2b77227b5e4b7ea549c5a50d2d5ff5ca | osbetel/LeetCode | /problems/lc66 - Plus One.py | 856 | 3.953125 | 4 | # Given a non-empty array of digits representing a
# non-negative integer, plus one to the integer.
#
# The digits are stored such that the most significant
# digit is at the head of the list, and each element in
# the array contain a single digit.
#
# You may assume the integer does not contain any leading
# zero, exc... |
381c475732a13da69b2c9308c9e84ac69c094ad8 | osbetel/LeetCode | /problems/lc303 - Range Sum Query (immutable).py | 821 | 3.71875 | 4 | # Given an integer array nums, find the sum of the
# elements between indices i and j (i ≤ j), inclusive.
# Example:
# Given nums = [-2, 0, 3, -5, 2, -1]
# sumRange(0, 2) -> 1
# sumRange(2, 5) -> -1
# sumRange(0, 5) -> -3
# Note:
# You may assume that the array does not change.
# There are many calls to sumRange funct... |
e3f5d9916e7a7cb4f8e30bb1ecf903e752debc38 | osbetel/LeetCode | /problems/dynamic_programming.py | 520 | 3.6875 | 4 |
def fib(n):
if n == 0:
return 0
elif n == 1:
return 1
else:
return fib(n-1) + fib(n-2)
def fib_dp(n):
if n == 0:
return 0
elif n == 1:
return 1
a, b = 0, 1
c = a + b
for i in range(2, n + 1):
c = a + b
a = b
b = c
... |
1763ef1b66f82c83795c3c8f35d5b30777ddf496 | osbetel/LeetCode | /problems/lc494 - Target Sum.py | 930 | 4.5 | 4 | # You are given an integer array nums and an integer target.
#
# You want to build an expression out of nums by adding one of the symbols '+' and '-' before each integer in nums and then concatenate all the integers.
#
# For example, if nums = [2, 1], you can add a '+' before 2 and a '-' before 1 and concatenate them t... |
0731f76dadf25d88177fd39874ac0aa78975965b | ivanmorenopy/Python-Mega-Course-Udemy | /Seccion 6 - Merging Text Files Sample-Files/Merge Files.py | 335 | 3.625 | 4 | import glob2
def getFileList(fileNameFilter=""):
return glob2.glob(fileNameFilter)
def main():
fileNames = getFileList("*.txt")
with open("merge.txt","w") as newFile:
for fileName in fileNames:
with open(fileName,"r") as fileToMerge:
print "Writing: " + fileName
newFile.write(fileToMerge.read() + "\n... |
d47f9941a76d17d5956e723531edacee00ca1a16 | muzamel79/programming_languages | /python/unit_testing/sut/hello_reader.py | 339 | 3.5 | 4 | class HelloReader:
def __init__(self, path: str) -> None:
self.input_file = path
def reading_hello(self) -> str:
with open(self.input_file, 'r') as f:
content = f.read()
if content.strip() == 'HELLO':
return 'HELLO'
else:
retur... |
815302acb49fab942b68c734b3cf967b489918eb | Tyresius92/exercism | /python/difference-of-squares/difference_of_squares.py | 399 | 3.796875 | 4 | def square_of_sum(count):
the_sum = 0
for i in range(count + 1):
the_sum = the_sum + i
return the_sum * the_sum
def sum_of_squares(count):
the_sum = 0
for i in range(count + 1):
the_sum = the_sum + (i**2)
return the_sum
def difference(count):
sum_of_sq = sum_of_squares(... |
b68914dbc51c003c82a5c86a083f4c9aebdd8bfd | Tyresius92/exercism | /python/twelve-days/twelve_days.py | 1,171 | 3.625 | 4 | LINES = {1: "a Partridge in a Pear Tree.",
2: "two Turtle Doves, ",
3: "three French Hens, ",
4: "four Calling Birds, ",
5: "five Gold Rings, ",
6: "six Geese-a-Laying, ",
7: "seven Swans-a-Swimming, ",
8: "eight Maids-a-Milking, ",
9: "nine Ladie... |
03fc7408b1098c6e322ce35deee021a58d7786ae | Tyresius92/exercism | /python/triangle/triangle.py | 605 | 3.96875 | 4 | def is_valid_triangle(sides):
for i in sides:
if i <= 0 or i > sum(sides) - i:
return False
return True
def is_equilateral(sides):
return is_valid_triangle(sides) and sides[0] == sides[1] == sides[2]
def is_isosceles(sides):
sides.sort() # if isosceles, gives us [a,b,b] or [a,a,b... |
eb7b468adbfbd48723f642c0179661533fc11c93 | shakesun/leetcode | /HOT100/longestPalindrome.py | 2,465 | 3.9375 | 4 | """
题目:给定一个字符串 s,找到 s 中最长的回文子串。你可以假设 s 的最大长度为 1000。
"""
import time
class Solution(object):
# def longestPalindrome(self, s):
# """
# 时间复杂度为O(n3),比较垃圾
# :type s: str
# :rtype: str
# """
# longest = ''
# longest_len = 0
# for cnt in range(len(s)):
... |
e92fd692c08bb4a524a85b5317a766d753755d6c | shakesun/leetcode | /HOT100/maxDepthAfterSplit.py | 1,840 | 3.625 | 4 | """
给你一个「有效括号字符串」 seq,请你将其分成两个不相交的有效括号字符串,A 和 B,并使这两个字符串的深度最小。
"""
class Solution(object):
# def maxDepthAfterSplit(self, seq):
# """
# :type seq: str
# :rtype: List[int]
# """
# dq = []
# depths = [-1]*len(seq)
# max_depths = 0
# for i, _ in enumerate... |
d690d9bf0d519aa1417668828223d8db53c74855 | winngo88/python_basic | /lambda_#12/lambda_type.py | 1,986 | 4.21875 | 4 | '''
Hàm Ẩn Danh - Lambda trong python
'''
# Lambda function is a small (one line) anonymous function
# that is defined without a name
# Example: a lambda function that adds 69 to the input argument
# lambda_test_func = lambda so: so + 69 # 1 dòng
# print(lambda_test_func(1))
# # hàm tương đương
# def lambda_test_func... |
67e66e933bae54e534c5cd0d0e25cb5d64444bd7 | winngo88/python_basic | /dictionary_#8/dictionary_type.py | 3,762 | 3.703125 | 4 | '''
Topic 8 - Dictionary: một tập hợp key-value không có thứ tự, có thể thay đổi và lập chỉ mục
Dictionary được khởi tạo với các dấu ngoặc nhọn {} và chúng có các khoá và giá trị (key-value).
Mỗi cặp key-value được xem như là một item. Key mà đã truyền cho item đó phải là duy nhất,
trong khi đó value có thể là bất kỳ k... |
a0dc71278fe3fbe849a61a39df93ade444e014a5 | DavidDzgoev/Yandex_trial_tasks_by_algorithms | /B/B.py | 790 | 3.65625 | 4 | class Stack:
def __init__(self):
self.items = []
def isEmpty(self):
return self.items == []
def push(self, item):
self.items.append(item)
def pop(self):
return self.items.pop()
def peek(self):
return self.items[len(self.items) - 1]
def size(self):
... |
b449a16006d10d94a8414f7e63e16767c813f76b | nrhint/PythonHTML | /test2.1/CssMaker.py | 1,031 | 3.765625 | 4 | ##This will create a CSS sheet.
def create(filename):
print("STARTING CssMaker.py...")
run = True
print()
print()
##Open the CSS file for edditing or createing.
inp = input("What sheet name will this have: ")
CssFile = open("style"+str(inp)+".css", 'x')
##Create basic outline... |
0fa51a2526e1a382eb338bda458c7247f6139299 | FranciscoAlveJr/Game-em-Python | /models/calcular.py | 3,649 | 3.796875 | 4 | from random import randint
class Calcular:
def __init__(self, dificuldade: int, /) -> None:
self.__dificuldade: int = dificuldade
self.__valor1: int = self._gerar_valor
self.__valor2: int = self._gerar_valor
self.__operacao: int = self._gerar_operacao # 1 = somar, 2 = diminuir, 3 ... |
d395ee62d8eac789a3d90767482a14f6a0937c83 | Eveey-Connolly/CP1404_Pracs | /prac_03/check_password.py | 443 | 4.1875 | 4 | MINIMUM_LENGTH = 3
def main():
password = input("Enter Password:")
get_password(MINIMUM_LENGTH, password)
asterisk_printer(password)
def get_password(min_length, password):
while len(password) < min_length:
print("Invalid Password Length")
password = input("Enter Password:")
r... |
6cfe6940df0eca5b1a62154115c3e3458e50a5f0 | JonatasLemos/SnakeGamePython | /apple.py | 919 | 3.546875 | 4 | import pygame
import random
class Apple:
def __init__(self, parent_screen):
self.parent_screen = parent_screen
self.image = pygame.image.load("apple.jpg").convert()
self.x = 280
self.y = 280
def draw(self):
self.parent_screen.blit(self.image, (self.x, self.y))
py... |
f10486f3a0611dc98039b69ce8ffea1634478b4a | mitamit/OW_Curso_Python | /listas.py | 551 | 3.9375 | 4 | my_list = ["strings", 5, 5.5, True]
my_list.append(6) #añade al final
my_list.insert(1, "CUALQUIER COSA") #añade en la posicion que queremos
my_list.remove(5) #qué queremos borrar
my_list.pop() #borra el ultimo valor del array
print(my_list)
my_integer_list = [1,3,5,90, 10, 23, 56]
my_integer_list.sort() #ordena ascen... |
083a708c81a7593ac94acae2544305f241d89cc4 | mitamit/OW_Curso_Python | /properties.py | 783 | 3.765625 | 4 | class Usuario:
def __init__(self, username, password, email):
self.username = username
self.__password = self.__generar_password(password) #atributo privado, las instancias no pueden acceder
self.email = email
def __generar_password(self, password):
return password.upper()
... |
1ad74cdc097011595070bae2a578f48e3c5a1b11 | kasrafallah/python_course | /exe1/Assigment-1-1.py | 140 | 3.6875 | 4 | a = eval(input('Entee a: '))
b = eval(input('Entee b: '))
c = eval(input('Entee c: '))
print(((a+b) > c and (b+c) > a and (a+c) > b))
|
d6a6762c1bbaea307183d2b379152d03e3bb71af | kasrafallah/python_course | /exe2/assignment-2-4.py | 276 | 3.59375 | 4 | num1 = eval(input())
num2 = eval(input())
bmm=1
if num1>1 and num2>1:
if num1>num2:
n= num2
else:
n =num1
for i in range(1,n+1):
if num2%i==0 and num1%i==0:
bmm =i
print(num2*num1/bmm)
else:
print('error')
|
67744fe2db390be6ff7a18a2707a7369a98191ef | JamesAC42/AlgCalc | /simple.pyw | 5,132 | 3.65625 | 4 | #! python3
from tkinter import *
import math
class Calc:
def __init__(self,master):
#checkers
self.multidigit = False
self.space = 0
self.operand_one = None
self.current_operator = None
self.operand_two = None
self.decimal = False
#display
self.result_string = ""
#frames
self.display_frame =... |
acfa3a40e958fe8011aff6b098daf481c7d54105 | superhman/New1 | /Mangat_Assignment_2.1_DSC510.py | 490 | 4.15625 | 4 |
#DSC 510
#Assignment 2.1
#date: 03/17/2020
#name: Harsimar Mangat
#Description: Program that asks for Company Name, Fiber Length and then prints out receipt detailing Cost, Company Name, & Fiber Optic Lenght
cost=.87
print("Welcome to Assignment #2")
name = input("What is your company name?\n")
fiber=float(inpu... |
864e9e390551165d322aa4303963dce2acca8a3d | marteczkah/BAM_coding_resources | /August_18th_Advanced/dog.py | 889 | 4.125 | 4 | # parent class
class Dog:
sound = 'woof woof'
def __init__(self, __name, age):
self.__name = __name
self.age = age
def description(self):
print('{} is {} years old.'.format(self.__name, self.age))
def get_name(self):
return self.__name
def get_size(self): #... |
6dfc39bf7b21e167b5c9566c43060553e9b80f38 | marteczkah/BAM_coding_resources | /August_3rd_Advanced/Homework/homework_august_3rd.py | 722 | 3.875 | 4 | # HOMEWORK by August 4th
# Try to solve those 2 exercises by the class tomorrow.
# We will go over the solutions at the beginning of the class.
# Exercise #1
# Write a function that checks whether inputted string is a palindrome.
# If palindrome return TRUE, else FALSE.
# A string is a palindrome when it reads the sa... |
a1b5a4f7532e1af8162bd2f710d93e7acdbb2a57 | marteczkah/BAM_coding_resources | /August_3rd_Advanced/Homework/homework_solution.py | 1,946 | 4.375 | 4 | # HOMEWORK by August 4th
# Try to solve those 2 exercises by the class tomorrow.
# We will go over the solutions at the beginning of the class.
# Exercise #1 - Solution
# Write a function that checks whether inputted string is a palindrome.
# If palindrome return TRUE, else FALSE.
# A string is a palindrome when it r... |
47e14e6e86572a6a0837ab020cbbd152775116e3 | louisgb/Qnabot | /gbNN.py | 7,917 | 3.828125 | 4 |
import numpy as np
from scipy import optimize as scipy_optimize
import nn_aux as aux
class gbNN(object):
"""A feedforward neural network class.
Currently only one hidden layer.
Translated from MATLAB/Octave from
Ng's Machine Learning in Coursera with my codes filled in.
"""
def __init__... |
82e23c22c9a6a3891babe1ebfab76be8d43f5af6 | 00LiRika00/IPT-2020-FE81 | /lab8.py | 1,658 | 4.03125 | 4 | from math import isinf,isnan
import numpy as np
import matplotlib.pyplot as plt
def func (x):
try:
return 1/(3*pow(x,2)+2*x+1)
except ZeroDivisionError:
print("Error; divided by zero")
def coef():
while 1:
try:
max=int(input("Enter max point of graph: "))
... |
55451cf773d1871c395ff8b4aa17c32c09b301af | NWanjiru/day_3_bootcamp | /word_count_lab/word_counts.py | 240 | 3.859375 | 4 | from collections import Counter
def words(word):
""" Check the number of times an element appears in a word"""
new_list = []
for i in word.split():
new_list.append(i)
return Counter(new_list)
|
10ab91f48212bbb6a3b2c0f87ff22a8be9cd05dc | YasPHP/recursion | /hanoi_tower.py | 670 | 4 | 4 | """
The Tower of Hanoi problem!
"""
# Contains 3 rods and a number of disks
# Main goal: To move all disks to the last rod from the 1st
# With a precursor of rules outlined in the hanoi problem
def move(f, t):
"""
>>> move(1, 2)
'move disc from 1 to 2'
>>> move('A', 'B')
'move disc from A to B'
... |
5a2915b514510085ddb9e53d2460654613affbab | biswas-neelesh96/Python-Scripts | /Mensuration_Area_Calculator.py | 1,856 | 4.21875 | 4 | import math
print("Area Calculator")
def rectangle(l,b):
a=l*b
return a
def square(r):
a=r*r
return a
def circle(r):
a=(22/7)*r*r
return a
def triangle(x,y,z):
s=0.5*(x+y+z)
s1=s*(s-x)*(s-y)*(s-z)
a=math.sqrt(s1)
return a
def eq_triangle(r):
a=(math.sqrt(3)/4)*r*r
return ... |
5f76832647d432899dc67d411c4b954eb6c954c1 | biswas-neelesh96/Python-Scripts | /Complete_Strings/main.py | 859 | 4.375 | 4 |
'''
PROBLEM STATEMENT - Complete String or not
A string is said to be complete if it contains all the characters from a to z. Given a string, check if it complete or not.
Example :
qwertyuioplkjhgfdsazxcvbnm , the quick brown fox jumps over the lazy dog are complete strings whereas qwerty , food , wyyga are not com... |
2d63cc0b276745b4f17d02b23d059b5705f3ce76 | biswas-neelesh96/Python-Scripts | /recursive_index.py | 589 | 3.921875 | 4 | def recursive_index(arr,n,m,res):
if(n<0):
return 0;
else:
if(arr[n]==m):
res.append(n)
n = n-1
recursive_index(arr,n,m,res)
arr = []
res = []
while True:
inp = input("Enter the elements of array / Enter 'done' : ")
if(inp == 'done'):
break
try:
inp = int(inp)
except:
print("Incorrect input.")
... |
c5c4f6f384822e70d6c98445688fc97144a38a38 | manump9/gas_dynamics | /gas_dynamics/fluids.py | 5,138 | 3.796875 | 4 | #!usr/bin/env
###
#The fluid class and some common fluids and their properties in metric and standard
###
#==================================================
#fluid
#==================================================
class fluid:
"""A class to represent the fluid and its properties
Attributes
----------
... |
e869f479d71798341c262e6838e24e83c2f03de0 | Ruthenic/word-predictor | /produce.py | 356 | 3.625 | 4 | import produce_api
letter = str(input("Hello! What word would you like to start with? ")) #var name is letters because legacy
howLong = int(input('How many words would you like to generate? '))
output = produce_api.generator.gen(letter,howLong)
print(output)
with open('result.txt', 'w') as f:
f.write(output)
print... |
d21d5e7e40a2ce955032091eccb6a9fd07209ec5 | Jordan-Voss/CA117-Programming2 | /ex.py | 985 | 3.8125 | 4 | import sys
def readint():
print('Please enter an Integer')
while True:
try:
x = input()
d = int(x)
break
except ValueError:
print('I said an *Integer*...')
return d
def readfile(filename):
try:
with open(filename, 'r') as f:
for line in f:
try:
line = line.split()
person = ' '.j... |
eb5dd1063b08fcbfd21ad423043bffc594b2016b | Jordan-Voss/CA117-Programming2 | /lecture_052.py | 420 | 3.890625 | 4 | import sys
def arithmetic(a, b, c=3, d=4):
return a + b + c + d
def main():
print(arithmetic(1, 2, 3, 4))
print(arithmetic(3, 4, 5))
print(arithmetic(3, 4))
print(arithmetic(3, 4, d=3))
print(arithmetic(4, b=5, d=2, c=1))
if __name__ == '__main__':
main()
def foo(x):
x = 33
print(x)
def main():
x = 44
fo... |
0d7fcef31dc4c179f40d96bb0544620b1d2bb7df | Jordan-Voss/CA117-Programming2 | /q2_051.py | 318 | 3.65625 | 4 | import sys
pattern = "evil"
def is_evil(s):
for c in pattern:
if s.count(c) != 1:
return False
ind = [s.index(c) for c in pattern]
return ind == sorted(ind)
def main():
words = [l.strip() for l in sys.stdin]
print(*[w for w in words if is_evil(w.lower())], sep="\n")
if __name__ == '__main__':
main() |
3f019a6f27fb4d8fb0c9f8ebf0496b7b96601868 | garrettblankenship456/Pacman | /point.py | 853 | 3.625 | 4 | # Holds the class for the cube that gives points
# Imports
from graphics import *
from boundingbox import *
# Class
class Square:
"""Point square"""
def __init__(self, pos, type):
self.pos = Point(pos.getX() - 5, pos.getY() - 5)
self.boundingBox = BoundingBox(pos, Point(10, 10))
self.v... |
8f4554b5fba77f3af378df420896984576334b9b | JudyCoelho/exerciciosCursoPython | /exerciciosfuncoes/exerciciosfuncoes.py | 1,215 | 4.15625 | 4 | """
1 - Crie uma função que exibe uma saudação com os parâmetros saudação e nome.
"""
def funcao ():
print('Oi, como você está?')
funcao()
def saudacao (saudacao, nome):
print(f'{saudacao} {nome}')
saudacao('Olá', 'Joãozinho')
"""
2 - Crie uma função que recebe 3 números com parâmetros e exiba a soma entre ... |
125d5fac74b4a34d9195f1c677526697d46e2055 | JudyCoelho/exerciciosCursoPython | /aula19/aula19.py | 201 | 3.953125 | 4 | """
For in e Python
Interando strings com for
Função range (start=0, stop, step=1)
"""
for n in range(10):
print(n)
print('###########')
for n in range(100):
if n % 8 == 0:
print(n) |
75dfb5635613d074020d7008ca27266a3f24f106 | kwoodson/compinvest | /quiz/sort_it.py | 872 | 4.0625 | 4 | #!/usr/bin/env python
import random
import sys
def quick_sort(array):
if len(array) < 1: return array
#select pivot
pivot = array[0]
#lower
lower = []
#upper
upper = []
for num in array[1:]:
if num >= pivot:
upper.append(num)
else:
lower.appen... |
dd45cdbbd1fde054c6614060461511bf4b2bf542 | SkryptKiddie/adventofcode2020 | /day3/part2/code.py | 2,235 | 3.9375 | 4 | # 2020 advent of code day 3 part 2
# https://adventofcode.com/2020/day/3#part2
import sys, time
map_1 = [] # map_1 is the instructions.txt file
map_2 = [] # map_2 is the map once we have expanded it
start_time = time.time()
count = 0 # tree encounter count
x = 0 # x coordinate
y = 0 # y coordinate
try:
with open("... |
d29d36eaa1ee6f2178342f7242aba5275931d715 | SatyamJindal/Beautiful-Soup | /beautiful soup(1).py | 1,020 | 3.90625 | 4 | # Session 1(Beautiful soup)
import bs4 as bs #importing beautiful soup4
import urllib.request # To make a request
sauce = urllib.request.urlopen('https://pythonprogramming.net/parsememcparseface/').read() # Source code
soup=bs.BeautifulSoup(sauce,'lxml') # lxml-->parser - Can also use HTML5lib
# Soup-->a beaut... |
6ca03032e05d6f1eb9160000b95aefe91190cbe3 | hqnjkkl/python_study | /Python_Crash_Course/Chapter4/4.3create_digital_list.py | 838 | 3.71875 | 4 | # #4-3
# for i in range(1,21):
# print(i)
# #4-4
# list_big = list(range(1,1000001))
# for num in list_big:
# print(num)
#
# #4-5
# list_big2 = list(range(1,1000001))
# print(min(list_big2))
# print(max(list_big2))
# print(sum(list_big2))
# #4-6
# list_odd = list(range(1,20,2))
# for num in list_odd:
# pri... |
f8d736816cf5fda0a5a4c60e2c1ef9b9dbf37b4d | NadiaaOliverr/Uri-Problem-Solutions | /Python/2060 - Desafio de Bino.py | 688 | 3.765625 | 4 | N = int(input())
multiple_two = 0
multiple_three = 0
multiple_for = 0
multiple_five = 0
values = input().split(' ')
values_correctly = values[:N]
for i in range(N):
values_correctly[i] = int(values_correctly[i])
if(values_correctly[i] % 2 ==0):
multiple_two+=1
if(values_correctly[i] % 3 ==0):
... |
53d0ab98e3714e60031f1b51cf9d7a28cc78ccac | boonchu/python3lab | /coursera.org/python3/2048/merge_4by4.py | 4,202 | 4.75 | 5 | #! /usr/bin/env python
'''
helper function that merges a single row or column in 2048
implement a function merge_v1(line) that models the process of merging all of the tile
values in a single row or column. This function takes the list line as a parameter
and returns a new list with the tile values from line slid tow... |
7576013275594782bb63978a4819888adae3d659 | boonchu/python3lab | /coursera.org/python1/week1/rSpls-assignment.py | 2,532 | 4.25 | 4 | import random
# Rock-paper-scissors-lizard-Spock assignment 1
# 0 - rock
# 1 - Spock
# 2 - paper
# 3 - lizard
# 4 - scissors
def name_to_number(name):
map = { 'rock':0, 'Spock':1, 'paper':2, 'lizard':3, 'scissors':4 }
if map.has_key(name):
return map[name]
else:
return None
def number_to... |
0b6b1590506c01a417eb98aca2f1806ce113c9a9 | boonchu/python3lab | /coursera.org/python3/quiz/homework2/quiz3-1.py | 1,147 | 4.28125 | 4 | #! /usr/bin/env python
"""
Example of creating a plot using simpleplot
Input is a list of point lists (one per function)
Each point list is a list of points of the form
[(x0, y0), (x1, y1, ..., (xn, yn)]
"""
import simpleplot
import math
# create three sample functions
def log1(x):
return math.log( (5 ** ... |
57f53782deb06d9417aa1f2145b8534ddae88929 | boonchu/python3lab | /coursera.org/python3/tictactoe/convert_float_int.py | 134 | 3.65625 | 4 | #! /usr/bin/env python
l1 = [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]
print l1
l1 = [map(int, nested_list) for nested_list in l1]
print l1
|
84ef8f18eb083eafc2bfac36161c920bab3a6a2f | boonchu/python3lab | /coursera.org/python3/tictactoe/monte_carlo.py | 1,896 | 3.828125 | 4 | #! /usr/bin/env python
"""
Monte Carlo simulation to compute the expectation that
you will get three-of-a-kind when rolling 5 dice.
"""
import random
import math
import simpleplot
try:
import SimpleGUICS2Pygame.codeskulptor as codeskulptor
except ImportError:
import codeskulptor
codeskulptor.set_timeout(20)
d... |
78daca7154fd09a6fee2d395057e56e2ecf24d12 | boonchu/python3lab | /coursera.org/python3/quiz/homework2/quiz2-1.py | 1,433 | 4.40625 | 4 | #! /usr/bin/env python
"""
Example of creating a plot using simpleplot
Input is a list of point lists (one per function)
Each point list is a list of points of the form
[(x0, y0), (x1, y1, ..., (xn, yn)]
"""
import simpleplot
# create three sample functions
def f1(x):
return 2 * x - 3
def f2(x):
ret... |
e04c4659d58d5681e21e10f3f6e9623c0053fa28 | boonchu/python3lab | /coursera.org/python1/week3/analog-clock-sample.py | 3,505 | 3.734375 | 4 | # Import modules
import simplegui
import math
import time
# Define globals
t = 0
t1 = time.time()
# Definte the helper functions
def alpha(t, per):
"""
the function returns the angle according to the speed
of the movement. This is quantified with the help of
per variable.
The canvas is ref... |
7cd0d9258be32f1ec4b789ff8eea17dc8c0b278d | boonchu/python3lab | /lists/enum.py | 259 | 4.03125 | 4 | #! /usr/bin/env python
my_container = ( 'Larry', 'Moe', 'Curly' )
def print_container( container ):
list_items = list(container)
for index, element in enumerate( list_items ):
print ' {} {} '.format(index, element)
print print_container(my_container)
|
bffac003e5084963c1a9f8d716e5c041ad7268eb | boonchu/python3lab | /lambda/len.py | 163 | 3.953125 | 4 | #! /usr/bin/env python
sentence = 'It is raining cats and dogs'
words = sentence.split()
print words
lengths = map( lambda word: len(word), words)
print lengths
|
e17bca24cf41921d9aa99bb9519bbe6d815c8872 | boonchu/python3lab | /coursera.org/python2/MyData.py | 650 | 3.96875 | 4 | #! /usr/bin/env python
# want to be able to initialize the class with, for example, a filename
# (which contains data to initialize the list) or with an actual list.
# http://stackoverflow.com/questions/141545/overloading-init-in-python
#
class MyData:
def __init__(self, data):
self.myList = list()
... |
111858474f514036949aa16674ecc82fdf5dca5b | boonchu/python3lab | /lists/Fruit.py | 1,860 | 3.53125 | 4 | #! /usr/bin/env python
# -- constructs dict from array --
# http://stackoverflow.com/questions/26112855/how-to-convert-an-array-to-a-dict-in-python?lq=1
# -- sort by value --
# http://stackoverflow.com/questions/613183/sort-a-python-dictionary-by-value
# -- OrderedDict class --
# https://docs.python.org/2/library/coll... |
477cb428ba03c9d7b0ae1a240d0f4c7d221f805c | boonchu/python3lab | /zip/headers.py | 300 | 3.75 | 4 | #! /usr/bin/env python
# http://stackoverflow.com/questions/1679384/converting-python-dictionary-to-list
#
headers = ['Capital', 'Food', 'Year']
countries = [
['London', 'Fish & Chips', '2012'],
['Beijing', 'Noodles', '2008'],
]
for olympics in countries:
print zip(headers, olympics)
|
48c85b2e97611f0449a6310eb5e262aaefe43bd8 | boonchu/python3lab | /coursera.org/python3/2048/example_2048_5.py | 7,087 | 3.859375 | 4 | """
Clone of 2048 game.
"""
#import poc_2048_gui
import random
# Directions, DO NOT MODIFY
UP = 1
DOWN = 2
LEFT = 3
RIGHT = 4
# Offsets for computing tile indices in each direction.
# DO NOT MODIFY this dictionary.
OFFSETS = {UP: (1, 0),
DOWN: (-1, 0),
LEFT: (0, 1),
RIGHT: (0, -1)}
... |
c2049c73a0e0f2fc2a615de1a153a1696c62951d | boonchu/python3lab | /coursera.org/python3/2048/cell_move.py | 1,552 | 3.828125 | 4 | #! /usr/bin/env python
#
# Did anyone use traverse_grid as a method in the TwentyFortyEight Class and what do you return from that method?
# https://class.coursera.org/principlescomputing1-004/forum/thread?thread_id=247
import random
grid_height = 4
grid_width = 4
UP = 1
DOWN = 2
LEFT = 3
RIGHT = 4
OFFSETS = {UP: ... |
2e59b5fc6c4e50dd1f9d9d7faa631a5e0298ad08 | boonchu/python3lab | /coursera.org/python2/Cheese.py | 451 | 3.59375 | 4 | #! /usr/bin/env python
import random
class Cheese(object):
def __init__(self, num_holes=0):
"defaults to a solid cheese"
self.number_of_holes = num_holes
@classmethod
def random(cls):
return cls(random(100))
@classmethod
def slightly_holey(cls):
return cls(random(... |
7578e56e506c0eb65022c5605b046bac41ce5718 | boonchu/python3lab | /coursera.org/python2/Accel.py | 544 | 4.0625 | 4 | #! /usr/bin/env python
# Consider a spaceship where the ship's thrusters can accelerate the ship
# by 10 pixels per second for each second that the thrust key is held down.
# If the friction induces a deceleration that is 10% of the ship's velocity
# per second, what is the maximal velocity of the ship? If you are ... |
66a43c78cde7912162da1d3bb7038c50746f6775 | boonchu/python3lab | /generators/prime | 1,144 | 4.40625 | 4 | #!/usr/bin/env python
# https://jeffknupp.com/blog/2013/04/07/improve-your-python-yield-and-generators-explained/
import math
def is_prime(number):
''' check if integer number is prime'''
number = abs(int(number))
# 0 and 1 are not primes
if number > 1:
# 2 is only even prime number, skip
... |
1bdb52193012cc07df8e5a6c210d85ea3abba54d | Skinc/C_Compiler | /tree.py | 871 | 4.1875 | 4 | """
Tree(root) class will create a tree object
with given root value.
tree.findLeave(leave) returns a boolean
representing whether a certain value exsits
on the branchs of a given root of a tree.
tree.grow(left, right) will create a left
branch and a right branch given the root of
a exsiting tree.
"""
class Tre... |
06d89b278604fcf694d95afdb1c2874d7bb58e07 | ghtjdah/FinalTest | /Question-1.py | 1,029 | 3.75 | 4 | # 1번 문제
from itertools import count
def textfilter1(text):
index=0
newtext=''
while(index != len(text)):
if(text[index]=='<'):
while(text[index]!='>'):
newtext +=''
index += 1
else:
newtext += ''
index += 1
... |
ea83363ee32354ace4c493b058d57091cb0bab1f | Artem-Vorobiov/bouncing_balls | /test.py | 213 | 3.640625 | 4 | import random
# colors = ['darkorange', 'black', 'red', 'white', 'purple']
# for i in range(5):
# digit = random.randint(0,4)
# print(colors[digit])
for i in range(10):
print(type(random.randint(-280,280))) |
f27fac68fca4d1f978644a1a1480b15a15d99e26 | ztan0057/FIT5136_S1_2020_17 | /MissionToMars/Login with txt/login.py | 3,018 | 3.71875 | 4 | '''登陆系统
1、可以选择创建新的用户
2、可以登陆原有的用户
3、输入密码错误三次后用户则被锁定'''
from typing import List
flag = True # 循环控制符
def createuser():
f = open('userlist.txt', 'r') # 打开已存在用户的文件,假设文件已经存在
flag = True
name = f.readlines()
f.close()
while flag:
username = input('username:')
flag2 = False # 用户名已存在的标记... |
4fe960f18065b7bd73d5cbd9721dc954b27d2450 | seyda109/Turkish-Poem-Generator | /poem generator/bigram_model.py | 2,869 | 3.53125 | 4 | import random
def tokenize():
"""Tokenizes and cleans the poems."""
poems = open("cleaned_poems.txt", "r", encoding='utf-8').read()
words = poems.split()
unwanted_tokens = ['i', 'e', 'a', 'ö', 'ı', 'u', 'ü', 'b', 'c', 'ç,', '’', 'guk', 'lir', 'd', 'f', 'g', 'ğ',
'h', 'j', 'k', 'l... |
ebee3cbd70deda96f91e6fbf0a4f90b2c21cf633 | Pari555/Dollars | /main.py | 930 | 3.75 | 4 | # Coins: amount of Cents that we outputted into least amount of coins.
# Dollars: amount of dollars that we output into least amount of bills.
# Hundred, Fifty, Twenty ,Ten, Five, One
# Ask the user for an amount of dollars
total = int(input("Enter a Number of Dollars: "))
hundred = 0
fifty = 0
twenty = 0
ten = 0
fiv... |
3ebe5f0dd3f16aedc63cccfb6a4dd08c6bd3b84c | patricknieto/python4ds | /machine-learning/kaggle/titanickaggle/firstpythongendermodel.py | 7,800 | 3.921875 | 4 | # -*- coding: utf-8 -*-
# The first thing to do is to import the relevant packages
# that I will need for my script,
# these include the Numpy (for maths and arrays)
# and csv for reading and writing csv files
# If i want to use something from this I need to call
# csv.[function] or np.[function] first
import csv as... |
53b41f224c88ff1b89ab68362e3d60ee74def115 | Even-github/HouseCrawler | /build/lib/HouseCrawler/utils/string_util.py | 830 | 3.515625 | 4 | # -*- coding: utf-8 -*-
import re
"""
字符串处理工具
"""
class StringUtil(object):
# 从字符串中获取第一个整数
@classmethod
def get_first_int_from_string(cls, string):
if string:
string = re.sub(r'\s', '', string)
string = re.search(r'\d+', string)
if string:
return s... |
af6526c6a8e494397ff851679cdf291327ee855e | dakloepfer/AdventOfCode2017 | /Day24Task1.py | 1,200 | 3.734375 | 4 | from _collections import defaultdict
global components;
global bridges;
def add_bridges(bridge):
global components;
global bridges;
bridge = bridge or [(0, 0)];
latest = bridge[-1][1];
for c in components[latest]:
if not ((latest, c) in bridge or (c, latest) in brid... |
1cd98a22fe2ce53835e8c14030cd11d8159c524b | dakloepfer/AdventOfCode2017 | /Day23Task2.py | 1,775 | 3.5625 | 4 | from math import sqrt, ceil
# This only works for the input; I would have liked to build an algorithm that detects loops and
# uses some clever trickery to fast-forward those, but that turned out to be rather hard when trying to
# consider all the different cases that can happen and that one would have to check for.... |
45589fe4bd2fdfe935f70f47435d46b87c439e00 | dakloepfer/AdventOfCode2017 | /Day03Task1.py | 607 | 3.828125 | 4 | # not the prettiest of algorithms but I think it does the job
from numpy import ceil;
n = input("Enter the position. ");
spiral = 0;
if n == 1:
distance = 0;
print distance;
quit();
spiral = ceil(sqrt(n));
if spiral%2 == 0:
spiral+=1;
spiral = 0.5*(spiral-1);
m = (n-(2*sp... |
1543373f82d03c24679a98239b70c921dc31ac9f | dakloepfer/AdventOfCode2017 | /Day24Task2.py | 1,452 | 3.765625 | 4 | from _collections import defaultdict
global components;
global bridges;
def add_bridges(bridge):
global components;
global bridges;
bridge = bridge or [(0, 0)];
latest = bridge[-1][1];
for c in components[latest]:
if not ((latest, c) in bridge or (c, latest) in brid... |
37a6dae031555ebf3826af3be87487cc6e579c62 | GeorgeKailas/python_fundamentals | /10_testing/10_02_tdd.py | 750 | 4.25 | 4 | '''
Write a script that demonstrates TDD. Using pseudocode, plan out a couple simple functions. They could be
as simple as add and subtract or more complex such as functions that read and write to files.
Instead of writing out the functions, only provide the tests. Think about how the functions might
fail and write te... |
3087b8b5f1bb71300ac8e3c755e58134824ec242 | GeorgeKailas/python_fundamentals | /06_functions/06_02_stats.py | 513 | 4.34375 | 4 | '''
Write a function stats() that takes in a list of numbers and finds the max, min, average and sum.
Print these values to the console when calling the function.
'''
example_list = [1, 2, 3, 4, 5, 6, 7]
def stats(l):
return max(l), min(l), sum(l)/len(l), sum(l)
# call the function below here
print(stats(example_... |
6d8967fb072988f82cc8db9c593483e823549278 | GeorgeKailas/python_fundamentals | /04_conditionals_loops/04_08_star_pyramid.py | 583 | 4.28125 | 4 | '''
Write a script that takes in a number from the user as input and prints the following structure.
Suppose the input is 5, you will output
*
* *
* * *
* * * *
* * * * *
i.e. number of rows will be 5, 1st row will have 1 star, 2nd row will have 2 stars, 3rd row 3 stars, 4th row will have 4 stars and 5th row will ha... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.