max_stars_repo_path
null
max_stars_repo_name
null
max_stars_count
null
id
null
text
string
score
float64
int_score
int64
from
string
blob_id
string
repo_name
string
path
string
length_bytes
int64
null
null
null
null
"""关于List的操作""" a = [1, 2, 3, 4, 2, 3, 1, 1] a.append((0)) # 表示在列表的最后添加上0这个数据 # 指定位置添加上指定值 a.insert(0, 0) # 表示在第一个位置添加上0的数据,默认索引从0开始 # remove函数将要remove掉的是value值,并且是列表中第一次出现的值 a.remove(2) print(a) # 对于python的索引如果是负数则是表示从后往前开始计数 print(a[-2]) # 对于数组索引 print(a[0: 3]) print(a[5:]) # 列表中第一次出现某值的索引值 print(a.index(4)) # 列表中出...
4.4375
4
smollm
2ec56d9da700664ff0d135f8d1e7e13b27d06ea7
Asurada2015/Python-Data-Analysis-Learning-Notes
/Pythontutorials/22_List_demo.py
804
null
null
null
null
#Andrew Shen import re import sys from operator import itemgetter ###Purpose: Calculates the exon size of the genes. ###To run this program, go to the command line and specify four parameters: ###python addCodingSize_exons.py (input file) (output file) ###This set of four lines takes an input file from the command l...
3.65625
4
smollm
466b2e5ddff9366476800e92f29177fc154762c3
andrew7shen/calculate_gene_size
/addCodingSize_exons.py
2,880
null
null
null
null
def lengthOfLongestSubstring(s): """ :type s: str :rtype: int """ char_map = {} front = 0 back = 0 answer = 0 for c in s: if c in char_map: front = max(char_map[c], front) answer = max(answer, back - front + 1) char_map[c] = back + 1 back +...
3.5
4
smollm
00859b3a50280040e86d675bb1502c3b339e6037
liamchzh/leetcode
/subs.py
415
null
null
null
null
import re str = "诸葛亮" print(re.match('\w{3}',str).group())
3.65625
4
smollm
a6e37f60fc426fc4b700f27c7024b00b76b56b25
jingwang622/AID1909
/day10/exercise03.py
64
null
null
null
null
""" ftp文件服务 客户端 """ from socket import * import time from day03.data_client import sockfd ADDR = ("127.0.0.1",8080) task_tuple = ("list", "get file", "put file", "exit" ) class FTPClient: def __init__(self,sockfd): self.sockfd = sockfd def do_list(...
3.578125
4
smollm
1582c4781bd42cfdcbc8f306a51709f39a29a5cf
jingwang622/AID1909
/day07/ftp_client.py
2,544
null
null
null
null
""" read_db.py pymysql 读数据库 """ import pymysql # 连接数据库 db = pymysql.connect(host='localhost', port = 3306, user = 'root', password = '123456', database = 'stu', charset = 'utf8') # 生成游标对象(用于操作数据库数据,获取sql执行结果的对象) cu...
3.515625
4
smollm
13f259342196ba7b513d2652150f872273ebcb09
jingwang622/AID1909
/day11/read_db.py
939
null
null
null
null
""" 使用udp完成,在客户端可以循环的输入单词,然后得到单词的解释 """ """ 提供一组数据,将该数据从客户段发送给服务端 有服务端记录在一个文件中,每个学生信息站一行 文件名:student.txt 客户端数据:[(1,'Lily',10,78), (2,'Tom',9,91), (3,'Jame',8,91), (4,'Abby',11,87), (5,'Leli',34,90), ] """ student_list = [(1,'Lily',10,78), (2,'Tom',9,91),...
3.71875
4
smollm
dc2fa744d369417a5c2add98eb0fe201b000e1ae
jingwang622/AID1909
/day03/exercise01.py
633
null
null
null
null
""" 练习1: 编写程序完成:使用input输入一个单词,打印出该单词的解释(或者这一行),如果输入的单词单词本中没有,则打印“找不到该单词” 温馨提示: 每个单词占一行 单词和解释之间一定有空格 单词按顺序排列 """ word = input("单词:") # 待查找单词 # 默认r方式打开 f = open('dict.txt') # 每次取一行 for line in f: # 提取一行中的单词 tmp = line.split(' ')[0] # 遍历的单词已经比目标大了 if tmp > word: ...
4.1875
4
smollm
acbffb96a97e72108e054982603b9b9127262210
jingwang622/AID1909
/day03/read.txt.py
749
null
null
null
null
# Import package import sqlite3 # Connect to the database conn = sqlite3.connect('customer.db') # Create a cursor c = conn.cursor() # List of customers customer_list = [ ('Tom','Jones','Tom@jones.com'), ('Dick','Feynman','Dick@Feynman.com'), ('Jerry','Springer','Jerry@Springer.com'), ] # Creat...
3.90625
4
smollm
24424c40d314fbafd239a74908a1eccfeefbf80c
ThomasRad/SQLite-Part-2-Populating-using-list-
/database.py
465
null
null
null
null
#! /usr/bin/env python3 ''' The above line is called the shebang, it lets your computer know which python to use. We'll cover the shebang in greater detail later, but for now know that this is the default shebang for python3 on macs, for the time being we'll start all our files with it. ''' ''' Next comes imports. In...
4.09375
4
smollm
5e70c813c78e673de9bede86893b4bdd3034e6c6
robotlightsyou/pfb-resources
/sessions/002-session-strings/exercises/string_practice_prompt_advanced.py
2,697
null
null
null
null
#! /usr/bin/env python3 """ This program is a basic calculator providing the user addition, subtraction, multiplication, float division, integer division, and the modulo operation. """ def main(): """ ask user what function to perform, take input, use control flow to print return of desired function, ...
4.4375
4
smollm
b7ff5e90c8cefbb20789e2f7673148c7303d36aa
robotlightsyou/pfb-resources
/sessions/003 session-numbers/exercises/calc-codealong-advanced.py
2,346
null
null
null
null
#!/usr/bin/env python # coding: utf-8 # # Data Science & Business Analytics Internship - The Sparks Foundation # ## Author - C Aparna # ### Task 2: # #### Problem : From the given ‘Iris’ dataset, predict the optimum number of clusters and represent it visually. # ##### Importing libraries # In[3]: import numpy ...
4.0625
4
smollm
0605b5670c84431ab0981179febf516ff93b1df8
anrapa2000/The-Sparks-Foundation-intern
/Task 2.py
2,355
null
null
null
null
#!/usr/bin/python import os, sys, signal, multiprocessing # Definimos la funcion para el primer proceso def stdinread(pipe, xD): sys.stdin = os.fdopen(xD) # Mostramos por consola el mensaje de que el proceso 1 esta leyendo. print("process 1 reading...") # Utilizamos el array para leer lo ingresado por...
3.53125
4
smollm
badce3a1ee7c1996128fc49663f4c826e3d16fc9
muskanmahajan37/computacion-2
/eje15.py
1,744
null
null
null
null
#!/usr/bin/python import sys, getopt, socket def read_options(): # Declaramos las variables address = port = protocol = None # Aplicamos el getopt para tomar los 3 argumentos que necesitamos: p(puerto),t(tipo de protocolo) y f(archivo de texto blanco) (opt, arg) = getopt.getopt(sys.argv[1:], 'a:p:t:'...
3.78125
4
smollm
9e3db3edb2284c241333d6d1b76a319428709f81
muskanmahajan37/computacion-2
/eje12cliente.py
2,716
null
null
null
null
# !/usr/bin/python3 import getopt, socket, sys # Definimos option_oeading para que el cliente ingrese la ip y el puerto para conectarse con el servidor.. def option_reading(): # Primero, inicializamos las variables que usaremos para la ip y puerto como "none", osea ningun valor asignado. ip_server = port_ser...
3.71875
4
smollm
0c9c0b7a77f449f1aa81dc5d905fd60d5a134d18
muskanmahajan37/computacion-2
/eje17cliente.py
1,936
null
null
null
null
# -> Megetahui apakah string terdiri dari huruf kecil atau besar CountBig = [] CountLow = [] t = input("Enter String : ") for x in t: if x == x.upper(): print('Huruf Besar :',x) CountBig.append(x) else: print('Huruf Kecil :',x) CountLow.append(x) print('Jumlah Huruf ...
3.984375
4
smollm
e564c912e47bca5bd82d9826cc89685c6dec779a
Baturaja1337/CekHuruf
/BigLowLetter.py
390
null
null
null
null
""" Facade Provides a simplified interface to a lager body of code , such as a class library. It can: + make a software library easier to use, understand and test + make the library more readable + reduce dependence of outside code on the inner classes + wrap with a single designed API """ # Parts of complex object...
3.828125
4
smollm
7ae1393fc708d320101219ff41a5c822fb7bd140
smartkot/desing_patterns
/structural/facade.py
1,746
null
null
null
null
""" Observer Implements a state machine in object-oriented way. """ class State(object): """ Base State """ def play(self): raise NotImplementedError() def train(self): raise NotImplementedError() class NormalState(State): """ Concrete State """ def play(self): return '...
4.03125
4
smollm
2dcc8a99a6f0a81516f9bc0ec59a30820e4988ec
smartkot/desing_patterns
/behavioral/state.py
1,323
null
null
null
null
user_input=input("Enter a phrase: ") phrase=(user_input.replace('of','')).split() acronym="" for word in phrase: acronym=acronym+word[0].upper() print(f'Acronym of {user_input} is {acronym}')
4.1875
4
smollm
c7665a25a3c32cfe9522100cf34287288fc2782c
KBVKarthik/Python_Miniprojects
/Acronym_Generator.py
204
null
null
null
null
#!/usr/bin/python3 import time print("chapter 8: Lists and Dictionaries\n") # :::::::::::::::: LIST COMMON literals AND operations :::::::::::::: mylist = [] print(f"is mylist empty?: {len(mylist) == 0}\n") mylist = ["tacos", "sushi", "burgers", "hotdogs"] print(f"i have {len(mylist)} favorite foods. They are...\n"...
4.28125
4
smollm
a6515fab678abb1ad113681774193dfa8381dc9b
henriavo/learning_python_5e
/part_2/ch8_lists.py
1,233
null
null
null
null
# exceptions occur when something goes wrong, whether it be # incorrect code or input. Exceptions stop the program immediately # eg. dividing by 0. # EXCEPTION HANDLING # exceptions are dealt with by using "try/except" statements # The try block contains code that may result in an exception # If the exceptio...
4.53125
5
smollm
ca6b7244d7e53e097cefa0ce2212cbd361773fdd
merlose/python-exercises
/ExceptionsAndFiles.py
2,312
null
null
null
null
from termcolor import colored class Tile(): def __init__(self, val, row, col): self.static = True if val else False self.val = val self.row = row self.col = col def __str__(self): if self.static: return colored(str(self.val), 'red') else: ...
3.53125
4
smollm
2033aac7ce68e5ea309f910f1ae2fbf20bc64df0
connorryanbaker/pydoku
/tile.py
362
null
null
null
null
text='hello hai hai hello hai' #o/phello:2 hai:3 words=text.split(' ') print(words) # cnt=0 # cnt_hai=0 # for i in words: # if i=='hello': # cnt+=1 # print(cnt) # # for i in words: # if i=='hai': # cnt_hai+=1 # print(cnt_hai) dict={} for word in words: if word not in dict: dict[...
3.859375
4
smollm
95e7e6f3ec8e316bd032186594cbcc59fd5e8491
amalmhn/PythonDjangoProjects
/python_data_structures/dictionary/word_count_program.py
375
null
null
null
null
cnt=1 for i in range(1,13): #1 2 print(i, end=' ') #1 if(cnt==4): #1==4 print() cnt=1 else: cnt+=1 #1+1=2
3.65625
4
smollm
3fcaa239c35bc79116cdf40ceeae95aaa78335c6
amalmhn/PythonDjangoProjects
/flow_controls/looping_statements/for_loop/Nested_forloop.py
145
null
null
null
null
#exception #exception and error are NOT the same #abnormal code that disrupt our normal execution no1=int(input('num1')) no2=int(input('num2')) lst=[1,2,3] try:#doubtful code res=no1/no2 print(res) print("I have data base") # except:#corresponding exception # print('Exception occured') except Exceptio...
3.8125
4
smollm
ed6d4b55912af7ae4ed6257eb1268cbb8c9cd2e7
amalmhn/PythonDjangoProjects
/exception_handling/exception_handling.py
478
null
null
null
null
import queue size=int(input('Enter the size of the queue')) Q=queue.Queue(maxsize=size) n=1 top=0 def Q_put(): global top if top==size: print('The queue is full') else: element=int(input("Enter the element")) Q.put(element) top+=1 def Q_get(): global top if top==0: ...
4.09375
4
smollm
8b9e8a4420a89961097b54b1e6b494a76dd9f392
amalmhn/PythonDjangoProjects
/miscell/hw_queue.py
804
null
null
null
null
limit = int(input("Enter limit")) i=1 sum=0 while(i<=limit): sum=sum+i i+=1 print(sum)
3.578125
4
smollm
d0c7e68f1b93b6c349073fbd8a89657049b43bce
amalmhn/PythonDjangoProjects
/flow_controls/looping_statements/while_loop/sum_of_n_numbers.py
97
null
null
null
null
lst=[2, 3, 4, 6] cnt=1 out=[] for num in lst: data=num**cnt out.append(data) cnt+=1 print(out)
3.609375
4
smollm
00133a74626fe377c59c37954f3b40720e24c043
amalmhn/PythonDjangoProjects
/python_data_structures/list_programs/list_range_function.py
114
null
null
null
null
#class className class Person: #attributes of person self.name,self.age,self.gender def set_person(self,name,age,gender): #initializing persons attributes self.name=name #person has name self.age=age self.gender=gender #methods def print_person(self): #'self' keyword used to po...
3.90625
4
smollm
793dcebfb06cd99e61a0b96c9c3f092b867d6482
amalmhn/PythonDjangoProjects
/object_oriented_programming/oops_first.py
659
null
null
null
null
employee={'emp_id':1001,'emp_name':'Amal','desig':'developer','salary':25000} #print employee name print(employee['emp_name']) #check exp key is there print('exp' in employee) #Add exp key to the dict if ('exp' not in employee): employee['exp']=5 print(employee) #Add 5000 to salary employee['salary']+=5000 ...
3.875
4
smollm
dd05734ebe6957a9d5d64b232dfb81b30779db4b
amalmhn/PythonDjangoProjects
/python_data_structures/dictionary/hw_employee_prog.py
416
null
null
null
null
lst=['java','python','c#','javascript'] print(lst) print(lst[0]) print(lst[3]) print(lst[-1]) print(lst[0:3]) print('---------------------------------') #list slicing (upper, lower, step) print(lst[0:4:2]) #iteration for item in lst: print(item) #to add a new element to the list lst.append("dart") print(ls...
4
4
smollm
78e39f15ebe4911e6996f72cf966256a80223ad4
amalmhn/PythonDjangoProjects
/python_data_structures/list_programs/list_part1.py
611
null
null
null
null
from functools import * lst=[10,11,12,13,14,15] sum=reduce(lambda no1,no2:no1+no2,lst) print(sum) min=reduce(lambda no1,no2:no1 if no1<no2 else no2,lst) print(min) max=reduce(lambda no1,no2:no1 if no1>no2 else no2,lst) print(max) #Sum of even numbers sum_even=reduce(lambda no1,no2:no1+no2,list(filter(lambda no:no%2...
3.59375
4
smollm
30080009de681c8ecb58b9efbd538eeb8a33c704
amalmhn/PythonDjangoProjects
/functional_programming/map_reduce_filter/reduce_function.py
457
null
null
null
null
with open('input.txt', 'r') as f: data = f.read().strip() alphabet = "abcdefghijklmnopqrstuvwxyz" pairs = [c + c.upper() for c in alphabet] pairs += [c.upper() + c for c in alphabet] def remove_polar_opposites(chain): for pair in pairs: chain = chain.replace(pair, '') return chain def full_polar_...
3.609375
4
smollm
07f5d47c5c9faee016d4d2666040d525c719f3c8
saurfangg/advent-of-code
/2018/dec-5/script1.py
635
null
null
null
null
def permutation(rep, prefixe, liste): if prefixe and prefixe[-1][1] == 'E': rep.append(prefixe) else: for i in range(len(liste)): if (prefixe and liste[i][0] == prefixe[-1][1]) or (not prefixe and liste[i][0] == 'A'): permutation(rep, prefixe...
3.640625
4
smollm
304b9b2daf00f0f24c9b64be38b6920caa621505
PaulFranssen/studio_WS
/permutation.py
515
null
null
null
null
#!/usr/bin/python3 ''' perimeter of island ''' def island_perimeter(grid): ''' couunt zeros around the land ''' if grid is None: return 0 zero = 0 for y in range(len(grid)): for x in range(len(grid[y])): if grid[y][x] == 1: zero += 1 if y == 0 or gr...
3.640625
4
smollm
defd4c250ebb58efc49fd5c60e43bcb930d7bc9a
DeniyiBams/holbertonschool-low_level_programming
/0x1C-makefiles/5-island_perimeter.py
578
null
null
null
null
def read_sim_data(filename): """ input: name of file output: - tuple with simulation data - dictionary with street data - dictionary with intersection data - list with vehicle routes """ """ key: streetname data: - start intersection ...
3.859375
4
smollm
0b6dce8e9c844efd5091380e8b095affe25f1b00
MatthiasCoppens/HashCode21
/heatmap.py
1,830
null
null
null
null
""" Task Given an integer, n, perform the following conditional actions: If is odd, print Weird If is even and in the inclusive range of 2 to 5, print Not Weird If is even and in the inclusive range of 6 to 20, print Weird If is even and greater than 20, print Not Weird Input Format A single line containing a pos...
4.28125
4
smollm
ab5f4c3215e5030d052d11e885502058806c03d2
daru23/my-py-challenges
/if-else.py
625
null
null
null
null
def isConsonant(word): ''' Takes a string and checks the last character. If it is consonant returns a True value. ''' for i in range(len(consonants)): #print(i) if word[-1:] == consonants[i]: return True break return False string = input("Type in t...
3.953125
4
smollm
6cdcddc77098756594eb2105aea85f2ef7f5eb0e
markdioszegi/SIW1
/SIW1/Set B/PresentParticipleForm.py
1,337
null
null
null
null
import time import random class Player: playerList = [] def __init__(self, name, armySize, diceValue): self.name = name self.armySize = armySize self.diceValue = diceValue self.playerList.append(self) def rollTheDice(): wait() max = 0 index = 0 ...
3.96875
4
smollm
72aa6b6aa4632bf08f699a885a1f49f32af6b2ca
markdioszegi/SIW1
/SIW1/Set A/RiskGame/DiceForRisk.py
1,913
null
null
null
null
from Stemmer import Stemmer stemmer = Stemmer('english') class StopWords: "Load stop words from stopWords.txt to a set" def __init__(self): self.stopWordsList = [] self.stopWordsSet = set() def readStopWords(self): with open("./stopWords.txt") as input_file: for input...
3.640625
4
smollm
5b3fe9fb459e21b7f50eee06ba7a3dca0e56978e
shadaabsiddiqie/wiki-search-engin
/stopWords.py
856
null
null
null
null
class Restaurant: def __init__(self,name,description,location,price,foodType,openH,closingH,address): self.__name = name self.__description = description self.__location = location self.__price = price self.__foodType = foodType self.__openH = openH ...
3.5
4
smollm
6edeb3fbe2ce385c204b9592f1b10c51d354d8c8
EtcBobo/Python-OOP-Project
/Restaurant.py
929
null
null
null
null
import random class Armor(object): def __init__(self): self.protection = 0 self.armor = "none" def assign(self): self.armorTypes = ["chain mail", "leather vest", "metal chest plate", "helmet"] armorAssign = self.armorTypes[random.randint(0,3)] if armorAssign == "chain mail": self.protection = random...
3.671875
4
smollm
0a7a0a452b14729237584d1b7816c2a6864033e4
BenjaminSmithOregon/DungeonGame
/armor.py
759
null
null
null
null
# ## Important Python Libraries used # >cv2, numpy, math, sys # In[2]: import cv2 import numpy as np import math import sys # ### circumcenter(p1,p2,p3) # # #### Use # >To Calculate the circumcenter of the three points given. # # #### Arguments # >This function takes 3 arguments as p1, p2 and p3. # # #### ret...
4.21875
4
smollm
ff0d27bd6db510c9737280f82180d546df7ea0c6
DebashisSahoo2001/Delaunay_Triangulation_MPA
/Morphing.py
14,041
null
null
null
null
factorial = 1 a = int(input("Ingresa un numero " )) b = 1 if a < 0: print ("El factorial es: ") print(factorial) elif a == 0 : print ("El factorial es: ") print (factorial) else : for b in range (1,a+1): factorial = b * factorial print("El factorial es: ") print(factorial)
4.03125
4
smollm
e0916b2ae5e500f9b55a84d684b5b4d2d513032f
edgardoruiz/-FD-_Tareas_de_clases_en_Python_00170019
/factorial.py
313
null
null
null
null
from typing import Any from pathlib import Path import pickle import os, urllib def dump_pickle(obj: Any, path: Path): with open(path, 'w+b') as f: pickle.dump(obj, f) def load_pickle(path: Path): with open(path, 'rb') as f: return pickle.load(f) def remove_url_args(url): return url.sp...
3.515625
4
smollm
9dfbeef497646bf5888f018afed1d3eb1b18204d
henry-prior/model_toolkit
/model_toolkit/utils/io.py
1,584
null
null
null
null
# Python implementation of a FIFO queue. class Fifo: def __init__(self): self.queue = [] def __str__(self): """ Allows printing of the queue """ return str(self.queue) def enqueue(self, item): """ Adds an items to the end of the queue """ ...
4.34375
4
smollm
3149177e6f08df90b60b45ad91f81cc2415ee821
ephreal/CS
/data_structures/queue/queue.py
703
null
null
null
null
# See documentation.needs.management/index.php/Sorting_Algorithms for # the algorithm followed. def mergesort(x): """ Mergesort implemented in python. """ if len(x) == 1: return x sorted = [] curr_first = 0 curr_last = 0 first = mergesort(x[:len(x)//2]) last = mergesort(x...
3.96875
4
smollm
8f4e09bea689d86c15455c1d4bcb30b8faf7cf40
ephreal/CS
/sorting/python/merge_sort.py
726
null
null
null
null
def quicksort(array,low,high): if low < high: # move all the numbers smaller than pivot to the left # and the numbers larger than pivot to the right print("\narray:%s, low:%d, high:%d\n" % (array,low,high)) mid = partion(array,low,high) quicksort(array,low,mid) quick...
4.21875
4
smollm
f1add98ec7589102eda225eb68564bcbd217b083
tristaaa/lcproblems
/quicksort.py
1,643
null
null
null
null
class Solution: def canPermutePalindrome(self, s): """ determine if a permutation of the string could form a palindrome :type s: str :rtype: bool """ # if a palindrome can be formed by permutate chars from the given string, # then there must be at ...
3.96875
4
smollm
c0c76cbab7595fff97672529014ecf613b7a4b81
tristaaa/lcproblems
/palindromepermutation.py
708
null
null
null
null
class Solution: def myAtoi(self, s): """ Implement `atoi` which converts a string to an integer. The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, tak...
3.90625
4
smollm
362887da696df1e7a90dace78ad6259a72b6cd69
tristaaa/lcproblems
/str2int_atoi.py
2,853
null
null
null
null
class Solution: def hIndex(self, citations): """ Given an array of citations of a reasearcher, return his max h-index. A scientist has index h if h of his/her N papers have at least h citations each, and the other N − h papers have no more than h citations e...
3.640625
4
smollm
605a40e31d2fde5e13863a30ca75dd28324a36fd
tristaaa/lcproblems
/hindex.py
2,310
null
null
null
null
class Solution: def favoriteGenre(self, userSongs, songGenres): """ Given a map Map<String, List<String>> userSongs with user names as keys and a list of all the songs that the user has listened to as values. Also given a map Map<String, List<String>> songGenres, with song genre as...
3.6875
4
smollm
c0bc8e005326e46c40e074441b2eb15df31fc199
tristaaa/lcproblems
/musicgenre.py
2,146
null
null
null
null
import collections class Solution: def findAnagrams(self, s, p): # find all the indicies of the anagrams of string p # Anagram: same letters but different order of the letters, # here anagram of p can be in the same order of letters # Sliding window ret = [] dict = ...
3.515625
4
smollm
00c74e6431a557d4b8750b0993d8497acddabd1d
tristaaa/lcproblems
/findAnagram.py
1,306
null
null
null
null
class Solution: def addToArrayForm(self, A, K): """ Add up two integers, one in array-form, return the summation in array-form. :type A: List[int], an array-form of integer :type K: int :rtype: List[int] """ # method 1 # r...
3.671875
4
smollm
5fbfbd88a733bdb33506010783a9fd97801d8c76
tristaaa/lcproblems
/add2arrayformofint.py
1,016
null
null
null
null
class Solution: def threeSumSmaller(self, nums, target): """ Find the number of index triplets (i,j,k) with 0<=i<j<k<n that satisfy the condition: nums[i]+nums[j]+nums[k] < target. :type nums: List[int] :type target: int :rtype: int """ ...
3.78125
4
smollm
119eccc71917c9e4943addffd732fbdf344a3917
tristaaa/lcproblems
/threesumsmaller.py
977
null
null
null
null
class Solution: def lengthOfLongestSubstring(self, s): """ find the length of the longest substring w/o repeating chars :type s: str :rtype: int/str """ if not s or len(s)<1: return 0 # store the last location of the char in string s ...
3.71875
4
smollm
73e81ff9aae67e92d5e29d5480c7a73037e900c1
tristaaa/lcproblems
/lssworeapeatingchars.py
1,490
null
null
null
null
from user import User class Admin(User): def __init__(self, username, password, access): super(Admin, self).__init__(username, password) self.access = access def __repr__(self): return f'<Admin {self.username}, access {self.access}>' def to_dict(self): return { ...
3.578125
4
smollm
0b50523e0260f1b8b3d16679f1d5b54989d544f3
PacktPublishing/The-Complete-Python-Course
/18_advanced_oop/sample_code/4-abc-3-and-interfaces/admin.py
432
null
null
null
null
# Complete Python Course — Jose Salvatierra # Link: my_string = "Hello, world!" single_quote_string = "Hello, world!" # Strings can use either single or double quotes. It's up to you which one you use! # Try to pick one and stick to it throughout all your code. # If you work with others, and they prefer a specific st...
4.71875
5
smollm
23833279a8e1d6d86d83ce2c9fac74af1e07659d
PacktPublishing/The-Complete-Python-Course
/1_intro/lectures/6_strings/code.py
1,358
null
null
null
null
import json with open('friends_json.txt', 'r') as file: file_contents = json.load(file) # reads file and turns it to dictionary print(file_contents['friends'][0]) cars = [ {'make': 'Ford', 'model': 'Fiesta'}, {'make': 'Ford', 'model': 'Focus'} ] with open('cars_json.txt', 'w') as file: json.dump(c...
3.75
4
smollm
c46bb4774272e943201e9eedb9e6226137eb425b
PacktPublishing/The-Complete-Python-Course
/6_files/files_project/json_context_managers.py
467
null
null
null
null
division_with_remainder = 12 // 5 # should be 2.4 print(division_with_remainder) # prints 2 # 5 goes into 12 two times. (5 * 2 is 10). The remainder is 2. # Getting the remainder of a division is such a popular operation, that Python gives us a way to do it really easily. remainder = 12 % 5 print(remainder) # prin...
4.4375
4
smollm
d1d792dcdd33add1ea69d21fc9593de8548f35b6
PacktPublishing/The-Complete-Python-Course
/1_intro/lectures/5_remainder/code.py
885
null
null
null
null
# Imagine you've got all your friends in a list, and you want to print it out. friends = ["Rolf", "Anne", "Charlie"] print(f"My friends are {friends}.") # Not the prettiest, so instead you can join your friends using a ",": friends = ["Rolf", "Anne", "Charlie"] comma_separated = ", ".join(friends) print(f"My friends a...
4.4375
4
smollm
2b043527889141e477e531bc36fb6b1c22f420d0
PacktPublishing/The-Complete-Python-Course
/1_intro/lectures/17_joining_a_list/code.py
453
null
null
null
null
# Python has two keywords, `and` and `or` # Here's how to use them: age = int(input("Enter your age: ")) can_learn_programming = age > 0 and age < 150 print(f"You can learn programming: {can_learn_programming}") # -- or -- age = int(input("Enter your age: ")) usually_not_working = age < 18 or age > 65 print(f"At ...
4.1875
4
smollm
0cb063e8449fc44bc396a76f0dfd1acb541c00da
PacktPublishing/The-Complete-Python-Course
/1_intro/lectures/10_and_or/code.py
1,229
null
null
null
null
# Define variables by giving them a name and a value age = 30 # Print their values out by using the print() function print(age) # You can print values directly if you prefer print(30) # But having variables means you can change them after the fact age = 30 print(age) age = 40 print(age) # Variable names can con...
4.46875
4
smollm
e01061124a3622551cddc8c9c8dfff60b5514026
PacktPublishing/The-Complete-Python-Course
/1_intro/lectures/3_variables_printing/code.py
772
null
null
null
null
""" A Boolean is a true/false, yes/no, one/zero value. We can use it to make decisions. In Python, True and False are keywords to represent these values. """ truthy = True falsy = False # ---- age = 20 is_over_age = age >= 18 is_under_age = age < 18 is_twenty = age == 20 """ Other symbols are > and <=. We can of c...
3.96875
4
smollm
1aff771ec516abe704169780df6a7b4735e1914f
PacktPublishing/The-Complete-Python-Course
/1_intro/lectures/9_booleans/code.py
565
null
null
null
null
class Car: def __init__(self, make, model): self.make = make self.model = model def __repr__(self): return f'<Car {self.make} {self.model}>' class Garage: def __init__(self): self.cars = [] def __len__(self): return len(self.cars) def add_car(self, car): ...
4.09375
4
smollm
e2b77c08778109b4d6a3d205efdbd3a431200350
PacktPublishing/The-Complete-Python-Course
/5_errors/errors_project/app.py
770
null
null
null
null
""" Working with dates and times is an extremely useful skill, and it can sometimes be a bit confusing. In this video we look at simplifying working with dates and times slightly using Python built-in modules. The main date and time module in python is called `datetime`, and confusingly enough the main class in that m...
4.65625
5
smollm
c83a4ca70fbc35ee2317263141e1bb49207fab15
PacktPublishing/The-Complete-Python-Course
/10_advanced_python/lectures/09_dates_and_times_python/code.py
1,800
null
null
null
null
# Write a new program that asks the user for their first name and then their surname. The program should then display the person’s initials. def initials(): firstName = input("Please enter your first name : ") lastName = input("Please enter your surname : ") initials = firstName[0] + lastName[0] print("Your init...
4.34375
4
smollm
18fe8d27dbffc2c6d4ea1652864adb3e4b74298f
ItzMeRonan/PythonBasics
/Initials.py
358
null
null
null
null
coin = input("") if coin[0:3] == "RMB": U = eval(coin[3:])/6.78 print("USD{:.2f}".format(U)) elif coin[0:3] == "USD": R = eval(coin[3:])*6.78 print("RMB{:.2f}".format(R))
3.71875
4
smollm
628c7f52bc0d38b96850907f9c810e1d4bc07966
wsr0727/pythonLessionTest
/tempretion.py
186
null
null
null
null
a = 1 b = 1 fib = [a, b] for i in range(20): a, b = b, a + b fib.append(b) print(fib)
3.546875
4
smollm
0c6cf9c9d76a4c3bd91fba813009c56164cc30f0
Semihozel/Workspace
/Fibonacci.py
107
null
null
null
null
print("""BASİT HESAP MAKİNESİ""") print("1.TOPLAMA\n2.ÇIKARMA\n3.ÇARPMA\n4.BÖLME") a = int(input("1.sayıyı giriniz")) b = int(input("2.sayıyı giriniz")) islem = input("Yapacağınız işlemi seçiniz") if (islem == "1" ): print("{} ile {}nin toplamı = {}".format(a,b,a+b)) elif (islem == "2" ): ...
3.84375
4
smollm
73778a65dcc4e1b61cebd8c145c2e2ff7c0bad36
Semihozel/Workspace
/Basit Hesap Makinası.py
622
null
null
null
null
def selection_sort(): # Der oprettes et array af tal ved navn tallist # og en variabel n som er længden af tallist tallist = [2, 4, 5, 1, 3, 6, 9, 8, 7] n = len(tallist) # printer tallisten inden sortering print(tallist) # Der oprettes en løkke i som er længden af tallisten -1 for i in...
3.703125
4
smollm
02e8b56980fd8719e407b13848aa3352cb387d4d
PatrickPLG/programmering_algoritmer_aflevering
/Opgaver/Opgave4.py
1,028
null
null
null
null
''' password manager which includes a simple GUI made with tkinter ''' import sqlite3 from tkinter import * from cryptography.fernet import Fernet conn = sqlite3.connect('pwmanager.db') c = conn.cursor() # Uncomment and run this section if it is your FIRST time running this script # c.execute("""CREATE TABLE passwor...
4
4
smollm
514ff6c8d7d1c0c28fcbfefbdd96f06b8c16f45c
danielwang-personal/password-manager
/pwmanager.py
5,493
null
null
null
null
from datetime import datetime current_year = datetime.now().year name = input(f"What is your name? ") age = int(input(f"What age will you or did you turn in the current year? ")) print_count = int(input(f"How many times should I print the message? ")) years_til_100 = 100 - age year_to_print = current_year + y...
4.0625
4
smollm
1cbd8ae91313d186fab8807f3dd685cee0f4cfc8
jameygronewald/python_challenges
/character_input.py
461
null
null
null
null
if __name__ == "__main__": playing = True player = 1 score = [0, 0, 0] board = [[0, 0 ,0], [0, 0, 0], [0, 0, 0]] vertical_line = """| """ end_ver_line = "|" def ask_user(): try: print(f"\nPLAYER {player}'s TURN") row_choice = int(input(f"\nPlease sele...
4.1875
4
smollm
a468c085b1c629ddc5ddb28c0d4232d652e1b417
jameygronewald/python_challenges
/tic_tac_toe_game.py
4,801
null
null
null
null
if __name__ == "__main__": def find_max(*nums): largest = None # num_list = [num for num in nums] # for num in num_list: for num in nums: if largest is None: largest = num elif largest < num: largest = num print(lar...
4.09375
4
smollm
b521c785489c3e329ba17da2d6c99f303102a8d5
jameygronewald/python_challenges
/max.py
400
null
null
null
null
# -*- coding: utf-8 -*- """ Created on Fri May 14 21:16:36 2021 @author: DELL """ ''' import random as r legal_x = [0,10] legal_y = [0,10] class Turtle: def __init__(self): self.num = 1 self.step = [1,2] self.energy = 100 self.position_x = r.randint(legal_x[0], le...
3.78125
4
smollm
bc5bff9bb70f21c5a15aa83896e99ef320070f36
SoeZeng/FishC
/P37_1.py
5,635
null
null
null
null
# -*- coding: utf-8 -*- """ Created on Wed May 19 15:45:39 2021 @author: DELL """ class Word(str): def __new__(cls, word): # 注意我们必须要用到 __new__ 方法,因为 str 是不可变类型 # 所以我们必须在创建的时候将它初始化 if ' ' in word: print("Value contains spaces. Truncating to first space.") ...
3.5
4
smollm
f0ca59b7d828d3c4fe68f93bdf5c889ad2f386ec
SoeZeng/FishC
/P43_1.py
795
null
null
null
null
n=int(raw_input()) temp=n re=0 while(n!=0): r=n%10 re=re*10+r n/=10 if(temp==re): print "yes" else: print "no"
3.734375
4
smollm
ba2b381d1a1c2021c9a2a0959caea5ef21568458
sravanee/sravani-1
/Palindrom.py
116
null
null
null
null
""" 2: Determina que el resultado tienen los siguientes ejemplos print(not True) print(True and True) print(not False) print(Falsa or True) """ def run(): print(not True) #False print(True and True) #True print(not False) #True print(False or True) #True if __name__ == "__main__": run()
3.796875
4
smollm
8f6ae23c39f05c9a2377e453a4757189b351f260
Zerobitss/Python-101-ejercicios-proyectos
/practica64.py
311
null
null
null
null
class Cuenta(): def __init__ (self, pro, sal, mon): self.__propietario = pro self.__saldo = sal self.__moneda = mon # Getters (metodo Get) def get_Saldo(self): return self.__saldo def get_Propietario(self): return self.__propietario def get_Moneda(self): ...
3.609375
4
smollm
21dd0a8647f63761c046bb7f7c68694f507347ec
Zerobitss/Python-101-ejercicios-proyectos
/practica95.py
724
null
null
null
null
""" Crear un mazo de cartas añadiendo las cartas a una lista usando bucles """ def run(): tantos = ["A", "2", "3", "4", "5", "6", "7", "S", "C", "R"] palos = ["oros", "copas", "espadas", "bastos"] baraja = [] for tanto in tantos: for palo in palos: baraja.append(f"Simbolo: {tanto}, v...
3.9375
4
smollm
d7e91ab022bfef21755a35b9df97c996a9ac4bee
Zerobitss/Python-101-ejercicios-proyectos
/practica26.py
430
null
null
null
null
""" Escribir un programa que pregunte al usuario los números ganadores de la lotería primitiva, los almacene en una lista y los muestre por pantalla ordenados de menor a mayor. """ def run(): loteria = [] for i in range(5): numeros = int(input("Ingresa los numeros ganadores: ")) loteria.append(n...
4.09375
4
smollm
a734ca5b8cf53b7e799f1a3d224f461e3708429d
Zerobitss/Python-101-ejercicios-proyectos
/practica36.py
500
null
null
null
null
""" Escribir un programa que pida al usuario dos números y muestre por pantalla su división. Si el divisor es cero el programa debe mostrar un error. """ def run(): num1 = int(input("Ingresa el primer numero: ")) num2 = int(input("Ingresa el segundo numero: ")) result = num1 / num2 if result == 0: ...
4.03125
4
smollm
acf10855273ddab02fed83bffac722e27263b94f
Zerobitss/Python-101-ejercicios-proyectos
/practica7.py
431
null
null
null
null
""" (2) Escribir un programa que pida al usuario una palabra y la muestre por pantalla 10 veces. """ def run(): word = str(input("Ingresa una palabra: ")) for i in range(1, 11): print(f"{i}:", word) if __name__ == "__main__": run()
3.921875
4
smollm
eb86aa78f1495e23ffa75882a2ac28abebffa0cf
Zerobitss/Python-101-ejercicios-proyectos
/practica68.py
251
null
null
null
null
""" Una juguetería tiene mucho éxito en dos de sus productos: payaso y muñeca. Suele hacer venta por correo y la empresa de logística les cobra por peso de cada paquete así que deben calcular el peso de los payasos y muñecas que saldrán en cada paquete a demanda. Cada payaso pesa 112 g y la muñeca 75 g. Escribir un pro...
4
4
smollm
b86a04dc00e267b115b8cc1c26c8052dd48adaa4
Zerobitss/Python-101-ejercicios-proyectos
/practica87.py
3,266
null
null
null
null
import csv class Contact:#Contenedor de variables ingresadas def __init__(self,name, phone, email): self.name = name self.phone = phone self.email = email class ContactBook: def __init__(self): self._contacts = []#Lista vacia donde se guardaran los contactos def add (self, na...
4
4
smollm
18a4d9053b506beb1ff83014039e6dd078d6768e
Zerobitss/Python-101-ejercicios-proyectos
/proyecto_agenda/contacts.py
4,647
null
null
null
null
""" Escribir un programa que pregunte al usuario su edad y muestre por pantalla todos los años que ha cumplido (desde 1 hasta su edad). """ def run(): age = int(input("Escribe tu edad: ")) for i in range(age): i += 1 if i == 1: print(f"Haz cumplido: {i} año") print(f"Haz cump...
4.0625
4
smollm
b9b52f2aab33cc5bbe64b5e4e7594d96fc52e58b
Zerobitss/Python-101-ejercicios-proyectos
/practica19.py
420
null
null
null
null
""" Escribir un programa que almacene la cadena de caracteres contraseña en una variable, pregunte al usuario por la contraseña e imprima por pantalla si la contraseña introducida por el usuario coincide con la guardada en la variable sin tener en cuenta mayúsculas y minúsculas. """ def run(): password = "sixsamura...
3.875
4
smollm
de68cff4ea3b677e07e118fc24163caa2cb0f964
Zerobitss/Python-101-ejercicios-proyectos
/practica15.py
573
null
null
null
null
""" Escribir un programa que cree un diccionario vacío y lo vaya llenado con información sobre una persona (por ejemplo nombre, edad, sexo, teléfono, correo electrónico, etc.) que se le pida al usuario. Cada vez que se añada un nuevo dato debe imprimirse el contenido del diccionario. """ def run(): d = {} conti...
3.953125
4
smollm
514c98a3747a76d7cd1a82e2253b2061be2e3324
Zerobitss/Python-101-ejercicios-proyectos
/practica48.py
734
null
null
null
null
""" Escribir un programa que pregunte al usuario una cantidad a invertir, el interés anual y el número de años, y muestre por pantalla el capital obtenido en la inversión cada año que dura la inversión. """ def run(): cantidad_inv = int(input("Ingresa la cantidad a invertir: ")) interes = int(input("Ingrese el ...
3.875
4
smollm
f1d86f758b21b4851a7730696d5667199d9c038e
Zerobitss/Python-101-ejercicios-proyectos
/practica22.py
712
null
null
null
null
x = int(input('Enter the age of your accoding to aadhar card:')) if x >= 18: print(" you are eligible for voting ") else: print("you are not eligible to voating")
3.921875
4
smollm
0f6495e8528825aaf3fcc4df2e639d7214ed870c
kunal-singh786/basic-python
/even no.py
173
null
null
null
null
''' Write a program to get the number of vowels in the input string''' def check_vow(string,vowels): #Here i am using comprehension statement to get the vowels in the string final = [each for each in string if each in vowels] #print(len(final)) print(final) string = "Python is cross platform programing language" v...
4.125
4
smollm
22c890b5ce84663885c9020346058c755a6fa046
kunal-singh786/basic-python
/find the vowels in the string.py
366
null
null
null
null
a = int(input("Enter a number: ")) if a > 0: print("Entered number positive") elif a == 0: print("zero") else: print("Entered number Negative")
4.125
4
smollm
f15159a343cf34d16ffe2e49929951127ac36818
kunal-singh786/basic-python
/positive number.py
146
null
null
null
null
a = int(input("enter the value of a=")) b = int(input("enter the value of b=")) g = int(input("enter the value of g(for addition enter 1, for substraction enter 2, for division enter 3, for multiplication enter 4=")) c = a+b d = a-b e = a%b f = a*b if g == 1: print("Addition of a and b is",c) elif g == 2: print("Sub...
3.875
4
smollm
aa14b6b0ed8f7ba0dcad6efa843dcb622ffcb54a
kunal-singh786/basic-python
/calculator.py
449
null
null
null
null
pi = 3.14159 raio = float(input()) volume = (4 / 3.0) * pi * (raio * raio * raio) print("VOLUME = %.3f" %volume)
3.609375
4
smollm
9cc69a36df5dc909ab53415da1f1c26203434e0a
rafaelacarnaval/uri-online-judge
/uri_1011.py
129
null
null
null
null
# 9/18/2018 def hi(): print("Hello!") hi() def start(): choice = input("\n\n\n\n\nGreetings! You are heading to the dining hall one day when there's a bear walking with a dinosaur on campus!! Do you \n\n1) stay inside, or \n walk with them?\n\n>> ") if choice == "1": inside() elif choice == "2": walkWithDi...
4.03125
4
smollm
f7cbfd496814c1923c04842ed0fd7ff7cf93b2c8
e998/CS550
/5functions.py
661
null
null
null
null
# 09/07/2018 # Computer Conversations - The computer enters a discussion about dessert, hobbies, favorite classes, future job aspirations, and favorite cities with the user. # Sources: N/A username = input("Hello! What is your name?" + "\n") day = input("Nice to meet you, " + username + "! How was your day?" + "\n") p...
4.3125
4
smollm
65320017602c9b8cc982a59d2e0d1273d1e9afcb
e998/CS550
/cs550_1hw.py
1,732
null
null
null
null
# 10/26/2018 # Bank Account! class Bank: def __init__(self, name, pin, balance, accNumber): self.name = name self.pin = pin self.balance = balance self.accNumber = accNumber def withdraw(self, balance): status = "" if self.balance > 0: self.balance -= amount1 statusWithdraw = self.name + " just to...
4.21875
4
smollm
c2a09e119358d3a260517dfa7e0b9961170466eb
e998/CS550
/14bankaccount.py
1,555
null
null
null
null
# 10/9/2018 # Recursion! """ 1! = 1 = 1 : base case pattern: 2! = 2 = 2*1 = 2*1! 3! = 6 = 3*2*1 = 3*2! ... n! = n(n-1)! """ """recursive factorial function # limit to recursive function ~ 998,999 def fact(n): # pseudo code - putting function on hold to come back later if n is 1: # return ends function retur...
3.96875
4
smollm
eac8990e220d762103c403c428fc01f2f57e40a6
e998/CS550
/10recursion.py
1,107
null
null
null
null
# Esther Sojung An # 11/14/2018 # Fall Final Project: More Fractals! # It was challenging to work with these fractals and to understand specific patterns, but it was really cool and rewarding. Learning turtle was a fun process and I loved working with it! There were some aspects, including when I was attempting to draw...
4.125
4
smollm
ca63aee50b6edb188196f236e87c97c8f8e39c9c
e998/CS550
/fallfinal.py
9,499