blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
79a063c01049ebd270d7105ec1874c35521de1a3
suhang319/exercise
/first/lianmxi.py
1,487
3.984375
4
#_*_ coding:utf-8 _*_ #@Time :2020-11-1922:16 #@Author :lemon_suhang #@Email :1147967632@qq.com #@File :lianmxi.py #@Software:PyCharm age =18 name ="tmo" weight =78.4 student_id =1 print("我的名字是%s" % name) print("我的学号是%4d" % student_id) print("我的体重是%.2f公斤" %weight) print("我的名字是%s,我今年%d岁了" % (name,age)) print...
7c7f9b7a353992d77b1f379a9f84aa2466dd57e5
suhang319/exercise
/第5天/继承.py
2,434
3.859375
4
#_*_ coding:utf-8 _*_ #@Time :2020-12-2016:36 #@Author :lemon_suhang #@Email :1147967632@qq.com #@File :继承.py #@Software:PyCharm class Master(object): def __init__(self): self.kongfu ="[煎饼果子配方]" def make_cake(self): print(f'运用{self.kongfu}制作煎饼果子') class Prentice(Master): pass...
8f04c3ad615ca23de30fb6a7f0746182e4d17827
suhang319/exercise
/第一天/数据转换.py
613
3.90625
4
#_*_ coding:utf-8 _*_ #@Time :2020-11-1514:41 #@Author :lemon_suhang #@Email :1147967632@qq.com #@File :数据转换.py #@Software:PyCharm num = input('请输入您的幸运数字:') print(f'您的幸运数字是{num}') print(type(num)) print(type(int(num))) num1 = 1 print((float(num1))) print((type(float(num1)))) num2= 10 print(type(str(n...
b4a51d3a3ac7ffc3855433a6dcc07033d0474c93
suhang319/exercise
/two/元组.py
712
3.828125
4
#_*_ coding:utf-8 _*_ #@Time :2020-11-2520:06 #@Author :lemon_suhang #@Email :1147967632@qq.com #@File :元组.py #@Software:PyCharm t1 =(10,20,30) t2=(10,) print(type(t1)) print(type(t2)) te =("helll") print(type(te)) # 元组不支持修改 只支持查找 tuple =('aa','bb','cc','bb') print(tuple[0]) # index()用法 tuple =('aa','bb'...
a37a40f52050f952a2d1c90e57ea13a20853da1b
suhang319/exercise
/练习.py
299
3.78125
4
#_*_ coding:utf-8 _*_ #@Time :2020-12-1311:01 #@Author :lemon_suhang #@Email :1147967632@qq.com #@File :练习.py #@Software:PyCharm list = [3,2,1,5,4,0,2] list1=[] for i in list: i = i **2 list.append(i) print(list1) list2 = [3,2,1,5,4,0,2] set1 ={i ** 2 for i in list2} print(set1)
846a95e8f46e67627accaaaaeb7433714f096749
suhang319/exercise
/第一天/循环.py
285
3.75
4
#_*_ coding:utf-8 _*_ #@Time :2020-11-1517:43 #@Author :lemon_suhang #@Email :1147967632@qq.com #@File :循环.py #@Software:PyCharm # 循环变量 n = 0 #循环条件 while n <5: # 循环体 print("媳妇,我错了,第%d" % (n+1)) #循环变量发生变化 n= n+1
70e670f3524cbe464107d88a7b6703c9bd0f6da6
suhang319/exercise
/two/公共操作.py
2,296
3.6875
4
#_*_ coding:utf-8 _*_ #@Time :2020-11-2620:19 #@Author :lemon_suhang #@Email :1147967632@qq.com #@File :公共操作.py #@Software:PyCharm # + 和并 # * 复制 # 元素是否存在 in # 元素是否不存在 not in # 字符串 str1 ="aa" str2 ="bb" str3 =str1 + str2 print(str3) # 列表 list1 =[10,20] list2 =[10,30] lsit3 =list1 + list2 print(lsit3) # 元...
fee1f96f514dd33f4fc9072f638462f4ea01def0
HL-HYX/pyDemo
/石头剪刀布.py
1,305
4
4
#!/usr/bin/env python # _*_ coding:utf-8 _*_ ''' 规则: 石头赢剪刀 剪刀赢布 布赢石头 实现: 1.系统随机出一个数(0,1,2),分别代表石头,剪刀,布 2.用户输入一个数(0,1,2),分别代表石头,剪刀,布 3.将随机数与用户所输入的数相比较 4.注意用户输入的数只能为(0,1,2),不可输错。 ''' import random print("规则如下:\n石头(0),剪刀(1),布(2)") while True: ran_num = random.randrange(0, 3) # 系统所出的手势 user_num = int(inpu...
10220e639aa4b43ff59957fe93113c793275e0a2
sanjeevkumar4574/mile_to_km
/mile_to_km.py
874
4
4
from tkinter import * windom = Tk() windom.title('mile to kilometer convertor') windom.config(padx=20,pady= 20,bg ='white') # Entry widget to get input in miles. entry = Entry(width=7, background ='red') entry.grid(column =1, row=0) # label1 label1 = Label(text= 'Miles', background ='white') label1.grid(column=2, r...
213ec1fc76347b9a3911d1d1f463e363b8a45dc2
catpython/Python-code-demo-
/b2.py
993
3.96875
4
class Person(object): def __init__(self,first_name,last_name,father): self.first_name=first_name self.last_name=last_name self.father=father def printName(self): print("first_name:", self.first_name) print("last_name:", self.last_name) print("father:",self.first_name) #just for print as sam...
a1c2521b83ad7cc88af3cead203f18cb350ba157
jgao222/monte_carlo
/ten_tuple_queue.py
602
3.671875
4
""" A special queue that can only store 10 elements Made so I can keep track of the last ten points and then print them """ from collections import deque class TenTuplesQueue: def __init__(self): self._q = deque() def add(self, tup): # while here just in case more than 10 elements got in so...
e4064c2d5fbb82bc458ccf29b15360372d0324da
agwhitney/quantum_dots
/fem.py
2,873
3.5625
4
"""J Wang's finite element method code Edited by Adam Whitney (primarily increasing readability) """ from numpy import zeros def abg(p1, p2, p3): """Returns alpha, beta, gamma, and area of a triangular element, which are related to the vertex points p1, p2, p3. """ x1, y1 = p1 x2, y2 = p2 x3,...
be5c68d2eedd897e155f6471a1b0e042a291a6f2
GLAU-TND/python-programming-assignment2-namah-shiv
/3.py
235
3.5
4
N=bin(int(input("enter the number"))) a=[] c=1 for i in range(1,len(N)): if(N[i-1]==N[i]): c+=1 a.append(c) else: c=1 print('binary number is',N) print('maximum consecutive number is',max(a))
0c957382dea60d860597e4702ecebc35bfab6861
kannan-c1609/Accenture
/38_Upper_and_Lower_case.py
891
4.125
4
""" Single File Programming Question Write a Python program that accepts a string and calculate the number of upper case letters and lower case letters. Input Format: A string in the first line Output Format: Print the original string in the first line. Number of upper case characters in the second line ...
22e44b6fbe19de104ad494f2c2bd15532455acf7
kannan-c1609/Accenture
/13_SumOfDivisors.py
579
4.125
4
""" Sum of Divisors Given an integer ‘n’ (1 <= n <= 109), find the sum of its unique divisors. Input Specification: Input 1: the integer ‘n’ Output Specification: Return the sum of divisors of ‘n’. Example 1: Input 1: 6 Output: 12 Explanation: Divisors of 6 are 1, 2, 3 and 6. Sum od number (i.e 1 +...
c4e26bd35da92d65d95db31784699242b0cbefee
kannan-c1609/Accenture
/28_Greeting.py
288
4.125
4
""" Create a program that take a name as input and returns a greeting. Examples Input: Gerald Example Output: Hello Gerald! Examples Input: Tiffany Example Output: Hello Tiffany! """ def Greeting(n): return 'Hello ' + n + '!' n = input() print(Greeting(n))
8cd48dd8c97dc1a53ada6678bd4cf3d3c1063325
kannan-c1609/Accenture
/33_Maxima_or_minima.py
1,083
4.15625
4
""" Implement the following function: int MaximaOrMinima(int a, int b, int c); Quadratic equation: A quadratic equation is any equation having the form, ax2 + bx + c, where ‘a’ cannot be zero. The function accepts coefficients of a quadratic equation, ‘a’, ‘b’ and ‘c’ as its argument. Implement the function to f...
6a15a433689efdaba671afe9e049ac15fbf78561
mikewalker92/Masters
/upflow/upwelling.py
1,976
3.8125
4
import iris ''' In this script, we will estimate the global CO2 flux due to upwelling (w). The model used here is that of a column of rising water in a 2 layer ocean. The top layer is warmer than the bottom layer by an amount dT. The rate at which water passes into this top layer is the rate of upwelling, w. When w...
f833d8a89d705ec93323d4a7521ed4e5e022954f
rodrigoqfcosta/Estrutura_Dados
/recursao.py
3,102
4.46875
4
''' Existem dados que tem uma caracteristica especial Chamamos de instancia o valor concredto que usamos ao chamar um método na função ''' def soma (a, b): print (f' Instancia: f({a}, {b})') return a+b #Até aqui so tenho uma função na memoria, nao tenho uma instância rodando print("Resultado:",soma...
8638b9e889149537ea76b5a4898ba511e4c869b3
aziddddd/parameter-estimation
/biexponential-decay-particle/data-generator/part1.py
6,900
3.796875
4
""" MyPDF, a class for generating random events with decay time and angle distributions according to the PDF described in the report. Authors: Azid Harun Date : 25/11/2018 """ import math import numpy import scipy.integrate as integrate import matplotlib.pyplot as plt import sys class PDFError(Exce...
b982c1c2e82ede46d257fc5f25aff78cbf7bc291
carlysonviana/AulasPython
/criptografia.py
792
4
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: lista = ['A','B','C','D','E','F','G','H','I','J'] while True: senha = input("Digite uma senha: ") if len(senha) < 6: print("Senha invalida!") pass elif len([x for x in senha if x not in lista]) != 0: print("Senha invalida!") ...
53a6208168d97b4b3ea6faa20d847e5ae58c0212
Environmental-Informatics/python-learning-the-basics-steve276
/steve276_Exercise3.3.py
1,244
3.734375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Jan 21 23:22:10 2020 by Miriam Stevens @author: steve276 ABE65100 - ThinkPython - Excercise 3.3 This program draws a 4x4 grid """ # prints row dividers def prt_a(): print('+ - - - -', end =" ") print('+ - - - -', end =" ") pr...
ec168af54000e4afe993b7fee9e88795658b8784
YoungCC/McCabe-Cyclomatic-Complexity
/parser/cases/1_Mytest_try_except.py
191
3.96875
4
def f(): D = {'jack':100, 'rose':101} for x in range(3): print "hello" try: print D[x] except: print "bad key" except: print "" for x in range(3): print x
cf17c5607441816e6dc149c990bbd20954292db3
AmanKishore/CodingChallenges
/Cracking the Coding Interview/Trees and Graphs/PathswithSum.py
2,189
3.921875
4
''' Paths with Sum: Method 2: Traverse through the tree using DFS. As we visit each node: 1. Track its runningSum.We'll take this in as a parameter and immediately increment it by node.val 2. Look up runningSum - targetSum in the hash table. The value there indicates the total number. Set totalPaths to this...
8d8afbe05d6b642fbfcf39aebe148abbb9afc2c7
AmanKishore/CodingChallenges
/Cracking the Coding Interview/Sorting and Searching/GroupAnagrams.py
784
4.34375
4
''' Group Anagrams: Write a method to sort an array of strings so that all of the anagrams are next to each other. ''' def GroupAnagrams(strings): anagrams = {} for i in range(len(strings)): key = "".join(sorted(strings[i].lower())) # get the key by sorting the string if key not in anagrams...
e875661a65534f55242470734e3f1a2a423a6e6e
AmanKishore/CodingChallenges
/Interview Cake/Arrays and Strings/SingleRiffle.py
658
3.765625
4
''' Single Riffle Shuffle: Write a function to tell us if a full deck of cards shuffled_deck is a single riffle of two other halves half1 and half2. Input: ([1, 4, 5], [2, 3, 6], [1, 2, 3, 4, 5, 6]) Output: true ''' def is_single_riffle(half1, half2, shuffled_deck): idx1, idx2 = 0, 0 for card in...
32c84bd9254d29fcb27604ae5d501bea536f70ac
AmanKishore/CodingChallenges
/Interview Cake/Recursion and Dynamic Programming/Fibonnaci.py
790
4.375
4
''' Fibonacci: Find the Nth fibonacci number. ''' memo = {0 : 0, 1 : 1} def fib(n): # Compute the nth Fibonacci number if n in memo: return memo[n] else: memo[n] = fib(n-1) + fib(n-2) # Store the newest discovered number return memo[n] def fib_bottom_up(n): if n < 0: ...
e9200b08abe892e1cc70fcb5d2e7ca824a3563c2
AmanKishore/CodingChallenges
/Interview Cake/Stacks and Queues/MatchingParenthesis.py
480
3.640625
4
''' Matching Parenthesis Write a function given the position of an opening parenthesis, finds the corresponding closing parenthesis. ''' def get_closing_paren(input, idx): stack = [] for i in range(idx + 1, len(input)): # Start right after the index of first one if input[i] == '(': st...
5b3d31d2fd939e84416653df6e4c9e04c20f9dcb
AmanKishore/CodingChallenges
/Interview Cake/HashMaps/PermuationPalindrome.py
503
4
4
''' Permutation Palindrome Write an efficient function that checks whether any permutation of an input string is a palindrome. Ex: "ivicc" should return True "civil" should return False ''' def palindrome_permutation(string): unpaired = set() # Track Odd Characters for char in string: ...
a7580dd2eefc877d111ada8784c4121f1c46c96d
AmanKishore/CodingChallenges
/Cracking the Coding Interview/Trees and Graphs/TopologicalSort.py
1,248
4.03125
4
''' Topological Sort: The linear ordering of vertices such that for every directed edge uv, vertex u comes before v in the ordering. ''' from collections import defaultdict class Graph: def __init__(self, vertices): self.graph = defaultdict(list) #dictionary containing adjacency List se...
317f96f28ade7d9e0ee8a214944d706de0ac2cd9
AmanKishore/CodingChallenges
/Interview Cake/Combinatorics/BinarySearch.py
308
3.890625
4
''' Binary Search: Binary Search ''' def binary_search(nums, target): l = 0 r = len(nums) - 1 while l <= r: m = l + (r-l)/2 if nums[m] == target: return m elif target < nums[m]: r = m - 1 else: l = m + 1 return -1
88b0178e34b3f8a98a277fd42725d5e663b3bfb0
AmanKishore/CodingChallenges
/Cracking the Coding Interview/Recursion and Dynamic Programming/RobotGrid.py
911
4.03125
4
''' Robot In a Grid: Determine if threre is a path for the robot if it can only move down and right. ''' def getPath(maze): if not maze or len(maze) == 0: return None path = [] failedPoints = [] if isPath(maze, len(maze)-1, len(maze[0])-1, path, failedPoints): return path return...
a614d70ef55dd7bbbe7cba0d438bce2a98f8f58d
zhoujin7/casestyle
/casestyle.py
2,089
3.5625
4
# coding=utf-8 import re def camelcase(string): s_list = casepreprocess(string) if s_list: string = ''.join(s.title() for s in s_list) string = string[0].lower() + string[1:] return string return '' def pascalcase(string): s_list = casepreprocess(string) if s_list: ...
ecec89a7f52eb309e7c01a35132cfe083d038ba1
vardhan-duvvuri/Challange
/ch18.py
195
3.890625
4
def splitWord(word, numOfChar): output = [] for i in range(0,len(word),numOfChar): output.append(word[i:i+numOfChar]) return output if __name__ == "__main__": print splitWord('google', 3)
01a7deb2f7a7b7e12aeb0f75ff1514d6bef815d8
vardhan-duvvuri/Challange
/ch10.py
257
3.703125
4
def getCommonLetters(word1, word2): li1=[] li2=[] for i in word1: li1.append(i) for j in word2: li2.append(j) return "".join(x for x in list(set(li1).intersection(set(li2)))) if __name__ == "__main__": print getCommonLetters('microsoft','apple')
6a1ae5ee59a0f726995e79ef161e79cf4a5c16de
vardhan-duvvuri/Challange
/ch23.py
230
4.125
4
def reverseLookup(dictionary, value): output = [] for key,val in dictionary.iteritems(): if val == value: output.append(key) return sorted(output) if __name__ == "__main__": print reverseLookup({'a':1, 'b':2, 'c':2}, 2)
c5b9cd4efb400faed6e6ca07ed0722f35129fc42
vardhan-duvvuri/Challange
/ch16.py
380
3.765625
4
def isAllLettersUsed(word, required): letters = [] requiredlist = [] for i in required: letters.append(i) letters = set(letters) for i in word: requiredlist.append(i) requiredlist = set(requiredlist) if len(letters.intersection(requiredlist)) == len(letters): return True else: return False if __name...
a51db982f123b89357930f79b1061be6b1c23c68
vardhan-duvvuri/Challange
/ch25.py
216
3.5625
4
def convertVector(numbers): out = {} for i in range(len(numbers)): if numbers[i] != 0: out[i] = numbers[i] return out if __name__ == "__main__": print convertVector([1, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0, 4])
de6afda4f902247b2564d347e687f5621d9a3bed
csgn/MY_DOCS
/pyNotes/note02.py
384
3.75
4
#!/usr/bin/env python from datetime import date, datetime class Book: def __init__(self, author:str, name:str, issueDate:date, numberOfPages:int): self.author = author self.name = name self.issueDate = issueDate self.numberOfPages = NumberOfPages x = Book("Paulo Coelho", "Alchemist", date(2018...
dc9c43acac3914eda03fe13c87882638aee26eff
harshita3199/basic_programming_codes
/finding_prime_till_n.py
527
4.09375
4
#finding the prime number till n def listprime(num): lst=[] print(num) for n in range(2,num+1): if(n>0): isDivisible=False for i in range(2,n): if(n%i==0): isDivisible=True break if not isDivisible: ...
1d6bc423fc32cec33981e5c4a10b61d59959ddf7
jb4503/PHYS4100_JBermeo
/Problem2.py
1,648
4.40625
4
import math import argparse import sys # A spaceship travels from Earth in a straight line at relativistic speed v to another planet x light years away. # Write a program to ask the user for the value of x and the speed v as a fraction of the speed of light c, # then print out the time in years that the spaceship take...
cd260a299fd88a32a46742e90355b1a9db4657d5
jb4503/PHYS4100_JBermeo
/PHYS4100_HW1.py
930
4.3125
4
import math import argparse # A ball is dropped from a tower of height h with initial velocity zero. # Write a program that asks the user to enter the height in meters of the tower # and then calculates and prints the time the ball takes until it hits the ground, # ignoring air resistance. Use your program to calculate...
0088252cfc015a81fd6e1d254e5a3e5b464ea692
luuhoailinh/apriori_code
/apri.py
1,463
3.6875
4
#!/usr/bin/env python # coding: utf-8 # In[24]: get_ipython().system('pip install apyori') # In[25]: import numpy as np import matplotlib.pyplot as plt import pandas as pd from apyori import apriori # In[26]: store_data = pd.read_csv('store_data.csv', header=None) # In[27]: store_data.head() # ## conve...
328762efec4c27a355b6a573a335da994a4f8ae5
davidhawkes11/PythonStdioGames
/src/gamesbyexample/trickquestions.py
10,284
3.890625
4
"""Trick Questions, by Al Sweigart al@inventwithpython.com A quiz of several trick questions.""" import random, sys QUESTIONS = [ {'question': "How many times can you take 2 apples from a pile of 10 apples?", 'answer': "Once. Then you have a pile of 8 apples.", 'accept': ['once', 'one', '1']}, {'question': 'Wh...
5a7b83a627d2fb5383e44c48ace87adcb1ba8581
davidhawkes11/PythonStdioGames
/src/gamesbyexample/analogclock.py
5,474
3.765625
4
"""Analog Clock, by Al Sweigart al@inventwithpython.com An analog clock animation. Press Ctrl-C to stop.""" __version__ = 1 import time, math, sys try: import bext except ImportError: print('''This program requires the bext module, which you can install by opening a Terminal window (on macOS & Linux) and run...
dc367a7922642a45abec48c4c2751ec0256d7e92
davidhawkes11/PythonStdioGames
/src/gamesbyexample/bouncingDots.py
3,814
3.59375
4
"""Bouncing Dots, by Al Sweigart al@inventwithpython.com A bouncing dots animation. Press Ctrl-C to stop. NOTE: Do not resize the terminal window while this program is running.""" __version__ = 1 import sys, random, time try: import bext except ImportError: print('''This program requires the bext module, wh...
c24aecd56e1e0074953f4097b2b9c273677e30b5
davidhawkes11/PythonStdioGames
/src/gamesbyexample/periodictable.py
3,691
4
4
"""Periodic Table of Elements, by Al Sweigart al@inventwithpython.com Displays atomic information for all the elements.""" __version__ = 1 # Data from https://en.wikipedia.org/wiki/List_of_chemical_elements # Highlight the table, copy it, then paste it into a spreadsheet program # like Excel or Google Sheets like in ...
b5a63f9f82ef1fdb13fdc7d917c7c0ed8d4a4c7b
davidhawkes11/PythonStdioGames
/src/gamesbyexample/pegsolitaire.py
5,324
3.953125
4
"""Peg Solitaire, by Al Sweigart al@inventwithpython.com A single-player, peg-jumping game to eliminate all the pegs. More info at https://en.wikipedia.org/wiki/Peg_solitaire""" __version__ = 1 import sys EMPTY = '.' PEG = 'O' NORTH = 'N' SOUTH = 'S' EAST = 'E' WEST = 'W' ALL_SPACES = 'C1 D1 E1 C2 D2 E2 A3 B3 C3 D3 ...
6b74465580a05da5e329c65a7cfb4483dc9a29ed
davidhawkes11/PythonStdioGames
/inprogress/dropspin.py
5,904
3.71875
4
# Dropspin, by Al Sweigart al@inventwithpython.com # TODO - check when puzzle is complete import sys, random, copy BLOCK_CHAR = chr(9608) TOP_BLOCK = chr(9600) # Character 9600 is '▀' BOTTOM_BLOCK = chr(9604) # Character 9604 is '▄' FULL_BLOCK = chr(9608) # Character 9608 is '█' NO_BLOCK = ' ' BORDER_CHAR = chr(96...
e147726475f4efe235ee2004edf59704db588801
davidhawkes11/PythonStdioGames
/src/gamesbyexample/zigzag.py
864
3.703125
4
"""Zigzag, by Al Sweigart al@inventwithpython.com A simple zig zag animation. Press Ctrl-C to stop.""" __version__ = 1 import time, sys indentSize = 0 # How many spaces to indent. try: while True: # The main program loop. # Zig to the right 20 times: for i in range(20): indentSize = i...
5696760cdc7f2832181bcad4937ef218244e7e71
davidhawkes11/PythonStdioGames
/src/gamesbyexample/fourinarow.py
6,409
3.984375
4
"""FOUR IN A ROW, by Al Sweigart al@inventwithpython.com A tile-dropping game to get four in a row, similar to Connect Four.""" __version__ = 1 import sys # Constants used for displaying the board: EMPTY_SPACE = '.' # A period is easier to count than a space. PLAYER_X = 'X' PLAYER_O = 'O' # Note: Update BOARD_TEMPLA...
74241bc87065aa6eea8c3341208ce769f34414c0
davidhawkes11/PythonStdioGames
/src/gamesbyexample/eenymeeny.py
3,965
4.09375
4
"""Eeny-Meeny-Miny-Moe, by Al Sweigart al@inventwithpython.com An elimination game for multiple players. Press Ctrl-C to stop. More info at https://en.wikipedia.org/wiki/Eeny,_meeny,_miny,_moe More info at https://en.wikipedia.org/wiki/Josephus_problem""" __version__ = 1 import random, time, sys SCREEN_WIDTH = 60 RH...
6ec17b3c289e8386b4255a61f05401d3a50f04b9
davidhawkes11/PythonStdioGames
/src/gamesbyexample/ulamspiral.py
1,787
3.78125
4
"""Ulam Spiral, by Al Sweigart al@inventwithpython.com The Ulam spiral is a mysterious mathematics pattern for prime numbers with turtle graphics. More info at https://en.wikipedia.org/wiki/Ulam_spiral""" __version__ = 1 import turtle import math turtle.tracer(1000, 0) # Make the turtle draw faster. SPACING = 3 DOT...
658810ed7a2ecafb78614e5abca6752301d6169f
davidhawkes11/PythonStdioGames
/src/gamesbyexample/magichexagon.py
6,378
4.03125
4
"""Magic Hexagon, by Al Sweigart al@inventwithpython.com Place numbers in a hexagon so each row adds up to 38. More info at https://en.wikipedia.org/wiki/Magic_hexagon More info at https://www.youtube.com/watch?v=ZkVSRwFWjy0""" __version__ = 1 import sys # Print the title and instructions: print('''MAGIC HEXAGON By ...
f8db5c7ee03aa32d66f337f9f18b76a1f1ba5680
HiroKHuang/shiyanlou
/calculator_project/calculator_tax_ver1.py
492
3.84375
4
#!/usr/bin/env python3 import sys try: salary = int(sys.argv[1]) - 3500 except ValueError: print("Parameter Error") if salary <= 1500: tax = salary * 0.03 elif salary <= 4500: tax = salary * 0.1 - 105 elif salary <= 9000: tax = salary * 0.2 - 555 elif salary <= 35000: tax = salary * 0.25 - 10...
cb1327c8f9f7549fabdd73f52e1e20f58c5758c8
k99sharma/AlienInvasion1.0
/alienInvasion.py
9,164
3.6875
4
""" Alien Invasion Game Version: 1.0 Author: Kalash Sharma Github: ghost_32 Date: 25 August 2020 """ # Importing libraries import math import random import sys import pygame # Initializing pygame pygame.init() # screen screen = pygame.display.set_mode((800, 600)) # Images ship1 = 'images/spaceship....
955d166f1f62e1006ee0d11898333eee60312e02
zuzinmeko/Python_lessons
/Chapter1/error_find.py
142
3.640625
4
# -*- coding: utf-8 -*- """ Created on Sat Sep 4 13:01:05 2021 @author: hp """ from math import sin x = 1; print('sin(%g)=%g' %(x, sin(x)))
af212d3ac013ed7cf7329f9c53ea045425667e10
zuzinmeko/Python_lessons
/Chapter2/index_nested_list.py
378
3.859375
4
# -*- coding: utf-8 -*- """ Created on Mon Aug 30 11:37:20 2021 @author: Lenovo """ q = [['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h']] print (q[0][0]) print (q[1]) #list (d,e,f) print (q[-1][-1]) #last element 'h' print (q[1][0]) #letter 'd' for i in q: #i are the lists of elements within q for j in range(len(i)...
66001855469feeb7d215c0a98b86b24810ff7d56
zuzinmeko/Python_lessons
/Chapter1/formulas_shapes.py..py
490
4.0625
4
# -*- coding: utf-8 -*- """ Created on Sat Sep 4 13:02:37 2021 @author: hp """ from math import pi h = 5.0 # height b = 2.0 # base r = 1.5 # radius area_parallelogram = h*b print ('The area of the parallelogram is %.3f’ % area_parallelogram') area_square = b**2 print ('The area of the square is %g’ % area_square') a...
8e97dcf1f10ee9d75f07c78ee98de09059e72b60
zuzinmeko/Python_lessons
/Chapter1/mathsqrt.py
218
3.5625
4
# -*- coding: utf-8 -*- """ Created on Fri Sep 3 11:51:30 2021 @author: hp """ import math r = math.sqrt(2) print(r) from math import sqrt d = sqrt(3) print(d) from math import * e = sqrt(4) print(e) print(sqrt(7))
b04dc337d96da4ef5c88ce017fc99f81160721f6
JaySwitzer/InformationTechnology
/calculator.py
414
4.28125
4
num1 = int(input("Enter Number 1: ")) num2 = int(input("Enter Number 2: ")) oper = input ("Enter the operator:") if oper == "*": ans = num1 * num2 print (num1,oper,num2,"=",ans) elif oper == "/": ans = num1 / num2 print (num1,oper,num2,"=",ans) elif oper == "+": ans = num1 + num2 print (num1,...
a93fad224215a81a594ebeedd9a034fc6334d012
shoe116/algo_study
/python/stack.py
791
3.9375
4
# coding: utf-8 class Node(object): def __init__(self, value): self.value = value self.next = None class Stack(object): def __init__(self): self.top = None def push(self, value): if self.top is None: self.top = Node(value) else: node = self.top self.top = Node(value) ...
53f6a5396c3391e00a5a7e538c770176a9c06e89
patilsachin6161/samplePythonExample
/RemoveDuplicateCharacterInSTring.py
167
3.859375
4
StringExm = "HELLLOHELLOHELLO" list1 = [] for ch in StringExm: if ch not in list1: list1.append(ch) print("Unique Char from String "+"".join(list1))
a5c911ec2190665880832c649c4a7b8da1ce66a5
RyLucky888/my-app
/decorator_lesson1.py
628
3.78125
4
def decorator(func): def wrapper(*args,**kwargs): func() print('ok, decorating...{0}'.format(func.__name__)) print('making skin and lips beautiful now') func.skin='tan' func.lips = 'smooth' print('you are now beautiful and you should be called beautiful') func...
10359e06201a5f450eee77a4acc63b75a15a4c42
ykingdsjj/CourseSelect
/core/teacher.py
898
3.625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2018/12/22 10:29 AM # @Author : zhangjiang # @Site : # @File : src.py # @Software: PyCharm teacher_info = {'name':None} def teacher_login(): pass def choose_teacher_course(): pass def check_course(): pass def check_student(): pass ...
3c44814bdafeca98736b4998d4cb604c5cc48811
StevenLu2004/Arduino
/WindTurbine/retrieval.py
1,660
3.71875
4
import datetime as dt import serial import time """ Get the current date and time as a string @return {str} a string representing the current date and time """ def getTimeString(): d = dt.datetime.now() return d.strftime("%Y_%m_%d__%H_%M_%S") """ Initialize the computer-side serial and call the ne...
15ecdb4422955b11f489ce3097583f95fdc5c9ff
umraz-hussain/test_repo
/test.py
417
3.84375
4
print("HI there, Umraz Hussain, im just testing git here.. Thank you!") print("lets add some more code here to see changes in git..") n = input("Enter your mood: ") if n == "sad": print("Play some game..") else: print("Listen to some songs...") #def sum(n1,n2): # return n1+n2 #n1 = int(input('Enter first num...
e25fc3262cb551f725cc7010edcbb383fed6d802
Tiiaraa1907/machineLearningPath
/transformChar.py
3,097
4
4
# upper # kata = 'dicoding' # kata = kata.upper() # print(kata) # lower # kata = 'DICODING' # kata = kata.lower() # print(kata) # # rstrip (hapus spasi belakang) # print('Dicoding '.rstrip()) # # lstrip (hapus spasi depan)\ # print(' Dicoding'.lstrip()) # # strip (hapus spasi depan belakang, dan menghapus kat...
249836c577560361ff81acdc892e3ea5bedca8c3
newstar123/Pythonlab_DEV
/Taining/Books/Core Python Programming 2nd Edition/Chapter 6/idcheck.py
1,055
3.984375
4
#!/usr/bin/env python #coding:utf-8 import string alphas = string.letters + '_' nums = string.digits print 'Welcome to the Identifier Checker v1.0' print 'Testees must be at least 2 chars long.' myInput = raw_input('Identifier to test? ') if len(myInput) > 1: if myInput[0] not in alphas: print '''inval...
efbe5750b9c79bfa7b5de85521a7c59474c520bf
newstar123/Pythonlab_DEV
/Taining/Books/Core Python Programming 2nd Edition/Chapter 13/hotel.py
1,239
3.828125
4
#!/usr/bin/env python #coding:utf-8 #定义一个类来计算旅馆租房费用,包括所有州销售税和房税。 class HotelRoomCalc(object): 'Hotel room rate calculator' def __init__(self, rt, sales=0.085, rm=0.1): '''HotelRoomCalc default arguments: sales tax == 8.5% and room tax == 10%''' self.salesTax = sales self.roomTax...
b416ec27c7e16d158e89b82a96d32a7c190c728e
Duk4/Microsoft-Python-for-beginners
/complex_conditions.py
488
4.1875
4
gpa = float(input('What was your Grade Point Average? ')) lowest_grade = float(input('What was your lowest grade? ')) # if gpa >= 0.85: # if lowest_grade >= 0.70: # print('You made the honour role!') # if gpa >= 0.85 and lowest_grade >= 0.70: # print('You made the honour role!') if gpa >= 0.85 and lo...
a2e1faf19f6a4f1bafdeddeb05cd070b95900bd2
Duk4/Microsoft-Python-for-beginners
/nums.py
645
4.21875
4
# pi = 3.14159 # print(pi) # first_number = 6 # second_number = 2 # print(first_number + second_number) # print(first_number ** second_number) # first_number = input('Enter first number: ') # second_number = input('Enter second number: ') # print(first_number + second_number) you get a string # print(first_number ** ...
b162cafbafbee522b1ca9d614a6e6f4f92c36166
oran2527/holbertonschool-higher_level_programming
/0x0A-python-inheritance/100-my_int.py
254
3.84375
4
#!/usr/bin/python3 """Module Myint Description: change the operator == and != Return: True or False""" class MyInt(int): """MyInt class.""" def __repr__(self): """repr function.""" return 'False' if self == 1 else 'True'
1fe0b87a6035e781010e6c07b96a540b7578ed07
oran2527/holbertonschool-higher_level_programming
/0x01-python-if_else_loops_functions/8-uppercase.py
259
3.828125
4
#!/usr/bin/python3 def uppercase(str): let = "" for x in range(0, len(str)): if ord(str[x]) >= 97 and ord(str[x]) <= 122: let += chr(ord(str[x]) - 32) else: let += chr(ord(str[x])) print("{:s}".format(let))
fd09f4bb306bbef6b2d93c2f8b0c91867b6dfd42
oran2527/holbertonschool-higher_level_programming
/0x0B-python-input_output/12-student.py
835
3.671875
4
#!/usr/bin/python3 """ My class module """ class Student: """ Student class """ def __init__(self, first_name, last_name, age): self.first_name = first_name self.last_name = last_name self.age = age def to_json(self): """to_json function""" return self de...
93deefbf280147fc2da903f38a12b86f0a105439
tpalit98/Raspberry-Pi-Morse-Code
/Main.py
2,795
4.03125
4
#A project that uses the Raspberry Pi and a LED to display morse code import time import RPi.GPIO as GPIO #Sets the numbering style of the GPIO pins GPIO.setmode(GPIO.BOARD) #Sets up the pin the LED will use GPIO.setup(8,GPIO.OUT) #Blink intervals in seconds SHORT_BLINK = 0.3 LONG_BLINK = SHORT_BLINK*3 #Dictionary...
731c8d3be4cb272271dd2326dcbdad770e7f3147
pypr-2122/pp-w06-lecture
/splittedtext_lc.py
198
4.09375
4
# using list comprehensions for texts mysentence = 'Random fact I am a fan of jam' words = mysentence.split() print(words) ending_m = [word for word in words if word[-1] == 'm'] print(ending_m)
e4742c38833e3e2b0828ed16b3f46bef9f7cbafe
letsjdosth/fluentPython
/chap16/yield_from_replace_for_585.py
1,368
3.84375
4
#yield from #사용처 1: for 루프 안 yield의 단축 (chap14 yield_from_basic535.py와 동일) #예1 def gen(): for c in 'AB': yield c for i in range(1,3): yield i def gen2(): #gen()과 완전히 동일하다 yield from 'AB' yield from range(1,3) print(list(gen())) #['A', 'B', 1, 2] print(list(gen2())) #['A', 'B', 1, 2] #예2 def chain(*iterable...
15f6446d0ccc3093823e0b23da1872f87de6aabf
letsjdosth/fluentPython
/chap12/problem_of_inheritance_of_built-in_type440.py
1,712
3.703125
4
#CPython에서 C로 짜여진 부분에 있어서는, 해당 클래스를 파이썬 내에서 상속받아 메서드를 오버라이드해도 동작하지 않는다 #예1 class DoppelDict(dict): def __setitem__(self,key,value): super().__setitem__(key,[value]*2) dd=DoppelDict(one=1) print(dd) #{'one': 1} #<-{'one': [1, 1]}이 아니다! dict의 __init__이 __setitem__의 오버라이드를 무시해버렸다.. dd['two']=2 print(dd) #{'one': 1, ...
ca85fdfaa0dffcc66c543dc5d29d213ecbeab3c9
letsjdosth/fluentPython
/chap2/genExp64.py
708
3.78125
4
symbols='$¢£¥€¤' print(tuple(ord(symbol) for symbol in symbols)) import array print(array.array('I',(ord(symbol) for symbol in symbols))) #I: unsigned int ''' first arg in array.array(arg,data) Type code / C Type / Python Type / Minimum size in bytes 'b' / signed char / int / 1 'B' / unsigned char / int / 1 'u' / Py_...
00987042099374983feeee2bd9840620c3bd1bf4
letsjdosth/fluentPython
/chap19/property/blackknight739_deleter.py
1,805
3.609375
4
#딜리터 class BlackKnight: def __init__(self): self.members=['an arm','another arm','a leg','another leg'] self.phrases=["'Tis but a scratch.","It's just a flesh wound.","I'm invincible!","All right, we'll call it a draw."] @property def member(self): print('next member is:') return self.members[0] @member.d...
96dc5c5f44a5674406e4f16587b47758bdedc6e1
adithyanps/Anandology-Solutions
/chapter5-6/tree_reverse.py
164
3.953125
4
import sys def reverse(x): i = 0 while i<len(x): if isinstance(x[i],list): reverse(x[i]) i=i+1 x.reverse() return x print reverse([[1,2],[3,[4,5]],6])
12833e24ae33fa2db1f1488f980d7cabbc087c32
adithyanps/Anandology-Solutions
/chapter1-2/invertdict.py
154
4
4
import sys def invert(x): d={} list=x.items() i=0 while i<len(list): d[list[i][1]]=list[i][0] i=i+1 return d print invert({'x':1,'y':2,'z':3})
94be0daff153b19e329367058d12e59df0e1dd35
jrcolas/Learning-Python
/100DaysBootcamp/Day15/CoffeeMachine.py
3,092
4.125
4
# Start of day 15 file. # Author: JrColas # 1. Print report. # 2. Check if resource is sufficient. # 3. Process coin. # 4. Check transaction successful. # 5. Make coffee. from menu import MENU, resources # Declarations avail_water = resources["water"] avail_milk = resources["milk"] avail_coffee = resources["coffee"...
587afe3ab9a77f586b3230bc5276600e411324b2
jrcolas/Learning-Python
/100DaysBootcamp/Day25/states/main.py
1,721
3.75
4
import turtle import pandas from stateplotter import StatePlotter screen = turtle.Screen() screen.title("U.S. States Game") image = "blank_states_img.gif" screen.addshape(image) turtle.shape(image) # # Getting state coordinate values from mouse click # def get_mouse_click_coor(x, y): # print(x, y) # # turtle.onsc...
5840505b583e8a27ad247cac1e3dc56447c3ed46
jrcolas/Learning-Python
/100DaysBootcamp/Day12/numberGuessing.py
1,450
4.15625
4
from art import logo from random import randint import os EASY_GUESS = 10 HARD_GUESS = 5 randomNumber = randint(1,100) os.system('cls') print(logo) print("Welcome to the Number Guessing Game!") print("I'm thinking of a number between 1 and 100.") difficulty = input("Choose a difficulty. Type 'easy' or 'hard': ").l...
1f08aca1d07f8e0a785b22aa64f2c6d70ab2279d
jrcolas/Learning-Python
/100DaysBootcamp/Day18/day18.py
1,439
3.71875
4
import turtle import random timmy = turtle.Turtle() turtle.colormode(255) #timmy.shape("turtle") #timmy.color("chartreuse2") # Drawing a square # for _ in range(4): # timmy.forward(100) # timmy.right(90) # Drawing a dashed line # for _ in range(15): # timmy.pd() # timmy.forward(10) # timmy.pu() #...
9bda24413a020140909a4b349ccedc261ea827fc
danwilliams34/Aktivitiez-bro
/bubble.py
410
3.9375
4
def swap(inlist, item): a = inlist[item] b = inlist[item + 1] inlist[item] = b inlist[item+1] = a return (inlist) def sort(sortList): swapped = True while swapped: swapped = False for item in range(len(sortList)-1): if sortList[item]>sortlist[item +1]: ...
fbf17a4b2389de4c7c6be95d7751a922d9b1359d
mveilleux/ml-for-trading
/ml.py
1,224
3.640625
4
from scipy import stats from sklearn import neighbors import numpy as np ''' # Linear Regression learner = LinRegLearner() # Makes an instance of the learner learner.train(Xtrain, Ytrain) # Trains the model with our data Y = learner.query(Xtest) # run test data to get the y data # KNN learner = KNNLearner(k=3) # sets ...
8187cbc384ad409f92ee1a2e807827242f8cab8f
satish259/Elevator
/Trip.py
444
3.84375
4
class Trip(object): """represents one elevator trip code from https://raw.githubusercontent.com/mxvanzant/pyelevator/master/elevator.py """ def __init__(self, trip): items = trip.split('-') self.startFloor = int(items[0]) self.endFloor = int(items[1]) if self....
3503bbf670e20960ffb54294ae13695cbbdb3de2
Michaelllllll25/Python-Learn
/Lists.py
2,435
4.34375
4
######################################### 5.1. Creating a list empty_list = [] empty_list #[] another_empty_list = list() another_empty_list #[] odd_nums = [1, 3, 5, 7, 9] odd_nums #[1, 3, 5, 7, 9] my_friends = ["Jim", "Joe", "Sally"] my_friends #['Jim', 'Joe', 'Sally'] vowels = ['a', 'e', 'i', 'o', 'u'] vowels #['a', ...
d3b76e9a095a627c181beeeca866789b056c4836
virajdesaiofficial/Currency-Converter
/getRate.py
455
3.5
4
#returns the conversion rate of country c2 wrt country c1 def getRate(c1,c2): r1,r2,flag=0,0,0 f=open('ConversionRates.txt','r') f1=f.readlines() for line in f1: c,r=line.strip().split(" ") if c==c1: flag+=1 r1=float(r) #rate between c1 and USD if c==c2: flag+=1 r2=float(r) #rate between c2 and U...
4c5eb5f2ede3d530ba1e7e87b06feeee73a9b698
inwk6312fall2018/programmingassignmentone-LakshayC
/1task1.py
2,550
3.75
4
'''THIS IS THE FUNCTION WHICH WILL RETURN A LIST OF (INTERFACE NAME,"nameif"- VALUE''' def int_and_int_name(file_name): file=open(file_name) list1=[] list2=[] #INTERFACE list3=[] #INTERFACE NAME list4=[] #TUPLE for l in file: l=l.strip() for word in l.split(): list1.append(word) # WILL MAKE A LIST OF A...
71db3c127edabdfaaa0b7b02fb9fadf96456de6b
iakinsey/things
/test/test_operator.py
950
3.53125
4
import things import unittest from queue import Queue class TestPutOperator(unittest.TestCase): def test_put(self): ''' Send a message to an actor using the put sugar syntax. ''' # use a queue queue = Queue() message = "hello world" class Actor(things.Acto...
c23e974f64979c06a1e7110e5934439ddd5c2c46
a01748155/Mision-04
/Triangulos.py
1,586
4.03125
4
# Autor: Erick David Ramírez Martínez, A01748155 """Descripción, programa que lee los 3 lados de un triángulo y con base a ello, descubre si el triángulo existe y lo clasifica según corresponda""" def calcularLaExistencia(lado1, lado2, lado3): if lado1+lado2 > lado3 and lado1+lado3 > lado2 and lado2+lado3 >...
2846974b37536874fc1b2fe56ea204171fcd66b1
surajsomani/Basic_Python
/Python Basics/22_Reading_CSV.py
1,244
4.46875
4
import csv #library to handle csv files with open('example.csv') as csvfile: #naming the file as csvfile readCSV = csv.reader(csvfile, delimiter=',') #reading the file for row in readCSV: #reading each row print(row) #print all columns in 1st row print(row[0]) #print 1st column Here also index s...
0b798c3c17c0b3302603edc792beb7c7ef9701cb
ferasmis/Repeated-Number-Finder-In-A-List
/RepeatedNumberList.py
241
4.15625
4
## Author: Feras ## Description: A program that finds repeated values in a list def repeated(myList): for i in myList: if myList.count(i) > 1: return i print("The repeated number is: ", repeated([1,2, 45, 67, 45]))
8c04bdb819419a5e0c0e18fcaa2040320e845436
thekuldeep07/DS-ALGO-PYTHON
/Sorting/InsertionSort.py
203
3.921875
4
def InsertionSort(arr): n=len(arr) for i in range(1,n): key=arr[i] j=i-1 while j>=0 and key<arr[j]: arr[j+1]=arr[j] j-=1 arr[j+1]=key
24700a9f78e4d5c99f6733aa1d2877bd6c09d63d
thekuldeep07/DS-ALGO-PYTHON
/LinkedList/SinglelinkedList implementation.py
2,178
3.9375
4
class Node(): def __init__(self,data): self.data=data self.next=None class LinkedList(): def __init__(self): self.length=0 self.head=Node(None) self.tail=Node(None) def append(self,data): newNode=Node(data) if self.head: self.tail.next=newN...
8ee6b505cdc445e983e08af0802e88f8e6ed9cf5
SeezSawz2222/python_data_structure
/data_strcture.py
1,219
3.546875
4
import random as rd def get_def(word_list,word_dict): ranrom_index = rd.randrange(len(word_list)) word = word_list.pop(ranrom_index) defi = word_dict.get(word) return word, defi def word_def(rstring): word, defi = rstring.split(',', 1) return word, defi fh = open("desktop\\PYTHONN...