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
55df7230f8c16978d330db41696460b89b2e25bd
shilpa5g/Python-Program-
/python_coding_practice/str_change.py
127
4.15625
4
def str_change(string): return string[-1] + string[1:-1] + string[0] str1 = input("enter a string: ") print(str_change(str1))
53b2d4df4596abff39f1a489f41415fce4a06b36
shilpa5g/Python-Program-
/python basic coding/midpoint.py
224
3.859375
4
x1 = int(input('value of x1: ')) y1 = int(input('value of 11: ')) x2 = int(input('value of x2: ')) y2 = int(input('value of y2: ')) mid_x = (x1 + x2)/2 mid_y = (y1 + y2)/2 print("mid point of the line is: ",mid_x,',',mid_y)
516defd5b62da3eb06cacfaddbd7e33b48c267f8
shilpa5g/Python-Program-
/python_coding_practice/leap_year.py
290
4.3125
4
# program to check a year is leap year or not year = int(input("enter a year: ")) if(year % 400 == 0): print(year,"is a leap year.") elif(year % 100 == 0): print(year,"is not a leap year.") elif(year % 4 == 0): print(year,"is a leap year.") else: print(year,"is not a leap year.")
fe9ba47442ce99a2ccdd68c6d58560997cbcc021
shilpa5g/Python-Program-
/python_coding_practice/square_root.py
171
4.4375
4
#program to find square root of any number num = float(input("enter a number: ")) square_root = num ** 0.5 print("The square root of {} is {}.".format(num, square_root))
0230151c53ea3f13baa6b353e2c9108452b1edff
shilpa5g/Python-Program-
/python_coding_practice/sum_of_series.py
276
4.25
4
# program to find Sum of natural numbers up to given range terms = int(input("Enter the last term of the series: ")) if terms < 0: print("please enter a positive number.") else: sum = 0 for i in range(1, terms+1): sum +=i print('sum of series = ',sum)
55084a7529445303cf7dc531022ee39ab52613d2
shilpa5g/Python-Program-
/python_coding_practice/palindrome.py
246
4.5625
5
# Program to check if a string is palindrome or not string = str(input("enter a string: ")) rev_str = reversed(string) if list(string) == list(rev_str): print("The string is a palindrome.") else: print("The string is not a palindrome.")
6f33f2e99c4c5109ff8a917182b6f2c3f83fca34
sadukie/IntroToPyForCSharpDevs
/PythonClassesAndInheritance2/PythonClassesAndInheritance.py
523
4.0625
4
from Person import Person from Employee import Employee p = Person("Thomas") print(p) print(isinstance(p,Person)) e = Employee("Bart","Senior Software Engineer") print(e) # Inheritance check print("Is Bart an employee?") print(isinstance(e,Employee)) print("Is Bart a person?") print(isinstance(e,Person)) print("Is...
c39d49ec380928762616cce6dbe4de019d4ecd0e
TobiAdeniyi/leetcode-problems
/Easy/LongestCommonPrefix/LongestCommonPrefix.py
620
3.703125
4
# Runtime: 28 ms, faster than 94.97% of Python3 online submissions # Memory Usage: 13.8 MB, less than 87.63% of Python3 online submissions # If list is empty return "" # Initialise i = 1, and s = "" # Let m be the length of the shortest strin # Whilest sliced strings are the same and i < m: ## s = slice of any string ...
6d36aab32f8e00dfb0f49b1107862a976501d85e
TobiAdeniyi/leetcode-problems
/Easy/ValidParentheses/ValidParentheses.py
337
3.578125
4
class Solution: def isValid(self, s): while len(s) > 0: if '()' in s: s = s.replace('()', '') elif '{}' in s: s = s.replace('{}', '') elif '[]' in s: s = s.replace('[]', '') else: return False ...
cefd16665ebbd31203aa4ccb0a50dc22bfc87b67
bentocg/Insight
/utils/encoder/match_dataset.py
1,133
3.625
4
""" Match Dataset ========================================================== PyTorch dataset construct to train MatchNN. Returns a pair of users and a binary y value for that pair when requested. Author: Bento Gonçalves License: MIT Copyright: 2020-2021 """ __all__ = ['MatchDataset'] import numpy as np from sklearn....
0933552780791231d049270508b209a25e1bea34
mvwei/omega-code
/helpers.py
5,296
3.578125
4
import numpy as np import pandas from classes import ScalarField """ For model-specific functions. Calculating things like distances, heat flux, etc. """ def great_circle_distance(coor1, coor2, unit='m'): """ Given two sets of coordinate arrays [lat, lon], calculate the great circle distance between them....
d943ce38136830334f3a5a2ef38014d4976ec611
alexlarin13/minesweeper
/minesweeper.py
2,962
3.71875
4
import random as r N, M = (5, 10) # размер игрового поля (N x N) и M мин на поле def getTotalMines(PM, i, j): '''определение числа мин на соседних клетках для кдетки на которой мины нет''' n = 0 for k in range(-1, 2): for l in range(-1, 2): x = i + k y = j + l if x < 0 or x >= N or y < 0 or y >= N: ...
7d8190cf258e8bc9858fc9dffd288f6dcc7f58c3
akshatrastogi25/Python
/continue.py
196
3.859375
4
for num in [20, 11, 9, 66, 4, 89, 44]: # Skipping the iteration when number is even if num%2 == 0: continue # This statement will be skipped for all even numbers print(num)
cd68a6b7dd5ad5eef25f0137a807afeecdc29622
akshatrastogi25/Python
/Numpy/basic9.py
163
3.625
4
import pandas as pd import numpy as np df = pd.DataFrame(np.random.randn(4,3),columns=['col1','col2','col3']) for key,value in df.iteritems(): print key,value
e0089706aef394def9db5ce8a3f7d2346b42eb19
tinypico/tinypico-micropython
/io-expander/mcp23017_test.py
1,429
3.78125
4
# Examples using the MCP23017 16-bit I/O Expander from tinypico_io_expander import * # ----------- # Simple IO # set pin 0 as input with pull-up mcp.pin(0, mode=1, pullup=1) print(mcp.pin(0)) # set pin 1 as output low mcp.pin(1, mode=0, value=0) # set pin 2 as output high mcp.pin(2, mode=0, value=1) # -----------...
88f472723c89f56003fa6d87b58f48e23ca49ed0
ITU-DASYALab/O3
/PhotoCube/photocube/actions/abstract.py
933
3.953125
4
from datetime import datetime class AbstractAction: """ Abstract class for actions. Provides basic functionality for for deriving actions. """ def __init__(self, actionType, actionName): """ Constructor for the AbstractAction. """ self.__actionType = actionTyp...
9ade554cd054c0cb8efd9fa570e5b30b6fcfb198
muratsoyaslan/simplecalculator
/atm.py
536
3.609375
4
bakiye = 1000 while True: islem= input("İşlemi seçiniz:") if(islem == "q"): print("Yine Bekleriz") break elif (islem=="1"): print("Bakiyeniz {} tl dir".format(bakiye)) elif (islem=="2"): miktar = int(input("Miktarı giriniz:")) bakiye += miktar elif (islem=="3")...
494bdf184ccfe09567a2d33ce3e84daad2c02ae9
aDerringer/pyCS161
/Week4/heap.py
4,458
4.125
4
########################################################################## # Author: Andrew Derringer # Object: Heap ADT # Last Modified: 5/16/2019 # Description: # Overview: Heap holds a list and size variable. Heap adjustments # intentionally omitted from list additions to show the # ...
4b88251838da819ffc9f7136e59ec9a105f5b0dd
aDerringer/pyCS161
/Week4/helperFunctions.py
2,203
4
4
### # Constants ### PI = 3.14 GRAVITY = 9.8 ### # Function: Validate integer input # Param: string message requesting input # Pre: None # Post: Stores string and attempts to conver to int. Loops if error. # Ret: integer input # Citation: https://stackoverflow.com/questions/23294658/asking-the-user-for-input-until-th...
cb28980a2a40cd93627eb53fad7b7f5fe96c6ee2
ian-su-sirca/advent_of_code_2015
/day03/part2.py
1,153
3.71875
4
#!/usr/bin/env python from common import * class Mover(object): def __init__(self): self.x = 0 self.y = 0 def move(self, move): if move == '^': self.y -= 1 elif move == 'v': self.y += 1 elif move == '<': self.x -= 1 elif move =...
9468880ca31206720cd31f73b42a63bdf98f039d
ian-su-sirca/advent_of_code_2015
/day11/part2.py
1,218
3.53125
4
#!/usr/bin/env python import sys sys.path.append('..') from common import * def string_to_num(s): num = 0 for c in s: charval = ord(c) - ord('a') num = num * 26 + charval return num def num_to_string(n): s = '' while n >= 26: charval = n % 26 s = chr(charval + ord('...
3de4aa1ec49da3b97520f0b652d3358d625658de
nelsonuhan/pdftrim2up
/pdftrim2up/pdftrim2up.py
4,154
3.5625
4
import os import argparse from PyPDF2 import PdfFileReader, PdfFileWriter def main(): ''' Trim and 2-up PDF file ''' parser = argparse.ArgumentParser( description="Trim the margins of a PDF, place them 2-up" ) parser.add_argument("input", metavar="FILE", help="P...
1f87712062336077126c1292402dd2d792874672
R-Saxena/Leetcode-Solutions
/Sort By Parity.py
330
3.609375
4
# -*- coding: utf-8 -*- """ Created on Fri May 15 14:52:18 2020 @author: rishabhsaxena01 """ class Solution: def sortArrayByParity(self, A: List[int]) -> List[int]: B = [] for i in A: if i%2==0: B.insert(0,i) else: B.append(i) ...
dae59d8d0e53211c50a9a6ffa45f223670e81262
DavidALlbaHernandez/taller4
/ejercicio2.py
680
3.53125
4
#Imprima todos los paises y capitales, cuyo inicio sea con la letra U archivo = open('paises.txt', 'r') print("las ciudades que inician con la Letra u son: ") print() lista1=[] ciudad=[] for i in archivo: a=i.index(":") for r in range(a+2,len(i)): lista1.append(i[r]) a="".join(lista1) ciudad.append(a) lis...
1d8b3bddd49c45bac5c67a9e00da112387e19dbe
gabrielSampaioDev/Python_code
/Primitivos/Codes/006 Dobro, Triplo, Raiz.py
200
3.84375
4
n1 = int(input('Digite um número: ')) dobro = n1*2 triplo = n1*3 raiz = n1**(1/2) print('O número \033[1;35m({})\033[m tem: \nDobro: {} \nTriplo: {} \nRaiz: {:.2f}'.format(n1, dobro, triplo, raiz))
f79a6881c3cdf7f8f950014b2484c43471d5644a
gabrielSampaioDev/Python_code
/Condicionais 2.0/Codes/045 Game - Pedra Papel e Tesoura.py
1,979
3.640625
4
import emoji from random import randint from time import sleep # INTRO print('-=-'*20) print('|', ' '*24, 'JOKENPÔ', ' '*23, '|') print('-=-'*20) # ESCOLHA DO JOGADOR print(emoji.emojize('[ 1 ] PEDRA :fist:', use_aliases= True)) print(emoji.emojize('[ 2 ] PAPEL :hand:', use_aliases= True)) print(emoji.emojize('[ 3 ] TE...
4efd6dbcb546dc2d1b7840efca5c0937b9b46608
gabrielSampaioDev/Python_code
/Primitivos/Codes/011 Pintando Parede.py
283
3.75
4
largura = float(input('Digite (em metros) a largura da parede: ')) comprimento = float(input('Digite (em metros) o comprimento(altura) da parede: ')) area = largura * comprimento litro = area / 2 print('A area tem {:.2f}M²\nSerá preciso {} litro(s) de tinta.'.format(area, litro))
a15bc773eba12fc466cd9e5c4741909badc7ae38
gabrielSampaioDev/Python_code
/Condicionais 2.0/Codes/043 IMC.py
509
3.953125
4
print('-=-'*20) print('|', ' '*15, 'ÍNDICE DE MASSA CORPORAL', ' '*15, '|') print('-=-'*20) altura = float(input('Digite sua altura(ex.: 1.70): ')) peso = float(input('Digite seu peso(ex.: 69.2): ')) imc = peso / (altura)**2 if imc <= 18.5: print('Abaixo do Peso.') elif imc > 18.5 and imc < 25: print('Peso Idea...
8c2e77ba3ed7a5377d295c3ce665d62d1f0e417a
gabrielSampaioDev/Python_code
/Condicionais/Codes/035 Analisando Triangulo v1.py
408
3.90625
4
r1 = float(input('Digite o comprimento da PRIMEIRA reta: ')) r2 = float(input('Digite o comprimento da SEGUNDA reta: ')) r3 = float(input('Digite o comprimento da TERCEIRA reta: ')) if (r2 - r3) < r1 < r2 + r3 and (r1 - r3) < r2 < r1 + r3 and (r1 - r2) < r3 < r1 + r2: print('\033[1;32mÉ possível\033[m formar um tr...
61aa81abf98baeaee9548422aa43d568b577a1e2
gabrielSampaioDev/Python_code
/Condicionais/Codes/029 Radar Eletrônico.py
459
3.53125
4
from time import perf_counter, sleep velocidade_carro = float(input('Qual a velocidade que o carro estava? ')) print('PROCESSANDO...') sleep(3) if velocidade_carro > 80: multa = (velocidade_carro - 80) * 7 print('Você foi \033[1;31m multado\033[m. O valor da multa é de: R$ \033[1;31m{:.2f}\033[m'.format(multa))...
269b9cf12e65eff33983e93b861d22c3d3b7a899
wonheejo/Algorithms
/algorithms.py
9,724
3.703125
4
import time import timeit import math """ print("\ /\ ") print(" ) ( ') ") print("( / ) ") print(" \(__)| ") # A+B problem a, b= input().split() def sum(a, b): return (int(a)-int(b)) print(sum(a, b)) # fibonacci algorithm problem counter = 0 counter1 = 0 def fibo(a): global counter global c...
a53a2ab42c28d64ab573c215bccad8ab08ecc55e
dmodena/grokking-algorithms
/algorithms/loop/key_search.py
700
3.8125
4
class Box: ''' Can hold a key and/or other boxes inside. ''' def __init__(self, items=[]): self.items = items def __str__(self): return 'box' class Key: ''' Item being searched for. ''' def __str__(self): return 'key' def key_search(item): ''' Looks...
7d6c09c863d6b57eea56540af4b7e6aa2d163057
dmodena/grokking-algorithms
/algorithms/loop/test_binary_search.py
472
3.5
4
import unittest from algorithms.loop.binary_search import binary_search class TestBinarySearch(unittest.TestCase): def test_binary_search(self): self.assertEqual(binary_search([1, 3, 5, 7, 9], 3), 3) self.assertEqual(binary_search([1, 3, 5, 7, 9], 5), 5) self.assertEqual(binary_search([1, 3...
3216902d4befc2cffc67d49fff5b3c5c6bb6b767
dmodena/grokking-algorithms
/algorithms/recursion/sum.py
150
3.671875
4
def sum(arr): ''' Returns the sum of all elements in an array. ''' if len(arr) > 0: return arr.pop(0) + sum(arr) return 0
7d7ac0d51758458af03015b2b016c7608d266232
fminor5/TonyGaddisCh13
/p13-7button_demo.py
849
4.28125
4
import tkinter import tkinter.messagebox class MyGUI: def __init__(self): self.main_window = tkinter.Tk() # Create a Button widget. The text 'Click Me!' should appear on the # face of the Button. The do_something method should be executed when # the user clicks the Button. ...
091662c3418ffd84ed6eacf932d6d5ed025ce50c
Alexander-Stewart/CS0111-Website
/assets/parsers/backupparser.py
7,832
4.03125
4
""" This file is to convert json to html so that we can dynamically create tables in assignments and lectures pages """ from json2html import * import json from collections import OrderedDict import webbrowser import os import lxml from bs4 import BeautifulSoup from pyquery import PyQuery as PQ def convert_json_to_ht...
a0191b9d075443f06a8b5c1a426e5de6d357f349
thangln1003/python-practice
/python/1-string/13-romanToInteger.py
1,265
3.734375
4
# 13. Roman to Integer (Easy) # https://leetcode.com/problems/roman-to-integer/ # Input: "III" # Output: 3 # Input: "IV" # Output: 4 # Input: "IX" # Output: 9 # Input: "LVIII" # Output: 58 # Explanation: L = 50, V= 5, III = 3. # Input: "MCMXCIV" # Output: 1994 # Explanation: M = 1000, CM = 900, XC = 90 and IV = 4....
9289651476ede2d7980c9c4cd9fb8e35479ed394
thangln1003/python-practice
/python/matrix/1232-checkStraightLine.py
2,545
3.671875
4
""" 1232. Check If It Is a Straight Line (Easy) https://leetcode.com/problems/check-if-it-is-a-straight-line/ https://hoc247.net/hoi-dap/toan-10/viet-phuong-trinh-ham-so-y-ax-b-cua-dt-di-qua-a-1-1-va-voi-ox-faq41125.html You are given an array coordinates, coordinates[i] = [x, y], where[x, y] represents the coordinate...
bd1ede8bb2352c4f1c834db206210d48f64f2f9e
thangln1003/python-practice
/python/2-array/nonDivisibleSubset.py
1,281
3.78125
4
# Non Divisible Subset # https://www.hackerrank.com/domains/algorithms # Given a set of distinct integers, print the size of a maximal subset of S where the sum of any 2 numbers in S' is not evenly divisible by k. # For example, the array S = [19, 10, 12, 10, 24, 25, 22] and k = 4. # One of the arrays that can be crea...
7cdf5ba9b7c9cf90abcc0f0592cff859ecde851a
thangln1003/python-practice
/python/trie/208-implementTrie_I.py
2,294
4.125
4
""" 208. Implement Trie (Prefix Tree) (Medium) https://leetcode.com/problems/implement-trie-prefix-tree/ Implement a trie with insert, search, and startsWith methods. Example: Trie trie = new Trie(); trie.insert("apple"); trie.search("apple"); // returns true trie.search("app"); // returns false trie.startsWi...
1b64f06984fc271650162c1c0994ddd6a58ba8b8
thangln1003/python-practice
/python/2-array/1089-duplicateZeroes.py
2,026
3.78125
4
""" 1089. Duplicate Zeroes (Easy) https://leetcode.com/problems/duplicate-zeros/ Given a fixed length array arr of integers, duplicate each occurrence of zero, shifting the remaining elements to the right. Note that elements beyond the length of the original array are not written. Do the above modifications to the inp...
ad9082d3fc8662aecaf9a9ed5376564bc04a239f
thangln1003/python-practice
/python/2-array/15-threeSum.py
1,894
3.53125
4
""" 15. 3Sum (Medium) https://leetcode.com/problems/3sum/ Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. !Note: !The solution set must not contain duplicate triplets. *Given array nums = [-1, 0, 1, 2, -...
1a41974e7d76808e305c645f38ef996db70a78ed
thangln1003/python-practice
/python/BST/98-isValidBST.py
1,973
4.0625
4
""" 98. Validate Binary Search Tree (Medium) https://leetcode.com/problems/validate-binary-search-tree/ https://leetcode.com/articles/validate-binary-search-tree/ Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains only nodes...
08fe44ea4f2f110a32051391846c80348e740bf5
thangln1003/python-practice
/python/matrix/74-search2dMatrix.py
1,593
3.921875
4
# 74. Search a 2D Matrix (Medium) # https://leetcode.com/problems/search-a-2d-matrix/ # Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: # Integers in each row are sorted from left to right. # The first integer of each row is greater than the last in...
ddb8b9291af3c447a5dfc9e7bac92e9748930a4c
thangln1003/python-practice
/python/2-array/442-findDupplicates.py
1,268
4.03125
4
""" 442. Find All Duplicates in an Array (Medium) https://leetcode.com/problems/find-all-duplicates-in-an-array/ Given an array of integers, !Constraint: 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements that appear twice in this array. Could you do it without...
b1516a542edce862b44d4d1833dd5cd54f37884f
thangln1003/python-practice
/python/2-array/slidingWindowI.py
1,157
3.53125
4
# Given an array, find the average of all contiguous subarrays of size ‘K’ in it. # Array: [1, 3, 2, 6, -1, 4, 1, 8, 2], K = 5 # Output: [2.2, 2.8, 2.4, 3.6, 2.8] # TODO: Approach 1: Brute Force [O(N*2) & O(1)] # TODO: Approach 2: Sliding Window [O(N) & O(1)] from typing import List class Solution: ...
a670acd7b46c33e6c19dbd4130be7b20860bc89e
thangln1003/python-practice
/python/1-string/438-findAllAnagrams.py
2,175
4.125
4
""" 438. Find All Anagrams in a String (Medium) https://leetcode.com/problems/find-all-anagrams-in-a-string/ Given a string s and a non-empty string p, find all the start indices of p's anagrams in s. Strings consists of lowercase English letters only and the length of both strings s and p will not be larger than 20,1...
84e40c081c2262ad8732b4c3048a8d337a6d854c
MichaelZalla/data-structures-review
/src/30-binary-search/py/BinarySearch.py
709
3.96875
4
from math import floor def binarySearch(sequence, query, leftIndex=0, rightIndex=None): if rightIndex == None: rightIndex = len(sequence) - 1 # Base case: Query is not found if leftIndex > rightIndex: return -1 midIndex = leftIndex + floor((rightIndex - leftIndex) / 2) # Base...
fdc7353e8e21f14aac080204a207a8d72b4f2be5
Zer0Name/mischievous
/un_encrypt.py
1,363
3.8125
4
import os #"en_" def un_encrypt(x): for z in range(len(x)): f = open(x[z][3:], 'w') with open(x[z], 'r') as file: for i, line in enumerate(file): try: filename = line.rstrip('\n') encrypt_string = "" for char in range(len(filename)): ...
04835b34caac2dcb287ce7ff4e8c08f059d1dd38
sghalebikesabi/loveUeveryday
/src/first_step.py
4,788
3.5625
4
''' This file gives you a translation of I love you in a vareity of languages in form of a list of tuples. Run this the first time you execute the code and make sure that 'data/langs_alphabet.txt' and 'data/langs_time.txt' are empty if you never said 'I love you' in any language yet. Otherwise change the files accordi...
f2f99c6a095ac7f4e2d359f2cb964d09cf78d547
X-Crux/translation_of_number_systems
/src/main.py
4,241
3.71875
4
from converter import NumConverter from functions import ALPHABET def run_check(in_ss): if in_ss == 16: in_num = input('Введите число для перевода СС: ') try: for i in str(in_num): if str(i) not in ALPHABET: raise Exception except Exception: ...
92cc1bb90a95b1cae1a034e3300d0b9103506390
lauraDamacenoAlmeida/Python3
/OrientacaoObjeto/cliente.py
397
3.96875
4
class Cliente: def __init__(self,nome): self.__nome = nome #ao colocar um metodo como @property, eu digo para o python que o metodo em questao trata-se de uma propriedade #onde poderei chama-lo sem os paremnteses no console @property def nome(self): return self.__nome ...
d864ec2abb726e38c55b1df85902540df745cea7
shivampawar123/python-
/nestediff.py
567
3.859375
4
a=input("enter age") if age=="age <60 ": if amt=("amount<5lakhs"): print("the intrest is ",6%) elif amt = "amount >5 lakhs and 10 lakhs": print("the interest is" ,8%) else amt="amount >10 lakhs": print("the interest is" ,10%) elif amt="age > 60": if amt=("amount <5 lakhs"): ...
8d34eb5474b2e98c9df3e16feb678b8ff2e4712f
calpaterson/typecheck-exam-paper
/typecheck_exam_paper.py
364
3.5625
4
from typing import * # wrongly typed variable a: str = 1 b: int = 2 # Wrong argument type def plus_one_bad(arg: str) -> int: return arg + 1 # Wrong return type def plus_one_bad_2(arg: int) -> str: return arg + 1 l: List[int] = [] # Adding wrong type to generic l.append(1) # Referring to a type further do...
8f02e84b272f1a6543e1e0f41809881c3fdf21f4
RosemaryNicky/PythonDemo
/demo1/setdemo1.py
1,521
4.03125
4
#!/usr/bin/env python # -*-coding:utf-8 -*- # name = input('请输入名字:') # age = input('请输入年龄:') # job = input('请输入工作:') # hobbie = input('请输入爱好:') # msg = ''' ---------------info of %%s-------------- # Name : %s # Age : %s # Job : %s # Hobbie : %s # -----------------end-------------------- # '''% (name,age,job,hobbie) #...
3c5bc82862d3f05da5ce7d0807de1e5d0e735e7d
rasmiranjanrath/PythonBasics
/Set.py
521
4.25
4
#A set is a collection which is unordered and unindexed. In Python sets are written with curly brackets. set_of_link={'google.com','facebook.com','yahoo.com','jio.com'} #loop through set def loop_through_set(): for links in set_of_link: print(links) loop_through_set() #check if item exists or not if 'google.com' ...
323cdaf9af801d645f1d3371b23a65ff10bad67e
rasmiranjanrath/PythonBasics
/reversestring.py
174
4.28125
4
string="rasmiranjan"; def reverse(s): str = "" for i in s: str = i + str return str print("original string="+string) print("reversed string="+reverse(string))
5b7543e3b0fc8cf24b22afb680da2e4f28a1b9ac
LeenaKH123/python3
/02_classes-objects-methods/02_04_classy_shapes.py
1,078
4.4375
4
# Create two classes that model a rectangle and a circle. # The rectangle class should be constructed by length and width # while the circle class should be constructed by radius. # # Write methods in the appropriate class so that you can calculate # the area of both the rectangle and the circle, the perimeter # of the...
f7fe24777d99688ce0f67c7f16ee4788d4c694d4
LeenaKH123/python3
/02_classes-objects-methods/02_06_freeform.py
695
4.125
4
# Write a script with three classes that model everyday objects. # - Each class should have an `__init__()` method that sets at least 3 attributes # - Include a `__str__()` method in each class that prints out the attributes # in a nicely formatted string. # - Overload the `__add__()` method in one of the classes s...
21f73065ffa672222162dbdc6ea9cb01c858da78
H33525/Password-Length
/Check your password length.py
163
3.6875
4
Username= input("What is your name") Password= input("What is your password") print(f '{username}, your password, {password}, is {len(password)} letters long')
ce3f48db249d0c9044be42ed72705691fc4ca567
yliu8976/FufuLeetCode
/2.add-two-numbers.py
1,882
3.734375
4
# # @lc app=leetcode id=2 lang=python3 # # [2] Add Two Numbers # # https://leetcode.com/problems/add-two-numbers/description/ # # algorithms # Medium (34.79%) # Likes: 10029 # Dislikes: 2519 # Total Accepted: 1.7M # Total Submissions: 4.8M # Testcase Example: '[2,4,3]\n[5,6,4]' # # You are given two non-empty li...
fc37558069b0f0fabea657e3b1b5474dc622167b
yliu8976/FufuLeetCode
/1299.replace-elements-with-greatest-element-on-right-side.py
1,044
3.6875
4
# # @lc app=leetcode id=1299 lang=python3 # # [1299] Replace Elements with Greatest Element on Right Side # # https://leetcode.com/problems/replace-elements-with-greatest-element-on-right-side/description/ # # algorithms # Easy (74.27%) # Likes: 571 # Dislikes: 136 # Total Accepted: 94.6K # Total Submissions: 127...
f4ff3550ca6300e45da41ad4a658a3b693791e60
yliu8976/FufuLeetCode
/1823.find-the-winner-of-the-circular-game.py
1,054
3.859375
4
# @lc code=start class Solution # construct a double linked list node class class DoubleLinkedListNode: def __init__(self, val): self.val = val self.prev = None self.next = None # step-1: construct the circular double linked li...
e532a8f56ae2120e40563670d48dcc456fbb5a2a
yliu8976/FufuLeetCode
/1825.finding-mk-average.py
3,853
3.59375
4
# @lc code=start # Solution - 1 (Dont' use) class Solution: def __init__(self, m: int, k: int): from queue import PriorityQueue import queue import heapq self.m = m self.k = k self.q = [] self.sum = 0 self.counter = 0 ...
de39c4449359f6b2b204d9d47a2e59d57eab19be
yliu8976/FufuLeetCode
/98.validate-binary-search-tree.py
2,081
4
4
# # @lc app=leetcode id=98 lang=python3 # # [98] Validate Binary Search Tree # # https://leetcode.com/problems/validate-binary-search-tree/description/ # # algorithms # Medium (28.46%) # Likes: 5176 # Dislikes: 617 # Total Accepted: 863.6K # Total Submissions: 3M # Testcase Example: '[2,1,3]' # # Given the root ...
a2b55a839411bfe767242b142515cef500a87630
yliu8976/FufuLeetCode
/240.search-a-2-d-matrix-ii.py
2,313
3.8125
4
# # @lc app=leetcode id=240 lang=python3 # # [240] Search a 2D Matrix II # # https://leetcode.com/problems/search-a-2d-matrix-ii/description/ # # algorithms # Medium (43.84%) # Likes: 3982 # Dislikes: 86 # Total Accepted: 383.9K # Total Submissions: 873.4K # Testcase Example: '[[1,4,7,11,15],[2,5,8,12,19],[3,6,9...
e75f60a5d7dfb194834986a7fddd0d381a4f89eb
guzman-raphael/addon-example
/addon-official/mzaddon_type_student/type.py
305
3.53125
4
class Student: def __init__(self, first_name=None, last_name=None, enrolled=None): self.first_name = first_name self.last_name = last_name self.enrolled = enrolled def __str__(self): return str(self.__dict__) student1 = Student('Raphael', 'Guzman', '2020-01-23')
9a2a0f1e6ead70cdfb1d8bb25e0cbe9216e10c0f
KosukeSaeki/pythonkadai1
/kadai6.py
771
3.859375
4
#------------------------------------------------------------------------------- # Name: module6 # Purpose: # # Author: kousuke saeki # # Created: 02/10/2019 # Copyright: (c) kousuke saeki 2019 # Licence: <your licence> #--------------------------------------------------------------------...
4446ec949b504524debc52d79bf88b15a1df248b
vktrkvl/poputka
/2.6.py
279
3.5625
4
N=int(input('Введите сколько прошло секунд с начала суток: ')) x = N % 3600 x = N // 60 if N > 3600: x = x % 60 print('Количество полных минут, прошедших с начала последнего часа: ',x)
fe402fd81766ae12bba78e036746bdf6e8e636e8
PyBookLearning/PyBook
/HarryPotter/3rdpost.py
1,333
3.515625
4
#See Settings post for function detail from secondpost.py import talksto(), answerto(), getsangry(), getshappy() #Settings used for this scene class Settings: def __init__(self, wizard_names,moggle_names): self.wizard_names= ['Harry_Potter'] self.moggle_names= ['Vernon_Dursley','Dudley_Dursley', 'Petunia_Dursley...
0c9ff7275e96c309b823844d42ac93dcc4dd2082
halida/handout_6.00
/ps3a.py
704
4.125
4
#!/usr/bin/env python #-*- coding:utf-8 -*- """ module: ps3a """ from string import * def countSubStringMatch(target, key): i = 0 k = 0 while i != -1: i = find(target, key, i) if i < 0: break i += len(key) k += 1 return k def countSubStringMatchRecursive(target, key): ...
465ca3919646442ae0a04c1fe384c4c03601cf06
Nmazil-Dev/Codingbat-Solutions---Old
/String-1/string_bits.py
227
3.765625
4
def string_bits(str): length = len(str) -1 letters = [] x = 0 while x <= length: letters.append(str[x]) x += 2 new_word = ''.join(letters) return (new_word) string_bits('hello')
f31e4024b49d6971c2b8a4c26a7847d12309295a
Nmazil-Dev/Codingbat-Solutions---Old
/String-1/extra_end.py
144
4
4
def extra_end(str): length = len(str) -2 new_word = (str[length] + str[length + 1]) * 3 return (new_word) extra_end('Hello')
e3c75b27d71c5017b7294600f47eda8aea8fdc8b
Nmazil-Dev/Codingbat-Solutions---Old
/Logic-1/love6.py
189
3.890625
4
def love6(a,b): sum = a + b diff = abs(a - b) if a == 6 or b == 6: return True elif sum == 6 or diff == 6: return True else: return False
fd66eacaf7e0fbcfcb7b6d1623aa6b647818fdb7
Nmazil-Dev/Codingbat-Solutions---Old
/List-1/make_ends.py
168
3.609375
4
def make_ends(nums): new_list = [] end = len(nums) -1 new_list.append(nums[0]) new_list.append(nums[end]) return new_list make_ends([1,2,3])
6bcc362169c04bf9034d03ab846083cccb3407e2
Nmazil-Dev/Codingbat-Solutions---Old
/List-1/common_end.py
193
3.921875
4
def common_end(a, b): end1 = len(a) -1 end2 = len(b) -1 if a[0] == b[0] or a[end1] == b[end2]: print (True) else: print (False) common_end([1,2,3], [7,3])
8c2e904e6b77310830ee8a6776e4562df357462b
Skyler3259/KCC
/CIS-121-Intro-to-Programming-Logic/Dictionaries_and_Sets/serializing.py
862
3.921875
4
""" Serializing a object is the process of converting the object to a stream of bytes that can be saved to a file for later retrieval """ import pickle import random grade_book = { "Mac": random.randint(0, 100), "Ben": random.randint(0, 100), "Alex": random.randint(0, 100), "Josh": random.randint(0, 10...
2735761b0d2cccca49991969a974ab294e1c33f0
Tom1405/Test
/findthenumber.py
912
3.65625
4
from random import randint def try_number(): x = randint(0, 99) y = -1 r = 0 #Runden print("Ich habe mir eine Zahl zwischen 0 und 100 überlegt.") print("Versuche die Zahl mit möglichs wenig Versuchen zu erraten.") while y != x: try: y_str = input("Rate ...
ade2f67f43ff225ecbb26b53f8296c0fba541a8a
arkoghoshdastidar/python-3.10
/15_function.py
904
4.09375
4
# simple function definition ####################################################################################################################### # AllFunctionDefinitionHere def print_name(fname, mname, lname): print(fname + " " + mname + " " + lname) def sum_of_number(*num): ret_sum = 0 for x in range...
d9dcd1205b58e9f5502d6b2fb183b95ff6e24deb
arkoghoshdastidar/python-3.10
/14_for_loop.py
524
4.5
4
# for loop can be used to traverse through indexed as well as un-indexed collections. fruits = ["apple", "mango", "banana", "cherry"] for x in fruits: if x == "cherry": continue print(x) else: print("fruits list completely traverse!!") # range function range(starting_index, last_index, step) for...
f4fc56008cdb9d12034813951f4ae6673bb32b5d
arkoghoshdastidar/python-3.10
/19_iterator.py
899
4.15625
4
# All python collections have their own inbuilt iterators list1 = list(("apple", "banana", "cherry", "guava")) list_iter = list1.__iter__() print(next(list_iter)) print(next(list_iter)) print(next(list_iter)) print(next(list_iter)) tuple1 = tuple(("apple", "mango", "pineapple")) tuple_iter = tuple1.__iter__() prin...
2c23a0353c485de49a6ae57ffa8600a451a6abb1
ArroyoBernilla/t10_Arroyo.Aguilar
/aguilar/men16.py
2,734
3.734375
4
import libreria def opcion1(): def opcionA(): #1. pedir el codigo del estudiante #2. guardar los datos en "reporte.txt" codigo=libreria.pedir_codigo("ingrese el codigo del estudiante:") contenido=codigo+"\n" libreria.agregar_datos("reporte.txt",contenido,"a") print("e...
e180d34a1846e017efceef7ac13b737fda77dfcd
ArroyoBernilla/t10_Arroyo.Aguilar
/aguilar/men14.py
2,654
3.640625
4
import libreria def opcion1(): def opcionA(): #1. pedir el nombre de usuario #2. pedir el correo de gmail #3. guardar los datos en "gmail.txt" nombre=libreria.pedir_nombre("ingrese el nombre de usuario:") correo=libreria.pedir_correo("ingrese su correo electronico (******@gma...
6dab830f4fb13d2aaefb0e8c54c31b8bacb5faa2
ArroyoBernilla/t10_Arroyo.Aguilar
/aguilar/men17.py
2,810
3.546875
4
import libreria def opcion1(): def opcionA(): #1. pedir el numero de asiento del pasajero #2. pedir el numero de dni #3. guardar los datos en "pasaje.txt" asiento=libreria.pedir_numero("ingrese el numero de asiento:",1,50) dni=libreria.pedir_dni("ingrese el dni: ") pa...
3dfa34a327f3468fe988aa11c6418f005f7b42ac
ArroyoBernilla/t10_Arroyo.Aguilar
/arroyo/APP12.py
4,017
3.65625
4
import libreria # 1. Pedir el nombre del alumno def subopcionA(): print("INGRESE el ID DEL PLAYER 1") nombre=libreria.pedir_nombre("Ingrese Nombre:") # 1. Pedir el nombre del alumno contenido=nombre+"\n" libreria.agregar_datos("LISTAJUGADORES.txt",contenido,"w") print("SI DESEA JUGAR INGRESE DOS...
4ded74124b0a8a72d4f3ef553470bc01609be6b9
shireeny1/Python
/python_basics_104_lists.py
2,208
4.4375
4
# Lists in Python # Lists are ordered by index ## AKA --> Arrays or (confusingly) as objects in JavaScript # Syntax # Declare lists using [] # Separate objects using , # var_list_name = [0 , 1, 2, 3,..] --> index numbers crazy_x_landlords = ['Sr. Julio', 'Jane', 'Alfred', 'Marksons'] print(crazy_x_landlords) prin...
8f2951530c234a9b8a390f8b1410a74a701635e4
BesedaDi/case3
/case3.py
1,284
3.765625
4
# Case3 # Besedina D. (100%) a = int(input()) b = int(input()) c = int(input()) d = int(input()) print('Срок размещения капитала (лет):', a) print('Начальный капитал ($):', b) print('Процентная ставка (%/мес.):', c) print('Инвестиционные вливания ($/мес.):', d) s = 0 # основа инвистицый investment # сумма процентов мес...
6474f5ce757cf179d11bbe923bc2662221697e36
Fazendaaa/project-euler
/src/python/26-50/problem_31.py
1,052
3.71875
4
""" Coin sums In England the currency is made up of pound, £, and pence, p, and there are eight coins in general circulation: 1p, 2p, 5p, 10p, 20p, 50p, £1 (100p) and £2 (200p). It is possible to make £2 in the following way: 1×£1 + 1×50p + 2×...
f5daefe5c518bc3a8d0c63a910750ab63ee0f12c
Fazendaaa/project-euler
/src/python/1-25/problem_25.py
907
4.0625
4
""" 1000-digit Fibonacci number The Fibonacci sequence is defined by the recurrence relation: Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1. Hence the first 12 terms will be: F1 = 1 F2 = 1 F3 = 2 F4 = 3 F5 = 5 F6 = 8 ...
2aeb1ace9e26bc3def7607d7cc3ba06d02cb0a90
Fazendaaa/project-euler
/src/python/1-25/problem_6.py
1,096
3.703125
4
""" Sum square difference The sum of the squares of the first ten natural numbers is, 1² + 2² + ... + 10² = 385 The square of the sum of the first ten natural numbers is, (1 + 2 + ... + 10)² = 55² = 3025 Hence the difference between the sum of...
b1504cd3e849e175ccd718a7fd0fdb62c76f8185
nirzaf/python_excersize_files
/section13/lecture_066.py
345
3.609375
4
### Tony Staunton ### Passing info to a function # Creating our function def book_description(book_type, author_name): """Display book informatio""" print("\nThis book is " + book_type + ".") print("The author of this book is " + author_name.title() + ".") book_description('non-fiction', 'ashlee vance') book_desc...
c78be85a9da6d09e946d70741619e646a462ace9
nirzaf/python_excersize_files
/section10/lecture_049.py
291
3.96875
4
### Tony Staunton ### Editing & deleting values in a dictionary terms = {'integer' : 'Is a number that contains a decimal place.', 'string' : 'a sequence of characters.'} terms['integer'] = 'A whole number' # Delete statement # del terms['integer'] # print(terms) print(terms.get('integer'))
59a086670088c61d4c018cf5ac3aa8c6afb8c665
nirzaf/python_excersize_files
/section12/lecture_061.py
194
3.5625
4
### Tony Staunton ### Removing vaules from a list books = ['big data', 'checklists', 'the firm', 'tesla', 'the firm', 'the firm'] while 'the firm' in books: books.remove('the firm') print(books)
a6eaba95a272ee846c96066a39d076dc54325112
nirzaf/python_excersize_files
/section7/lecture_031.py
242
3.765625
4
### Tony Staunton ### Tuples coordinates = (1001, 5002) print("Original coordinates: ") for coordinate in coordinates: print(coordinate) coordinates = (2002, 7003) print("\nNew coordinates: ") for coordinate in coordinates: print(coordinate)
05914b5d60e645143435e614c3acde81281f5afd
nirzaf/python_excersize_files
/section17/lecture_124.py
266
3.921875
4
### Tony Staunton ### Storing and reading user data import json username = input("What is your username? ") filename = 'username.json' with open(filename, 'w') as file_object: json.dump(username, file_object) print("Thank you, I'll remember you when you come back.")
5e7dbf191a2b1396cb23f1bdc870d8b1dbcbff7e
nirzaf/python_excersize_files
/section9/lecture_043.py
289
4.125
4
### Tony Staunton ### Working with empty lists # Empty shopping cart shopping_cart = ['pens'] if shopping_cart: for item in shopping_cart: print("Adding " + item + " to your cart.") print("Your order is complete.") else: print("You must select an item before proceeding.")
edb115e5a043e70668684de5ac215346c59df01b
nirzaf/python_excersize_files
/section9/9. Branching and Conditions/8.1 lecture_040.py.py
324
4.21875
4
### 28 / 10 / 2016 ### Tony Staunton ### Checking if a value is not in a list # Admin users admin_users = ['tony', 'frank'] # Ask for username username = input("Please enter your username?") # Check if user is an admin user if username not in admin_users: print("You do not have access.") else: print("Access ...
7109992218146dfd2f8632cec2cda9c70e1d1499
njberland/makerspace
/main.py
398
3.5625
4
# code that will run on micropython on startup # to run forever make a loop of type "while True" from machine import Pin import time # configure pin 13 p13 = Pin(13, Pin.OUT) # run for a few seconds for i in ra...
48dafbca7f4d876d2aeb43968781d0109de11736
rosalogia/M250
/lib/matrix.py
2,798
3.609375
4
from random import uniform from copy import deepcopy # Helper functions def indexed(l): return range(len(l)) def zinit(n, m): """Returns an n by m matrix initialised to 0""" return [[0] * m] * n def dimensions(m): """Returns the dimensions of a matrix in a tuple""" return (len(m), len(m[0])) def...
d4d7ddf9bac3658959f888dda9c75d49491fdfad
AnetaEva/NetPay
/NetPay.py
837
4.25
4
employee_name = input('Name of employee: ') weekly_work_hours = float(input('How many hours did you work this week?: ')) pay_rate = float(input('What is your hourly rate?: $')) #Net Pay without seeing the breakdown from gross pay and tax using the pay rate * work hours * (1 - 0.05) net_pay = pay_rate * weekly_work_h...