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 |
|---|---|---|---|---|---|---|
3d026db4b884410466b556969e959783841d55ef | mosabelagha/Project-Euler | /3 and 5.py | 291 | 3.6875 | 4 | n = 999
three = int(n/3) + 1
five = int(n/5) + 1
fivethree = int(n/(3*5)) + 1
sum = 0
print(three, five, fivethree)
for i in range(1, three):
sum += 3*i
print(sum)
for i in range(1, five):
sum += 5*i
print(sum)
for i in range(1, fivethree):
sum -= 15*i
print(sum)
print(sum)
|
6e9752ce8e003643c978b7b7891cdec63a4cd01a | clln62/mycode | /lab_input/shebang_challenge.py | 185 | 3.859375 | 4 | #!/usr/bin/env python3
name_input = input("Please enter your name:")
day_input = input("Please enter the day of the week:")
print("Hello,", name_input + "!", "Happy", day_input + "!")
|
1528eae8242b18c1df8438a99d00d44cee9072cb | ranjankaul/Machine_Learning | /Data_preprocessing/Template.py | 1,203 | 3.53125 | 4 | ## Data pre-processing template ##
## importing libraries ##
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
## importing dataset ##
dataset = pd.read_csv("Data.csv")
## segragating the values ##
X = dataset.iloc[:,:-1].values
Y = dataset.iloc[:,-1].values
## editing the missing data ##
... |
e0794d056dad5ce33581e7e7ba22ca034ce2c5d0 | hassyGo/NLP100knock2015 | /iwai/set6/exp59.py | 2,692 | 3.609375 | 4 | # !/usr/bin/python
# coding:UTF-8
# 6-(59):S式の解析
#Stanford Core NLPの句構造解析の結果(S式)を読み込み,文中のすべての名詞句(NP)を表示せよ.入れ子になっている名詞句もすべて表示すること.
import re
import sys
import exp50
#(が来た時、新しくリスト作ってappend続けて、)が来た時はそれまでappendしたリストをpopしてひとくくりにする
def make_parse_list(tree_split):
tree_split = tree_split.split( )
root = [[]]
... |
6d89392a11ae36d479965ad22d00582fd6949ee5 | hassyGo/NLP100knock2015 | /eriguchi/Chap1/chap1_4.py | 1,346 | 3.75 | 4 | #!/usr/bin/env python
# coding: utf-8
"""
04. 元素記号
"Hi He Lied Because Boron Could Not Oxidize Fluorine. New Nations Might Also Sign Peace Security Clause. Arthur King Can."という文を単語に分解し,1, 5, 6, 7, 8, 9, 15, 16, 19番目の単語は先頭の1文字,それ以外の単語は先頭に2文字を取り出し,取り出した文字列から単語の位置(先頭から何番目の単語か)への連想配列(辞書型もしくはマップ型)を作成せよ.
"""
import re
def... |
5ef08a03d7ec69fdea7f81749b94d1289194211d | hassyGo/NLP100knock2015 | /murakami/section4/fib.py | 134 | 3.640625 | 4 | def fib(n):
if n < 2:
return 1
else:
x = fib(n - 1)
y = fib(n - 2)
return x + y
print "aaaaa" |
84ab45a5b9a2e03ca03eee3dea0459e5c46a675c | hassyGo/NLP100knock2015 | /hashimoto/sec01/08.py | 491 | 3.8125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
def cipher(s):
sl = list(s)
for i in range(0, len(sl)):
if sl[i].islower(): # 正規表現を遣え
sl[i] = unichr(219-ord(s[i]))
return "".join(sl)
def hukugou(s):
sl = list(s)
for i in range(0, len(sl)):
if ord(sl[i]) >= 219-ord("z") an... |
7235387f27b886b81703dbebe8f0c4db22b8a6d3 | hassyGo/NLP100knock2015 | /murakami/section8/q73.py | 5,028 | 3.5 | 4 | #!/usr/bin/env python
#coding: utf-8
"""
73. 学習
72で抽出した素性を用いて,ロジスティック回帰モデルを学習せよ.
74. 予測
73で学習したロジスティック回帰モデルを用い,与えられた文の極性ラベル(正例なら"+1",負例なら"-1")と,その予測確率を計算するプログラムを実装せよ.
"""
from q71 import *
from q72 import *
import numpy as np
import math
def sigmoid(x):
return 1.0 / (1 + math.exp(-1*x))
cla... |
64c4855cd8f1f79a00fd7bc128b642240d0198ea | hassyGo/NLP100knock2015 | /murakami/section2/16.py | 743 | 3.625 | 4 | # -*- coding: utf-8 -*-
#16. ファイルをN分割する
#自然数Nをコマンドライン引数などの手段で受け取り,入力のファイルを行単位でN分割せよ.同様の処理をsplitコマンドで実現せよ.
#http://stackoverflow.com/questions/2233204/how-does-zipitersn-work-in-python
import string
import sys
import math
import itertools
if __name__ == "__main__":
f = open("hightemp.txt")
lines = f.rea... |
7fa5664229775a71bb765ba8cdc5d5fde10a4e97 | hassyGo/NLP100knock2015 | /iwai/set1/exp6.py | 456 | 3.703125 | 4 | # !/usr/bin/python
# coding:UTF-8
# 1-(6)
def n_gram(uni,n):
return [uni[k:k+n] for k in range(len(uni)-n+1)]
s1 = []
s2 = []
s1 = n_gram('paraparaparadise', 2)
s2 = n_gram('paragraph', 2)
#print s1
#print s2
inter = set(s1).intersection(set(s2))
print "積集合",
print inter
uni = set(s1).union(set(s2))
print "和集合... |
a25f468da1b2344bd102161ab88fa70a1a981fb9 | nVidiaPriyadarshini/learnpython3hardway | /learnpython3hardway/temparature.py | 188 | 4.0625 | 4 | # Convert celcius to farenheit based on formula : (0 C * 9/5) + 32 = 32 F
print("Let's convert 97.0 degree celcius to farenheit")
print("Farenheit conversion is:", (97.0 * 9/5) + 32.0)
|
3175206b9d152bed4e484eff5dc8c229c9fa74af | ruthiler/Python_Exercicios | /Desafio077.py | 526 | 4.15625 | 4 | # Desafio 077: Crie um programa que tenha uma tupla
# com várias palavras (não usar acentos). Depois disso,
# você deve mostrar, para cada palavra, quais são as suas vogais.
palavras = ('aprender', 'programar', 'linguagem', 'python',
'curso', 'gratis', 'estudar', 'praticar',
'trabalhar', 'merca... |
a5ebf20c156b15656edf78d82b0c90331f5c1f27 | ruthiler/Python_Exercicios | /Desafio039.py | 744 | 4 | 4 | ''' Exercício Python 039: Faça um programa que leia o ano de nascimento
de um jovem e informe, de acordo com a sua idade, se ele ainda vai
se alistar ao serviço militar, se é a hora exata de se alistar ou
se já passou do tempo do alistamento. Seu programa também deverá
mostrar o tempo que falta ou que p... |
6cd508557a1fe3d17d7e1eb8a051e0b5282b96cf | ruthiler/Python_Exercicios | /Desafio085.py | 630 | 4.21875 | 4 | # Desafio 085: Crie um programa onde o usuário possa digitar sete valores
# númericos e cadastre-os em uma lista única que mantenha separados os valores
# pares e ímpares. No final, mostre os valores pares e ímpares em ordem crescente
# encoding: utf-8
numeros = [[], []]
for n in range(1, 8):
num = int(input('0{}... |
548836246ca70975deb9ec5b23b079f5fed164d6 | ruthiler/Python_Exercicios | /Desafio051.py | 291 | 3.9375 | 4 | #Desafio 051: Desenvolva um programa que leia o primeiro termo
#e a razao de uma PA. No final, mostre os 10 primeiros termos dessa progressao.
termo = int(input('Digite o primeiro termo: '))
razao = int(input('Digite a razao: '))
for c in range(termo, (razao*10)+10, razao):
print(c)
|
e4b5f7e681c9d120db28b00022e9a90d36bf3014 | ruthiler/Python_Exercicios | /Desafio081.py | 778 | 4.15625 | 4 | # Desafio 081: Crie um programa que vai ler vários números
# e colocar em uma lista. Depois disso, mostre:
# A) Quantos números foram digitados.
# B) A lista de valores, ordenada de forma decrescente.
# C) Se o valor 5 foi digitado e está ou não na lista.
lista = []
while True:
num = int(input('Digite um numero: '... |
6f4039233e295b6f0b1ac09a8861a5a307ee2cc4 | ruthiler/Python_Exercicios | /Desafio038.py | 294 | 4.03125 | 4 | num1 = int(input("Digite o primeiro numero: "))
num2 = int(input("Digite o segundo numero: "))
if num1>num2:
print("{} é maior que {}".format(num1,num2))
elif num2>num1:
print("{} é maior que {}".format(num2,num1))
elif num1==num2:
print("{} e {} são iguais".format(num1,num2))
|
727fb67efdb4c4f31137c433559543de48646213 | ruthiler/Python_Exercicios | /Desafio072.py | 843 | 4.03125 | 4 | # Desafio 072: Crie um programa que tenha uma dupla totalmente preenchida
# com uma contagem por extenso, de zero até vinte. Seu programa deverá
# ler um número pelo teclado (entre 0 e 20) e mostrá-lo por extenso.
from time import sleep
num = ('Zero', 'Um', 'Dois', 'Três', 'Quatro', 'Cinco', 'Seis', 'Sete', 'Oito', 'N... |
21ea5145afa2db32a411a408e16cd7ba06fe6480 | ruthiler/Python_Exercicios | /Desafio01.py | 121 | 3.796875 | 4 | nome= input('Qual seu nome? ')
print('Olá ',nome,'!','Seja bem-vindo!')
print('Olá {}, Seja bem-vindo!'.format(nome))
|
cc5203cf1f138b131130337512745fe83cb912e7 | ruthiler/Python_Exercicios | /Desafio078.py | 889 | 3.890625 | 4 | # Desafio 078: Faça um programa que leia 5 valores numéricos e
# guarde-os em uma lista. No final, mostre qual foi o maior e
# o menor valor digitado e as suas respectivas posições na lista.
lista = []
maior = menor = 0
for n in range(0, 5):
lista.append(int(input('Digite o valor p posição {}: '.format(n))))
i... |
35853a004f0e5aea696984841f8fcf415c30f9ca | XisnZhang/learning | /enjoy_algorithms/2_bracket_complete.py | 984 | 3.703125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
问题定义:判断一个表达式中的括号是否匹配
"""
class solution:
def bracket_complete(self, s):
a = []
for char in s:
if char == "(":
a.append(char)
elif char == ")":
if not a:
re... |
e3542a6abf8d75e6de6c50cbdc197b1a43e5ce6f | mrogove/PythonMegaCourse | /Section7/simpleCreateFileUsingDatetime.py | 730 | 3.71875 | 4 | import datetime
"""
Use script to create empty file using now()
"""
#variable for now time
now = datetime.datetime.now()
#use strftime
#function to create empty file
def create_file():
with open(now.strftime("%Y-%m-%d-%H-%M")+".txt","w") as file:
file.write("")
#create an identical dummy log for "tomorrow"... |
19bb035bc4899e7ac021c4d8f8b73940ef70de0d | geiszla/object-tracking-test | /src/sliding_window.py | 5,628 | 3.734375 | 4 | """ Sliding Window Detection Module
This module contains the class SlidingWindow, which contains methods to detect an object on an image
using sliding windows.
"""
from time import sleep
import cv2
import numpy
from skimage.measure import compare_ssim
class SlidingWindowDetector:
""" Sliding Window Detector Cla... |
1c92bd33c1eda5465685fcc1c88bd98d9fb25d72 | JimmyMejiaaa/ESTRUCTURA-DE-DATOS | /DEF.py | 525 | 3.84375 | 4 | """Funciones de retorno"""
def vocales(frase):
for car in frase:
if car in ('a', 'e', 'i', 'o', 'u'):
print(car)
"""Llamada a función"""
oracion = input('Ingrese una oracion: ')
vocales(oracion.lower())
"""Funcion con retorno de valor"""
def promedio(notas):
summ = 0
for n i... |
f168f1d3ff956cf9a104824866e819fe662957c4 | Brettehwarrior/ProjecTosh | /announcements.py | 1,579 | 3.703125 | 4 | # announcements.py retrieves announcements from https://threeoakshighschool.wordpress.com/daily-announcements and converts it to array of strings
# (https://stackoverflow.com/questions/328356/extracting-text-from-html-file-using-python)
# Imports
import urllib.request
from bs4 import BeautifulSoup
import re
import str... |
921fba9a00451f138726a5b53b00856ec1be4b15 | wbligh/bankchurn | /Bank Churners.py | 5,027 | 3.859375 | 4 |
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
'''
Prliminary EDA
1) Data prepocessing
2) Univariate analysis & distribution review
3) Bivariate & Correlation analysis with target & Feature importance
4) Models
... |
781e4f354a7c16a20aab15a9f5de48c1612d3cb1 | browniebroke/deezer-python | /src/deezer/dates.py | 648 | 3.609375 | 4 | from __future__ import annotations
import datetime as dt
DATE_FORMAT = "%Y-%m-%d"
DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S"
def parse_date(date_str: str) -> dt.date | None:
"""Parse a date from a string to a date object."""
datetime = parse_datetime(date_str, DATE_FORMAT)
return datetime.date() if datetime ... |
25c2d9079661036a692f31fb5c5d48e0b8091117 | dhruv1214/Basic_py_data_types | /listofevenodds.py | 194 | 3.625 | 4 | def ListofEvenOdds():
l1 = []
l2 = []
l1 = [x for x in range(0, 21) if (x % 2 == 0)]
l2 = [x for x in range(0, 21) if (x % 2 != 0)]
return[l1, l2]
print(ListofEvenOdds())
|
59eb5921f598e546e674cd015a720a4d0ad7e214 | Racso1993/EjerciciosCondicionales | /estereos (1).py | 355 | 3.84375 | 4 | #Ejercicio 7 - Estereos
marcaequipos = input("escriba la marca del equipo: ")
precio = int(input("escibe el costo del producto: $"))
if precio >= 2000:
total = precio - (precio * 0.10)
else:
total = precio + (precio * 0.16)
if (marcaequipos == "NOSY"):
total = total - (precio * 0.05)
print(f"El costo defini... |
c8e1f20839a0f4b8bd1f5d303de2cd27fee09bc5 | santoshray/DataStructuresandAlgorithms | /P0/Task3.py | 3,220 | 4.3125 | 4 | """
Read file into texts and calls.
It's ok if you don't understand how to read files.
"""
import csv
import re
with open('texts.csv', 'r') as f:
reader = csv.reader(f)
texts = list(reader)
with open('calls.csv', 'r') as f:
reader = csv.reader(f)
calls = list(reader)
"""
TASK 3:
(080) is the area cod... |
0e706dcc21a3eff4a2001a6e90b33a95e4136c20 | santoshray/DataStructuresandAlgorithms | /P3/P4_route_planner.py | 3,297 | 3.6875 | 4 | # Below two lines need to be commented
import map_10
import map_40
import math
def shortest_path(M,start,goal):
if start == goal :
return [start]
path_obj={}
path_obj["intersect"] = start
path_obj["path"] = [start]
path_obj["g_cost"] = 0
path_obj["h_est"] = get_distance(M,start,goal)
path_obj["f_total"] = ... |
65742c04d9eef370aad1439195eef6538ec192af | JocelynLi0616/Uber- | /UBER_V2.py | 11,157 | 3.53125 | 4 |
# coding: utf-8
# # UBER
# ### Jocelyn Li
#
# ## Overview
#
# This UBER-Xchange Leasing dataset contains 999 car purchashing entries and 13 variables. Those records were randomly selected from Xchange’s executed lease contracts table.
#
# ## Variable Description
# 1. **Date**: the date that UBER purchased the ca... |
a564e58d3557adef47a16ad4630d7ce854b9e4a2 | banibad/textadventureSUMMER | /buns.py | 2,120 | 3.96875 | 4 |
go_again = True
while go_again == True:
user = input("It's Summer Break! You can press 1 and go to coding camp or press 2 to stay home all summer\n")
if user == "1":
rekt = input("You can press 1 to do coding all day or press 2 to choose not to focus and be bored in class\n")
if rekt == "1":... |
2915228766989e3f9ac379229691bf533f616dc5 | Jock2018/Data_Structure_and_Algorithm | /sorts/quick_sort.py | 1,252 | 4.0625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on 2019/5/5 15:31
@author: Jock
"""
def quick_sort(collection, low, high):
# 快速排序
if low >= high:
return collection
else:
pivot = collection[low] # 把第一个作为基准值
left = low
right = high
while left < right:
... |
31f61dbd20c547748d3757a42de7f9451cc8f0ed | GargoyleLizy/PythonFiles | /Python3/Q2/old/Q_B.py | 1,887 | 3.5625 | 4 | def allMinusInt(num_lst, sub):
for i in range(0,len(num_lst)):
num_lst[i] -= sub
if(num_lst[i] <=0):
num_lst[i] = 0
clearZero(num_lst)
def clearZero(num_lst):
while 0 in num_lst:
num_lst.remove(0)
def clearOneAndTwo(num_lst):
temp_minutes = 0
while (num_lst.coun... |
48911a8fea5d535d1ff35054aec81a73be58219c | MASantos/DragonCompSci | /Algorithms/AllPairsN.py | 3,511 | 3.765625 | 4 | '''
/* Given set N elements, generates all partitions of floor( [N+1]/2 ) blocks, i.e., each block has 2 elements or it is a singleton. Only 1 singleton per partition.
*
* For each partition, print an array with all pairs. Leave the singleton out, if there is one.
*
* Induction:
* When N=1, there is none. For N=2, t... |
9a159afa6331c71396142a0d34aa240cfca497af | midikang/TradeBot | /python/zclasses/zfuncs/tree_func.py | 2,698 | 3.828125 | 4 | def treeToList(rootNode):
''' rootNode is the root of the tree
returns a list containing all branches,
where each branch is a list containing TradingPairs'''
branchList = []
def populateBranchList(node, branch = []):
kids = node.getChildren()
branch.append(node)
... |
7b7109e4c9e2beac4132e217448fdb55c4f616d3 | JiniousChoi/encyclopedia-in-code | /quizzes/00.organize.me/Cracking the Coding Interview/p149_03_getIntFromRotatedSequence.py | 1,469 | 3.625 | 4 | def getIntRotatedSequence(arr, find):
left = 0
right = len(arr)-1
#okay: if arr[left] >= arr[right]:
if arr[left] < arr[right]:
assert(False)
if arr[left] == find:
return left
elif arr[right] == find:
return right
#case: 5,6,7,[8],1,2,3,4
if arr[left] ... |
074c31a4df1e211c6b316c323b0a3873ee2f50bf | JiniousChoi/encyclopedia-in-code | /toyPoC/monad/monad.py | 2,752 | 3.84375 | 4 | #!/usr/bin/env python
# reference: https://rmarcus.info/blog/2016/12/14/monads.html
def step1(x):
return "Hello " + x
def step2(x):
return x + ", monads aren't that complicated."
def step3(x):
return "***" + x + "***"
def prep01():
def run():
x = "friend"
x = step1(x)
x = step2(x)
x = st... |
fbed72494627fd2a6ee76b7b5a1a7f0042580c16 | JiniousChoi/encyclopedia-in-code | /quizzes/interviewbit/programming/arrays/merge_intervals.py | 1,423 | 3.921875 | 4 | #!/usr/bin/python3
## author: jinchoiseoul@gmail.com
# Definition for an interval.
class Interval:
def __init__(self, s=0, e=0):
self.start = s
self.end = e
class Solution:
# @param intervals, a list of Intervals
# @param new_interval, a Interval
# @return a list of Interval
def ... |
ce2c3d6ee52cb37018f7ec427110a9978010a9ec | JiniousChoi/encyclopedia-in-code | /quizzes/00.organize.me/Cracking the Coding Interview/9-6-checkme.py | 1,215 | 3.84375 | 4 | '''
9-6
n이 주어졌을 때 n-쌍의 괄호로 만들 수 있는 모든 합당한 조합(괄호가 적절히 열리고 닫힌)을 출력하는 알고리즘을 구현하라.
'''
def _parenthesis(opening, closing):
assert opening>=0 and closing >=0
if opening==0 and closing==0:
return [[]]
tmp = []
if openable(opening, closing):
for sub in _parenthesis(opening-1, closing):
... |
bf8929b62197da6954a2f7ea5835272936245755 | JiniousChoi/encyclopedia-in-code | /jpylib/jstrings/_strings.py | 1,045 | 3.984375 | 4 | #!/usr/bin/python3
## author: jinchoiseoul@gmail.com
def comma0(n):
s = str(n)
stack = []
while s:
s, t = s[:-3], s[-3:]
stack.append(t)
return ','.join(stack[::-1])
def comma1(n):
return '{:,}'.format(n)
comma = comma0
import unittest
class CommaTest(unittest.TestCase)... |
5a1b5222cd525c176564afc3c16e223acbbb6410 | JiniousChoi/encyclopedia-in-code | /quizzes/codejam/2019/02.you_can_go_your_own_way/solution.py | 358 | 3.8125 | 4 | #!/usr/bin/env python3
def solve(n, her_path):
return ''.join(['E' if c=='S' else 'S' for c in her_path])
def main():
t = int(input())
for i in range(1, t+1):
n = int(input())
her_path = input().strip()
my_path = solve(n, her_path)
print("Case #{}: {}".format(i, my_path))
... |
03bb4eda078c349b9d769b158127cd6b968b35a6 | JiniousChoi/encyclopedia-in-code | /quizzes/codejam/2019/01.foregone_solution/solution.py | 634 | 3.515625 | 4 | #!/usr/bin/env python3
M = { '0': ('0','0'),
'1': ('1','0'),
'2': ('1','1'),
'3': ('2','1'),
'4': ('2','2'),
'5': ('3','2'),
'6': ('3','3'),
'7': ('2','5'),
'8': ('3','5'),
'9': ('3','6') }
def solve(n : int):
s = str(n)
s1, s2 = [], []
for c in s:
... |
e6b9ae7608dc3a2ed57b9d0445a527fab421ee14 | JiniousChoi/encyclopedia-in-code | /quizzes/00.organize.me/Cracking the Coding Interview/18-13-3.py | 5,004 | 3.75 | 4 | '''
백만 개의 단어 목록이 주어졌을 때, 각 단어의 글자들을 사용하여 만들 수 있는 최대 크기 직사각형을 구하는 알고리즈을 설계하라. 이 정사각형의 각 행은 하나의 단어여야 하고(왼쪽에서 오른쪽 방향). 리스트에서 단어를 선정할 때 연속된 단어를 선정할 필요는 없다. 모든 행의 길이는 서로 같아야 하고, 모든 열의 길이도 서로 같아야 한다.
'''
import datetime
perm_dict = {}
WORD_LIST = []
with open('english_dictionary.txt', 'r', encoding="ISO-8859-1") as fp:
... |
2eb9d102e66b936816a160c45e807cae1d73551f | JiniousChoi/encyclopedia-in-code | /quizzes/00.organize.me/Cracking the Coding Interview/18-13-ultimate2.py | 7,779 | 3.59375 | 4 | '''
백만 개의 단어 목록이 주어졌을 때, 각 단어의 글자들을 사용하여 만들 수 있는 최대 크기 직사각형을 구하는 알고리즈을 설계하라. 이 정사각형의 각 행은 하나의 단어여야 하고(왼쪽에서 오른쪽 방향). 리스트에서 단어를 선정할 때 연속된 단어를 선정할 필요는 없다. 모든 행의 길이는 서로 같아야 하고, 모든 열의 길이도 서로 같아야 한다.
'''
import datetime
DEBUG = False
perm_dict = {}
WORD_LIST = []
with open('english_dictionary.txt', 'r', encoding="ISO-8859... |
d4140ac50b819a7f7e5a912199b1f37af8948d93 | JiniousChoi/encyclopedia-in-code | /quizzes/interviewbit/programming/arrays/kth_row_of_pascal_triangle.py | 946 | 3.828125 | 4 | #!/usr/bin/python3
## author: jinchoiseoul@gmail.com
## brief: Given an index k, return the kth row of the Pascal’s triangle.
class Solution:
# @param A : integer
# @return a list of integers
def getRow(self, A):
K = 0
arr = [1]
while K < A:
res = [1]
... |
09d6a4cce243b18a4552f31bbfe5659ae90a81ea | JiniousChoi/encyclopedia-in-code | /jpylib/jtrees/_tree_traversers.py | 2,357 | 3.546875 | 4 | #!/usr/bin/python3
## author: jinchoiseoul@gmail.com
from ._nodes import TreeNode as Tree
def traverse_pre_order(tree):
'''returns string'''
if not tree:
return
yield tree
if tree.left:
yield from traverse_pre_order(tree.left)
if tree.right:
yield from traverse_pre_orde... |
d01846d35f0ed392b0ba76fec057eb5f57ac7bf7 | JiniousChoi/encyclopedia-in-code | /mooc/udacity/st101/my_avg.py | 610 | 3.5 | 4 | #!/usr/bin/env python3
import unittest
def mean(A):
return sum(A)/len(A)
def median(A):
lenA = len(A)
half = int(lenA/2)
if lenA%2==0:
return sum(A[half-1:half+1])/2
else:
return A[half]
def mode(A):
from statistics import collections
c = collections.Counter(A)
return... |
1ab70a22b3063ba778fb737d6c66709fcbf3b1c1 | JiniousChoi/encyclopedia-in-code | /jpylib/jmath/_factors.py | 2,415 | 3.859375 | 4 | #!/usr/bin/python3
## author: jinchoiseoul@gmail.com
def divisor_factors(n):
''' return [divisor]
i.e. 1 -> [1]
2 -> [1,2]
4 -> [1,2,4]
10 -> [1,2,5,10] '''
left, right = [], []
for f in range(1, int(n**.5)+1):
if n%f == 0:
l, r = f, n//f
... |
9e535e34732497baeebc982182303eee00c51aba | JiniousChoi/encyclopedia-in-code | /tools/calc_relative_path.py | 3,326 | 3.78125 | 4 | #!/usr/bin/env python3
'''
This script calculates the shortest relative path
from current position to the destination
For example,
curr: /home/jin/program/ninja.py
dest: /home/ted/program/
res: ../../ted/program/
NOTE: folder always should have a trailing slash at the end. For example,
right: /dir1/dir2/, /dir1/fi... |
311667f095cc0e40d2d973fbbcff56e87c7ef5c0 | JiniousChoi/encyclopedia-in-code | /quizzes/00.organize.me/pick_marvels.py | 1,635 | 3.515625 | 4 | #!/usr/bin/python3
import unittest
class PickMarvelTest(unittest.TestCase):
def test_basecase1(self):
marvels = [1,1]
result = pick_marvel(marvels)
self.assertEqual(result, [[1],[1]])
def test_basecase2(self):
marvels = [2,1]
result = pick_marvel(marvels)
self.... |
c69989c9c31bbd2b7a4c12cc45d5c03f8a00a908 | JiniousChoi/encyclopedia-in-code | /quizzes/cracking_coding_interview/1711.build_rand7.py | 932 | 3.71875 | 4 | #!/usr/bin/python3
## author: jinchoiseoul@gmail.com
''' With the given rng, `rand5`
configure uniformly-distributed `rand7`
and/or as uniformly distributed as `rand5` '''
def rand5():
''' @return randomly generated number in [0,1,2,3,4] '''
import random
return random.randint(0,4) #including bot... |
fd0ce75c48c705b16c5a3b3f843a338ecb541db5 | JiniousChoi/encyclopedia-in-code | /languages/figuredrawer/circle.py | 301 | 3.75 | 4 | from PIL import Image, ImageDraw
SIZE = 256
r = SIZE / 3
image = Image.new("L", (SIZE, SIZE))
d = ImageDraw.Draw(image)
for x in range(SIZE):
for y in range(SIZE):
is_inner = (x - SIZE//2)**2 + (y - SIZE//2)**2 <= r**2
d.point((x,y), is_inner * 255)
image.save('./circle.jpg')
|
4a72aaa1e3f17047b49c43c446f3d4b296ed3217 | JiniousChoi/encyclopedia-in-code | /jpylib/jtrees/_nodes.py | 2,741 | 4.0625 | 4 | #!/usr/bin/python3
## author: jinchoiseoul@gmail.com
from collections import deque
# Definition for a binary tree node
class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
def tree_builder(vals, nil=None):
if not vals:
return None
... |
387119ec16c8c77523e201f8e4d4bd51da0ea603 | JiniousChoi/encyclopedia-in-code | /quizzes/interviewbit/programming/dp/min_jumps_array.py | 2,972 | 3.765625 | 4 | #!/usr/bin/python3
## author: jinchoiseoul@gmail.com
## brief: Given an array of non-negative integers,
## you are initially positioned at the first index of the array.
## Each element in the array represents your maximum jump length at that position.
## Your goal is to reach the last index in the minimum number of jum... |
ce37a2077a018d3eb33bbbd72c3b84b7928fe91a | JiniousChoi/encyclopedia-in-code | /quizzes/00.organize.me/hackerrank/rng/solution.py | 2,655 | 3.703125 | 4 | #!/usr/bin/env python3
import time
class Random(object):
def __init__(self, seed = None):
if seed is None:
_seed = int(time.time() * 1000)
self._seed = (seed ^ 0x5deece66d ) & ((1 << 48) -1)
def next(self, bits):
"""
Generate next random number.
Method retu... |
bd60dc71b2f333e88b4de589f80812b0c52e602e | JiniousChoi/encyclopedia-in-code | /quizzes/00.organize.me/Cracking the Coding Interview/product.py | 1,332 | 3.65625 | 4 | '''
this should function the same as from itertools.product
'''
def product(*lists):
for ls in lists:
assert len(ls)>0
idx_list = [0]*len(lists)
len_list = [len(ls) for ls in lists]
while True:
val_list = []
# ex) idx_list = [0,1,0]
for i,idx in enumerate(idx_list):
... |
6d3f40ea4e1a4743d783ecd008310813d9fdb549 | JiniousChoi/encyclopedia-in-code | /quizzes/00.organize.me/Cracking the Coding Interview/9-9.py | 1,641 | 3.984375 | 4 | #!/usr/bin/env python3
import unittest
def eight_queens(queens_pos):
''' returns every possible eight queen placements
return type is [ queens_pos ]
param quees_pos: [(i,j),]'''
def colide(i, j, queens):
def slope(i1,j1,i2,j2):
return (j1-j2)/(i1-i2)
for qi,qj in ... |
d9e61c7e180acb27ab13e04382b1cbf271fe1f57 | CDM3a/python-course | /homeworks/homework2/task1.py | 458 | 3.8125 | 4 | def prime(x):
if x > 1:
if x == 2:
return True
else:
for i in range(2, x):
if x % i == 0:
S = False
break
else:
S = True
if S == False:
return False
... |
3ab9e65327cbc2733c778b716280b670be005578 | AtticusKuhn/calculatorExample | /beginner/main.py | 1,055 | 3.78125 | 4 | def isNumber(num:str)-> bool:
try:
int(num)
return True
except:
return False
def isOperator(char:str)-> bool:
return char in ["+", "-"]
def solve(problem: str) -> int:
accumulator:int = 0
for (index, character) in enumerate(problem):
if isNumber(character):
... |
58e440b671368c81df73bd6e6bb82d619d9ec385 | zkxjzmswkwl/l0lscape | /actions/movement/movement.py | 1,574 | 3.671875 | 4 | from abc import ABC, abstractmethod
from time import sleep
from random import uniform
class Movement(ABC):
def __init__(self, **kwargs):
self.tile_count = kwargs.pop('tiles', None)
self.direction = kwargs.pop('direction', None).lower()
self._input = kwargs.pop('rs_input', None)
... |
ae1562f866cb8c54589f22867ba55c460fde26b3 | keshavsingh4522/Data-Structure-and-Algorithm | /prefix infix postfix/prefix_to_postfix.py | 689 | 4.21875 | 4 | '''
Algorith:
- Read the Prefix expression in reverse order (from right to left)
- If the symbol is an operand, then push it onto the Stack
- If the symbol is an operator, then pop two operands from the Stack
- Create a string by concatenating the two operands and the operator after them.
- string = operand1 + operand2... |
fb00924b515bce0dd63716c267fed9f94e621d56 | Jeevan1351/30_days_of_code | /Day_8_Dictionaries.py | 390 | 3.609375 | 4 | n = int(input())
phoneBook = {}
for i in range(n):
values = input().split()
phoneBook[values[0]] = values[1]
answers = []
while True:
try:
values = input()
if values in phoneBook:
answers.append(f"{values}={phoneBook[values]}")
else:
answers.append("Not found... |
e84b9db4d7a836380ed62cae26ad30ea4a163ed2 | ReX342/flaskusers | /app/database.py | 2,026 | 3.546875 | 4 | import sqlite3
import bcrypt
from app import app
DATABASE = app.config['DATABASE']
def hash_password(password):
"""Hashes an utf-8 string and returns an utf-8 string of the hash"""
password_bytes = password.encode('utf-8')
salt = bcrypt.gensalt()
hashed_bytes = bcrypt.hashpw(password_bytes, salt)
... |
03c4f02311f597bc214292441911ac7c243c13a4 | codebypugazh/python-beginner | /day 2/if.py | 508 | 3.9375 | 4 | is_hot = True
is_cold = False
if is_hot:
print("It is a hot day")
print("Have some cool drinks")
elif is_cold:
print("It is a cool day")
print("Have some hot drinks")
else:
print("It's neither cold nor hot")
print("Enjoy")
mat = 90
eng = 30
if mat>=40 and eng>=40:
print("pa... |
b61eae5251d2ccefebe1b1bb77e30759fbe3126e | larsenv/wii-remote-date | /wii-remote-date.py | 891 | 4.09375 | 4 | import sys
if len(sys.argv) != 2:
print("Usage: python wii-remote-date.py <date string>")
sys.exit(1)
if len(sys.argv[1]) < 3:
print("Invalid string")
sys.exit(1)
if sys.argv[1][0] == "Z":
year = "2006"
else:
year = ord(sys.argv[1][0]) + 1942
if ord(sys.argv[1][1]) >= 49 and ord(sys.argv[1]... |
01da22806be755b637c3faaee2a94f80ee4bfb54 | stephenramthun/secret_santa | /secret_santa/secret_santa.py | 3,033 | 3.609375 | 4 | import random
import csv
import sys
import argparse
from email_handler import get_template, EmailHandler
class Participant:
def __init__(self, name='no name', email='no email'):
self.name = name
self.email = email
def assign_receiver(self, receiver):
self.receiver = receiver
def _... |
657d381e62ef436721d65905f3edd3dc84cb6de5 | jain7727/html | /funtion/fun1.py | 459 | 3.71875 | 4 | def sum(num1,num2):
add=num1+num2
return add
def diff(num1,num2):
sub = num1 - num2
return sub
def pro(num1, num2):
mul = num1 * num2
return mul
def div(num1, num2):
quot = num1 / num2
return quot
#a prog ia a module
#coll of modules is a package
# import package(name).module(name... |
1b8213b334c5926d619bded5e2dc737803157766 | jain7727/html | /looping/for loop/pattern 6.py | 86 | 3.5 | 4 | for i in range(6,1,-1):
for j in range(0,i):
print(j,end=" ")
print()
|
d75470d54e7df37a33491c24579ebe875fff4a6d | jain7727/html | /collections/list/slicing.py | 328 | 3.78125 | 4 | # lst=[1,2,3,4,5,6,7,8,9]
# print(lst[])
#
# lst=[2,4,5,6,4,7,8,9,6,7,4]
# if (lst)
# n=int(input("enter a number"))
# m=int(input("enter a number"))
# while n<m:
# n += 1
# if n == 3:
# continue
# print(n)
i = 1
while i < 6:
print(i)
i += 1
else:
print("i is no longer less ... |
4f6ed76686f67406c259b2b286ee6dcb3d986339 | jain7727/html | /collections/dictionary/d1.py | 492 | 3.828125 | 4 | # dictionary
#dic={} syntax
# key-value pairs
# insertion order preserved
#doesnt support duplicate key
dic = {"name": "Jain", "id": 10, "loc": "Mh", "marks": 0,"data": 10.70, "result": False}
for i in dic:
print(i, end=" : ")
print(dic[i])
print(dic["name"],dic["loc"],dic["data"])
print(dic["... |
561ee4fb8b21c6eb2b2a3e0d9faab32145c58318 | jain7727/html | /2nd largest.py | 278 | 4.25 | 4 | num1=int(input("enter the first no"))
num2=int(input("enter the second no"))
num3=int(input("enter the third no"))
print(num1,num2,num3)
if(num1>num2>num3):
print("2nd largest no is ", num2)
elif(num2>num3>num1):
print("2nd largest no is ", num3)
else:
print(num1) |
28bc21a04e1028085df065e55531343db6b5d709 | jain7727/html | /oops/oops1.py | 6,510 | 4.0625 | 4 | #class :design pattern
#object real world entity
# references : name that refers a memory location of an object
# class Person:
# def print(self,name,age,gender):
# self.name=name
# self.age=age
# self.genger=gender
# print(self.name,self.age,self.genger)
# pe=Person()
# pe.pri... |
21c9bd89e9269042df2ee015cc3d79532c952881 | jain7727/html | /looping/for loop/cal.py | 234 | 3.578125 | 4 | ll=int(input("enter the limit"))
ul=int(input("enter the limit"))
sumofeven=0
sumofodd=0
for i in range(ll,ul+1):
if(i%2==0):
sumofeven=sumofeven+i
else:
sumofodd=sumofodd+i
print(sumofeven)
print(sumofodd)
|
06d8c36ae21bc44a1460ecf7c547982d0e154b35 | jain7727/html | /collections/list/lkist6.py | 701 | 3.921875 | 4 | # 2nd largest ele
# lst=[9,6,4]
# if lst[0]>lst[1]>lst[2]:
# print(lst[1])
# elif lst[1]>lst[2]>lst[0]:
# print(lst[2])
# else:
# print(lst[0])
#rem dup
# list=[1,5,3,7,5,1]
# dup=[]
# for i in list:
# if i not in dup:
# dup.append(i)
# print(dup)
#triangle
#
# for i in range(0,5):
# fo... |
8d915ce0c2ea70ad568593cb7c6f974dbecef67f | yehudrums/Plataformas | /riddle.py | 1,123 | 4.09375 | 4 | #!/usr/bin/env python3
'''Riddle game
1. A random number is generated
2. User tries to guess wich is the number
3. The program compares the number
from user with the ones generated in 1,
and tell if it was rigth. If not, tells if it
was greater or lesser than the one generated.
By: Yehudy Román Hern... |
3318253c9ad1b1a6442c4ade295560569fe85050 | vanishh/python-tutorial | /question/codewars.py | 2,621 | 4 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Apr 12 15:40:00 2018
@author: Administrator
"""
# code wars练习
# 三阶斐波那契数列
# 1,1,1,3,5,9...
def tribonacci(signature, n):
#your code here
list1 = []
if n == 0:
return list1
for index in range(1,n+1):
result = tribonacci_at_number(signature, index... |
e8d4bf0aa53414d3e6cc99aae64e00c81cafc54c | vanishh/python-tutorial | /question/04.Ex_PTA03.py | 2,608 | 3.703125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Mar 3 22:48:37 2018
@author: Administrator
"""
# 数据结构起步能力自测题
# 自测1
# 把给定的符号打印成漏斗形状
#*****
# ***
# *
# ***
#*****
# 自测2
# 定义dn = p(n+1) - p(n), 其中p(i)是第i个素数,显然有d1 =1,且对于n > 1,有dn是偶数。
# 素数对猜想认为"存在无穷多对相邻且差为2的素数"
# 现给定任意正整数N ,N 小于10**5,计算不超过N的满足猜想的素数对个数
# 判断一个数是否非素数
import... |
7af45c141b143ac95250365c3cbc6498458fcc91 | vanishh/python-tutorial | /data structure/MyStack.py | 2,352 | 3.828125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Mar 7 00:19:24 2018
@author: Administrator
"""
# 定义栈类和栈中的节点
# 栈有长度属性、当前栈顶元素、
# 栈有入栈方法、弹栈方法、获取栈顶元素方法
class MyStack(object):
def __init__(self):
# 前驱
self.before = None
# 后继
self.behind = None
# 栈长度
self.__length = 0
... |
b3028266863fe2714ce6a7464207cee80bb41aa7 | vanishh/python-tutorial | /question/03Ex_PPT6.py | 6,014 | 3.890625 | 4 | # -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
# 计算m ~ n之间整数的和
'''
def sum(m, n):
sumRange = 0
if m > n:
return
else:
for index in range(m, n+1):
sumRange += index
return sumRange
sum(5, 8)
'''
# 2018年1月28日练习题
#题目1:使用Python编程,求1~100间所有偶数的和... |
95582ceb8380128b1142a5f26253e64bdb00b8fb | Vilikt/DungeonAndTreasure | /main.py | 2,872 | 3.515625 | 4 | import sys
from pygame.locals import * # import pygame constant, like KEYUP, K_ESCAPE for examples
from classes.Game import *
from constants import config
"""
This is the main entry of the game. The game loop is wrote at the end.
The main mechanic is based on 4 functions. It is near from PICO-8 system.
On the main fu... |
aded1823e15df8c84ee2b6bd225221e60009215e | Christasen/CSCI1133_FALL2017 | /lab7/stretch1.py | 279 | 3.515625 | 4 | #stretch 1
def ltrcount(astring):
for ch in ",.!&*%@;: ":
astring = astring.replace(ch, "")
astring = astring.lower()
return astring
def main():
s = input("Enter a single string: ")
s = ltrcount(s)
print(s)
if __name__ == "__main__":
main()
|
17ad7c3e634c599eb1d9b057b370b4dca3c9a4f1 | Christasen/CSCI1133_FALL2017 | /lab12/stretch1.py | 3,620 | 3.984375 | 4 | import turtle
import random
import math
def mouseInput(x,y):
print(x,',',y)
class Shape:
def __init__(self,x=0, y=0, fil="",bol = False):
self.xlo... |
aeacf45d361391794fdb3966e1a5ee11942601cc | Christasen/CSCI1133_FALL2017 | /lab2/olympics.py | 598 | 4.4375 | 4 | import turtle
turtle.pensize(10)
def drawcircle(radius):
turtle.circle(radius)
radius1 = int(input("Enter the radius of the circle: "))
turtle.color("black")
drawcircle(radius1)
turtle.color("red")
turtle.penup()
turtle.forward(128)
turtle.pendown()
drawcircle(radius1)
turtle.color("blue")
turtle.penup()
turtl... |
e6c7a8b83bd15edad2d4d50a09e545739fe3b1b2 | delroy2826/Programs_MasterBranch | /pynativedatastruct6.py | 482 | 3.765625 | 4 | #Question 6: Given a following two sets find the
#intersection and remove those elements from the first set
#firstSet = {10, 30, 40 , 60, 45}
#secondSet = {20, 50, 10 , 40, 55}
#Expected Outcome: firstSet = {30, 60, 45}
fSet = {10, 30, 40 , 60, 45}
sSet = {20, 50, 10 , 40, 55}
newSet = set(fSet&sSet)
for i in newSet:
... |
53355c7cc98b984c18a5ab5ed45675fbe428882a | delroy2826/Programs_MasterBranch | /AMCAT_easy.py | 720 | 3.984375 | 4 | #Write a program to generate multiplication table
n=10
for i in range(1,10+1):
print("{} * {} = {}".format(n,i,n*i))
#Write a program to swap two integers
n1 = 10
n2 = 20
print(n1,n2)
temp = n1
n1 = n2
n2 = temp
print(n1,n2)
#Write a program to swap two numbers without using third variable(AMCAT -7 times , Cocube... |
7483f053a8d5e3ebf3f62d93b3743541c452543c | delroy2826/Programs_MasterBranch | /InterviewQuesstion7.py | 359 | 3.609375 | 4 | weekdays = ['sun','mon','tue','wed','thu','fri','sat','sun','mon','tue','wed','thu','fri','sat']
list1 = [[x,weekdays.count(x)] for x in set(weekdays)]
print(list1)
weekdays = ['sun','mon','tue','wed','thu','fri','sat','sun','mon','tue','wed','thu','fri','sat','mon','mon']
my_dict = dict()
for i in weekdays:
my_di... |
ce82b959a4c69edd5f154945200738d35e89461f | delroy2826/Programs_MasterBranch | /Iterator.py | 419 | 4.125 | 4 | #1
l=[1,2,3,4,5]
a=iter(l)
print(next(a))
print(next(a))
#2
l=[1,2,3,4,5]
a=iter(l)
print(*a)
#3
l=[1,2,3,4,5]
a=iter(l)
for i in range(len(l)):
print(next(a))
#4
l=[1,2,3,4,5,6]
a=iter(l)
while True:
try:
print(next(a))
except Exception:
break
#5
l=[1,2,3,4,5,6]
a=iter(l)
for i in l:
... |
9bd412588c55243b5121ca1c11e507c4405fdefb | delroy2826/Programs_MasterBranch | /Number_Pattern 2.py | 151 | 3.65625 | 4 | #Number Pattern
'''
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5'''
n = 6
for row in range(1,n):
for col in range(1,row+1):
print(col,end=' ')
print() |
18d1349155c4a17df235d6ef2a6adbaefd711cf8 | delroy2826/Programs_MasterBranch | /regular_expression_excercise.py | 2,675 | 4.59375 | 5 | #1 Write a Python program to check that a string contains only a certain set of characters (in this case a-z, A-Z and 0-9).
import re
def check(str1):
match = pattern.search(str1)
return not bool(match)
pattern = re.compile(r'[^\w+]')
str1 = "delro3y1229"
print(check(str1))
str1 = "delro#3y1229"
print(check(st... |
9737bed475ae6770ea9824571b23b31f8417a9e0 | delroy2826/Programs_MasterBranch | /Multiplication_Table.py | 159 | 4.40625 | 4 | #Python Program to Print Multiplication Table using For loop
number = 5
for i in range(1,10+1):
val=number*i
print("{} * {} = {}".format(number,i,val)) |
685b6d24ea305987969e83fd0c892c1a4c81c730 | delroy2826/Programs_MasterBranch | /pynative10.py | 781 | 4.21875 | 4 | #Question 10: Given a two list of ints create a third list such that should
#contain only odd numbers from the first list and even numbers from the second list
def merge_even_odd(listOne,listTwo):
l=[]
for i in listOne:
if i%2!=0:
l.append(i)
for i in listTwo:
if i%2==0:
... |
b9a308aee7d5db77e4d0124eb8532bed6287bf08 | delroy2826/Programs_MasterBranch | /oyo1.py | 669 | 3.921875 | 4 | '''Given a list , subtract the last value from first
and put it to first, subtract the second last value from
second and put it to second
Example: [1,4,2,3,8,1,2]
Output: -1 ->3 ->-6 ->3 ->8 ->1 ->2 '''
list1 = [1,4,2,3,8,1,2,8]
list2 = []
len_list1 = len(list1)//2
list3=list1[:len_list1]
for i in range(len(list1)):
... |
486aa4794860648d1d84166f70304e9c15d4c45a | delroy2826/Programs_MasterBranch | /InterviewQuesstion10.py | 246 | 3.9375 | 4 |
def SimpleSymbols(str1):
for i in str1:
if i.isalpha():
if "+"+i+"+" in str1:
a=True
else:
return False
return a
# keep this function call here
print(SimpleSymbols("==a+")) |
3ad1873c71a5d8231020f49cef7ed83ff6e50158 | delroy2826/Programs_MasterBranch | /string_validators_hackerrank.py | 1,433 | 3.765625 | 4 | str1 = "#$%@^&*kjnk svskjnbui h 4oi3hheuh /dfh uidshvhdsuihv suihc 0hrem89m4c02mw4xo;,wh fwhncoishmxlxfkjsahnxu83v 08 n8OHOIHIOMOICWHOFCMHEOFMCOEJMC0J09C 03J J3L;JMFC3JM3JC3'JIOO9MMJ099U N090N9 OOHOLNHNLLKNLKNKNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNKKKKKKKKK... |
bb4387856d4d8d6e7d993d228cd87988a69ad828 | delroy2826/Programs_MasterBranch | /Encapsulation.py | 1,787 | 4.125 | 4 | #1
class Student():
def __init__(self):
self.name=input("Enter The Name:")
self.__grade = "A+"
def display(self):
print("Name: {} ".format(self.name))
print("Grade: {}".format(self.__grade))
s=Student()
s.display()
#2
class Student():
def __init__(self,__grade):
self... |
d4352cfdd84a15f13d8c17ce5e69d6f20b0d3952 | delroy2826/Programs_MasterBranch | /pynativedatastruct5.py | 277 | 4.21875 | 4 | #Given a two list of equal size create a set such that it shows the element from both lists in the pair
firstList = [1, 2, 3, 4, 5]
secondList = [10, 20, 30, 40, 50]
new_list = []
for i in range(len(firstList)):
new_list.append((firstList[i],secondList[i]))
print(new_list) |
c994b8ebc9a7d6a31d35188d64ea1f4ba01662fb | delroy2826/Programs_MasterBranch | /InterviewQuesstion1.py | 861 | 3.734375 | 4 | # #Merging Two Sorted List
# # #Solution 1
# # a = [3, 4, 6, 10, 11, 18]
# # b = [1, 5, 7, 12, 13, 19, 21]
# # print(sorted(a+b))
# #
# # #Solution 2
# # a = [1, 5, 7, 12, 13, 19, 21]
# # b = [3, 4, 6, 10, 11, 18]
# # c = []
# # while a and b:
# # if a[0]<b[0]:
# # c.append(a.pop(0))
# # else:
# # ... |
baefa2da88299fb1232eb5b6457e87352ee7710d | hr1day/Sem4-PracticalExams | /Q9.py | 1,062 | 3.703125 | 4 | from tkinter import *
def isPalindrome():
str=string.get().upper()
solutionField.place(x=50,y=300,height=60,width=200)
strRev=str[::-1]
if(str == strRev):
solutionString.set("{} is a Palindrome!!".format(str))
else:
solutionString.set("{} is a not a Palindrome".format(str))
def reset():
sol... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.