blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 3.06M | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 3.06M |
|---|---|---|---|---|---|---|
80082f949d1589ddc0a79a9067b95413e873b4f4 | wulinlw/leetcode_cn | /leetcode-vscode/406.根据身高重建队列.py | 1,933 | 3.546875 | 4 | #
# @lc app=leetcode.cn id=406 lang=python3
#
# [406] 根据身高重建队列
#
# https://leetcode-cn.com/problems/queue-reconstruction-by-height/description/
#
# algorithms
# Medium (62.74%)
# Likes: 272
# Dislikes: 0
# Total Accepted: 21.8K
# Total Submissions: 34.2K
# Testcase Example: '[[7,0],[4,4],[7,1],[5,0],[6,1],[5,2]]... |
e727d73d45d67bf07c8a7cf7bcf3103d8acd75b4 | wulinlw/leetcode_cn | /数组和字符串/array_6.py | 939 | 3.75 | 4 | #!/usr/bin/python
#coding:utf-8
# https://leetcode-cn.com/explore/featured/card/array-and-string/202/conclusion/792/
# 杨辉三角 II
# 给定一个非负索引 k,其中 k ≤ 33,返回杨辉三角的第 k 行。
# 在杨辉三角中,每个数是它左上方和右上方的数的和。
# 示例:
# 输入: 3
# 输出: [1,3,3,1]
# 进阶:
# 你可以优化你的算法到 O(k) 空间复杂度吗?
class Solution(object):
def getRow(self, rowIndex):
"... |
e17240c468f25e13762598f4f7c18bb9fbacd888 | wulinlw/leetcode_cn | /二叉树/search-tree_1_2.py | 1,994 | 4.09375 | 4 | #!/usr/bin/python
#coding:utf-8
# https://leetcode-cn.com/explore/learn/card/introduction-to-data-structure-binary-search-tree/64/introduction-to-a-bst/172/
# 二叉搜索树迭代器
# 实现一个二叉搜索树迭代器。你将使用二叉搜索树的根节点初始化迭代器。
# 调用 next() 将返回二叉搜索树中的下一个最小的数。
# 示例:
# BSTIterator iterator = new BSTIterator(root);
# iterator.next(); // 返回 ... |
1926f0d51153da212fbfd132588b7547ca9b9e9d | wulinlw/leetcode_cn | /初级算法/linkedList_4.py | 1,718 | 4.25 | 4 | #!/usr/bin/python
#coding:utf-8
# https://leetcode-cn.com/explore/interview/card/top-interview-questions-easy/6/linked-list/44/
# 合并两个有序链表
# 将两个有序链表合并为一个新的有序链表并返回。新链表是通过拼接给定的两个链表的所有节点组成的。
# 示例:
# 输入:1->2->4, 1->3->4
# 输出:1->1->2->3->4->4
# 新建链表,对比两个链表指针,小的放新链表中,直到某条链表结束,
# 将另一条链表剩余部分接入新链表
# Definition for singly-l... |
1270af1e1c684481ba5488a2fcff3aa3ca656284 | wulinlw/leetcode_cn | /leetcode-vscode/637.二叉树的层平均值.py | 1,670 | 3.703125 | 4 | #
# @lc app=leetcode.cn id=637 lang=python3
#
# [637] 二叉树的层平均值
#
# https://leetcode-cn.com/problems/average-of-levels-in-binary-tree/description/
#
# algorithms
# Easy (63.16%)
# Likes: 98
# Dislikes: 0
# Total Accepted: 14.5K
# Total Submissions: 22.9K
# Testcase Example: '[3,9,20,15,7]'
#
# 给定一个非空二叉树, 返回一个由每层节... |
096fdd8e7212763ede543a13cdad2240dd9f91ae | wulinlw/leetcode_cn | /dynamic-programming/dynamic-programming_63.py | 2,054 | 3.75 | 4 | #!/usr/bin/python
#coding:utf-8
# 63. 不同路径 II
# 一个机器人位于一个 m x n 网格的左上角 (起始点在下图中标记为“Start” )。
# 机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角(在下图中标记为“Finish”)。
# 现在考虑网格中有障碍物。那么从左上角到右下角将会有多少条不同的路径?
# 网格中的障碍物和空位置分别用 1 和 0 来表示。
# 说明:m 和 n 的值均不超过 100。
# 示例 1
# 输入:
# [
# [0,0,0],
# [0,1,0],
# [0,0,0]
# ]
# 输出: 2
# 解释:
# 3x3 网格的正中间... |
ecaa303c54ccfc6abc2d3e1c76799df9dabe7794 | wulinlw/leetcode_cn | /程序员面试金典/面试题04.01.节点间通路.py | 2,549 | 3.765625 | 4 | # #!/usr/bin/python
# #coding:utf-8
#
# 面试题04.01.节点间通路
#
# https://leetcode-cn.com/problems/route-between-nodes-lcci/
#
# 节点间通路。给定有向图,设计一个算法,找出两个节点之间是否存在一条路径。
# 示例1:
#
# 输入:n = 3, graph = [[0, 1], [0, 2], [1, 2], [1, 2]], start = 0, target = 2
# 输出:true
#
#
# 示例2:
#
# 输入:n = 5, graph = [[0, 1], [0, 2], [0, 4]... |
1ffbfbbbc0ea0c6f4725b89363464d734a17cd94 | wulinlw/leetcode_cn | /剑指offer/3_数组中重复的数字.py | 935 | 3.8125 | 4 | #!/usr/bin/python
#coding:utf-8
# 数组中重复的数字
# 在一个长度为n的数组里的所有数字都在0到n-1的范围内。
# 数组中某些数字是重复的,但不知道有几个数字是重复的。也不知道每个数字重复几次。
# 请找出数组中任意一个重复的数字。
# 例如,如果输入长度为7的数组{2,3,1,0,2,5,3},那么对应的输出是重复的数字2或者3。
class Solution(object):
def duplicate(self, nums):
if len(nums)== 0:
return False
re = []
for... |
bb2dd47c253fd1d7226b49f6a73d0f93658334c8 | wulinlw/leetcode_cn | /top-interview-quesitons-in-2018/string_3.py | 1,781 | 3.65625 | 4 | #!/usr/bin/python
#coding:utf-8
# https://leetcode-cn.com/explore/featured/card/top-interview-quesitons-in-2018/275/string/1138/
# 单词拆分
# 给定一个非空字符串 s 和一个包含非空单词列表的字典 wordDict,判定 s 是否可以被空格拆分为一个或多个在字典中出现的单词。
# 说明:
# 拆分时可以重复使用字典中的单词。
# 你可以假设字典中没有重复的单词。
# 示例 1:
# 输入: s = "leetcode", wordDict = ["leet", "code"]
# 输出: true... |
7799a49165b44fdc5f7c6064432c6204f384286b | wulinlw/leetcode_cn | /leetcode-vscode/563.二叉树的坡度.py | 1,736 | 3.875 | 4 | #
# @lc app=leetcode.cn id=563 lang=python3
#
# [563] 二叉树的坡度
#
# https://leetcode-cn.com/problems/binary-tree-tilt/description/
#
# algorithms
# Easy (53.09%)
# Likes: 54
# Dislikes: 0
# Total Accepted: 8.9K
# Total Submissions: 16.7K
# Testcase Example: '[1,2,3]'
#
# 给定一个二叉树,计算整个树的坡度。
#
# 一个树的节点的坡度定义即为,该节点左子树的... |
66fbee2c03751ac6ca76c7b9e1b1449cc609597d | wulinlw/leetcode_cn | /leetcode-vscode/98.验证二叉搜索树.py | 4,208 | 3.8125 | 4 | #
# @lc app=leetcode.cn id=98 lang=python3
#
# [98] 验证二叉搜索树
#
# https://leetcode-cn.com/problems/validate-binary-search-tree/description/
#
# algorithms
# Medium (29.10%)
# Likes: 543
# Dislikes: 0
# Total Accepted: 103.5K
# Total Submissions: 340.3K
# Testcase Example: '[2,1,3]'
#
# 给定一个二叉树,判断其是否是一个有效的二叉搜索树。
# ... |
d8ee8504bbeea0dc8d222d93e9a13c16ff5ca4d8 | wulinlw/leetcode_cn | /leetcode-vscode/820.单词的压缩编码.py | 4,185 | 3.796875 | 4 | #
# @lc app=leetcode.cn id=820 lang=python3
#
# [820] 单词的压缩编码
#
# https://leetcode-cn.com/problems/short-encoding-of-words/description/
#
# algorithms
# Medium (40.03%)
# Likes: 70
# Dislikes: 0
# Total Accepted: 14.1K
# Total Submissions: 32.8K
# Testcase Example: '["time", "me", "bell"]'
#
# 给定一个单词列表,我们将这个列表编码... |
15acb129012387c2a2c05e982a16a9e2d454660a | wulinlw/leetcode_cn | /leetcode-vscode/897.递增顺序查找树.py | 2,420 | 3.9375 | 4 | #
# @lc app=leetcode.cn id=897 lang=python3
#
# [897] 递增顺序查找树
#
# https://leetcode-cn.com/problems/increasing-order-search-tree/description/
#
# algorithms
# Easy (65.76%)
# Likes: 58
# Dislikes: 0
# Total Accepted: 8K
# Total Submissions: 12.1K
# Testcase Example: '[5,3,6,2,4,null,8,1,null,null,null,7,9]'
#
# 给... |
3192958328b62328c5bcc2c89a2ef2fc53ba001b | wulinlw/leetcode_cn | /leetcode-vscode/606.根据二叉树创建字符串.py | 2,203 | 3.640625 | 4 | #
# @lc app=leetcode.cn id=606 lang=python3
#
# [606] 根据二叉树创建字符串
#
# https://leetcode-cn.com/problems/construct-string-from-binary-tree/description/
#
# algorithms
# Easy (52.76%)
# Likes: 98
# Dislikes: 0
# Total Accepted: 9.4K
# Total Submissions: 17.7K
# Testcase Example: '[1,2,3,4]'
#
# 你需要采用前序遍历的方式,将一个二叉树转换... |
940b4d34f8c3c69f861cb1073cb9935f503835bf | wulinlw/leetcode_cn | /leetcode-vscode/350.两个数组的交集-ii.py | 1,630 | 3.765625 | 4 | #
# @lc app=leetcode.cn id=350 lang=python3
#
# [350] 两个数组的交集 II
#
# https://leetcode-cn.com/problems/intersection-of-two-arrays-ii/description/
#
# algorithms
# Easy (48.66%)
# Likes: 315
# Dislikes: 0
# Total Accepted: 103.1K
# Total Submissions: 205.9K
# Testcase Example: '[1,2,2,1]\n[2,2]'
#
# 给定两个数组,编写一个函数来... |
2d2c4fe3cd12f51c41aeb1dea6920d4d2752bb53 | wulinlw/leetcode_cn | /剑指offer/43_从1到n整数中1出现的次数.py | 3,313 | 3.640625 | 4 | #!/usr/bin/python
#coding:utf-8
# // 面试题43:从1到n整数中1出现的次数
# // 题目:输入一个整数n,求从1到n这n个整数的十进制表示中1出现的次数。例如
# // 输入12,从1到12这些整数中包含1 的数字有1,10,11和12,1一共出现了5次。
class Solution:
def NumberOf1Between1AndN_Solution(self, n):
# https://blog.csdn.net/ggdhs/article/details/90311852
# 如果要计算百位上1出现的次数,它要受到3方面的影响:百位上的数... |
db50eae1594cc0bc7ee8f331ca3b6383a3217288 | wulinlw/leetcode_cn | /递归/recursion_5_3.py | 4,062 | 3.9375 | 4 | #!/usr/bin/python
#coding:utf-8
# https://leetcode-cn.com/explore/orignial/card/recursion-i/260/conclusion/1233/
# 不同的二叉搜索树 II
# 给定一个整数 n,生成所有由 1 ... n 为节点所组成的二叉搜索树。
# 示例:
# 输入: 3
# 输出:
# [
# [1,null,3,2],
# [3,2,null,1],
# [3,1,null,null,2],
# [2,1,3],
# [1,null,2,null,3]
# ]
# 解释:
# 以上的输出对应以下 5 种不同结构的二叉搜... |
b43fa3334180039300923931d9259fe5a6ba832e | wulinlw/leetcode_cn | /leetcode-vscode/69.x-的平方根.py | 1,050 | 3.671875 | 4 | #
# @lc app=leetcode.cn id=69 lang=python3
#
# [69] x 的平方根
#
# https://leetcode-cn.com/problems/sqrtx/description/
#
# algorithms
# Easy (37.57%)
# Likes: 364
# Dislikes: 0
# Total Accepted: 126.8K
# Total Submissions: 335.5K
# Testcase Example: '4'
#
# 实现 int sqrt(int x) 函数。
#
# 计算并返回 x 的平方根,其中 x 是非负整数。
#
# 由... |
72aadd6ad7c82acd94fd6500aea2f08d406da84e | wulinlw/leetcode_cn | /哈希表/hash-table_1_1.py | 2,228 | 3.984375 | 4 | #!/usr/bin/python
# coding:utf-8
# https://leetcode-cn.com/explore/learn/card/hash-table/203/design-a-hash-table/799/
# 设计哈希集合
# 不使用任何内建的哈希表库设计一个哈希集合
# 具体地说,你的设计应该包含以下的功能
# add(value):向哈希集合中插入一个值。
# contains(value) :返回哈希集合中是否存在这个值。
# remove(value):将给定值从哈希集合中删除。如果哈希集合中没有这个值,什么也不做。
# 示例:
# MyHashSet hashSet = new My... |
54cd0bace7d37beaf42ea3520896257a5bd3d19b | wulinlw/leetcode_cn | /中级算法/sorting-and-searching_5.py | 2,508 | 3.765625 | 4 | #!/usr/bin/python
#coding:utf-8
# https://leetcode-cn.com/explore/interview/card/top-interview-questions-medium/50/sorting-and-searching/100/
# 在排序数组中查找元素的第一个和最后一个位置
# 给定一个按照升序排列的整数数组 nums,和一个目标值 target。找出给定目标值在数组中的开始位置和结束位置。
# 你的算法时间复杂度必须是 O(log n) 级别。
# 如果数组中不存在目标值,返回 [-1, -1]。
# 示例 1:
# 输入: nums = [5,7,7,8,8,10],... |
5f492700d7482fa2df271ec9088f8f06fbeeb568 | Bhavya-Tripathi/ComputerNetworks | /Assignment-3/test.py | 1,245 | 3.765625 | 4 | import socket,sys
print("Setting up server: ")
#Get hostname,IP
sock = socket.socket()
hostname = socket.gethostname()
ip = socket.gethostbyname(hostname)
port = 6969
sock.bind((hostname,port)) #binds IP of localhost to port
print(hostname, '({})'.format(ip))
name = input('Enter your name:')
sock.listen(1) #to locate... |
efa5b93f22db52d9dfe98f8a95f3c8da4866aa24 | VictorSHJ/fundamentos-python | /palindroma.py | 1,116 | 4.125 | 4 | # GRUPO 2:
# Crea una funcion que dado una palabra diga si es palindroma o no.
def palindroma(palabra):
print(f"Palabra Normal: {palabra}, Palabra Invertida: {palabra[::-1]}")
if palabra == palabra[::-1]:
print("Es palindroma")
else:
print("No es palindroma")
print("Ingrese una palabra :"... |
893ad93e796a1e7ac5fd1df23c8ab4a4c432a454 | SebastianStaab/AEMLproject | /tetris/testing.py | 806 | 3.515625 | 4 | cols = 10
rows = 20
board = [
[ 0 for x in range(cols) ]
for y in range(rows)
]
board += [[ 1 for x in range(cols)]]
def join_matrixes(mat1, mat2, mat2_off):
off_x, off_y = mat2_off
for cy, row in enumerate(mat2):
for cx, val in enumerate(row):
mat1[cy+off_y-1 ][cx+off_... |
b7908c0d09dd1a60a6c355b67ad4d7f2b5b324a6 | jamesdschmidt/exercises-for-programmers | /23-troubleshooting-car-issues/troubleshooting_car_issues.py | 1,024 | 3.984375 | 4 | answer = input("Is the car silent when you turn the key? ")
if answer.lower().startswith("y"):
answer = input("Are the battery terminals corroded? ")
if answer.lower().startswith("y"):
print("Clean terminals and try starting again.")
else:
print("Replace cables and try again.")
else:
ans... |
df0d8ad8924c8948c854619cef38c87f90a74e7e | jamesdschmidt/exercises-for-programmers | /11-currency-conversion/currency_conversion.py | 309 | 3.875 | 4 | DOLLAR_RATE = 100
euros = int(input("How many euros are you exchanging? "))
exchange_rate = float(input("What is the exchange rate? "))
dollars = round((euros * exchange_rate) / DOLLAR_RATE, 2)
print(f"{euros} euros at an exchange rate of {exchange_rate:,.2f} is\n"
f"{dollars:,.2f} U.S. dollars.")
|
a81d2c7a6c3213eb61126ec23759d462e0b6862c | jamesdschmidt/exercises-for-programmers | /14-tax-calculator/tax_calculator.py | 305 | 3.75 | 4 | TAX_RATE = 0.055
amount = float(input("What is the order amount? "))
state = input("What is the state? ")
total = amount
output = ""
if "wi" == state.lower():
tax = amount * TAX_RATE
output = f"The tax is ${tax:,.2f}.\n"
total += tax
output += f"The total is ${total:,.2f}"
print(output)
|
e75d330b5e9e8fa368266108785fad07875ffd97 | jamesdschmidt/exercises-for-programmers | /16-legal-driving-age/legal_driving_age.py | 119 | 4.09375 | 4 | age = int(input("What is your age? "))
print("You", "are not" if age < 16 else "are", "old enough to legally drive.")
|
bbf1b7caf79ccf7f09fa42a45915a12feb88eb8d | jamesdschmidt/exercises-for-programmers | /13-determining-compound-interest/determining_compound_interest.py | 503 | 3.734375 | 4 | principal = float(input("What is the principal amount? "))
rate = float(input("What is the rate? "))
years = int(input("What is the number of years? "))
compound = int(input("What is the number of times the interest\n"
"is compounded per year?"))
amount = round(principal * ((1 + (rate / 100) / com... |
14a129dab9189feff13e5be95e38aae5fefb5b36 | dwighthubbard/ipython_embedded_notebooks | /intro/3_tail.py | 754 | 3.828125 | 4 | # Blink an LED on pin 18.
# Connect a low-ohm (like 360 ohm) resistor in series with the LED.
import RPi.GPIO as GPIO
import time
# A variable so we can change the PIN number for this script in once place
# if we move the LED to a different pin.
PIN = 7
# Set the pin to do output
GPIO.setmode(GPIO.BCM)
GPIO.setup(PI... |
b107480b098897c85a77f5bfa88ea20a4f78a497 | AlNiLo/LearnPython | /HomeW/!!!!L2_test_classroom_list.py | 1,326 | 3.875 | 4 | quest = input('По какому классу вывести оценки? ')
school = [
{'class':[
{'1':[
{'a':[1, 3, 4, 4, 3, 5, 3],
'b':[1, 2, 4, 4, 3, 4, 4],
'c':[1, 2, 2, 5, 4, 5, 5]
}
],
... |
e5f82bbb3538305b49f22f9c1e8530a0e87a20fa | kardeepak/protostar | /format0.py | 228 | 3.609375 | 4 | import struct
# padding will pad and print an integer fron the stack. It will print 64 integers
padding = "%64d"
# Value that will be written to the target variable
value = struct.pack("I", 0xdeadbeef)
print(padding + value)
|
498cdb043ed9f878303fedb8d72019ce27d8faa0 | CodecoolBP20173/game_enhancement | /tictac_test.py | 6,627 | 3.71875 | 4 | import string
field = []
player_x_win = 0
player_o_win = 0
def print_field(): # print empty field with nested lists
alphabet = string.ascii_lowercase
print("\n" * 50)
for i in range(field_size):
field.append([" "])
for j in range(field_size):
field[i].append(" ")
... |
cfba2c4ac2beb767417b1e8e46486dea23cdf26e | adamcharnock/repose | /repose/validators.py | 1,626 | 3.703125 | 4 | from booby.validators import *
import six
class Range(Integer):
"""This validator forces fields values to be within a given range (inclusive)"""
def __init__(self, min=None, max=None):
self.min = min
self.max = max
@nullable
def validate(self, value):
if self.max is not None:... |
5a0be252fff51c358f1360716f892c69078c98a1 | mirzaevolution/Python-Basics | /PythonApplication2/Statements.py | 790 | 3.890625 | 4 | import constant
"""
Python Program #1
"""
#line continuation statement
number1 = 1 + 2 + \
3 + 4 + \
5 + 6
number2 = (1 + 2 +
3 + 4 +
5 + 6)
print(number1)
print(number2)
# One line assignment
var1,var2,var3 = 1,12.4,"Mirza Ghulam Rasyid"
print(var1)
print(var2)
print... |
ca5941b7b2355135eb03c3d8880a741db9a221f2 | November29th/ObjectedOrientedCards | /objectOrientedCards.py | 1,719 | 3.796875 | 4 | from random import*
class Card(object):
def __init__(self, suit = None, value = None):
self.value = value
class Diamond(Card):
def __init__(self):
super(Diamond, self).__init__("Diamond", 4)
class Heart(Card):
def __init__(self):
super(Heart, self).__init__("Heart", 3)
class Club... |
20bb2a14fbb695fa1d1868147e8e2afc147cecc3 | fatychang/pyimageresearch_examples | /ch10 Neural Network Basics/perceptron_example.py | 1,157 | 4.25 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Dec 9 12:56:47 2019
This is an example for runing percenptron structure to predict bitwise dataset
You may use AND, OR and XOR in as the dataset.
A preceptron class is called in this example.
An example from book deep learning for computer vision with Python ch10
@author: ... |
fd608e74e03f957482ac06f6b55b9f2f3363434a | fatychang/pyimageresearch_examples | /barcode-detection-guide/detect_barcode.py | 2,746 | 3.578125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Feb 4 13:04:46 2020
This script demonstrates the technique to detect the barcode
using computer vision and image processing technique
A edge detection approach is implemented in this script with opencv
This sample is inspired by the post from pyinagesearch
@author: jscha... |
b7c3cf717dea0f7c9b95599c99e691e6b0fe16ea | amcatlin/CSCI156-ExceptionHandling | /ExceptionHandling answers.py | 1,155 | 3.859375 | 4 | __author__ = 'Alicia'
y = 'Enter SS#: '
inputstring = 'Please enter a valid social security number of the form ###-##-#### including the dashes: '
def question(s):
social = input(s).strip()
try:
AAA, GG, SSSS = social.split('-')
area = int(AAA)
group = int(GG)
serial = int(SSSS... |
84f18c6f127360133af6802d2cd698551d6a6665 | rarafa/crypto-course | /rot13.py | 778 | 3.765625 | 4 | #!/usr/bin/python3
import sys
def rot13(input):
output=""
for i in input:
if i.isalpha():
if i.islower():
if (ord(i)+13)%ord('z') < ord('a'):
output += chr( ((ord(i)+13)%ord('z'))+ord('a') )
else:
output += chr( (ord(i... |
c83a41d51e6061033feaf6054f63c3f570c1f03b | junejunejune/numpy_practice | /sort.py | 460 | 3.671875 | 4 | import numpy as np
def selection_sort(x):
for i in range(len(x)):
swap = i + np.argmin(x[i:])
(x[i], x[swap]) = (x[swap], x[i])
return x
def bogosort(x):
while np.any(x[:-1] > x[1:]):
np.random.shuffle(x)
return x
x = np.array([2,1,4,3,5])
print(selection_sort(x))
x = np.arra... |
b7a04a3f5513cfa9d6aca9f3cb548726ec953326 | Hegerstrand/energyMapperOld | /Python/venv/Lib/site-packages/copyfile/copyfile.py | 1,403 | 3.625 | 4 | import os
import shutil
import logging
def touch(fname, times=None):
"""Creates an empty file at fname, creating path if necessary
Answer taken from Stack Overflow http://stackoverflow.com/a/1160227
User: ephemient http://stackoverflow.com/users/20713
License: CC-BY-SA 3.0 https://creativecommons.org/... |
f2e5accccddc156ccc92d48cca4b7bc2a1f50d4f | szwagiers/sqlite | /ccsqlite/lesson3.py | 319 | 3.96875 | 4 | import sqlite3
conn = sqlite3.connect("database.db")
# put cursor
c = conn.cursor()
# execute sql directly to database
c.execute("CREATE TABLE IF NOT EXISTS books (title TEXT,pages INTEGER)")
c.execute('INSERT INTO books VALUES("The Count of Monte Cristo",1316)')
conn.commit()
c.execute('SELECT * FROM books')
|
2423751e0607aa434d00d5e909e19126ac366ee9 | PPCCCSCS/Flippant | /FlippantTutor.py | 91,171 | 4.28125 | 4 | """
File: FlippantTutor.py
The program teaches users how to play the dice game Flippant
via a simulated game with one to three computer-controlled
opponents. Their choices are chosen randomly, so players
shouldn't expect to learn strategies for competing with skilled
players, but this program should provide an ... |
feea22a9815e0067f55718d5c59f90f16a5c4c69 | hannahmok/webhax_samples | /04-shellsanitization-better/index.py | 810 | 3.515625 | 4 | #!/usr/bin/env python3
import os
import sys
import urllib.parse
# parse the query string (?x=1&y=2) into the parameters dict {'x': ['1'], 'y': ['2']}
parameters = urllib.parse.parse_qs(os.environ['QUERY_STRING'])
# handle ?query=xx to search for text
if 'query' in parameters:
print('Content-type: text/plain\n')
... |
f963c5c6e26976b826456b634c80ed388d7cde55 | ptsteadman/qfo-algo-console | /strategy/monkey.py | 370 | 3.6875 | 4 | import random
class Monkey(object):
""" Silly monkey strategy every freq tick roll the dice
To instantiate a 30 tick monkey:
>>> monkey = Monkey(30)
"""
def __init__(self, freq):
self.freq = freq
def __call__(self, tick):
if tick.index % self.freq:
return None
... |
a73e83cd06a469cbbea8440e836f359715d1ff08 | ptsteadman/qfo-algo-console | /strategy/bollinger.py | 920 | 3.53125 | 4 | class Bollinger(object):
""" Bollinger's band trading strategy, for Mean Reversion or Breakout
Bollinger's band take 2 parameters the period N of the underlying moving
average and the widht of the band K.
To instantiate a 20 days, 2 standard dev:
>>> bollinger = Bollinger(20, 2, reversion)
""... |
847ace6bebef81ef053d6a0268fa54e36072dd72 | chenshaobin/python_100 | /ex2.py | 1,113 | 4.1875 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
"""
# Write a program which can compute the factorial of a given numbers.
# The results should be printed in a comma-separated sequence on a single line.Suppose the following input is supplied to the program: 8 Then, the output should be:40320
"""
# 使用while
"""
n = int... |
baa5ff5f08103e624b90c7a754f0f5cc60429f0e | chenshaobin/python_100 | /ex9.py | 581 | 4.15625 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
"""
# Write a program that accepts sequence of lines as input
# and prints the lines after making all characters in the sentence capitalized.
"""
# solution1
"""
lst = []
while True:
x = input("Please enter one word:")
if len(x) == 0:
break
lst.appen... |
04d0d49313ad3fd020a1dd5364f663819160c825 | wongxinjie/python-tools | /profile/timer.py | 1,177 | 3.5625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""程序片函数运行时间测量模块
usage:
from timer import Timer
...
with Timer():
...
"""
import gc
import timeit
class Timer(object):
def __init__(self, timer=None, disable_gc=False,
verbose=False, program=None):
if timer is None:
... |
fd3a3adc3b657f5f3d72697827658c1ecf804ea9 | seanxwh/github | /Python/miscellaneous/Nerual_Network.py | 5,830 | 4.09375 | 4 | #A neural network implementation for data/labels classification using Python. User can train the network
#by provide data that has labels in it. User can also fine tune the network by modifying it parameters (e.ghidden layers, learning rate, etc)
# Package imports
import matplotlib.pyplot as plt
import math
import num... |
8c551099820670650129116ba923151ccffcc6dc | Agugu95/AlgoPy | /algo_py/BridgeOnTrucks.py | 652 | 3.78125 | 4 | from collections import deque
def solution(bridge_length, weight, truck_weights):
answer = 0
waited_truck = deque(truck_weights)
cur_bridge = [0] * bridge_length
cur_weight = 0
while cur_bridge:
cur_weight -= cur_bridge.pop(0)
if waited_truck:
if(cur_weight + waited_tr... |
ab46a3b79cb7eeeba170fd2db174876fca14b900 | ritik1234/calculator | /calculatorgui.py | 5,091 | 3.71875 | 4 | from tkinter import *
import math
root = Tk()
def click(event):
global value
text = event.widget.cget("text")
if text == "sin":
value.set(math.sin(float(exp.get())))
exp.update()
elif text == "cos":
value.set(math.cos(float(exp.get())))
exp.update()
elif t... |
855fab989e0c28a10cfd7459bfcf6cd03091a061 | AlibekAbd/- | /Gauss.py | 826 | 3.71875 | 4 | import numpy as np
import random
import scipy.linalg as sla
n = int(input())
A = np.random.rand(n,n)
f = np.random.rand(n)
#diagonal dimension
for i in range(0,n):
summa = 0
for j in range(0,n):
summa += abs(A[i][j])
c = random.uniform(1,2)
A[i][i] = summa + c
def forward_elimination(A, f, n):
for k in range(... |
932dffef241b7aadab1551b63db501e7146457c0 | Ankirama/Epitech | /B5---Java-I-Programming/JWeb/data/initDB.py | 5,787 | 4.09375 | 4 | import sqlite3
import sys
class Database:
'''
Helper to use sqlite3 and init our database
'''
def __init__(self, dbname):
'''
It will connect to the database name (or create it) and create (if not exists) our tables
@param: dbname: database name
'''
try:
... |
0a0e107f75b9549da0db80273d81ff7b4e84e88a | alanmanderson/advent_of_code_2020 | /2/validate_passwords.py | 1,435 | 3.515625 | 4 | INPUT_FILE = 'my_input.txt'
def read_file(filename):
with open(filename, 'r') as fp:
data = []
for line in fp:
data.append(line.strip().split(': '))
return data
def old_valid_passwords(data):
valid_passwords = []
for str_policy, password in data:
policy = parse_poli... |
eaeed21766f75657270303ddac34c8dcae8f4f01 | Scientific-Computing-at-Temple-Physics/prime-number-finder-gt8mar | /Forst_prime.py | 605 | 4.375 | 4 | # Marcus Forst
# Scientific Computing I
# Prime Number Selector
# This function prints all of the prime numbers between two entered values.
import math as ma
# These functions ask for the number range, and assign them to 'x1' and 'x2'
x1 = int(input('smallest number to check: '))
x2 = int(input('largest number to ... |
d40172caa6c5f944dd0db4a8a2b7af65ec861c63 | piotrbla/pyExamples | /format_poem.py | 580 | 3.78125 | 4 | from unittest.test.test_case import Test
def format_poem(poem):
if poem[-1:] == ".":
return ".\n".join(x.strip() for x in str.split(poem, '.'))
else:
return ".\n".join(x.strip() for x in str.split(poem, '.'))[:-1] + poem[-1:]
x=[1, 2, 3]
a = sum(x)/len(x)
print(format_poem('Beautiful is bette... |
c38197e38f25c0a4897daf349529adb8371fd860 | piotrbla/pyExamples | /chess.py | 578 | 3.609375 | 4 | class Field:
def __init__(self, r, c):
self.r = r
self.c = chr(c + ord('A') - 1)
class Board:
def __init__(self):
self.fields = []
for row in range(1, 9):
row_fields = []
for column in range(1, 9):
row_fields.append(Field(row, column))
... |
eb2dcb63ce695d4787b4269754005b9ff9074834 | piotrbla/pyExamples | /random_stack.py | 4,073 | 3.515625 | 4 | from random import randint
from random import seed
class element:
def __init__(self, data, prev=None):
self.data = data
self.prev = prev
class stos:
def __init__(self, first):
self.length = 1
self.porownania = 0
self.przypisania = 4
self.last = element(first)
... |
7a04c5413d26c1daf88792f0353f5a5ed0872a98 | piotrbla/pyExamples | /resistor.py | 3,887 | 3.734375 | 4 | import unittest
def encode_resistor_colors(ohms_string):
result = ""
codes = {0: "black", 1: "brown", 2: "red", 3: "orange", 4: "yellow", 5: "green", 6: "blue", 7: "violet", 8: "gray",
9: "white"}
without_ohms = ohms_string.replace(" ohms", "")
x = 0
if without_ohms.endswith('k'):
... |
83b7c6b2d13a748299802172b49f6cd0f51e1e25 | Charnub/python-code | /Python Programming Sheets/Q22.py | 284 | 3.984375 | 4 | myMessage = (input("Enter Message: "))
upperLower = (input("Shout or Whisper?: "))
upperLower = upperLower.lower()
if upperLower == "shout":
myShout = myMessage.upper()
print(myShout)
elif upperLower == "whisper":
myShout2 = myMessage.lower()
print(myShout2)
|
fe3c86ed4282507f3f96c7f070bc1ac0036db547 | Charnub/python-code | /Python Programming Sheets/Q13.py | 301 | 3.796875 | 4 | import random
character = (input("Do you want to create a Character?"))
character = character.lower()
dice1 = random.randint(1,6)
dice2 = random.randint(1,12)
if character == "yes":
calculate = dice2/dice1+10
print("Hit Points: "+(str(calculate)))
elif character == "no":
exit()
|
97ec90e598582256b2ba729af7cde46277481412 | Charnub/python-code | /Test Files/y10help.py | 242 | 3.96875 | 4 | print("Welcome to The Quiz!")
print("Please create a username and password:")
name = (str(input("What is your name?")))
age = (str(input("What is your age?")))
name2 = name[:3]
username = name2+age
print("Your username is: "+username)
|
7134c88c5828fd1675705ccecc1d9d6ad12f446e | Charnub/python-code | /Python Programming Sheets/Q27.py | 145 | 3.609375 | 4 | def coinToss():
import random
if(random.randint(0,1)==0):
return "Heads"
else:
return "Tails"
print(coinToss()) |
90ab247a769e653a54ddc3165106f74e85d83543 | kimstone/itp_week_3 | /day_3/exercise-daniel.py | 597 | 3.828125 | 4 | import requests
import json
# using the requests package, we can make API calls to retrieve JSON
# and storing it into a variable here called "response"
response = requests.get("https://rickandmortyapi.com/api/character")
# verify the response status as 200
# print(response)
# verify the raw string data of the respo... |
1e9988d1becd1cf946dd8d26f614cc0d142edd52 | annilq/python | /chapter-9/admin.py | 482 | 3.625 | 4 | from user import User
class Privileges():
"""docstring for Privileges"""
def __init__(self):
super().__init__()
self.privileges = ["can add post","can delete post","can ban user"]
def show_privileges(self):
print("the admin ",self.privileges)
class Admin(User):
"""docstring for Admin"""
def __init__(self, f... |
f72db317acd78d63bae31468bcece656e696a540 | Nrams1/CSC1015F_Assignment-2 | /pi.py | 332 | 3.984375 | 4 | # calculate pi
# neo ramotlou
# 15 march 2018
x = 0
fraction = 2
import math
p = 2
while x !=2:
x = math.sqrt(x+2)
fraction = (2/x)
p = p*fraction
print('Approximation of pi:', round(p, 3))
radius = eval(input('Enter the radius: \n'))
print('Area:', round((p*(radius**2)), 3))
... |
35cd940e9184686fb80f549dad3555404537714a | daniel321c/coding_quiz | /leafSum.py | 665 | 3.515625 | 4 | # class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def sumNumbers(self, root: TreeNode) -> int:
self.total = 0
self.getNumber(root, 0)
return self.total
def getNumber(self, node, carry):
... |
1ee05d52209e23c2cacd5b512cb3963b26af6b30 | daniel321c/coding_quiz | /filter.py | 710 | 3.625 | 4 | from abc import ABC, abstractmethod
class BaseFilter(ABC):
def __init__(self, field, constraint):
self.field = field
self.constraint = constraint
@abstractmethod
def apply(self, object):
print("i am abstract")
pass
class EquationFilter(BaseFilter):
def __init__(sel... |
076fbda9c9524d527abe372d12f5ab69659bb100 | chz224/Apply-Security-HW1 | /HW_1.py | 760 | 3.90625 | 4 | #Cheng Hao Zheng
#HW 1 Spell Checker
#Github user name: chz224
#import spellchecker library
from spellchecker import SpellChecker
def main():
spell = SpellChecker()
#change the file to the text file you want to spell check
#currently spell checking file MisspelledText.txt
misspelledFile = o... |
f6d7f32228e90e46336cab48bafca14da5be421a | jarbus/epsilon-machine-python | /em/parse_tree_node.py | 4,436 | 3.59375 | 4 | from collections import defaultdict, Counter
from typing import Dict, Sequence, List
from functools import partial
import plantuml
import sys
class ParseTreeNode:
"""Node of a parse tree.
Arguments:
depth: Level of depth in a tree. For roots, depth=0.
target_depth: Denoted as D in Crutchfield... |
4845e44fa0afcea9f4293f45778f6b4ea0da52b0 | jamiegowing/jamiesprojects | /character.py | 402 | 4.28125 | 4 | print("Create your character")
name = input("what is your character's name")
age = int(input("how old is your character"))
strengths = input("what are your character's strengths")
weaknesses = input("what are your character's weaknesses")
print(f"""You'r charicters name is {name}
Your charicter is {age} years old
stren... |
18c4527e5b18282b5d023fe97dbd880bc0f91796 | UPML/python2017 | /62.py | 1,097 | 3.6875 | 4 | import random
def british_word(word, param):
if len(word) >= param + 2:
last_to_change = min(param, len(word) - 2)
positions = random.sample(range(1, len(word) - 1), last_to_change)
characters = []
for j in positions:
characters.append(word[j])
random.shuffle(ch... |
45822bdb6dc53702eff7f2a899117558bb05e4f0 | UPML/python2017 | /4.py | 812 | 3.75 | 4 | def memoize(function):
memo = {}
def wrapper(*args):
if args in memo:
return memo[args]
else:
rv = function(*args)
memo[args] = rv
return rv
return wrapper
# не сложилось=(
@memoize
def fib(n):
if (n == 0):
return 0
if (n ==... |
142ecec208f83818157ce4c8dff7495892e5d5d2 | yagizhan/project-euler | /python/problem_9.py | 450 | 4.15625 | 4 | # A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
# a2 + b2 = c2
# For example, 32 + 42 = 9 + 16 = 25 = 52.
# There exists exactly one Pythagorean triplet for which a + b + c = 1000.
# Find the product abc.
def abc():
for c in range(1, 1000):
for b in range(1, c):
... |
004571b005999b28b9913db8d646c82f1e562b1b | peterlew/euler-python | /p14.py | 379 | 3.5 | 4 |
results = {1 : 1}
def chainLen(n):
if n in results:
return(results[n])
if n % 2 == 0:
result = 1 + chainLen(n // 2)
else:
result = 1 + chainLen(n * 3 + 1)
results[n] = result
return result
longestChain = 0
longestChainStart = 0
for i in range(1, 1000000):
c = chainLen(i)
if c > longestChain:
longestCh... |
1258ef4008a50145318fbd3e8bd13fabc8989cbb | peterlew/euler-python | /p31.py | 457 | 3.625 | 4 |
coins = [200, 100, 50, 20, 10, 5, 2, 1]
# results dic: (target, max coin index) -> ways to make target
# using coins at max index or greater
results = {}
for i in range(8):
results[(0, i)] = 1
def waysToMake(n, ind):
if (n, ind) in results:
return results[(n, ind)]
total = 0
for i in range(ind, 8):
coin =... |
e7db4be32011e9c773b088453853c24d0c98f4a7 | SoyeonHH/Algorithm_Python | /LeetCode/819.py | 562 | 3.5 | 4 | import collections
import re
paragraph = "Bob hit a ball, the hit BALL flew far after it was hit."
banned = ["hit"]
# Solution
# --------------------------------------------------------------
# 입력값 전처리
words = [word for word in re.sub(r'[^\w]',' ', paragraph)
.lower().split()
if word not in ... |
850cb22e85b943a16b872d0d826b498ab118b90b | SoyeonHH/Algorithm_Python | /LeetCode/206.py | 745 | 3.90625 | 4 | # Definition for singly-linked list.
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution:
# 재귀 구조로 뒤집기
def reverseList_1(self, head: ListNode) -> ListNode:
def reverse(node: ListNode, prev: ListNode):
if not node... |
77b2c0824d422ba288765da390bd2b7c068bdb62 | Alston-Tang/Spam-Filter | /proc_mail.py | 1,858 | 3.671875 | 4 | # -*- coding: utf-8 -*-
"""
This file contains functions of processing emails
"""
import re
from html2text import html2text
def get_mail_body(_mail_file):
"""
Extract the mail body from the mail file.
:param mail_file: file contains the raw content of email
:type mail_file: str
:return: string th... |
aa8d3118caa910d1b2198cc6882b755d5dcb68c8 | shivg7706/CodeJam | /gcj1.py | 923 | 3.53125 | 4 | def curdam(s):
charge = 1
damage = 0
for i in s:
if i == 'C':
charge *= 2
else:
damage += charge
return damage
def swap_required(s, d):
swap_c = 0
while True:
current_damage = curdam(s)
if current_damage <= d:
return swap_c
else:
pos = -1
for i in range(len(s)-1):
if s[i] == 'C' and ... |
42c2467e03efa96cb2e2c7a250ce9e741e0f383b | GitOsku/Olio-ohjelmointi | /Exercise 1 p4.py | 196 | 4.0625 | 4 | counter = 0
while True:
number = int(input("Enter a number "))
if number > 0 :
continue
if number < 0 :
counter += 1
else:
break
print (counter) |
d6f65d9feaf588632bda256f7ddf3d41ca2c9208 | GitOsku/Olio-ohjelmointi | /Harjoitus5/Actual/PlayerClass.py | 1,466 | 3.875 | 4 | from Dicefilu import Dice
class Player(Dice):
def __init__(self, id):
self.firstname = "Oskari"
self.lastname = "Helenius"
self.ID = id
self.roll = 0
#setters
def setFirstname(self):
set_firstname = input("Gimme your firstname: ")
self.firstna... |
504ef80a8922a640784e7cb0d63fb3e20324a41e | AlvisonHunterArnuero/EinstiegPythonProgrammierung- | /spam_catcher.py | 806 | 4.09375 | 4 | # let us create a list containing a set of phrases that could be considered as spam.
# Made with ❤️ in Python 3 by Alvison Hunter - January 28th, 2021
spams_lst = ["make","money","buy","subscribe","click","claim","prize","win","lottery"]
def spam_catcher():
# Bool variable to determine if the phrase is an spam or not... |
ffbaeccca8238647d0d8b397684fad814b47e7e7 | AlvisonHunterArnuero/EinstiegPythonProgrammierung- | /sales_commission_calculation.py | 1,177 | 3.6875 | 4 | # --------------------------------------------------------------------------------
# Calculate Sales commision for sales received by a salesperson
# Made with ❤️ in Python 3 by Alvison Hunter - October 16th, 2021
# JavaScript, Python and Web Development tips at: https://bit.ly/3p9hpqj
# --------------------------------... |
2e0daa14381cb9216d32d9b564747b51fc381487 | AlvisonHunterArnuero/EinstiegPythonProgrammierung- | /MACHINE LEARNING/ai_basic_decision_tree.py | 361 | 3.734375 | 4 | # -------------------------------------------------------------------------
# Basic operations with colletion types | Python exercises | Beginner level
# Made with ❤️ in Python 3 by Alvison Hunter Arnuero - April 7th, 2021
# JavaScript, Python and Web Development tips at: https://bit.ly/3p9hpqj
# ----------------------... |
7d45513f6cb612b73473be6dcefaf0d2646bc629 | AlvisonHunterArnuero/EinstiegPythonProgrammierung- | /decorators.py | 1,146 | 4.96875 | 5 | # INTRODUCTION TO BASIC DECORATORS USING PYTHON 3
# Decorators provide a way to modify functions using other functions.
# This is ideal when you need to extend the functionality of functions
# that you don't want to modify. Let's take a look at this example:
# Made with ❤️ in Python 3 by Alvison Hunter - June 15th, 202... |
27c3847708abed4649efa487ed02fbe4d89904e5 | AlvisonHunterArnuero/EinstiegPythonProgrammierung- | /randomPwdGenerator.py | 1,828 | 4.0625 | 4 | # This function will generate a random string with a lenght based
# on user input number. This can be useful for temporary passwords
# or even for some temporary login tokens.
# Made with ❤️ in Python 3 by Alvison Hunter - December 28th, 2020
from random import sample
import time
from datetime import datetime
# We will... |
ef45a2be2134cdf0754d5f41a9245f4a242fdb0e | AlvisonHunterArnuero/EinstiegPythonProgrammierung- | /updating_dicts_lst.py | 1,327 | 4.40625 | 4 | # -------------------------------------------------------------------------
# Basic operations with colletion types | Python exercises | Beginner level
# Generate list with random elements, find the first odd number and its index
# Create empty dict, fill up an empty list with user input & update dictionary
# Made wit... |
9d079ba2115bf5b9fc4a88255b33959813c6ce1c | AlvisonHunterArnuero/EinstiegPythonProgrammierung- | /reverse_words_order_and_swap_cases.py | 604 | 3.890625 | 4 | # Esta es una antigua Forma de comunicacion inventada por un famoso general salvadoreño
# llamado Francisco Malespin en 1845 a las tropas en el salvador, honduras y nicaragua.
# Made with ❤️ in Python 3 by Alvison Hunter - November 27th, 2020
IN = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
OUT = "ABCDEFGHI... |
f5469143697a9cdcbdf8bd41c326bafa3416137d | AlvisonHunterArnuero/EinstiegPythonProgrammierung- | /euclidian_algorithm.py | 843 | 3.796875 | 4 | # Made with ❤️ in Python 3 by Alvison Hunter - November 3rd, 2020
# primero importaremos este modulo para usar su metodo reduce
import functools as ft
# procedamos ahora a declarar la lista con los numeros que usaremos
numblst = [2, 6, 8, 4, 10, 24, 9, 96]
# Vamos a usar una funcion lambda para hacer nuestro calculo... |
a6be5496ab9c0802d4142373f2dc4724faf74429 | AlvisonHunterArnuero/EinstiegPythonProgrammierung- | /units_inducement_calculations.py | 944 | 4.0625 | 4 | # -------------------------------------------------------------------------
# Basic operations with colletion types | Python exercises | Beginner level
# Get weekly production units per day & calculate if employee gets bonus
# Made with ❤️ in Python 3 by Alvison Hunter Arnuero - April 16th, 2021
# JavaScript, Python an... |
01a58f453134cfd65c7a80a32c61b00cae4bb91f | AlvisonHunterArnuero/EinstiegPythonProgrammierung- | /PYTHON NOTEBOOKS/9.0.6_file_function_questions_&_solutions.py | 2,277 | 4.09375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Oct 26 15:15:24 2019
@author: giles
"""
# Exercises
'''
#Question 1
#Create a function that will calculate the sum of two numbers. Call it sum_two.
#'''
#
#def sum_two(a,b):
# ''' This function returns the sum of two numbers. '''
#
# return a + b
... |
ef10b945cf9569f72e199b22b35f839eae98c7ce | AlvisonHunterArnuero/EinstiegPythonProgrammierung- | /PYTHON NOTEBOOKS/9.0.1_Files_&_Functions.py | 2,846 | 3.6875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Oct 24 10:19:52 2019
@author: giles
"""
# File handling in Python
# Python can open, close, read to and write to files
#f = open('kipling.txt','w')
#
#print(type(f))
#
#f.write('If you can keep your head while all about you \nare losing theirs\
#and blaming i... |
a2a6348689cab9d87349099ae927cecad07ade1a | AlvisonHunterArnuero/EinstiegPythonProgrammierung- | /intro_to_classes_employee.py | 1,839 | 4.65625 | 5 | # --------------------------------------------------------------------------------
# Introduction to classes using getters & setters with an employee details example.
# Made with ❤️ in Python 3 by Alvison Hunter - March 16th, 2021
# JavaScript, Python and Web Development tips at: https://bit.ly/3p9hpqj
# --------------... |
a1f5c161202227c1c43886a0efac0c18be4b2894 | AlvisonHunterArnuero/EinstiegPythonProgrammierung- | /population_growth.py | 1,199 | 4.375 | 4 | # In a small town the population is p0 = 1000 at the beginning of a year.
# The population regularly increases by 2 percent per year and moreover
# 50 new inhabitants per year come to live in the town. How many years
# does the town need to see its population greater or equal to p = 1200 inhabitants?
# ---------------... |
fd287a7a3dad56ef140e053eba439de50cdfd9b6 | AlvisonHunterArnuero/EinstiegPythonProgrammierung- | /dice.py | 983 | 4.40625 | 4 | #First, you only need the random function to get the results you need :)
import random
#Let us start by getting the response from the user to begin
repeat = input('Would you like to roll the dice [y/n]?\n')
#As long as the user keeps saying yes, we will keep the loop
while repeat != 'n':
# How many dices does the use... |
d94493c20365c14ac8393ed9384ec6013cf553d4 | AlvisonHunterArnuero/EinstiegPythonProgrammierung- | /interest_calc.py | 2,781 | 4.1875 | 4 | # Ok, Let's Suppose you have $100, which you can invest with a 10% return each year.
#After one year, it's 100×1.1=110 dollars, and after two years it's 100×1.1×1.1=121.
#Add code to calculate how much money you end up with after 7 years, and print the result.
# Made with ❤️ in Python 3 by Alvison Hunter - September 4t... |
00575e9b32db9476ffc7078e85c58b06d4ed98f2 | AlvisonHunterArnuero/EinstiegPythonProgrammierung- | /format_phone_number.py | 1,248 | 4.1875 | 4 | # --------------------------------------------------------------------------------
# A simple Phone Number formatter routine for nicaraguan area codes
# Made with ❤️ in Python 3 by Alvison Hunter - April 4th, 2021
# JavaScript, Python and Web Development tips at: https://bit.ly/3p9hpqj
# -------------------------------... |
1c03ec92c1c0b26a9549bf8fd609a8637c1e0918 | AlvisonHunterArnuero/EinstiegPythonProgrammierung- | /weird_not_weird_variation.py | 960 | 4.34375 | 4 | # -------------------------------------------------------------------------
# Given an integer,n, perform the following conditional actions:
# If n is odd, print Weird
# If n is even and in the inclusive range of 2 to 5, print Not Weird
# If n is even and in the inclusive range of 6 to 20, print Weird
# If n is eve... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.