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
49d3fbe78c86ab600767198110c6022be77fefe9
SagarikaNagpal/Python-Practice
/QuesOnOops/F-9.py
507
4.1875
4
# : Write a function that has one character argument and displays that it’s a small letter, capital letter, a digit or a special symbol. # 97-122 65-90 48-57 33-47 def ch(a): if(a.isupper()): print("u...
fe87fda53fd053e70d978d0204461c0aeb69058a
SagarikaNagpal/Python-Practice
/QuesOnOops/A-25.py
137
3.8125
4
a=int(input("a is: ")) b=int(input("b is: ")) print("before swapping") print(a) print(b) print("After Swaping") a,b=b,a print(a) print(b)
7099d78eb77a62ea5960a55130123ca386f261e1
SagarikaNagpal/Python-Practice
/QuesOnOops/B-39.py
105
3.953125
4
num = int(input("Num for its table: ")) for i in range(1,11): print("table of",num,"*",i,"=",num*i)
934c3fb94a7536650b6810b5a50467f84faf2952
SagarikaNagpal/Python-Practice
/tiny_progress/list/Python program to print odd numbers in a List.py
402
3.875
4
def listCreate(): n = int(input('Number of elements in list: ')) l =[] for i in range(n): l.append(int(input('element is: '))) return l def odd(l): odd = [] for i in l: if i%2 ==1: odd.append(i) return odd def main(): first = listCreate() second= odd(l...
a131bce1690e9cef62f40819824fd3e6c7cf0d51
SagarikaNagpal/Python-Practice
/QuesOnOops/C-15.py
430
4.03125
4
# to check a string for palindrome. # also work with b-79 # String="aIbohPhoBiA" # String1=String.casefold() # Rev_String=reversed(String1) # if(list(String1)==list(Rev_String)): # print("The string is palindrome") # else: # print("no its not") s= input("string: ") s1 = s.casefold() print(s1) rev = reversed(s...
3aa25f3fba06beaa6fecf9403e4de839549e2660
SagarikaNagpal/Python-Practice
/QuesOnOops/A-5.py
132
4.15625
4
radius= int(input("radius is:")) circu= 2*3.14*radius area=3.14*radius print("circumfrence is: ",circu) print("area is: ",area)
e0675cb6771465070dbd479f662a7e3e8f9eef2a
SagarikaNagpal/Python-Practice
/QuesOnOops/B30.py
181
3.90625
4
# Question B30: WAP to print counting from 10 to 1. # Question B31: WAP to print counting from 51 to 90. for i in range(10,0,-1): print(i) for f in range(50,91): print(f)
696000f189c565377613191ebbaf86299cf6614f
SagarikaNagpal/Python-Practice
/tiny_progress/basic/A1.py
302
3.890625
4
# Question A1: WAP to input roll number, name, marks and phone of a student and display the values. from tokenize import Name rollNum = int(input("RollNumber : ")) name = (input("Name: ")) marks = int(input("Marks: ")) phone = int(input("Phone: ")) print(rollNum,name,marks,phone) print(type(Name))
fc996b4899875fbf48ca5b5e4da4a4f194cbef70
SagarikaNagpal/Python-Practice
/QuesOnOops/B8.py
452
3.640625
4
# Question B8: WAP to input the salary of a person and calculate the hra and da according to the following conditions: # Salary HRA DA # 5000-10000 10% 5% # 10001-15000 15% 8% name = str(input("name")) sal = int(input("sal is: ")) HRA = 1 DA = 1 if((sal>5000 and sal< 1000)): HRA = (0.1*sal) ...
43462ac259650bcea0c4433ff1d27d90bbc7a09e
SagarikaNagpal/Python-Practice
/QuesOnOops/C-4.py
321
4.40625
4
# input a multi word string and produce a string in which first letter of each word is capitalized. # s = input() # for x in s[:].split(): # s = s.replace(x, x.capitalize()) # print(s) a1 = input("word1: ") a2 = input("word2: ") a3 = input("word3: ") print(a1.capitalize(),""+a2.capitalize(),""+a3.capitalize()...
c56fecfa02ec9637180348dd990cf646ad00f77f
SagarikaNagpal/Python-Practice
/QuesOnOops/B-78.py
730
4.375
4
# Write a menu driven program which has following options: # 1. Factorial of a number. # 2. Prime or Not # 3. Odd or even # 4. Exit. n = int(input("n: ")) menu = int(input("menu is: ")) factorial = 1 if(menu==1): for i in range(1,n+1): factorial= factorial*i print("factorial of ",n,"is",factorial) el...
7b8acefe0e74bdd25c9e90f869009c2e3a24a4fc
SagarikaNagpal/Python-Practice
/QuesOnOops/C-13.py
213
4.40625
4
# to input two strings and print which one is lengthier. s1 = input("String1: ") s2 = input("String2: ") if(len(s1)>len(s2)): print("String -",s1,"-is greater than-", s2,"-") else: print(s2,"is greater")
96e4195413797d376b936e6b5d1b04aaa8c01cac
SagarikaNagpal/Python-Practice
/QuesOnOops/C-14.py
61
4.15625
4
# to reverse a string. s = input("string: ") print(s[::-1])
e09aad9458b0eceb8a8acfc23db8a78637e3ebfe
SagarikaNagpal/Python-Practice
/tiny_progress/list/Python program to swap two elements in a list.py
809
4.25
4
# Python program to swap two elements in a list def appendList(): user_lst = [] no_of_items = int(input("How many numbers in a list: ")) for i in range(no_of_items): user_lst.append(int(input("enter item: "))) return user_lst def swapPos(swap_list): swap_index_1 = int(input("Enter First In...
04ac72941293d872cecb6d12f3cf1ba2d8747452
SagarikaNagpal/Python-Practice
/QuesOnOops/Removing_Duplicates.py
511
3.984375
4
# Question: Complete the script so that it removes duplicate items from list a . # # a = ["1", 1, "1", 2]-- "1 is duplicate here" # Expected output: # # ['1', 2, 1] # ********************Diifferent Approach*********************** # a = ["1",1,"1",2] # b = [] # for i in a: # if i not in b: # b.append(i) ...
a33e791b4fc099c4e607294004888f145071e6ff
SagarikaNagpal/Python-Practice
/QuesOnOops/A22.py
254
4.34375
4
#Question A22: WAP to input a number. If the number is even, print its square otherwise print its cube. import math a=int(input("num: ")) sq = int(math.pow(a,2)) cube =int (math.pow(a,3)) if a%2==0: print("sq of a num is ",sq) else: print(cube)
cd04469d80121d7c9f10221c30f0bf4963d888d1
SagarikaNagpal/Python-Practice
/QuesOnOops/D-7.py
83
3.9375
4
# Question D7: WAP to reverse an array of floats. arr = [1,2,3,4] print(arr[::-1])
470e9fa497bef6af068fa708ac1c2fb68569c71c
SagarikaNagpal/Python-Practice
/QuesOnOops/C-11.py
140
4.1875
4
# WAP to count all the occurrences of a character in a given string. st = "belief" ch = input("chk: ") times = st.count(ch) print(times)
0cdf4fb881b84941e0ff4f29600092f65a65d001
SagarikaNagpal/Python-Practice
/QuesOnOops/B-8.py
416
4.0625
4
name = input("name of an employee: ") salary = int(input("input of salary: ")) HRA = 0 DA = 0 if(salary> 5000 and salary <10000): print("Salary is in between 5000 and 10000") HRA = salary *0.1 DA = salary * 0.05 elif(salary>10001 and salary<15000): print("Salary is in between 10001 and 15000") HR...
169945565fd5ffb9c590d7a38715b3a08a8280ff
SagarikaNagpal/Python-Practice
/QuesOnOops/A-10.py
248
4.34375
4
# to input the number the days from the user and convert it into years, weeks and days. days = int(input("days: ")) year = days/365 days = days%365 week = days/7 days = days%7 day = days print("year",year) print("week",week) print("day",day)
832c6af00dcabd3682df2be233f20bc677e8718a
SagarikaNagpal/Python-Practice
/QuesOnOops/B25.py
385
4.125
4
# Question B25: WAP to input two numbers and an operator and calculate the result according to the following conditions: # Operator Result # ‘+’ Add # ‘-‘ Subtract # ‘*’ Multiply n1= int(input("n1")) n2 = int(input("n2")) opr = input("choice") if(opr== '+'): print(n1+n2) elif(opr== '-'): ...
2b0cb7449debeaa87b082dccc621f78bdf0719f4
chrispy227/python_quiz_1
/OOP_quiz_app.py
2,776
4.09375
4
from random import sample class QUIZ: """A Customizable Quiz using a 2D list to store the questions, answer choices and answer key.""" def __init__(self, questions, topic): self.questions = questions # Question 2D List self.topic = topic # topic decription String def question_randomize...
c59280763191995bef0ced4a13fc5cdc2f72f4b7
sys-bio/tellurium
/tellurium/analysis/parameterestimation.py
5,589
3.671875
4
""" Parameter estimation in tellurium. """ from __future__ import print_function, absolute_import import csv import numpy as np import tellurium as te from scipy.optimize import differential_evolution import random class ParameterEstimation(object): """Parameter Estimation""" def __init__(self, stochastic_simu...
e5944d3d25b846e0ba00b84150eff7620517e608
juthy1/Python-
/e16-1.py
1,673
4.28125
4
# -*- coding: utf-8 -*- #将变量传递给脚本 #from sys import argv from sys import argv #脚本、文件名为参数变量 #script, filename = argv script, filename = argv #打印“我们将建立filename的文件”%格式化字符,%r。字符串是你想要展示给别人或者从 #从程序里“导出”的一小段字符。 #print ("We're going to erase %r." % filename) print ("We're going to erase %r." % filename) #打印提示,如何退出,确定回车 #print ...
27c6843b2391f62f6705b7da4bdcd8ab3e00a7c7
Rexzarrax/CounterClockPython
/clock_pyth-sub.py
576
3.59375
4
import time import os from clock import Clock #clears console def cls(): os.system('cls' if os.name=='nt' else 'clear') #program entry point def main(): #Set the time per increment and the maximum length the clock will run for Sleeper = 0.1 maxLength = 86410 * 7 myClock = Clock() print(...
adaab441216118f4623e724194bcd008c3241d9b
Anjali-225/PythonCrashCourse
/Chapter_3/Pg_93_Try_It_Yourself_3_10.py
515
3.953125
4
languages = ['English','Afrikaans','Spanish','German','Dutch','Latin'] print(languages[0]) print(languages[-1]) languages.append('Hindi') print(languages) languages.insert(0, 'French') print(languages) del languages[0] print(languages) languages.sort(reverse=True) print(languages) languages.rev...
1571c5675a0e614056cfcee317d8addcfb5c474d
Anjali-225/PythonCrashCourse
/Chapter_4/Pg_122_Try_It_Yourself_4-15.py
1,018
4.15625
4
#4-14 Read through it all ################################ #4-15 players = ['charles', 'martina', 'michael', 'florence', 'eli'] print(f"The first three items in the list are: {players[0:3]}") print("") print(f"Three items from the middle of the list are: {players[1:4]}") print("") print(f"The last th...
6c22bafc0f152bbfc9b16be1f1359b2a287ee53c
Anjali-225/PythonCrashCourse
/Chapter_4/pg_116_Try_It_Yourself_4-11+4-12.py
729
3.921875
4
#4-11 MyPizzas = ['Margherita', 'Chicken Tikka', 'Vegetarian'] print(f"My pizzas: {MyPizzas}") friend_Pizzas = MyPizzas[:] print(f"Friends pizzas: {friend_Pizzas}\n") MyPizzas.append("BBQ") friend_Pizzas.append("Cheese") print(f"\nMy favourite pizzas are:") print(MyPizzas) print("My friend's favorite...
f9677f8d6ca5f1abf2938b43b7e4f550fe2ab600
Anjali-225/PythonCrashCourse
/Chapter_8/greeter.py
7,856
3.703125
4
def greet_user(): """Display a simple greeting.""" print("Hello!") greet_user() def greet_user(username): """Display a simple greeting.""" print(f"Hello, {username.title()}!") greet_user('jesse') ###################################################################### def describe_pet(animal_type, pet_...
f2006e52c4b4a5fae1cf0a321455ba575d59557f
Anjali-225/PythonCrashCourse
/Chapter_5/Pg_139_Try_It_Yourself.py
3,940
4.0625
4
#5-3 alien_color = 'green' if 'green' in alien_color: print("The player just earned 5 points") if 'blue' in alien_color: print("The player just earned 5 points") #5-4 alien_color = 'green' if 'green' in alien_color: print("The player earned 5 points for shooting the alien") else: print("The player ...
0432421e007f7c65b6e1b8bf1aea0c1571a92974
Anjali-225/PythonCrashCourse
/Chapter_7/Pg_185_TIY_7-7.py
285
3.765625
4
''' 7-7. Infinity: Write a loop that never ends, and run it. (To end the loop, press CTRL-C or close the window displaying the output.) ''' #---------------------------------------------------- x = 1 while x <= 5: print(x) #----------------------------------------------------
70b19ed1651a51b47d3452bd2369df9cd6ea3436
Anjali-225/PythonCrashCourse
/Chapter_9/Pg_250_TIY_9_13.py
1,604
4.03125
4
#9-13 from random import randint #------------------------------------------------------------------------------- class Die(): def __init__(self, sides=6): self.sides = sides def roll_dice(self): number = randint(1, self.sides) return (number) #-------------------------------------------------------...
8cbcd7f1c63bbd9fe093848de4edd1a5f80ff05b
maheshnavani/python
/Graph.py
3,568
3.578125
4
import abc import numpy as np # abc library is for Python abstract-base-class class Graph(abc.ABC): def __int__(self, numVertices, directed=False): self.numVertices = numVertices self.directed = directed @abc.abstractmethod def add_edge(self, v1, v2, weight=1): pass @abc.abst...
3696239fa5b153fae838212c6d01305ae480b28b
Sandro-Tan/Game-2048
/Game_2048.py
6,355
3.765625
4
""" 2048 game Move and merge squares using arrow keys Get a 2048-value tile to win Author: Sandro Tan Date: Aug 2019 Version: 1.0 """ import GUI_2048 import random import SimpleGUICS2Pygame.simpleguics2pygame as simplegui # Directions, DO NOT MODIFY UP = 1 DOWN = 2 LEFT = 3 RIGHT = 4 # Offsets f...
1557048a28338cabcc7f003dd71f6649fbfae7ac
teinhonglo/leetcode
/problem/swapPairs.py
521
3.625
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def swapPairs(self, head): """ :type head: ListNode :rtype: ListNode """ prev = head while prev: ...
def85ca7efbf7147eb11250af67354c85f2b4de1
teinhonglo/leetcode
/problem/Binary-Tree-Level-Order-Traversal.py
1,104
3.734375
4
tion for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def levelOrder(self, root): """ :type root: TreeNode :rtype: List[List[int]] """ # check ...
3f3e498ae7b843294dca0c558d97b0c020522e6c
GeekHanbin/DLAction
/tflearn/base_kn/base.py
2,997
3.640625
4
import tensorflow as tf # https://blog.csdn.net/lengguoxing/article/details/78456279 # TensorFlow的数据中央控制单元是tensor(张量),一个tensor由一系列的原始值组成,这些值被形成一个任意维数的数组。一个tensor的列就是它的维度。 # Building the computational graph构建计算图 # 一个computational graph(计算图)是一系列的TensorFlow操作排列成一个节点图 node1 = tf.constant(3.0,dtype=tf.float32) node2 = tf.c...
63ada01e7b5655945f6c1800be50015960faef95
LuserName01/entergame
/main.py
750
3.796875
4
import time time.sleep(2) print("Welcome to my first game!") time.sleep(1) print("All you have to do is hold enter!") time.sleep(2) print("STOP AT 30 OR RESULTS.TXT WILL BE FILLED!!!") time.sleep(3) print("3") time.sleep(1) print("2") time.sleep(1) print("1") time.sleep(1) input(1) input(2) input(3) input(4) input(5) ...
fad78bd651abc58de459ca5c050cd33c4fc317e4
laijnaloo/TheZoo
/ZooUtils.py
2,354
3.59375
4
__author__ = 'Lina Andersson' # Programmeringsteknik webbcourse KTH P-task. # Lina Andersson # 2016-03-29 # Program for a zoo where the user can search, sort, buy, sell and get recommendations on what to buy or sell. # This file contains helpclasses that occurs in the other files and is one of five modules in this prog...
b66a00e7bbb55c394e587942a80fb58ccb725173
rainly/binanace_test
/Signals.py
9,652
3.734375
4
""" 《邢不行-2020新版|Python数字货币量化投资课程》 无需编程基础,助教答疑服务,专属策略网站,一旦加入,永续更新。 课程详细介绍:https://quantclass.cn/crypto/class 邢不行微信: xbx9025 本程序作者: 邢不行 # 课程内容 币安u本位择时策略实盘框架需要的signal """ import pandas as pd import random import numpy as np # 将None作为信号返回 def real_signal_none(df, now_pos, avg_price, para): """ 发出空交易信号 :param...
d2d07622e38f3cc865281e179ddd46f64f85c3f2
RoozbehSanaei/snippets
/python/swig/numpy/test.py
785
3.8125
4
import numpy from numpy.random import rand from example import * def makeArray(rows, cols): return numpy.array(numpy.zeros(shape=(rows, cols)), dtype=numpy.intc) arr2D = makeArray(4, 4) func2(arr2D) print ("two dimensional array") print (arr2D) input_array1 = rand(5) sum = sum_array(input_array1,arr2D) print('...
d9dc0e1bde1e78fdac69f0c6f4a52d12eba9874a
umangsaluja/CAP930autumn
/set.py
702
4.03125
4
numbers={23,34,2} name={'firstname','lastname'} print(name) print(type(name)) print(numbers) empty_Set=set() set_from_list=set([1,2,34,5]) basket={"apple","orange","banana"} print(len(basket)) basket.add("grapes") basket.remove("apple")#raises keyerror if "elements" is not present basket.discard("app...
07af6c34d8365158a21250d6dc858399169fb80c
bharathkumarreddy19/python_loops_and_conditions
/odd_even.py
232
4.21875
4
# -*- coding: utf-8 -*- """ Created on Sat Apr 25 19:00:17 2020 @author: bhara_5sejtsc """ num = int(input("Enter a number: ")) if num%2 == 0: print("The given number is even") else: print("The given number is odd")
ac50dc8238e1ccbcc2dd600cacbbdd58806cf719
dlucidone/py-scripts
/LuckyVendingMachine/LuckyVendingMachine.py
6,983
3.953125
4
from random import randint class player: player_name = "Bot" player_prizes = 10 player_money = 100 def set_player_details(self,name, prizes, money): self.player_name = name self.player_prizes = prizes self.player_money = money def get_player_details(self): print("...
d1613d1c58f62c640070de20ad563a2838594ef3
esponja92/flaskforge
/tools/dbgen.py
2,479
3.765625
4
import sqlite3 def create(): nome_tabela = input("Informe o nome da tabela a ser criada: ") criar = "s" nomes_campo = [] tipos_campo = [] while(criar == "s"): nome_campo = input("Informe o nome do novo campo: ") tipo_campo = input("Informe o tipo do novo campo: (1-NULL, ...
81320a3170127cc515b57c40f7b8404994ddc94d
phani1995/logistic_regression
/src/binomial_logistic_regression_using_scikit_learn.py
2,318
3.671875
4
# -*- coding: utf-8 -*- # Imports #import numpy as np import pandas as pd import seaborn as sns import matplotlib.pyplot as plt # Reading the Dataset # Iris Dataset dataset = pd.read_csv('..//data//titanic_dataset//iris.csv') x_labels = ['sepal length', 'sepal width', 'petal length', 'petal width'] y_labels = ['iris'...
91cdf6b7b67fa470fad661736551b72f350702a5
motovmp1/basic_python
/function_python.py
272
3.65625
4
# function in Python def greet_me(name): print("Dentro da funcao: " + name) def add_integers(a, b): result = a + b #print(result) #return result print("Passei por este ponto") greet_me("Vinicius Pinho") #add_integers(10, 20) print(add_integers(10, 20))
6e8706930de1075ae63c9e0c2c18bfd2f718fb84
aaronclong/volunteer-generator
/trie.py
1,790
3.921875
4
"""Trie implementation""" class Trie: """ Try structure to help sort users more quickly Will hold a list with 27 indexes a-z will start and end from 0-25 The 27th index (26) will be space indicating the seperation between firt and last names """ def __init__(self): self.child...
88a18d9da1b8033f5aae2953aa23dc4e96171d4a
syeong0204/Python_Challenge
/jupyters_better.py
964
3.59375
4
import os import csv import sys csvpath = os.path.join("budget_data.csv") print(csvpath) with open(csvpath) as csvfile: budgetdata = csv.reader(csvfile, delimiter=",") next(budgetdata) budgetlist = list(budgetdata) file =open("analysis.txt", "w") text = "Financial analysis \n" text += "---------...
5909e815fa3c0572f4df5d03c64d8a8c08de8e0b
JinleiZhao/note
/threadings/threads.py
1,370
3.71875
4
#线程 import time, threading lock = threading.Lock() def loop(): print('Thread %s is running...'%threading.current_thread().name) for i in range(5): print('Thread %s >> %s'%(threading.current_thread().name, i)) time.sleep(1) print('Thread %s ended.'%threading.current_thread().name) print('Th...
0f708b95d21e5ca068c4ec39aca0483404629632
christophmeise/OOP
/lol.py
373
3.875
4
# -*- coding: utf-8 -*- """ Created on Fri May 11 09:18:26 2018 @author: D062400 """ def collatz(n): liste = [] for i in range(1, n): innerListe = [] while i > 1: if (i % 2) == 0: i = i / 2 else: i = i*3 + 1 innerListe.append(...
1fde8c17db645850ebcab985c19ba9e5955d3081
matheuskolln/URI
/Python 3/1146.py
173
3.828125
4
while True: x = int(input()) if x == 0: break for n in range(1, x+1): if n == x: print(n) else: print(n, end=' ')
70efc1a488e86fcec6f76db989fd97f468fe5997
matheuskolln/URI
/Python 3/1049.py
376
3.828125
4
x = input() y = input() z = input() if x == 'vertebrado': if y == 'ave': if z == 'carnivoro': s = 'aguia' else: s = 'pomba' else: if z == 'onivoro': s = 'homem' else: s = 'vaca' else: if y == 'inseto': if z == 'hematofago': s = 'pulga' else: s = 'lagarta' else: if z == 'hematofago':...
fec2bf34d375fd7cf022ccdbfa391ad64940616a
matheuskolln/URI
/Python 3/1045.py
487
3.75
4
a, b, c = map(float, input().split(' ')) aux = 0 if a < c: aux = a a = c c = aux if a < b: aux = a a = b b = aux if a >= b + c: print('NAO FORMA TRIANGULO') else: if a ** 2 == b ** 2 + c ** 2: print('TRIANGULO RETANGULO') if a ** 2 > b ** 2 + c ** 2: print('TRIANGULO OBTUSANGULO') if a ** 2 < b ** 2 +...
b3ea1e7ef0acfb8d2f5bbd2b61f45c3f465dde31
esentemov/hw_python_18
/calculator_testing/calculator.py
1,286
4.09375
4
class Calculator(object): """Класс калькулятора """ def addition(self, x, y): types_numbers = (int, float, complex) if isinstance(x, types_numbers) and isinstance(y, types_numbers): return x + y else: return ValueError def subtraction(self, x, y): ...
f8087e5bf4e1234b7dddf18f6cd7f3612b4563c4
ElminaIusifova/week1-ElminaIusifova
/04-Swap-Variables**/04.py
371
4.15625
4
# # Write a Python program to swap two variables. # # Python: swapping two variables # # Swapping two variables refers to mutually exchanging the values of the variables. Generally, this is done with the data in memory. # # # ### Sample Output: # ``` # Before swap a = 30 and b = 20 # After swaping a = 20 and b = 30 # `...
da4cf09617b4a09e36a1afa5ebcb28ae049331fe
ElminaIusifova/week1-ElminaIusifova
/01-QA-Automation-Testing-Program/01.py
968
4.28125
4
## Create a program that asks the user to test the pages and automatically tests the pages. # 1. Ask the user to enter the domain of the site. for example `example.com` # 2. After entering the domain, ask the user to enter a link to the 5 pages to be tested. # 3. Then display "5 pages tested on example.com". # 4. Add e...
9df66d83233065fb320ae2f5f3a9ef80434055ee
aayushi0402/Python365
/Day 1.py
3,189
4.53125
5
#What are Python Lists? #A a valid list can contain Data Types of the following types : Strings, Lists, Tuples, Dictionaries, Sets, Numeric #How to create Python Lists? #Following are the ways to create Python Lists #Method 1: my_list = ["Hello","Strings",12,99.9,(1,"Tuple"),{"a": "dictionary"}, ["anothe...
090ce23803d6268131fbd6bcefa9774a702a368e
gauravdal/write_config_in_csv
/python_to_csv.py
1,199
3.875
4
import json import csv #making columns for csv files csv_columns = ['interface','mac'] #Taking input from json file and converting it into dictionary data format with open('mac_address_table_sw1','r') as read_mac_sw1: fout = json.loads(read_mac_sw1.read()) print(fout) #naming a csv file csv_file = 'names.csv' tr...
a2229d5d7d63fa271fd365af5b4891f6c9412ea5
scriptclump/algorithms
/small-program/prime_number.py
213
4.0625
4
def primeNumber(num): if (num > 1): for i in range(2, num): if(num % i == 0): print('{0} is prime number'.format(num)) break else: print('{0} is not a prime number'.format(num)) primeNumber(6)
9c333b3055ed6e776404509c97e70998e389804d
scriptclump/algorithms
/sortings/recurssive_bubble_sort.py
389
3.921875
4
def bubble_sort(arr): for i, val in enumerate(arr): try: if arr[i+1] < val: arr[i] = arr[i+1] arr[i+1] = val bubble_sort(arr) except IndexError: pass return arr arr = [12,11,44,23,55,1,4,54] print("Unsorted array", ...
7e0a2b6644640412aceefb06af083539e083bdf3
Dilan/projecteuler-net
/problem-051.py
2,187
3.890625
4
# By replacing the 1st digit of the 2-digit number *3, # it turns out that six of the nine possible values: 13, 23, 43, 53, 73, and 83, are all prime. # By replacing the 3rd and 4th digits of 56**3 with the same digit, # this 5-digit number is the first example having seven primes among the ten generated numbers, ...
0d284f9890525066151f05669956630987970410
Dilan/projecteuler-net
/problem-058.py
2,265
3.828125
4
# -*- coding: utf-8 -*- # Starting with 1 and spiralling anticlockwise in the following way, a square spiral with side length 7 is formed. # 37 36 35 34 33 32 31 # 38 17 16 15 14 13 30 # 39 18 5 4 3 12 29 # 40 19 6 1 2 11 28 # 41 20 7 8 9 10 27 # 42 21 22 23 24 25 26 # 43 44 45 46 47 48 49 # It is interesti...
563c9c6658a045bee7b35b510f706a1ae17039b8
Dilan/projecteuler-net
/problem-057.py
1,482
4.15625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # It is possible to show that the square root of two can be expressed as an infinite continued fraction. # √ 2 = 1 + 1/(2 + 1/(2 + 1/(2 + ... ))) = 1.414213... # By expanding this for the first four iterations, we get: # 1 + 1/2 = 3/2 = 1.5 # 1 + 1/(2 + 1/2) = 7/5 = 1.4...
b73e5e51e531658b2fc6e778652cca63651e6dc9
Dilan/projecteuler-net
/problem-050.py
1,557
3.59375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # The prime 41, can be written as the sum of six consecutive primes: # # 41 = 2 + 3 + 5 + 7 + 11 + 13 # This is the longest sum of consecutive primes that adds to a prime below one-hundred. # # The longest sum of consecutive primes below one-thousand that adds to a prime, ...
5b75f751142a34486e920527e7bd0ec0d0de4727
LieutenantDanDan/snake
/snake.py
3,380
3.65625
4
import random import time class Snake: snake = [] board = [] width = 0 height = 0 food = (None, None) def __init__(self, height, width): random.seed(555) self.height = height self.width = width for i in range(height): self.board.append([' '] * wid...
f197017c4a97aa27b19770e4db6bb93f3186d12b
klimarichard/project_euler
/src/problems_51-75/53_combinatoric_selections.py
844
3.640625
4
def find_combinations(upper, lower=1, threshold=1): """ Find all combinatoric selections within given range. :param upper: upper bound :param lower: optional lower bound (default=1) :param threshold: optional, only list selections greater than threshold (default=1) :return: list of combinatoric ...
428e563df3b6db99b2b4f78bf3e9a62bc807fc24
klimarichard/project_euler
/src/problems_51-75/68_magic_5-gon_ring.py
2,325
3.796875
4
from itertools import combinations, permutations def find_magic_5gons(numbers): """ Find all 5-gons containing numbers from the set. :param numbers: a set of numbers :return: all possible 5-gons """ five_gons = [] combs = combinations(numbers, 5) for c in combs: # we want the ...
d4ad193e97126530ae6c33104ca43670894c97b5
klimarichard/project_euler
/src/problems_51-75/75_singular_integer_right_triangles.py
1,344
4.03125
4
# we can generate primitive Pythagorean triples and their multiples, # until we reach the limit # we will use Euclid's formula for generating the primitive triples: # - we have m, n coprimes, where m > n, exactly one of m, n is even, then # - a = m^2 - n^2 # - b = 2mn # - c = m^2 + n^2 # - perimeter p = a ...
04e3feede860b7798f1cccf2548dae6a37001027
klimarichard/project_euler
/src/problems_51-75/65_convergents_of_e.py
848
3.96875
4
def compute_nth_iteration(n): """ Computes n-th iteration of continued fraction for e, 2 + (1 / (1 + 1 / (2 + 1 / (1 + 1 / (1 + 1 / (4 + ...)))))) :param n: an integer :return: numerator and denominator of n-th iteration """ # generating sequence for continued fraction of e # [1, 2, 1, 1...
d7579f80023f2fe443bff2c8fbd43e3243ca388b
klimarichard/project_euler
/src/problems_76-100/87_prime_power_triples.py
793
3.734375
4
from algorithms import eratosthenes def prime_power_triples(n): """ Find all numbers in given range, that can be written as a sum of a squared prime, a cubed prime and a prime to the power of four. :param n: upper limit :return: list of numbers that can be written in such way """ primes = ...
93d5e72b4a15da9a9be4f6a1ff219cf1314ee392
klimarichard/project_euler
/src/problems_51-75/62_cubic_permutations.py
534
3.6875
4
from algorithms import gen_powers cubes = gen_powers(3) perms = {} found = False while not found: current = next(cubes) # find largest permutation of current cube (used as key in dictionary) current_largest = ''.join(sorted([x for x in str(current)], reverse=True)) if current_largest not in perms.ke...
4ae3ee90a0eb7d7dc3c8132e77d912eebbb42986
klimarichard/project_euler
/src/problems_1-25/02_even_fibonacci_numbers.py
439
3.9375
4
from algorithms import gen_fibs def sum_of_even_fibs(n): """ Returns sum of all even Fibonacci numbers up to given bound. :param n: upper bound :return: sum of even Fibonacci numbers lesser than n """ f = gen_fibs() next_fib = next(f) sum = 0 while next_fib < n: if next_fi...
34517033c09ac9a5553694024233868fde06d06b
klimarichard/project_euler
/src/problems_76-100/80_square_root_digital_expansion.py
704
3.765625
4
from decimal import Decimal, getcontext from algorithms import gen_powers def compute_decimal_digits(n, k): """ Computes first k digits of square root of n. :param n: an integer :param k: number of decimal digits :return: first k decimal digits of square root of n """ digits = str(Decimal(...
a95e569efdb37dbe4fbb974ac652d74170a59624
klimarichard/project_euler
/src/problems_26-50/34_digit_factorials.py
526
4
4
from algorithms import fact def find_digit_factorials(): """ Find all numbers which are equal to the sum of the factorial of their digits. :return: list of all such numbers """ df = [] factorials = [fact(i) for i in range(10)] # upper bound is arbitrary, but I couldn't find it analyticall...
f3c5ec72cdba045f43d657d5b30cf2ae51a1c293
klimarichard/project_euler
/src/problems_26-50/36_double-base_palindromes.py
462
3.9375
4
from algorithms import palindrome def find_double_based_palindromes(n): """ Find double-based palindromes in given range. :param n: upper bound :return: list of all double-based palindromes """ dbp = [] for i in range(n): if i % 10 == 0: continue if palindrome(...
a9ab45d85f900abace366094ffcdae724664ed2a
NasBeru/IRS_PROJECT
/recommendation_system/data_lnsert.py
6,169
3.53125
4
# -*- coding: utf-8 -*- import pandas as pd import pymysql class BookSqlTools: # 链接MYSQL数据库 # 读取出来转化成pandas的dataframe格式 def LinkMysql(self, sql): print('正在连接====') try: connection = pymysql.connect(user="root", password="...
a6f3a4c377816302913a0b15d534cf09490395e9
ymdt142/Search-files-and-folder-using-python
/fns.py
614
3.953125
4
import os def searchfolder(a): c=input("Search in") os.chdir(c) for path, dirnames, files in os.walk(c): for file in dirnames: if file==a: print("found file") print(path) def searchfile(a): c=input("Search in") os.chdir(c) for path,...
1233fb6db537375f7fee234f54f3c67bb6012933
bereczb/trial-exam-python
/2.py
797
3.78125
4
# Create a function that takes a filename as string parameter, # and counts the occurances of the letter "a", and returns it as a number. # It should not break if the file does not exist, just return 0. def counter(name_of_file): try: f = open(name_of_file, 'r') text_list = f.readlines() f...
08d99476bdc41ba3da11a293aee6d8236285bde3
isaacmm110/Projeto01
/Translator.py
630
3.890625
4
def translate(phrase): letter1 = input("Enter the letter which all the vocals will turn on: ") letter2 = input("Enter the letter which all the r will be changed: ") translation2 = "" translation = "" for letter in phrase: if letter in "AEIOUaeiou": translation = translat...
fee7b252fcbfa29968ec94308e5f4040ef67381f
nytaoxu/Flask_API
/code/models/user.py
1,090
3.609375
4
import sqlite3 DATABASE_NAME = "data.db" class UserModel: def __init__(self, _id, username, password): self.id = _id self.username = username self.password = password @classmethod def find_by_username(cls, username): with sqlite3.connect(DATABASE_NAME) as connection: ...
3c8802f63b9ff336168a750a2d82e7e42c6ee7ec
Chou-Qingyun/Python006-006
/week06/p5_1classmethod.py
2,320
4.25
4
# 让实例的方法成为类的方法 class Kls1(object): bar = 1 def foo(self): print('in foo') # 使用类属性、方法 @classmethod def class_foo(cls): print(cls.bar) print(cls.__name__) cls().foo() # Kls1.class_foo() ######## class Story(object): snake = 'python' # 初始化函数,并非构造函数。构造函数: __n...
87033b460c1943e78a137d2bc0caae0c51f9293c
jmflynn81/advent-of-code-2020
/01/calculate_expense.py
691
3.8125
4
import itertools def add_em(a): sum = 0 for item in list(a): sum = sum + int(item) return sum def multiply_em(a): product = 1 for item in list(a): product = product * int(item) return product def get_values(size_of_set, expense_list): combinations = itertools.combination...
e9b5367c1302a02b9323458f2c6e6747f485248a
ljs-cxm/algorithm
/select_sort.py
331
3.5625
4
from check import check_func def select_sort_func(nums): n = len(nums) for i in range(n-1): min = i for j in range(i+1, n): if nums[min] > nums[j]: min = j nums[i], nums[min] = nums[min], nums[i] return nums if __name__ == '__main__': check_func(select...
3570330e75fab9747d1865f6298163ead45b8263
uwhwan/python_study
/test/selectionSort.py
428
3.640625
4
#选择排序 from randomList import randomList iList = randomList(20) def selectionsort(iList): if len(iList) <= 1: return iList for i in range(0,len(iList)-1): if iList[i] != min(iList[i:]): minIndex = iList.index(min(iList[i:])) iList[i],iList[minIndex] = iList[minIndex],iLi...
9c6ab989761682252642271f09bcb45a62266476
sunny0212452/CodingTraining
/s.py
895
3.75
4
# -*- coding:utf-8 -*- #将字符串中的空格替换成%20 def replaceSpace(s): # write code here l = len(s) print 'l:',l num_blank=0 for i in s: if i==' ': num_blank+=1 l_new = l+num_blank*2 print 'l_new:',l_new index_old = l-1 index_new = l_new s_new=[' ']*l_new while(index...
fba35b9f3c384df1768ce9f0500536a3dc0c1e2d
AshutoshInfy/Python_Selector
/list_sorting.py
215
3.875
4
# sorting the list def sort_list(sam_list): # sort the list sam_list.sort() return sam_list # print new sorted list new_list = [1,2,8,9,4,3,2] sorted_list = sort_list(new_list) print('Sorted list:', sorted_list)
3f2e1e7f00004e07ed45b0499bfcacb873d6ef92
CodedQuen/python_begin1
/simple_database.py
809
4.34375
4
# A simple database people = { 'Alice': { 'phone': '2341', 'addr': 'Foo drive 23' }, 'Beth': { 'phone': '9102', 'addr': 'Bar street 42' }, 'Cecil': { 'phone': '3158', 'addr': 'Baz avenue 90' } } # Descriptive lables for the phone...
d16499e85a3ce89f60adaff02b043075e876b308
ArnthorDadi/Kattis
/NumberFun.py
368
3.921875
4
n = int(input("")) for i in range(n): x, y, z = input("").split(" ") x = int(x) y = int(y) z = int(z) if(x+y == z): print("Possible") elif(x-y == z or y-x == z): print("Possible") elif(x/y == z or y/x == z): print("Possible") elif(x*y == z): print("...
fb49ab4a7a2703dd82c68819f2862444954776f2
kininge/Algoritham-Study
/matrixMultiplication.py
826
3.625
4
def bruteForceWay(matrixA, matrixB): rowsA= len(matrixA) rowsB= len(matrixB) columns= len(matrixB[0]) matrixAnswer= [] #For loop to choose row of matrixA for index in range(rowsA): row= [] #For loop to choose columns in matrixB for index_ in range(columns): ...
2c217215bc105cf3622113c0ee457b89409ed8ce
johnhuzhy/MyPythonExam
/src/junior/practice_forth.py
1,312
4.0625
4
""" 1.正整数を入力して、それが素数かどうかを判別します。 素数は、1とそれ自体でのみ除算できる1より大きい整数を指します。 """ from math import sqrt print('*'*33) num = int(input('正整数を入力してください:')) if num > 0: is_prime = True end = int(sqrt(num)) for i in range(2, end+1): if(num % i == 0): is_prime = False break if is_prime: ...
c98d8baa7b0837b19dbf13304cc3c64da6541da7
akanksha0202/pythonexercise
/input.py
139
3.953125
4
name = input('What is your name? ') favorite_color = input('What is your fav. color ') print('Hi ' + name + ' likes ' + favorite_color)
36a19156307e70367bcce02584e85405c85ac586
hew123/python_debug
/scanInput.py
813
3.65625
4
def main(): ''' while(1): try: line = int(input()) print(line) except EOFError: break ''' numOfID = int(input()) numOftrxn = int(input()) counter1 = 0 ids = [] while counter1 < numOfID: id = int(input()) ids.app...
40094cc34343b6b87869d0a8bcc1cfa196b28237
RELNO/RELNO.github.io
/tools/folder_resize.py
2,709
3.578125
4
import os from PIL import Image def process_images(folder_path, rename=False): # Create "raw" folder if it doesn't exist raw_folder = os.path.join(folder_path, "raw") os.makedirs(raw_folder, exist_ok=True) # Get all file names in the folder file_names = os.listdir(folder_path) image_counter ...
07c959fbafe8a7d2498e6fa022485029a6a3dc13
RabbitUTSA/Rabbit
/HW2.py
1,908
3.5625
4
# -*- coding: utf-8 -*- """ Created on Tue Sep 25 14:16:58 2018 @author: Rabbit/Joshua Crisp """ def trap(f, lower, upper, numberOfPoly): """code (upper and lower) and (n) number of polygons Trapaziod Rule calculations return approx area and error inputs upper-bound, lower-boun...
08008169f146b72c3d28627b05022bd51c0d2128
Tigul/pycram
/src/pycram/designator.py
9,145
3.515625
4
"""Implementation of designators. Classes: DesignatorError -- implementation of designator errors. Designator -- implementation of designators. MotionDesignator -- implementation of motion designators. """ from inspect import isgenerator, isgeneratorfunction from pycram.helper import GeneratorList from threading impor...
264f8f4f27f31ecdd317fac502200a839ac884bc
OuYangMinOa/linebot
/RSA.py
1,583
3.71875
4
def make_rsa_(n): out = [2] for i in range(3,n,2): if (check(i)): out.append(i) return out def check(num): if (num%2==0): return False for i in range(3,int(num**0.5),2): if (num%i==0): return False return True lib = make_rsa_(500) # 生...
369649dce4a898825618f0ff807ccf228b2c124f
james-roden/google-foobar
/level1/Guard_Game.py
2,161
3.84375
4
# ----------------------------------------------- # Google-Foobar # Name: Guard Game aka adding_digits # Level: 1 # Challenge: 1 # Author: James M Roden # Created: 11th August 2016 # Python Version 2.6 # PEP8 # ----------------------------------------------- """ Guard game ========== You're being held in a guarded roo...
92ab0a09b8eab1d3a27beab9c4093d3acd30991b
JunaidRana/MLStuff
/Advanced Python/Virtual Functions/File.py
364
4.125
4
# -*- coding: utf-8 -*- """ Created on Tue Sep 25 19:51:27 2018 @author: Junaid.raza """ class Dog: def say(self): print ("hau") class Cat: def say(self): print ("meow") pet = Dog() pet.say() # prints "hau" another_pet = Cat() another_pet.say() # prints "meow" my_pets = [pet, anothe...
959b8244e952ce4f393004b7c8730987fdc08ed5
darshita1603/testing
/operators.py
192
3.96875
4
# x=3>2 # print(x) w=int(input("enter your weight: ")) unit=input("(K)g or(L)bs :") if unit.lower()=="k": print(str(w//0.45)) elif unit.lower()=="l": print(str(w*0.45)) print("hh")