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
5b6c30a480f395fdf9435ed863ad7c4902a7fbef
base64g/iikanji_medley
/copy_music.py
582
3.515625
4
import os import shutil def copyall(path): files = os.listdir(path) for file in files: if os.path.isdir(path+file): copyall(path+file+"/") elif os.path.isfile(path+file): ftitle, fext = os.path.splitext(path+file) if fext == ".wav": print(path+...
c6d6ada93ee7f597f20b7b7b79216cc9a85e49d0
ankurdengla/Sem_4_AI_Codes
/Base Codes AI/8puzzle astar.py
3,836
3.8125
4
from queue import PriorityQueue from copy import deepcopy goal = [[0, 1, 2], [3, 4, 5], [6, 7, 8]] q = PriorityQueue() def findx(val): for i in range(3): for j in range(3): if (goal[i][j] == val): return i def findy(val): for i in range(3): for j in range(3): ...
a4e5e1373ece078d9b8fdda85102244298076198
chakryaros/CSCI3010-Programming-WorkShop
/PS/PE12/pe12.py
4,405
4.40625
4
# PE 12 - CSCI 3010 - python prep work # Name: Chakrya Ros # Comments in python start with a # ############################## Python Interpreter Questions ########################## # Explore these questions in a python interpreter from the command line # Run the python interpreter by typing "python". Make sure that ...
76bee8112c0bf099871e55d23c4625c4b0d8b061
guizhouln/Py
/expression.py
120
3.9375
4
length = 5 breadth = 2 area = length*breadth print('Area is',area) print('Perimeter is', 1 * (length + breadth))
f314b602cfccfc7296969fd81374b2b2b9f5e395
n18013/programming-term2
/src/basic-c2/elif.py
283
4.0625
4
#BMI判定プログラム weight = float(input("体重(kg)は ? ")) height = float(input("身長(cm)は ? ")) #BMIの計算 height = height / 100 # m に直す bmi = weight / (height * height) #BMIの値に応じて結果を分岐 result = "" resultを空にしておく(初期化)
199fad3fe58209c28a054801145818753d9bb4f8
n18013/programming-term2
/src/algo-p2/task20180807_q06.py
377
3.890625
4
fruits = {'apple': 'りんご', 'banana': 'バナナ', 'grape': 'ぶどう'} #for文を用いて、辞書のキーを1つずつ取り出し、繰り返しの中で「◯◯は△△という意味です」と出力させてください # 例:「appleはりんごという意味です」 for name in fruits: print('bananaは' + 'バナナ' + 'という意味です。')
32a0166f8a776ee7c3529cf7f9a7f73d3212cfcd
anvarknian/preps
/Arrays/searching/linear_search.py
380
4.03125
4
value1 = 5 value2 = 7 array = [1, 2, 3, 4, 5, 6] unsorted_array = [1, 2, 3, 4, 5, 6, 4, 3, 2, 6, 7, 8, 0] def linear_search(array, value): for i in array: if i == value: print('linear_search - Found value ' + str(value)) else: print('linear_search - Value not found array') ...
f9f86abfd5bab24edac6d6149fefd15b451f438e
anvarknian/preps
/Heaps/min_heap.py
2,621
4.1875
4
import sys # defining a class min_heap for the heap data structure class min_heap: def __init__(self, sizelimit): self.sizelimit = sizelimit self.cur_size = 0 self.Heap = [0] * (self.sizelimit + 1) self.Heap[0] = sys.maxsize * -1 self.root = 1 # helper function to swa...
f7f06e95b030bf9abeb4ac080e61b7bbd9f0ebae
TheoPapafotiou/VROOM-BFMC-Simulator
/vroom_workspace/src/startup_package/src/bfmclib/Parking.py
7,178
3.546875
4
import os import rospy import cv2 from time import sleep import numpy as np import math class Parking: """ This class is used for the implementation of the parking maneuver of the vehicle. Both vertical and horizontal parking maneuvers have been implemented. """ """ TODO: Fill the co...
83912689e13da3357a671b0898a02de7b19ae01f
cstewart20/lab8
/gamez.py
14,438
3.5625
4
# gamez.py #Chloe Stewart # 2020 #So that it can seem like the npc is thinking. Adds a lot of dramatics. import time #To make up for input variability option_A = ["A","a"] option_B = ["B","b"] option_C = ["C","c"] left = ["Left","left","L","l"] right = ["Right","right","R","r"] yes = ["Yes","yes","y","Y"] no =...
db89c4b3c5adc087bd3c322b48b6ab0644207a3e
Vinaypatil-Ev/aniket
/1.BASIC PROGRAMS/7.swap.py
665
4.0625
4
# WAP to demonstrate arithmetic operation on two integer numbers. # with third variable print("Enter two no") a = int(input("Enter first No: ")) b = int(input("Enter second No: ")) c = b b = a a = c print(f"swap using third variable: {a}, {b}") # without third varible print("\nEnter two no") a = int(input("Enter firs...
7b3d002f1a4c40696eac36308f6a463345492bd4
Vinaypatil-Ev/aniket
/8.Array/4.multiply_3_3_matrix.py
461
3.765625
4
def mul(a, b): arr = [[0] * len(a[0]) for _ in range(len(a))] for i in range(len(a)): for j in range(len(a[0])): for k in range(len(a)): arr[i][j] += a[i][k] * b[k][j] return arr if __name__ == "__main__": a = [ [1, 1, 1], [10, 30, 10], ...
1a8b55b7889a63cb5bf8151d82694ff786c360ba
Vinaypatil-Ev/aniket
/4.LOOPING_STATEMTNS/6.gcd.py
104
3.640625
4
def gcd(a, b): if b == 0: return a return gcd(a, a%b) x = gcd(gcd(10, 14), 40) print(x)
643bb8a4c5100d1f22dbd60132317b66f6fb3b06
Vinaypatil-Ev/aniket
/1.BASIC PROGRAMS/4.fahrenheit_to_degree.py
286
4.40625
4
# WAP to convert Fahrenheit temp in degree Celsius def f_to_d(f): return (f - 32) * 5 / 9 f = float(input("Enter Fahrenheit temprature: ")) x = f_to_d(f) print(f"{f} fahreheit is {round(x, 3)} degree celcius") # round used above is to round the decimal values upto 3 digits
9ddc747b3de61a5a4f007eabd638dd4614470dda
Vinaypatil-Ev/aniket
/8.Array/1.calculate_avg_marks_of_10_students.py
240
3.515625
4
# WAP to calculate average marks of a 10 students. def cal_avg(arr): return sum(arr) / len(arr) if __name__ == "__main__": arr = [60, 92, 68, 85, 87, 70, 98, 55, 39, 98] x = cal_avg(arr) print(f"Avg of 10 students: {x}")
9baca54a40fd9826d3522a7dcdcc8eaea37ad01f
cosmicRover/algoGrind
/linked-list/UniqueLL.py
763
3.65625
4
# Definition for singly-linked list. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution(object): def deleteDuplicates(self, head): """ :type head: ListNode :rtype: ListNode """ first, second = head...
4743c11262547e3f93855ae094efd1b272e8e9ab
cosmicRover/algoGrind
/slow-fast-pointers/circular-array-loop.py
2,065
3.546875
4
class Solution: def circularArrayLoop(self, nums: List[int]) -> bool: ''' slow/fast pointer. slow.next -> fast.next.next #requirements: 1) can't reverse direction 2) if we end up back at where we started, we have a cycle except for 0 values time O(n^2) for in...
56bf9c7d765fcc6186c4fc1ffb9d1641fc89a82a
cosmicRover/algoGrind
/trees/construct-tree-pre-post.py
1,348
3.78125
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def constructFromPrePost(self, pre: List[int], post: List[int]) -> TreeNode: ''' P NLR ...
5be0ee58450e4a7d5e5e6621c0b1b33505bb5e12
cosmicRover/algoGrind
/unions/unionFind.py
1,159
3.625
4
#leetcode 684 class Solution: def findRedundantConnection(self, edges: [[int]]) -> [int]: maxValue = float("-inf") #find the max node value for start, end in edges: maxValue = max(maxValue, start, end) #create a table to store root values with the length of maxValue ...
5ac6ecf0855087c41e0f7d2b3edbf1a17e1bd5b8
cosmicRover/algoGrind
/DP/minCoins.py
1,661
3.828125
4
class Solution: def coinChange(self, coins: List[int], amount: int) -> int: ''' dp problem approach. find small problem -> init dp table for this problem, the smaller problem is to reach a sum < the given amount. Since there are only one set of resources (coins) and one targ...
dab4653508c86acf6c6ccbd0e6212ebc485519d8
cosmicRover/algoGrind
/array-strings_stacks/FindRes.py
996
3.53125
4
class Solution: def filterRestaurants(self, restaurants: [[int]], veganFriendly: int, maxPrice: int, maxDistance: int) -> [int]: #list att in-order: [id, rating, veganFriendly, price, distance] # 0 1 2 3 4 #query out the items that match...
f6d639a4eb07d07781e9d31e4eeab29ef9329f3c
cosmicRover/algoGrind
/graphs/BFS_DFSFromList.py
2,149
3.5625
4
#BFS on a graph's nodes with inputs as [[nodes]]. Cycles are allowed. Nodes are ints class BFSandDFS: #nodes -> [[source, destination]] in this exapmple we dont care #about edge-weights. If edge-weight provided, we set the aside def findBFS(self, nodes:[[int]], start_node) -> [int]: #init ds to ho...
ae4f06a8b6e751aa6b263a786e6a65c7ea6ef03d
cosmicRover/algoGrind
/trees/maxdepth.py
1,861
3.984375
4
# Definition 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 maxDepth(self, root): """ :type root: TreeNode :rtype: int """ queue = [root...
cf98af5f8efdc8fba477f9c67a3f375234ef6cc2
cosmicRover/algoGrind
/greedyAlgo/Jump3.py
1,179
3.671875
4
''' We transform the given list into a directed graph. Then we bfs through the nodes from the starting point and attempt to find our target. ''' class Solution: # Time O(v+e)? (can someone clarify it please?), space O(len(graph) + len(visited)) -> O(2n) -> O(n) def canReach(self, arr: [int], start: int) -> b...
68f0346f59fc0f9067d8a3adc97df89d1fdea837
cosmicRover/algoGrind
/trees/validateBst.py
1,914
3.796875
4
''' Time O(n) | Space O(n) for q or on the recursive callsatck Remember, each node has an alternating set lower and upper boundry that they cant cross ''' # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left #...
dc02d9527e3ea024858ce9dff5aff5702b5741f4
cosmicRover/algoGrind
/graphs/graphBfs.py
2,673
3.96875
4
class Vertex: def __init__(self, name): self.name = name self.neighbors = list() self.visited = False def addNeighbor(self, vertex): neighborSet = set(self.neighbors) if vertex not in neighborSet: self.neighbors.append(vertex) self.neighbors.so...
cdedd3c3fea76a38be226a9606b1141b60babddf
cosmicRover/algoGrind
/trees/LCA.py
1,714
4.0625
4
#leetcode 236 # use a hastab to remember parents # use dfs to traverse # use a set later to backtrack from given nodes to it's parents # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: ...
a5ea33990ea81e2b74f114772dfa912169d39d14
cosmicRover/algoGrind
/tries/WordDict.py
1,633
3.875
4
class TrieNode: def __init__(self): #a dict that holds the children self.children = {} self.isEnd = False class WordDictionary: def __init__(self): self.root = TrieNode() def addWord(self, word): node = self.root for w in word: #if letter alread...
c331264c584488f9bc0deab8d3e425a68754c276
cosmicRover/algoGrind
/array-strings_stacks/NoZero.py
960
3.515625
4
#this is one of the stupidest questions on leetcode... class Solution: #Time (# of time n decerements before no 0 encounters + # of time diff incerments when encountering a 0) | space O(1) def getNoZeroIntegers(self, n: int) -> List[int]: upper = None if '0' in str(n): uppe...
92171422e44492af9164e4255312eeac2b1eb85d
cosmicRover/algoGrind
/greedyAlgo/dijkstra-prac.py
2,032
3.78125
4
# Practicing me some of the all powerful Dijkstra # find the cheapest path to one node to it's destination node # Time O((Edges + Vertices) log(Vertices)) with the binary heap # Space O(V^2E + E)?? # import some collections + prirority queue heapq modules for less boiler plate from collections import defaultdict impor...
78cf2641035773c91fd62769187693fd0bb1bcde
cosmicRover/algoGrind
/DP/ClimbStairs.py
585
3.59375
4
''' DP slution. You can take single steps from i-1 steps or double steps from i - 2 steps Combind, you can take [i-1] + [i-2] steps Time O(n) | Space O(n) Can improve space to O(1) using fibbonachi sequence since this problem qualifies ''' class Solution: def climbStairs(self, n: int) -> int: if n == 0: ...
d5e9b460ab29225d283b124b76e3a605d83208e1
cosmicRover/algoGrind
/trees/FlattenTree.py
1,094
4
4
''' Time O(N) | In place return ***Always keep a pointer to the previous element whenever you need to modify links ''' # Definition for a binary tree node. class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: ...
b879b4e63f9a341bf5f0d6870e5c997836cbbf82
cosmicRover/algoGrind
/array-strings_stacks/ReorderLogs.py
975
3.703125
4
''' sort lexographically using lambda function and priority [:] the key observation in this problem is that letter logs have words after the first word, and dig logs have a number after the first log. We use this to determine were to append a particular log Time O(n + idSort + suffSort) Space O(n for let + nums) ''' ...
9f362fbd2cd25b3cb4f2a809dc5bd5b740d2bc35
cosmicRover/algoGrind
/bfs/level-order-successor.py
900
3.828125
4
from collections import deque class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None def find_successor(root, key): ''' level order bfs pop(0) return the next item that comes after matching with key ''' q = [root] returnNext = False while q: size = l...
2d2c79af06739f40db5da637e6441f8120d15550
cosmicRover/algoGrind
/DP/count1s.py
1,141
3.5
4
class Solution(object): def countBits(self, num): """ :type num: int :rtype: List[int] """ # DP solution # Time and space O(n) # base case 0 array = [0] # if > 0, insert a 1 if num > 0: array.append(1) """ ...
efb82810c38b016283291c3f1e33b0373911c433
cosmicRover/algoGrind
/recursion/NthFib.py
884
3.84375
4
# Problem E5 # Soultions # O(2^n) | O(n) space # use recursion to get the nth fib def nthFib(target): if target == 2: return 1 elif target == 1: return 0 else: return nthFib(target - 1) + nthFib(target - 2) # O(n) time | O(n) space # use a hash table to store fibs and return th...
c3da30b46e4fc83e3408a3a07e6493f5c33b85d3
cosmicRover/algoGrind
/trees/isBadVersion.py
839
3.875
4
# The isBadVersion API is already defined for you. # @param version, an integer # @return an integer # def isBadVersion(version): # can use isBadVersion(version) to check for a bad version ''' This is a simple problem but confusingly worded. This basically boils down to given a numbr, I want you to find a number usin...
49b7c2fde5660c55e4359958f15dd43fee538c42
cosmicRover/algoGrind
/array-strings_stacks/NUniqueIntsTo0.py
482
3.796875
4
''' why does arr[i] = i*2 - n+1 work? If you make a line on the x axis and start from -n and end at n, you can plug the formula in to find n unique values that will add up to 0. arr[0] = 0*2 - n+1 -> -4, arr[1] = -2 ... arr[4] = 4 ''' class Solution: # time and space O(n) def sumZero(self, n: int) -> [int]: ...
afbacf601c0f0b1a6fb6720c044c008b285c5cf9
sugano-nu/uni17ci
/ass2/coding/nn_regression.py
14,300
3.8125
4
import numpy as np from sklearn.metrics import mean_squared_error from sklearn.neural_network.multilayer_perceptron import MLPRegressor import matplotlib.pyplot as plt from nn_regression_plot import plot_mse_vs_neurons, plot_mse_vs_iterations, plot_learned_function, \ plot_mse_vs_alpha,plot_bars_early_stopping_mse...
478f23c25c59853c90d37a1fea6e23b1a9079147
SuleimanMS/topshiriqlar
/masala 24.06.21/6)3 ta sondan kattasi.py
181
3.734375
4
while True : a = int(input('\n3ta son kiriting:\na = ')) b = int(input('b = ')) c = int(input('c = ')) toplam=[a, b, c] toplam.sort() print(toplam[-1])
c9a5a1712841608979e3c65a28005cf7f297362f
SuleimanMS/topshiriqlar
/masala 25.06.21/9)oy, kunlari bilan.py
701
3.828125
4
while True : n = int(input('\nOy tartib raqamini kiriting:\n---> ')) oy = ['Yanvar','Fevral','Mart','Aprel','May','Iyun','Iyul','Avgust','Sentyabr','Oktyabr','Noyabr','Dekabr'] if n < 1 or n > 12 : print('Xatolik!') else : print(f'\n{oy[n-1]}',end=': ') if n == 1 or n == ...
a65a75c1374212d477ad90e5bd36d5d9aadcba54
SuleimanMS/topshiriqlar
/masala 24.06.21/7)raqamlar bir xilligi.py
243
4
4
while True : a = int(input('\n3ta son kiriting:\na = ')) b = int(input('b = ')) c = int(input('c = ')) if a == b and a == c : print(3) elif a == b or a == c : print(2) else : print(0)
f8d49a1e188b10b1208cbbf4002f964be732f4b3
SuleimanMS/topshiriqlar
/masala 24.06.21/12)yoshni aniqlash.py
269
3.75
4
while True : n = int(input('\nYoshingizni kiriting: ')) if n <= 0 or n >= 130 : print('Inson buncha yashamaydi') else : if n >=25 and n <=40 : print('To`g`ri keladi') else : print('To`g`ri kelmaydi')
a400ff86fd8f049f4b29ccee8ec1c2dfe5e7d77e
Ratta-Chindasilpa/CP3-Ratta-Chindasilpa
/assignment/Lecture71_Ratta_C.py
687
3.859375
4
menuList = [] priceList = [] totalPrice = 0 def showBill(): sayMyFood = "My Food" print(sayMyFood.center(50,"-")) for number in range(len(menuList)): print(menuList[number], priceList[number]) priceList[number] = priceList[number] + priceList[number] print("Total Price : ", totalPrice) ...
f6331ed3696d80409560ddbc09894ed9abe32ec3
Ratta-Chindasilpa/CP3-Ratta-Chindasilpa
/example/AssertExample.py
278
4.03125
4
#x = 'hello' x = 'goodbye' assert x == 'goodbye', "x should be 'hello'" #ถ้าเงื่อนไขถูกต้อง(เป็นTrue) จะไม่Error #assert i < 5, "Error" for i in range(10): #assert i < 5, "Error" print(i) assert i < 5, "Error"
39ae0cc0d3518ccd7e951f2126e00db32fe1d0a2
Ratta-Chindasilpa/CP3-Ratta-Chindasilpa
/example/JSONExample.py
1,192
3.984375
4
#https://www.w3schools.com/js/js_json_arrays.asp #JSON จะเป็นข้อมูลที่มีรูปแบบคล้ายกับ list ใน python ที่เก็บข้อมูลแบบ key value '''{ "name": "John", "age": 30, "cars": ["Ford", "BMW", "Fiat"] }''' import json #Read JSON def readJson(): # ข้อมูล JSON ที่เราต้องการอ่าน x = '{ "name":"John", "age":...
fb41df467e717429c6e76de068d57d8f392d6d12
Ratta-Chindasilpa/CP3-Ratta-Chindasilpa
/example/Lecture53_Ratta_C.py
151
3.734375
4
def vatCalculate(totalPrice): result = totalPrice + (totalPrice * 7 / 100) return result print(vatCalculate(int(input("Enter Total Price: "))))
aef07908a7b1c1091861e915c412304917c75860
BruceSniper/MarkdownFiles
/数据库/search_old.py
2,035
3.578125
4
#!/usr/bin/env python # -*- coding:utf-8 -*- # Author:Bruce Zhang from pymysql import connect class JD(object): def __init__(self): pass def show_all_items(self): conn = connect(host='localhost', port=3306, user='root', password='1892', database='jing_dong', charset='utf8') # 获得Cusor...
60cdf471078d8423b7668c1104f7398daad4a8aa
serikisaev/serikisaev
/fibonacci.py
369
3.765625
4
class Fibonacci: def __init__(self): self.first = 0 self.second = 1 def __next__(self): result = self.first self.first, self.second = self.second, self.first + self.second return result def __iter__(self): return self for i in Fibonacci(): ...
3211aaae0cdbca9324479483fb2206519ccf8ca2
TonyPwny/cs440Ass1
/board.py
1,614
4.1875
4
# Thomas Fiorilla # Module to generate a Board object import random #import random for random generation def valid(i, j, size): roll = random.randint(1, max({(size - 1) - i, 0 + i, (size - 1) - j, 0 + j})) return roll # function to generate the board and place the start/end points # returns the built board and...
bd30e544beabc8a27f9dc2397b1395c233d8c583
rotuloveio/CursoEmVideoPython
/Mundo3/Aula21/ex104.py
507
4.1875
4
# Crie um programa que tenha a função leiaint(), que vai funcionar de forma semelhante à função input() do Python, só # que fazendo a validação para aceitar apenas um valor numérico. def leiaint(msg): while True: num = str(input(msg)) if num.isnumeric(): return int(num) ...
5b4cb97e92b1ed1b811bd4d1a84533a56df741f1
rotuloveio/CursoEmVideoPython
/Mundo3/Aula20/ex096.py
371
3.90625
4
# Faça um programa que tenha uma função chamada área(), que recebe as dimensões de um terreno retangular (largura e # comprimento) e mostre a área do terreno. def area(a, b): print(f'A área de um terreno {a} x {b} é de {a*b}m².') print('Controle de Terrenos') print('-' * 20) area(float(input('Largura [m]:...
2802f036222e88fcfb5da67c5f3fcb5144a224d1
rotuloveio/CursoEmVideoPython
/Mundo2/Aula13/ex053.py
362
4.09375
4
# Crie um programa que leia uma frase qualquer e diga se ela é um palíndromo, desconsiderando os espaços. frase = input('Digite uma frase: ').upper().split() spaceless = ''.join(frase) reverso = spaceless[::-1] if spaceless == reverso: print('A frase digitada é um palíndromo.') else: print('A frase...
bb4ebfdb468e6f11421cd977331c291d3d12f351
rotuloveio/CursoEmVideoPython
/Mundo1/Aula8/ex019.py
409
3.921875
4
# Um professor quer sortear um dos seus quatro alunos para apagar o quadro. Faça um programa que ajude ele, lendo o nome # deles e escrevendo o nome do escolhido. # Copiado da solução do exercício. import random n1 = input('Aluno 1: ') n2 = input('Aluno 2: ') n3 = input('Aluno 3: ') n4 = input('Aluno 4: ') ...
4180bc914c45bcb6e14396bea5645f9106b7265c
rotuloveio/CursoEmVideoPython
/Mundo1/Aula8/ex016.py
195
4.0625
4
# Crie um programa que leia um número real qualquer pelo teclado e mostra na tela a sua porção inteira. d = float(input('Digite um número: ')) print(f'A parte inteira de {d} é {d:.0f}.')
68edf05eacc3113f09a101c78825ce260ba82ce9
rotuloveio/CursoEmVideoPython
/Mundo3/Aula21/ex101.py
601
4.15625
4
# Crie um programa que tenha uma função chamada voto() que vai receber como parâmetro o ano de nascimento de uma pessoa, # retornando um valor literal indicando se a pessoa tem voto NEGADO, OPCIONAL ou OBRIGATÓRIO nas eleições. from datetime import date def voto(ano): idade = date.today().year - ano re...
4cf450f3653e17577c5f02b3d3a7c4406a2d57e2
rotuloveio/CursoEmVideoPython
/Mundo2/Aula13/ex048.py
309
3.703125
4
# Faça um programa que calcule a soma entre todos os números ímpares que são múltiplos de três e que se encontram no # intervalo de 1 até 500. s = 0 val = 0 for i in range(3, 501, 3): if i % 2: s += i val += 1 print(f'A soma de todos os {val} valores solicitados é {s}.')
97f920c434fed694b9f1e40dbb8bc674a6c06e6e
rotuloveio/CursoEmVideoPython
/Mundo1/Aula10/ex029.py
365
3.796875
4
# Escreva um programa que leia a velocidade de um carro. Se ele ultrapassar 80km/h, mostre uma mensagem dizendo que ele # foi multado. A multa vai custar R$7,00 por cada km acima do limite. vel = int(input('Velocidade [km/h]: ')) if vel > 80: print(f'Você foi multado em R${7*(vel-80):.2f}.') else: print('...
01017d8126a3d166dfd73b415b4044e9a8afbce1
rotuloveio/CursoEmVideoPython
/Mundo3/Aula16/ex073.py
767
3.890625
4
# Crie uma tupla preenchida com os 20 clubes do brasileirão, na ordem de colocação. # Depois mostre: # - os 5 primeiros. # - os 4 últimos. # - os times em ordem alfabética. # - em que posição está a Chapecoense bra = ('Atlético-MG', 'Palmeiras', 'Fortaleza', 'Bragantino', 'Flamengo', 'Athletico-PR', 'Atlé...
9a32164436491a06e9dff367bd8ce1b533a60826
rotuloveio/CursoEmVideoPython
/Mundo3/Aula23/ex113.py
783
4.09375
4
# Reescreva a função leiaint() do DESAFIO 104, incluindo agora possibilidade da digitação de um número de tipo inválido # Aproveite e crie também uma função leiafloat() com a mesma funcionalidade. def leiaint(msg): while True: n = input(msg) try: return int(n) except: ...
c9517047532b457a55f4261cde6135d596dab73c
rotuloveio/CursoEmVideoPython
/Mundo2/Aula12/ex045.py
511
3.875
4
# Crie um programa que faça o computador jogar jokenpô com você. import random jokenpo = ['pedra', 'papel', 'tesoura'] while 1: pl = input('Digite pedra, papel ou tesoura: ') pc = random.choice(jokenpo) print(f'PC: {pc} x PLAYER: {pl}') if pc == pl: print('Empate.') elif(pc ==...
1991144be979f625a67871413ef4480589d4236f
rotuloveio/CursoEmVideoPython
/Mundo2/Aula12/ex038.py
418
3.859375
4
# Escreva um programa que leia dois números inteiros e compare-os, mostrando na tela uma mensagem: # - o primeiro valor é maior. # - o segundo valor é maior. # - os valores são iguais. n1 = int(input('Primeiro número: ')) n2 = int(input('Segundo número: ')) if n1 > n2: print(f'O primeiro é maior.') elif n...
8dd13cbf2b88bab990ef287434a8f65595fa3ed9
rotuloveio/CursoEmVideoPython
/Mundo1/Aula7/ex007.py
225
3.859375
4
# Desenvolva um programa que leia as duas notas de um aluno, calcule e mostre a sua média. n1 = float(input("Primeira nota: ")) n2 = float(input("Segunda nota: ")) print(f"A média entre {n1} e {n2} é {(n1+n2)/2:.1f}")
87361760eb8dfb19557a5b350190100857bf4229
mplaw/Eagle
/PhysicalConstants.py
3,108
3.609375
4
""" Contains all physical constants in an object called 'Constant', with some methods to change their units. Imports directly into global namespace. Constants (default units are cgs): pi exp : Euler's number c : Speed of light e : Elementary charge k_B ...
2ec5b970796d83dcffd35cdb01ce080353e9dfd9
rajubapi/NN-Notes
/Blog/MLFFNN/MLFFNN-2/Figures/approx3.py
1,015
3.6875
4
import matplotlib.pyplot as plt import math import numpy as np def f(x): return 1 if x >= 2 and x <= 6 else 0 def sigmoid(x): """The Sigmoid function""" return 1 / (1 + math.exp(-x)) def draw(): global sigmoid, f x1 = np.linspace(0, 10, 8000) f = np.vectorize(f) y1 = f(x1) x = np.a...
f6cf5e0eee9808bfb149471ffb26bc259d769d8f
sushantdesh/MyCodeJamSolutions
/cj2019p2.py
3,054
3.8125
4
#https://codingcompetitions.withgoogle.com/codejam/round/0000000000051705/00000000000881da #Problem #You have just entered the world's easiest maze. You start in the northwest cell of an N by N grid of unit cells, #and you must reach the southeast cell. You have only two types of moves available: a unit move to the ...
eff65f9770a0da36684c96ccf172d2c675f71da7
texttxet/my_python
/huashidu_zhuan_sheshidu.py
227
3.703125
4
f = float(input('请输入要转换的华氏度:')) # 获取输入的数据 c = (f - 32) / 1.8 print('华氏度:{:.5} \n对应的摄氏度:{:7.2f}'.format(f,c)) # 格式化字符串,以7个字符宽度和保留2位小数
15eaf07cb7eec11b874204566870fda78e5dcb10
psarangi550/PratikAllPythonRepo
/Python_Logging_Example/custome_logger_wirth_both_handler.py
1,493
3.515625
4
#here if we need to add the both Handler we can do that which is not possible with the root logger #here we will also can take different different logging level for the logger import logging#iomporting the logging module logger=logging.getLogger("demoLogger") #creating the logger object logger.setLevel(logging.DEBUG)#s...
30b85504154a9a22042c416955ca643818f45e63
psarangi550/PratikAllPythonRepo
/Python_OOS_Concept/Monkey_Pathching_In_Python.py
2,149
4.4375
4
#changing the Attribute of a class dynamically at the runtime is called Monkey Patching #its a common nature for dynamically typed Language #lets suppose below example class Test:#class Test def __init__(self):#constructor pass#nothing to initialize def fetch_Data(self):#instance method #remeber...
d277cf72b228081e6047132829055d4534cfff2d
psarangi550/PratikAllPythonRepo
/python_misc_program/checking_the_sorting_order.py
496
3.828125
4
class Employee(object): def __init__(self,ename,age,salary): self.ename=ename self.age=age self.salary=salary def __repr__(self): return f"[{self.ename},{self.age},{self.salary}]" def employee_sorting(emp): return emp.salary e1=Employee("pratik",30,10000) e2=Employee("Rika",2...
a7d4f6ccd49bf76efc96d5de97c2c0fe506eb927
psarangi550/PratikAllPythonRepo
/Python_OOS_Concept/Operator_Overloading_Example_2.py
1,235
3.96875
4
#here we are considering the > and < along with >= and <= and == and != operator on the student object #method=========================>Magic Method #> it is =======================>__gt__() #< it is =======================>__lt__() #<= it is =======================>__le__() #== it is =======================>__eq__() #...
4c7327f7039c55a5f92a449044e833b4f878157f
psarangi550/PratikAllPythonRepo
/Django_python_Package_checking/packagepratik/build/lib/packagepratik/addition_by_pratik.py
184
3.765625
4
# import time def add(a,b):#defining the function with arguments # time.sleep(3)#sleeping for 3 seconds print(f"The addition is {a+b} value")#printing the value to the console
868fdabbf74497aa90b88822bde778e5ea271ed7
psarangi550/PratikAllPythonRepo
/python_with_sqlite_db_by_corey_schafer/Employee_Demo_module.py
427
3.640625
4
class Employee(object):#employee class def __init__(self,first,second,pay): self.first=first self.second=second self.pay=pay @property def email(self): return "{}.{}@gmail.com".format(self.first,self.second) @property def fullname(self): return "{} {}".format(...
7eda2be6f4870cc72a85f40ec1b452fe6f30a8b2
marcelmon/react-fhe
/fhe/shield_spark/fhe_server.py
4,164
3.609375
4
""" Very simple HTTP server in python. Usage:: ./dummy-web-server.py [<port>] Send a GET request:: curl http://localhost Send a HEAD request:: curl -I http://localhost Send a POST request:: curl -d "foo=bar&bin=baz" http://localhost """ from http.server import BaseHTTPRequestHandler, HTTPServer import ...
813e22af67bacb273416b2c00759f389faae1e9b
shnlmn/Rhino-Grasshopper-Scripts
/IronPythonStubs/release/stubs.min/System/__init___parts/Math.py
26,012
3.65625
4
class Math(object): """ Provides constants and static methods for trigonometric,logarithmic,and other common mathematical functions. """ @staticmethod def Abs(value): """ Abs(value: Single) -> Single Returns the absolute value of a single-precision floating-point number. value: A number that is g...
e2376180e55ebe3a358e939e1fcfc7926f193dca
shnlmn/Rhino-Grasshopper-Scripts
/IronPythonStubs/release/stubs.min/System/Windows/Forms/__init___parts/PowerStatus.py
1,189
3.53125
4
class PowerStatus(object): """ Indicates current system power status information. """ BatteryChargeStatus=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets the current battery charge status. Get: BatteryChargeStatus(self: PowerStatus) -> BatteryChargeStatus """ BatteryFullLifetime...
80ef0ed987bd197d292af547084d41dfaea4efa2
shnlmn/Rhino-Grasshopper-Scripts
/IronPythonStubs/release/stubs.min/System/__init___parts/BitConverter.py
8,722
3.765625
4
class BitConverter(object): """ Converts base data types to an array of bytes,and an array of bytes to base data types. """ @staticmethod def DoubleToInt64Bits(value): """ DoubleToInt64Bits(value: float) -> Int64 Converts the specified double-precision floating point number to a 64-bit signed integer. ...
06a6e62444df3a2460624e39e2ef290b479e05d8
shnlmn/Rhino-Grasshopper-Scripts
/IronPythonStubs/release/stubs.min/System/Drawing/__init___parts/Point.py
4,334
3.71875
4
class Point(object): """ Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional plane. Point(x: int,y: int) Point(sz: Size) Point(dw: int) """ @staticmethod def Add(pt,sz): """ Add(pt: Point,sz: Size) -> Point Adds the specified System.Drawing.Size...
9aa97dc3fddbb58eba3c29a69812f8b4e51440eb
shnlmn/Rhino-Grasshopper-Scripts
/IronPythonStubs/release/stubs.min/System/Windows/Forms/__init___parts/HtmlHistory.py
2,695
3.734375
4
class HtmlHistory(object,IDisposable): """ Manages the list of documents and Web sites the user has visited within the current session. """ def Back(self,numberBack): """ Back(self: HtmlHistory,numberBack: int) Navigates backward in the navigation stack by the specified number of entries. numberBack: ...
303ab295f1b4e7514de1e48197a5460aff175d92
shnlmn/Rhino-Grasshopper-Scripts
/IronPythonStubs/release/stubs.min/System/__init___parts/Byte.py
11,913
3.59375
4
class Byte(object,IComparable,IFormattable,IConvertible,IComparable[Byte],IEquatable[Byte]): """ Represents an 8-bit unsigned integer. """ def bit_length(self,*args): """ bit_length(value: Byte) -> int """ pass def CompareTo(self,value): """ CompareTo(self: Byte,value: Byte) -> int Compares this inst...
f1a92ac4d9e4b11d0440ea8f428cf5c1f4e2ebe1
tommyhall/arsenHAL
/MatchScraper/main.py
1,605
3.5
4
__author__ = 'tom' # This is the program entry point # Creates a list of matches to scrape, sends to the match scraper # TODO: your current method of getting # goals does not account for own-goals # TODO: scrape and store player data import os from MatchScraper import MatchScraper def get_matchday_dict(data_direct...
0811b2ac345765eda7229b5a9a87dd75d16c7af7
ola-sumbo/initial-week-1-and-2-with-taken-mind
/handling_null_data.py
1,060
3.765625
4
import numpy as np import pandas as pd from pandas import Series, DataFrame series1 = Series(['A', 'B', 'C', 'D', np.nan]) # function to validate to check if there is null print(series1.isnull()) # to drop null values print(series1.dropna()) # How it works with data frames df1 = DataFrame([[1, 2, 3, 4], [3, np.nan,...
e6e72531bbe3495617f27147a9d09f48fdd9f210
wesleykruger/open-office-mass-text-replace
/odt-string-replace.py
5,594
3.5625
4
import os, fnmatch, zipfile, sys, shutil from pathlib import Path textToReplace = "" textToInsert = "" # Use forward slashes for this path even if you are on Windows, pathlib's Path functionality handles it this way pathToOdtDirectory = "" def renameFileExtension(directory, startingExtension, endingExtension): ...
f39ab2c5262fc685abb52fa942ed53d0bda36ae3
celiawaves/python-gb-homeworks
/4.py
1,511
4.0625
4
# Запросите у пользователя значения выручки и издержек фирмы. # Определите, с каким финансовым результатом работает фирма # (прибыль — выручка больше издержек, или убыток — издержки больше выручки). # Выведите соответствующее сообщение. # Если фирма отработала с прибылью, вычислите рентабельность выручки (соотношен...
1bbc38978d15042164c2a458952ea34ba30853db
yuliia11882/CBC.Python-Fundamentals-Assignment-1
/Yuliia-py-assignment1.py
1,380
4.21875
4
#Canadian Business College. # Python Fundamentals Assignment 1 #PART 1:------------------------------- #enter how many courses did he/she finish # the input value (which is string) is converted into number with int() num_of_courses = int(input("How many courses have you finished? ")) print(num...
f1c9bf691912ff6580e255880651725c3201b4b4
willcritchlow/euler
/12e.py
297
3.53125
4
from math import sqrt triangle = 0 i = 0 while True: i += 1 triangle += i f = 0 for n in xrange(1,int(sqrt(triangle))): if triangle%n == 0: f += 2 if f > 500: print "we win" print i print triangle exit()
e62af9bd5466ba89a2011dbcfbeb499f6c1ce128
willcritchlow/euler
/14.py
806
3.796875
4
def iterative(n): if n%2 == 0: return n / 2 else: return 3*n + 1 def chain(n,count,cache): if n == 1: return 1, count, cache else: try: answer, count = cache[n] except: answer, count, cache = chain(iterative(n), count,cache) co...
f0f79977b017703c952a549575b1671440993d6f
samiCode-irl/programiz-python-examples
/Functions/ascii.py
111
4.15625
4
# Python Program to Find ASCII Value of Character char = 'A' print(f'ASCII value of {char} is: {ord(char)}')
6e3568a6057b0d88393120ad65238b14834d53ba
samiCode-irl/programiz-python-examples
/Native_Datatypes/count_vowels.py
273
4.125
4
# Python Program to Count the Number of Each Vowel vowels = 'aeiou' ip_str = 'Hello, have you tried our tutorial section yet?' sent = ip_str.casefold() count = {}.fromkeys('vowels', 0) for letter in sent: if letter in count: count[letter] += 1 print(count)
4832b19420ecb262df84c072ac3d680dbab8cc1b
samiCode-irl/programiz-python-examples
/Introduction/hello_world.py
175
4.09375
4
# Python Program to Print Hello world! # A simple program that displays “Hello, World!”. It's often used to illustrate the syntax of the language. print('Hello, World!')
0e8df91bfde24a4b21b0e92f0e6dfe0cee11c5a0
samiCode-irl/programiz-python-examples
/Decision_Making_and_Loops/even_or_odd.py
154
4.4375
4
# Python Program to Check if a Number is Odd or Even num = float(input('Enter the number: ')) if num % 2 == 0: print('even') else: print('odd')
983e95b6eea3dff980ca9c80bc45db7fed2d20eb
kilicmustafa/Python
/Python Temel/Döngüler ve koşullu ifade örnekleri/Ebob.py
1,711
3.796875
4
###Kullanıcıdan 2 tane sayı alarak bu sayıların en büyük ortak bölenini (EBOB) dönen bir tane fonksiyon yazın ## ##def ebobBulma(sayi_1 ,sayi_2): ## bolenler_1 = list() ## bolenler_2 = list() ## ## for i in range(1,sayi_1+1): ## i # #def ebob_bulma(sayı1,sayı2): # # i = 1 # ebob = ...
732ffa09000bc315c3f66a54a141e5b46b807aa3
kilicmustafa/Python
/Nesne Tabanlı Programlama/Sınıflar ve Mıras/MirasYapısı.py
369
3.625
4
class Person: def __init__(self,FirstName,LastName,Age): self.FirstName = FirstName self.LastName = LastName self.Age = Age class Worker(Person): def __init__(self,Salary): self.Salary = Salary class Customer(Person): def __init__(self,CrediCardNumber): self.CrediC...
3fc10f5de6e1cfc0f45cf9a066c655ec86b1b3ff
kilicmustafa/Python
/Python Temel/Döngüler ve koşullu ifade örnekleri/BirSayininTamBolenleriListe.py
414
3.765625
4
def tamBolen(sayi): tamBolenler = list() for i in range(sayi,1,-1): if (sayi % i == 0): tamBolenler.append(i) for i in tamBolenler: print(i) while True : sayi = input("Bir sayı girin (Cıkmak için q 'a basın) : ") if (sayi == "q"): print("Programdan cıkılıyor..."...
9c0fbd86c91378d2add3b6ae486d0176f5f28f1c
kilicmustafa/Python
/Python Temel/Döngüler(Loop) for, while/WhileAndForExercises.py
1,316
3.796875
4
islemler = ["1-toplama ","2-Çıkarma","3-Çarpma","4-Bölme","Çıkmak için 'q' tuşuna basınız"] while True: print("Programa Hoşgeldiniz") print("*********************") for islem in islemler: print(islem) secenek = input("Ne yapmak istersiniz ? = ") if secenek == "q": print("Çıkış Yapıl...
faf7c84cb43727087014141f1dc92c0e77e305eb
kilicmustafa/Python
/Python ileri Seviye Modülleri ile Çalışmalarım/PyQt5/login.py
4,894
3.640625
4
import sys import sqlite3 from PyQt5 import QtWidgets class Kullanici(): def __init__(self ,USERNAME ,USERPASSWORD ,FIRSTNAME ,LASTNAME): self.USERNAME = USERNAME self.USERPASSWORD = USERPASSWORD self.FIRSTNAME = FIRSTNAME self.LASTNAME = LASTNAME class Veritabanı(): def __i...
b7fcb604287f7f2f08c79de69ce127bd909c46cc
kilicmustafa/Python
/Python Temel/Metin İslemleri/stringFrekansi.py
560
3.59375
4
"""Elinizde uzunca bir string olsun. "ProgramlamaÖdeviİleriSeviyeVeriYapılarıveObjeleripynb" Bu string içindeki harflerin frekansını (bir harfin kaç defa geçtiği) bulmaya çalışın. """ def metinFrekansiBul(metin): pass metin = "ProgramlamaÖdeviİleriSeviyeVeriYapılarıveObjeleripynb" sozluk = di...
fefd87c3d78a411d85aacbb59190ca3ee039b9f6
Tugceulu/GlobalAIHubMachineLearningCourse
/Homeworks/HW1.py
183
4.125
4
#Explain your work #Question 1 list1=[1,3,5,7,9] list2=[0,2,4,6,8] list=list1+list2 list=list*2 print("New list:",list) for i in list: print("Type of ",i," is: ",type(i),sep="")
a556813143ad5475d556a243697d3923a3edf672
Bala432/Python
/inheritance.py
282
3.578125
4
class A: def __init__(self): print("In A init") def show1(self): print("A show1") class B(A): def __init__(self): print("In B init") def show1(self): super().show1() print("B show1") a = A() # a.show1() b = B() b.show1()
5b58e04404c88a64164dbedd0f252a5aafba68cf
tomamic/paradigmi
/python/e3_2010_5_substr.py
678
3.65625
4
#!/usr/bin/env python3 ''' 3.5 Sottostringhe * Leggere da tastiera un testo generico * Estrarre le parti comprese tra '<' e '>' * Riprodurre in output, ciascuna su una riga, le parti selezionate (Es. “Scrivete a < john@example.com > per informazioni” → “john@example.com”) @author Michele Tomaiuolo - http://www.ce.unip...