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
a21a4886244b603c81b147aeec065751b76df75f
Gwinew/To-Lern-Python-Beginner
/Pluralsight/Beginner/Core_Python_Getting_started/Module_7/2_Strings.py
1,254
3.78125
4
a=len("llalslewfnuvbvsjvbjsdsdvubayuvavebauyvg") print(a) s= 'New' s+="found" s+='land' print(s) ############## # str.join() # # - Concatention with + result in temporaries # - str.join() insert a separator betweem a collection of strings. # - Call join() on the separator string colors = ';'.join(['#45ff23','#2321fa'...
fb944b3fecd23aa7374512449099bbaa0e51dafd
Gwinew/To-Lern-Python-Beginner
/Pluralsight/Beginner/Core_Python_Getting_started/Module_6/3_Scopes.py
1,435
3.71875
4
# Scopes in Python: # - Local - Inside the current function # - Enclosing - Inside enclosing functions # - Global - At the top level of the module # - Built-in - In The special builtins module # import sys # sys - G # from urllib.request import urlopen # urlopen - G # def fetch_words(ur...
952e75a28702bc977f8c14aaf26db03b50767995
Gwinew/To-Lern-Python-Beginner
/Pluralsight/Beginner/Core_Python_Getting_started/Module_7/3_Ranges.py
334
3.796875
4
# Range: # s=[0,1,4,6,13] for i in range(len(s)): # not prefer print(s[i]) for v in s: print(v) # enumerate: # # - Constructs an iterable of (index, value) tuples around another iterable object. # t= [6,372,8862,148800,2096886] for p in enumerate(t): print(p) for i, v in enumerate(t): print(f"i=...
1c8c891ce51c38d6099a1e139a384baeb0145d44
Gwinew/To-Lern-Python-Beginner
/Tutorial_from_Flynerd/Lesson_8_whileloop/Task5.py
683
4.0625
4
# Using random module create a another simple game. Computer a draw lot word from list range. # Next the letters are lotterying and show this to guess for user. # User guesses until he or she find out correct answer and game is over. # # Press "q" or "Q" to end a game. import random names=("andrzej","krzysztof", "andze...
a9544cc1ca5ad4c4adcf5d403e874e9b7d6cb8e3
Gwinew/To-Lern-Python-Beginner
/edx_Introduction_to_Python_for_Data_Science/1_Lists.py
3,050
4.65625
5
# - Lists # Lists are keep different elements separate comma place in square brakcet. # Elements on that lists could have different types. lista=[3,5,"tea",False] print(lista) print(type(lista)) # # Lists allow to elements modification, we can replace elements on the list. # Lists are indexed from "0" - that is mean th...
7a85e32340f82247a32ce4f234a38b3b30c9ffc9
Gwinew/To-Lern-Python-Beginner
/Tutorial_from_Flynerd/Lesson_4_typesandvariables/Task2.py
817
4.21875
4
# Make a list with serial movie # # Every serial movie should have assigned rate in scale 1-10. # Asking users what they serial movie want to see. # In answer give they rate value. # Asking user if they want to add another serial movie and rate. # Add new serial movie to the list. # -*- coding: utf-8 -*- dictserial={...
b1077695d8b814286c878c7d809eed423b224f72
Gwinew/To-Lern-Python-Beginner
/Tutorial_from_Flynerd/Lesson_3_formattingsubtitles/Task2.py
886
4.125
4
# -*- coding: utf-8 -*- # # Create a investment script which will have information about: # -Inital account status # -Annual interest rate # -The number of years in the deposit # # Result show using any formatting text. # enter=input("Hi! This is Investment script.\nI want to help you to count your money impact at the ...
931c283cfe56acb0b02c9e26205980a3fda9f4ff
Gwinew/To-Lern-Python-Beginner
/Pluralsight/Intermediate/Unit_Testing_with_Python/1_Unit_Testing_Fundamentals/2_First_Test/test_phonebook.py
1,405
4.1875
4
"""Given a list of names and phone numbers. Make a Phonebook Determine if it is consistent: - no number is a prefix of another - e.g. Bob 91125426, Anna 97625992 - Emergency 911 - Bob and Emergency are inconsistent """ import unittest #class PhoneBook: # Right-cli...
b1e947fa7af94c9878ee8032f9f58e03499404e4
Gwinew/To-Lern-Python-Beginner
/Pluralsight/Beginner/Core_Python_Getting_started/Module_6/2_Types.py
159
3.59375
4
# Python's Type System def add(a,b): return a+b print(add(5,7)) print(add(3.1,2.4)) print(add([1,6],[21,107])) # print(add('The answer is',42)) <- Error
c44adf28927db11122d152bbdb993e30c69707fe
APuck003/Python-Sandbox
/Interactive_Dictionary.py
1,008
3.96875
4
#!/usr/bin/env python3 import json from difflib import get_close_matches data = json.load(open('/Users/Austin_MacBook/Desktop/Austin_Python_Projects/Interactive Dictionary/data.json')) def word_return(word): if word in data: return data[word] elif word.lower() in data: return data[word.lower()...
1acf86f0a54e9b34fa3d0e37753af419cbfe72d0
wmclt/KaprekarsNumber
/src/mappingsprinter.py
1,435
3.515625
4
##This class prints the mappings with the mappings one below the other. class MappingsPrinter(): def __init__(self, digitsNr): self.digitsNr = digitsNr self.fileWriter = open(str(digitsNr) + '-Digits-Prototypes.txt', 'w') def printPrototypes(self, prototypes): self.fileWriter.write('------PROTOTYPES------...
faf8710bf8d92523ced8642c574ab6b1d36d4239
vivek-ku-gu/Python_development
/basic python prog/keep_adding.py
283
3.90625
4
#keep adding the string number till enter is pressed sum = 0 while(True): userInput = input("Enter your price and press q to quit\n") if(userInput != "q"): sum=sum + int(userInput) print(f"sum till is {sum}") else: break print(f"Total Amount is {sum}")
43c8c18997b1b1884db7a30f3b6cdcb2522aaaac
danrneal/unscramble-computer-science-problems
/Task3.py
1,284
3.9375
4
"""Read file into texts and calls. Print a list of area codes and mobile prefixes called by people in Bangladore Print the percentage of calls from fixed lines in Bangalore made to fixed lines also in Bangladore Usage: Task3.py """ import csv prefixes = set() calls_from_bangladore = 0 calls_to_bangladore = 0 ...
c9cbe81958f8301af59917442d880fd9011bf5be
Jakub-Kaczmarczyk/prac_prog_03
/zad24.py
140
3.78125
4
a=0 for x in range(1,10): a=a+1 if x>5: a=a-2 word="" for y in range(1,a+1): word=word+"* " print(word)
669d7eb58ef417ca288d6358c7811e7449933d21
ojoilesanmi/user_data_validation
/user_data_validation.py
1,370
3.9375
4
from random import choice from string import ascii_letters import sys user = 0 while user < 2: container = [] first_name = input("Kindly enter your first name: ") last_name = input("Kindly enter your last name: ") e_mail = input("Kindly enter your email address: ") letters = ''.join(choice(ascii...
ce461ca6acdbdf1d6712d7507e463fd7ad9e44e0
PVyukov/GB_HW
/Lesson1_welcome/1_all.py
2,119
3.84375
4
# Task 1 a = 'hello' b = 'world' print(a, b) num_1 = int(input()) print('Вы ввели: ', num_1) # Task 2 time = int(input('Enter time in seconds: ')) hours = time // 3600 minutes = (time // 60) - (hours * 60) seconds = time % 60 print(f'{hours:02}:{minutes:02}:{seconds:02}') # Task 3 n = input('Enter integer: ') print(f...
282c157d1cbdcbc56f2445b45cc21da4109c5993
PVyukov/GB_HW
/Lesson8_OOPadd/8_1.py
1,731
4.09375
4
""" 1) Реализовать класс «Дата», функция-конструктор которого должна принимать дату в виде строки формата «день-месяц-год». В рамках класса реализовать два метода. Первый, с декоратором @classmethod, должен извлекать число, месяц, год и преобразовывать их тип к типу «Число». Второй, с декоратором @staticmethod, должен ...
ffb18fd304ce9911519da8c6e9cf0bcc38997721
PVyukov/GB_HW
/Lesson5_files_os/5_all.py
7,074
4.15625
4
'''1. Создать программно файл в текстовом формате, записать в него построчно данные, вводимые пользователем. Об окончании ввода данных свидетельствует пустая строка.''' # with open('test.txt', 'w') as f: # while True: # line = input('Введите строку: ') # if line == '': # break # ...
671798da4111fd22a17eeb27b905483ded5b1205
nithintech/datastructures_and_algorithms
/3_bubblesort.py
474
4.0625
4
def bubblesort(mylist): swaps = True while swaps: swaps = False count =0 for element in range(len(mylist)-1): count=count+1 if mylist[element] > mylist[element+1]: swaps = True temp = mylist[element] mylist[element]=mylist[element+1] my...
36e79d5ac4c62d708b66dda0caef35f0c34c3e93
heheddff/myPythonProcess
/数学运算/gongyue.py
224
3.9375
4
#求公约数 def getMax(x,y): if x < y: x,y = y,x while (x%y) !=0: r = x%y x = y y = r return y a = eval(input("输入整数")) b = eval(input("输入整数")) print(getMax(a,b))
bf6c845c5504ea67eede84570f72268b5ac1783e
jkuruzovich/medi-chal
/code/processing/normalization.py
420
3.515625
4
import pandas as pd def standard(df, column, mean=None, std=None): x = df.copy() if not mean and not std: mean = x[column].mean() std = x[column].std() x[column] = (x[column] - mean) / std return x, (mean, std) def min_max(df, column, min=None, max=None): x = df.copy() if not min and not max: min = x[colu...
024d12ccb27f4b125ed6551a376515cbb5cd9582
luisone/Python_study
/python20180730/p4_2.py
122
3.640625
4
for i in range(10): if i % 2 != 0: print(i) continue i += 4 print('i+2 = ' + str(i)) print(i)
f715727ee09157d63012256004858a4b3259760d
fayssica/leetcode
/Python/majority-element.py
678
4
4
''' Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the array is non-empty and the majority element always exist in the array. Example 1: Input: [3,2,3] Output: 3 Example 2: Input: [2,2,1,1,1,2,2] Output: 2 ''' cla...
fbefada0f6be9b3abfced218353eda805a399332
GadiHerman/machine_learning_book
/lab6/line_regression_img_3.py
2,486
3.71875
4
from PIL import Image import numpy as np import matplotlib.pyplot as plt #--------start get data from images---------------------------------- sea_colors = list() for i in range(10): img = Image.open("data/sea" + str(i) + ".jpg") img.load() data = np.array(img, dtype=np.uint8) sea_colors.a...
fbacad3332aaaf68a9b0dea69d97bdfcf76d0e97
GadiHerman/machine_learning_book
/lab11/NN-final-parabola4_listPoint.py
5,195
3.515625
4
import numpy as np import matplotlib.pyplot as plt class NeuralNetwork: def __init__(self,inputLayerNeurons,hiddenLayerNeurons,outputLayerNeurons): self.hidden_weights = np.random.uniform(size=(inputLayerNeurons,hiddenLayerNeurons)) self.hidden_bias =np.random.uniform(size=(1,hiddenLayerNeurons)) self.ou...
71940b138b5c417e1a255b1772fa5ce8c50041fe
GadiHerman/machine_learning_book
/lab11/NN-final-line3_listPoint.py
4,861
3.515625
4
import numpy as np import matplotlib.pyplot as plt class NeuralNetwork: def __init__(self,inputLayerNeurons,hiddenLayerNeurons,outputLayerNeurons): self.hidden_weights = np.random.uniform(size=(inputLayerNeurons,hiddenLayerNeurons)) self.hidden_bias =np.random.uniform(size=(1,hiddenLayerNeurons)) self.ou...
91bbf7caa9bae5d6ef6fd0a051d62ffdaad3627d
GadiHerman/machine_learning_book
/lab2/nparr_12.py
100
3.8125
4
import numpy as np x1 = np.array([1, 2, 3, 4, 5 ]) x2 = x1[x1>3] print("\n x1>3 : \n",x2)
e625ad76fdbf7c9abcfbfb854ff94cc8a587ad1b
alessandrovaccaro/hkrrnk
/warmup/python/cavity_map.py
712
3.6875
4
#!/opt/local/bin/python3.4 def cavity(m,x): if x == 0 or x == (len(m)-1): return m[x] line = m[x][0] for i in range(1,len(m)): #print('value of index i %d' % i) if i == len(m)-1: line+=m[x][i] elif int(m[x][i]) > int(m[x-1][i]) and int(m[x][i]) > int(m[x+1][i]) a...
8f2866ea13596b1e14afaa8b50e2dde7fc0b8ffc
alessandrovaccaro/hkrrnk
/strings/python/palindrome_index.py
662
3.9375
4
#!/opt/local/bin/python3.4 #https://www.hackerrank.com/challenges/palindrome-index def check_palindrome(s): index = -1 lng = len(s) for i in range(int(lng/2)): if s[i] != s[lng - i - 1]: if is_palindrome(s[(i+1):(lng-i)]): index = i else: inde...
096f4f86e2a6db35b4e77ae188ebebe4b98d293c
351116682/Test
/04.py
532
3.671875
4
#coding=utf-8 ''' 输入某年某月某日,判断这一天是这一年的第几天? ''' year = int(raw_input('请输入年份:\n')) month = int(raw_input('请输入月份:\n')) day = int(raw_input('请输入日期:\n')) days = [0,31,59,90,120,151,181,212,243,273,304,334] result = 0 if 0 < month <= 12: result = days[month] else: result = 0 result += day if year % 400 == 0 or...
4a4c3ea900dc710fa66c8f11fec9710e071ca1c1
351116682/Test
/24.py
573
3.75
4
#coding=utf-8 ''' 使用Tkinter画同心圆 ''' def circle(width = 800,height = 600,bg = 'green'): from Tkinter import * # 确定画布信息 canvas = Canvas(width = width,height = height,bg = bg) canvas.pack(expand = YES,fill = BOTH) k = 1 j = 1 # 确定圆的个数 for index in range(0,32): # 画圆需要提供的参数信息 ...
3816745c2b680faf5ed5b87fb6a9cc7503a5a818
351116682/Test
/20.py
572
4.25
4
#coding=utf-8 ''' 交换两个数的值 其实原理都是一样的,只不过Python可以借助于tuple,元组的形式来一次性的返回多个值 相对于其他编程语言而言,这真的很方便 ''' def change(a,b): temp = a a = b b = temp return a,b def exchange(a,b): a,b = b,a return a,b if __name__ == "__main__": a ,b = 1,2 print '原来的值:%d---%d'%(a,b) a,b = exchange(a,b) pri...
662b27273e7f2d77ab135cd35fcb818e3d04ebb8
EarlHaigCS/Traffic-Director-Game
/TrafficDirector/__init__.py
28,690
3.59375
4
""" Coded by: Khashayar Pourdeilami Yaml library is used to parse yaml files. (pyyaml) Pygame is the game engine used to make this game. """ import pygame from pygame.locals import * from classes import * from menu import * import os from math import * import time import yaml import webbrowser scriptDir = os.path.dirn...
d708dbf01e0460ce00ef0ce9de4d586044e27e01
gutierrpdev/robot_arm
/MotionPlanner2D.py
8,885
3.578125
4
from numpy import sin, cos import numpy as np from itertools import product, combinations from functools import partial class MotionPlanner2D: """ Auxiliary methods for handling subsets """ @staticmethod def findsubsets(s, n): return [set(i) for i in combinations(s, n)] """ Gene...
dd2c20eaabeebda1a923b5127852c9eb62a34b24
exnx/mnist-convnet
/mnist-convnet.py
5,562
3.84375
4
import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data # the mnist data (included in TensorFlow) mnist = input_data.read_data_sets("/tmp/data/", one_hot=True) # model parameters n_classes = 10 # output classes (the 10 numbers) batch_size = 128 # size of each batch when reading i...
f97b7b24c217f3ae1756cb44578e4879dca9774e
virgorasion/My-Python
/Check_palindrom.py
605
3.984375
4
from Module import Deque as deq def isPalindrome(katas): palindrome = deq.createDeque() for kata in katas: deq.addFront(palindrome, kata) cek = True while deq.size(palindrome) > 1: if deq.removeFront(palindrome) == deq.removeRear(palindrome): cek = cek and True els...
e9722a78625920c60735da43b80727f6838ba3f7
virgorasion/My-Python
/faktorial.py
481
3.75
4
# def faktorial(x): # hasil = 1 # for i in range(2, x + 1): # hasil *= i # return hasil # print(faktorial(10)) def towerOfHanoi(n, asal, bantuan, tujuan): if n == 1: print("Pindahkan Lempengan 1 dari {0} ke {1}".format(asal,tujuan)) else: towerOfHanoi(n-1, asal, tujuan, ban...
4146fbec8019031e942fc66eba9d1327c18a2891
virgorasion/My-Python
/Postfix_sule.py
2,663
3.53125
4
import Module.Stack as st def isValidate(strinfix): data = st.stack() kurung ={")":"(","}":"{","]":"["} for i in strinfix: if i in kurung.values(): st.push(data, i) elif i in kurung.keys(): if st.isEmpty(data): return "Kelebihan kurung tutup" ...
88d53685deee93530f4ceaa56d7cf89e778088c1
virgorasion/My-Python
/SquentialSearch.py
399
3.546875
4
data = [5,2,1,2,4,5,3,2,7,5,8,8,5,3,2,4,6] def seqSearch(data,value): position = [] length = len(data) for i in range(len(data)): if value == data[i]: position.append(i) if position == []: position = "Data tidak ada" return position,length [hasil,jumlahIterasi] = seqSear...
c1a9d1a2a42855f2dabff0e46e489252f4a315d7
lvhx0322/python-
/robot/tktest/insert_tktest.py
626
3.5
4
import tkinter as tk window = tk.Tk() window.title('TEST') window.geometry('200x200') e = tk.Entry(window, show='**') e.pack() def insert_point(): e.clear() var = e.get() t.insert('insert', var) def insert_end(): var = e.get() t.insert('end', var) def insert_position(): var = e.get() t....
2aab2612b2204e66611670ba0e4dcf7061719770
SurajB/sudoku
/sudoku.py
6,664
4.03125
4
#This is sudoku game built in python3 #learnings - enumerate, list comprehension, deepcopy, recursive function return problem, limiting recurssion from random import randint, choice from copy import deepcopy from time import sleep print("\nLet us play sudoku\n") user_choice = input("Enter your choice of difficulty -...
dac63848a28c3ff16dafedc5cdaa68c75bdb8763
adilevi12/Tic-Tac-Toe-game-python-implementation
/tic_tac_toe.py
10,093
3.875
4
P1_TOKEN = 'X' P2_TOKEN = 'O' EMPTY_SPOT = '_' MS_INVALID_MOVE = -1 MS_VALID_MOVE = 0 MS_OUT_OF_RANGE = 1 MS_OCCUPIED = 2 GS_FULL_BOARD = 0 GS_WIN = 1 GS_ONGOING = 2 def scan_dimensions(): '''asks dimensions of the board if input is valid returns brd_input if input is not valid asks again u...
31ef3712e0d41da0267b0aacf3062b4060043abf
shrivathsap/randsim
/lsystems.py
1,701
3.625
4
import turtle, math turtle.screensize(2000, 2000) def draw_tree(number_of_iterations, angle): turtle.left(90) step = number_of_iterations*2 i = 1 positions = [] new_positions = [] turtle.forward(step) positions.append([turtle.pos(), turtle.heading()]) while i <= number_of_i...
d8b4012442c376b7f5554289642085972e4a56f2
avidyalalala/AbiteOfLife
/algorithm/decidePrimeNumber.py
363
4.03125
4
import sys def isPrimeNumber(_num): for value in range(1,_num-1): if(_num%value!=0): return False return True if __name__=="__main__": input=sys.argv[1] text="" re=isPrimeNumber(int(input)) if(re is not True): text=" not" print("the number you input %s i...
801f728f0fd7c55517b3f6fe0685baf170c28552
avidyalalala/AbiteOfLife
/algorithm/divide_conquer/power_x.py
982
3.84375
4
import datetime ''' failed start ''' def partion(n): if(n%2==0): n=n/2 else: n=(n-1)/2 #print(n) return n def conquer(temp_x,x,n): if(n%2==0): temp_x=temp_x*temp_x else: temp_x=temp_x*temp_x*x return temp_x ''' x is like coefficient or constant, in the whole...
ee0eb65582ce9db9cc635038101221a257bbc5f6
Aa-yush/Learning-Python
/BMICalc.py
331
4.28125
4
weight = float(input("Enter your weight in kg : ")) height = float(input("Enter your height in meters : ")) BMI = weight / (height**2) if(BMI <= 18.5): print("Underweight") elif(BMI >18.5 and BMI <= 24.9): print("Normal weight") elif(BMI>24.9 and BMI<=29.9): print("Overweight") else: print("...
a1b0101b256323fa826dbb9cba8a22986784b42e
Aa-yush/Learning-Python
/NumberExercise.py
175
4.3125
4
radius = float(input("Enter radius of circle : ")) import math Pi=math.pi print("Area = ",round((Pi*(radius ** 2)),4)) print("Circumference = ",round((2*Pi*radius),4))
fa63c4f06d514a19cb98b08ead811726d31cf3ad
LiuHaoLung/08_Data_Analysis
/Pandas/PandasPractice1/classforpandas1.py
646
3.640625
4
import pandas d = pandas.DataFrame([['Andy', 46, 'Engineer'], ['Jane', 33, 'Nurse'], ['Robert', 21, 'Student'], ['Maria', 30, 'Student']]) print(type(d)) print(d) d = pandas.DataFrame([['Andy', 46, 'Engineer'], ['Jane', 33, 'Nurse'], ['Robert', 21, 'Student'], ['Maria', 30, 'Student']],columns = ['Name','Age','Occup...
d44d7f27d291c4d0cb578a0838bdf541e1a9a2b9
LiuHaoLung/08_Data_Analysis
/NumPy/classforNumpy1.py
4,359
4.28125
4
''' 判斷陣列維度的方法: 1. 如果在回傳 array() 裡面,只有一對 [] 則代表是一維陣列。 2. 如果再回傳 array() 裡面,有兩對 [[]] 則代表是二維陣列。 arange 和 linspace 的差別在: 1. arange() 裡的參數為,起始值、終值和增值。 2. linspace() 裡的參數為,起始值、終值和出現多少個數。 ''' import numpy as np # 將最原始的 list 轉變成 NumPy 中的 array。 my_list = [1,2,3] print(np.array(my_list)) # 將原始的多個 list 轉變成 NumPy 中的 二維陣列。 my_...
00f03d13cb62aed3bd9f3726847641aee9ad3da3
AyselHavutcu/FlaskBlog
/blog.py
16,588
3.53125
4
from flask import Flask,render_template,flash,redirect,url_for,session,logging,request from flask_mysqldb import MySQL #mysql icin gerekli olan fromları dahil ettik from wtforms import Form,StringField,PasswordField,validators,TextAreaField #bunlarda formda kullanmak icin dahil ediyourz from passlib.hash import sha256...
fbe9b0a9d2c6dc596e43d2af27342a7c5750e1f7
lang321/fisher-flask
/generatorTest/tes1.py
640
3.875
4
# coding:utf-8 ''' @author: fight139 @file: tes1.py @time: 2018/7/22 10:08 @desc: ''' class A(object): def show(self): print('hello') def fun(): print('enter') yield A() print('exit') def fib(max): n, a, b = 0, 0, 1 while max > n: yield b a, b = b, a + b n = n...
c398e963e328b2ef970dc05b4128df28ddd67ffa
anandvimal/hackerrank
/algorithms/implementation/Sherlock_and_the_Beast.py
619
3.609375
4
#!/bin/python import sys t = int(raw_input().strip()) for a0 in xrange(t): n = int(raw_input().strip()) #print t is number of test cases a = "3" number = int( a+(n-1)*"3") print "start number",number n_of_3 = str(number).count('3') n_of_5 = str(number).count('5') print "number of ...
a55ba3d68028b5822a43874eb98419cd3ebfbfce
anandvimal/hackerrank
/python/data types/lists.py
757
3.9375
4
# Enter your code here. Read input from STDIN. Print output to STDOUT import sys n = int(raw_input()) store = [] for i in range(0,n): data = (raw_input()).split(" ") if (data[0] == "insert"): store.insert( int(data[1]), int(data[2]) ) #print store elif (data[0]== "print"): #print ...
9731fb609637a189b18388963dbff4b55027d2a7
scott-ammon/cs-fundamentals
/algorithms/Python/bubble_sort.py
329
3.921875
4
test_array = [24, 2, 16, 103, 45, 22, 133, 7, 9] def bubble_sort(arr): for i in range(len(arr)): for j in range(0, len(arr) - i - 1): print(arr[j]) if arr[j] > arr[j + 1]: arr[j + 1], arr[j] = arr[j], arr[j + 1] return arr print("Unsorted:", test_array) print("Sorted:", bubble_sort(test_ar...
67b9e2f4f90bab5e3cf41f56e3402361519470ac
binti-family/hellosign-python-sdk
/hellosign_python_sdk/utils/utils.py
313
4.03125
4
import re def is_email(email): """Check if an email is valid Args: email (str): Email address Returns: True if email is valid, False otherwise. """ pattern = '[\.\+\-\w]{1,}[@]\w+[.]\w+' if re.match(pattern, email): return True else: return False
1ead0f826412e9f21ad4d878f7cc8353922ea7d8
Sirtobey24/UnitTests
/Part3/conditional.py
260
3.734375
4
def max_of_two(x, y): if (x > y): return x else: (y > x) return y def max_of_three(x, y, z): if (x > y) & (x > z): return x elif (y > x) & (y > z): return y else: (z > x) & (z > y) return z
3fecdd8fcd643cc9626bb5e19673364b3c131b3f
amohacker/NS-miniproject
/guiTest/guitest3.py
289
3.640625
4
from tkinter import * root = Tk() label = Label(master=root, text='Hello World', background='yellow', foreground='blue', font=('Helvetica', 16, 'bold italic'), width=14, height=3) label.pack() root.mainloop()
716741558e5575f6d301760f8029137739156ca7
amohacker/NS-miniproject
/guiTest/guitest8.py
202
3.609375
4
from tkinter import * root = Tk() button1 = Button(master=root, text='Button 1') button1.pack(pady=10) button2 = Button(master=root, text='Button 2') button2.pack(side=LEFT, pady=10) root.mainloop()
b56f6a2c017da7a95241a857d224c8cec50c1a63
AnimeshSinha1309/terminal-joyride
/firebeam.py
2,249
3.53125
4
""" Implements the obstacles (beams of fire) hanging in the air """ import numpy as np import colorama as cl import container from spawnable import Spawnable class FireBeam(Spawnable): """ The FireBeam obstacles that destroy the player if colliding """ def __init__(self): self._type = np.ran...
926273d86f73d19a90c1d05f6f329ff1e6a312e7
rohit98077/python_wrldc_training
/03_if_else.py
366
3.953125
4
''' Lesson 3 Using if, elif, else in python ''' x = 10 if x == 1: print('processing...') print('x is one') elif x==2: print('processing...') print('x is two') elif x==4: print('processing...') print('x is four') else: print('processing...') print('condition not hit :-(') print('x i...
8a2edf5d14180fefe7c387a81465edb89c12eca0
rohit98077/python_wrldc_training
/24_read_write_text_files.py
816
4.375
4
''' Lesson 2 - Day 4 - read or write text files in python ''' # %% # read a text file # open the file for reading with open("dumps/test.txt", mode='r') as f: # read all the file content fStr = f.read() # please note that once again calling f.read() will return empty string print(fStr) # this will...
b096fbd435e5058f59aa46d546a0a4ade727fa69
rohit98077/python_wrldc_training
/13_pandas_dataframe_loc.py
574
4.125
4
''' Lesson 2 - Day 3 - Pandas DataFrame loc function loc function is used to access dataframe data by specifying the row index values or column values ''' #%% import pandas as pd # create a dataframe df = pd.DataFrame([[2, 3], [5, 6], [8, 9]], index=['cobra', 'viper', 'sidewinder'], columns=['max_speed', 's...
c32441d06cb6b092341a134d13daef8df5a57812
rohit98077/python_wrldc_training
/26_timedelta.py
874
3.953125
4
''' Lesson 4 - Day 4 - timedeltas in datetime module ''' # %% import datetime as dt # %% # create a desired time interval timePeriod = dt.timedelta( days=5, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0) print(timePeriod) print(type(timePeriod)) # %% # get the difference between 2 dateti...
0b2fc06568846aabe4ee89eb92e8972ecf23c0c4
iita-robotica/RoboligaVirtual
/Rescate/controllers/MainSupervisor/obstacleCheck.py
6,841
3.703125
4
def checkIntersect(circleCentre:list, circleRadius:float, wallPos:list, wallDim:list) -> bool: '''Returns true if the circle intersects the wall''' #Calculate the closest point on the wall (rectangle) to the circle (obstacle) xChange = circleCentre[0] - max(wallPos[0], min(circleCentre[0], wallPos[0] + wall...
688af7672ad55833dd8f5caff436ee139a6591d5
jfjlaros/dict-trie
/dict_trie/dict_trie.py
8,200
4.1875
4
def _add(root: dict, word: str, count: int) -> None: """Add a word to a trie. :arg root: Root of the trie. :arg word: A word. :arg count: Multiplicity of `word`. """ node = root for char in word: if char not in node: node[char] = {} node = node[char] if '' ...
6937b9a085552fcceb8996e1de3316c03aa81ab3
fengkaiwhu/A_Byte_of_Python3
/learn/if.py
220
3.640625
4
#!/usr/bin/env python # coding=utf-8 # Filename: if.py number = 23 guess = int(input("Enter an int:")) if guess == number: print("feng") elif guess < number: print("kai") else: print("else") print("done")
0e66cef7b14800d47a750139d943d8c439338232
fengkaiwhu/A_Byte_of_Python3
/example/addr_book.py
1,812
4.1875
4
#!/usr/bin/env python # coding=utf-8 # Filename: addr_book.py class addr_book: '''Represent an addr_book''' book = {} def __init__(self, book): addr_book.book = book def get_book(self): return addr_book.book def add_person(self): name = input('Please input name-->') ...
85ca3ab76550a0092f926eb777a834246c85c557
RyanWaltersDev/NSPython_chapter3
/travel_dest.py
729
4.71875
5
#Ryan Walters Nov 21 2020 -- Practicing the different sorting methods with travel destinations #Initial list travel_dest = ['tokyo', 'venice', 'amsterdam', 'osaka', 'wales', 'dublin'] #Printing as a raw Python list and then in order print(travel_dest) print(sorted(travel_dest)) #Printing in reverse alphabetical orde...
471e5fe020f376a15cd1ecff9a32d6f3e22d2c79
allsmilesnnc/ProjectWork
/Python/learn/dict.py
499
3.578125
4
name = raw_input("Enter file:") if len(name) < 1 : name = "mbox-short.txt" handle = open(name) dic = {} maxvalue = 0 name = "" line = [text.split()[1] for text in handle.readlines() if text.startswith("From") and text.find("@")>0 and len(text.split()) > 2] for text in line: if not dic.has_key(...
e8b5d3bff13d48e8bf35f964221071d3c59e22b7
allsmilesnnc/ProjectWork
/Python/learn/fileread2.py
1,354
4
4
# Write a program that prompts for a file name, then opens that file and reads through the file, looking for lines of # the form: X-DSPAM-Confidence: 0.8475 # Count these lines and extract the floating point values from each of the # lines and compute the average of those values and produce an output as # sho...
9237922af4d00ff1aa56373beebcc560542c1c62
brandondebison/Python
/Assignment-1/Assignment-1-B.py
335
3.828125
4
#!/usr/local/bin/python3 from datetime import datetime inputTime = input("Please enter a timestamp in YYYY-MM-DD format \n") tempTime = datetime.strptime(inputTime, "%Y-%m-%d") compTime = datetime.strptime("2018-06-30", "%Y-%m-%d") calTime = (tempTime-compTime).days output = "Number of days are: " + str(calTime) ...
65f0e878aec1ce073be2a61747fb312953820b07
brandondebison/Python
/Assignment-2/Assignment-2-B.py
2,792
3.53125
4
from tkinter import ttk from tkinter import * import tkinter from tkinter import messagebox window = Tk() window.geometry("600x600") window.title("Assignment 2 - Question 2") informationLabel = Label( window, text="Please choose a pizza size and your toppings", font='Helvetica 10 bold') outputLabel...
bcf5879ec4f4e3cd0d85ba9f8da64160f13431ef
brandondebison/Python
/Intro/test2.py
426
3.9375
4
#!/usr/local/bin/python3 myInput = input("what is your value? ") # inputs come in as a string convertedNumber = int(float(myInput)) print(myInput) print("I entered %s" % myInput) print ("I entered %d" % convertedNumber) counter = 0 # print(counter) # counter += 1 # print(counter) # for i in range (0,15): # ...
80b1e358850088606881ade34c2f5f33d3265680
brandondebison/Python
/Class/TestClass2.py
981
4.09375
4
#!/usr/local/bin/python3 class Employee: empCount = 0 def __init__(self,name,salary): super().__init__() self.name = name self.salary = salary Employee.empCount += 1 def displayCount(self): print("We have ", Employee.empCount, " employees") def display(self): ...
c469f1e4930205ad48580205369d93a11b0d8d21
mrbengutierrez/Musical-Instrument-Recognizer
/old_code/decoder_06.py
4,178
3.9375
4
import numpy as np import matplotlib.pyplot as plt def sigmoid(x): """ This function computes the sigmoid of x (np.array)""" return 1.0/(1 + np.exp(-x)) def sigmoidDerivative(x): """ This function computes the sigmoid derivative of x (np.array)""" return sigmoid(x) * (1.0 - sigmoid(x)) class NeuralNe...
74dffd46219d3a53069a5e55002215ee971e5ea9
gandie/Planets
/Planets.Stable/lib/planet.py~
4,644
3.625
4
#!/usr/bin/env python import pygame from itertools import cycle from math import * GRAVITY=50 class Planet: # wrap parameters into dictionary! def __init__(self, diameter, colour, pos, mass, vel_x, vel_y, fixed, centrum): self.mass = mass self.diameter = diameter self.colour = colour...
599219daf55e05ff428a7e63e9383284b1240d85
denizsucu/PythonProjects
/SomeBasicPrograms/Loops/while.py
861
4
4
# #iki sayı arasındaki tek sayılar # first = int(input("Birinci Sayı: ")) # second = int(input("İkinci Sayı: ")) # first+=1 # while (first < second): # if first % 2 == 1: # print(first) # first+=2 # else: # print(first+1) # first+=2 # #kullanıcıdan sayılar alıp, sıralı yazdır ...
e84bb5c935b0e92fa975725f924f25395257b6ad
QuentinPotgieter/PythonRead-Write
/33361908_Practical_10.py
2,270
3.953125
4
#cd c://programs #python 33361908_Practical_10.py studentNumberList = [] countStudentNumbers = 0 #Read from file def Read(): try: with open("Data.txt", "r") as file: linesTotal = 0 listItems = [] for line in file: listItems.append(line) li...
f2bcba354ca2998aa2deded7fd0fd1f872d24a65
shigihenrique/IPL-2021
/p3_1.py
786
3.5
4
#Henrique Shigihara #IPL-2021 #Problema 3.1: Codificação Run Length def run_length_encode_2d(array): lista = [] #Unificar a lista: for i in range(len(array)): for j in array[i]: lista.append(j) repeat = 0 lista_final = [] atual = lista[0] size = len(lista)...
e1ad3cddd1324354ae8f59562eda2bc57d998a3d
shigihenrique/IPL-2021
/p2_5.py
792
3.703125
4
#Henrique Shigihara #IPL-2021 #Problema 2.5: Cifra de César import string def caesar_cipher(texto, shift): abc = string.ascii_lowercase digits = string.digits text = texto.lower() out = '' for i in text: if i in digits: #numeros num = digits.find(i) ...
bc0e69a4fe6709cabdf062677cde99ebe7e57e3b
itsmnsi/Data-Structure-Programs
/Sorting/Bubble Sort/BubbleSort.py
259
3.8125
4
***** Python program ***** a = [10,9,7,101,23,44,12,78,34,23] for i in range (0,len(a)): for j in range (i+1,len(a)): if a[j] < a[i]: temp = a[j] a[j] = a[i] a[i] = temp print("printing sorted element list...") for i in a: print(i)
e252b8e45df12925dc408830ac9ab7e4c0062958
aniketh27/Projects
/Hangman/hangman.py
1,021
4.09375
4
import random name = input("What is your name? -->") if not name: print("Please enter your name!") exit() print("Good Luck ! " + name) words = ['rose','red','elephant','loop','timeline'] hidden_word = random.choice(words) print("----Hangman----") guess_word = '' guess_count = 5 try: while(guess_count ...
b55b56333b209f2c91a5b16f8b640c819c1b30cb
danielmlima1971/CursoemVideo-Python-Exercicios
/Mundo2/Ex051-ProgressaoAritmetica.py
358
3.96875
4
# Exercício Python 51: Desenvolva um programa que leia o # primeiro termo e a razão de uma PA. No final, mostre os # 10 primeiros termos dessa progressão. termo = int(input('Digite o termo da P.A.: ')) razao = int(input('Digite a razão da P.A.: ')) for c in range(1, 11): print('{}'.format(termo), end=' ') ...
4ca4e141304cac59a47ae96c22a9d54ea6bd4ef2
danielmlima1971/CursoemVideo-Python-Exercicios
/Mundo 1/Ex022.py
645
4.3125
4
# EXERCICIO 022 # Exercício Python 22: Crie um programa que leia o nome # completo de uma pessoa e mostre: # – O nome com todas as letras maiúsculas e minúsculas. # – Quantas letras ao todo (sem considerar espaços). # – Quantas letras tem o primeiro nome. nome = str(input('Digite seu nome completo: ')) print...
47febcc6fd3c2b2d986ede9da903840e6132b863
danielmlima1971/CursoemVideo-Python-Exercicios
/Mundo 1/Ex003.py
143
3.90625
4
n1 = float(input('Digite um valor: ')) n2 = float(input('Digite outro valor: ')) s=n1+n2 print('A soma entre {} e {} é {}'.format(n1,n2,s))
e4a79d6a56885eed560cf5a5f2c7ab6c614cb164
danielmlima1971/CursoemVideo-Python-Exercicios
/Mundo2/Ex036-EmprestimoBancario.py
1,167
4.34375
4
# Exercício Python 36: Escreva um programa para aprovar # o empréstimo bancário para a compra de uma casa. # Pergunte o valor da casa, o salário do comprador e em # quantos anos ele vai pagar. A prestação mensal não pode # exceder 30% do salário ou então o empréstimo será negado. print('\033[7;30;41m=\033[m' * 2...
cc84edb418307a77da6c6bddff9d2c49865c30fa
danielmlima1971/CursoemVideo-Python-Exercicios
/Mundo2/Ex047-MostrarPares.py
225
3.640625
4
# Exercício Python 47: Crie um programa que mostre na tela # todos os números pares que estão no intervalo entre 1 e 50. import time for c in range (0, 51, 2): print(c, end=' ') time.sleep(0.4) print('FIM')
3258b20967a514f46ae3325860dc8db0f3fa4991
danielmlima1971/CursoemVideo-Python-Exercicios
/Mundo 1/Ex029.py
553
3.984375
4
# # Exercício Python 29: Escreva um programa que leia a # velocidade de um carro. Se ele ultrapassar 80Km/h, mostre # uma mensagem dizendo que ele foi multado. A multa vai # custar R$7,00 por cada Km acima do limite. vel = int(input('Qual a velocidade do veículo? ')) if vel <= 80: print('VOCÊ ESTÁ DENTRO...
299d79229cd592ff51bf999ca53b85427bd47cd0
daisyzl/program-exercise-python
/ArrayDeal/cunzaichongfuyuansu.py
1,683
3.8125
4
#-*-coding:utf-8-*- ''' 存在重复元素 题目:https://leetcode-cn.com/problems/contains-duplicate/ 答案:https://blog.csdn.net/qq_17550379/article/details/80642667 给定一个整数数组,判断是否存在重复元素。 如果任何值在数组中出现至少两次,函数返回 true。如果数组中每个元素都不相同,则返回 false。 示例 1: 输入: [1,2,3,1] 输出: true 示例 2: 输入: [1,2,3,4] 输出: false 示例 3: 输入: [1,1,1,3,3,4,3,2,4,2] ...
4e84b9bcd4f42f57b7f87c6003e3e7137eeddf84
daisyzl/program-exercise-python
/Sort/selectsort_test.py
342
3.703125
4
#-*-coding:utf-8-*- from random import randint if __name__ == '__main__': def heapsort(A,n): for i in range(0,n-1): for j in range(i+1,n): if A[i]>A[j]: A[i],A[j]=A[j],A[i] return A li=[randint(1,999) for i in range(10)] n=len(li) ...
9207040ba05bb7cceb6eff73afcae3d3e2d2232a
daisyzl/program-exercise-python
/Sort/4insertsort.py
1,706
4.375
4
#-*-coding:utf-8-*- ''' 插入排序 基本思想:插入排序是一种简单直观的排序算法。它的工作原理是通过构建有序序列,对于未排序数据,在已排序序列中从后向前扫描, 找到相应位置并插入。插入排序在实现上,在从后向前扫描过程中,需要反复把已排序元素逐步向后挪位,为最新元素提供插入空间。 插入排序的时间复杂度问题 最优时间复杂度:O(n) (升序排列,序列已经处于升序状态) 最坏时间复杂度:O(n2) 稳定性:稳定 https://www.runoob.com/python3/python-insertion-sort.html 思想: 把n个待排序的元素看成一个有序表和一个无序表,开始时有序表中只包含一个元素,无序...
d7932d0968599e1aebe904ea14950c805c08d4fc
daisyzl/program-exercise-python
/Binarysearch/xunzhaobimubizimudadezuixiaozimu.py
1,569
3.78125
4
#-*-coding:utf-8-*- ''' 寻找比目标字母大的最小字母 题目:https://leetcode-cn.com/explore/learn/card/binary-search/213/conclusion/852/ 答案:https://blog.csdn.net/qqxx6661/article/details/80172363?utm_source=blogxgwz1 给定一个只包含小写字母的有序数组letters 和一个目标字母 target,寻找有序数组里面比目标字母大的最小字母。 数组里字母的顺序是循环的。举个例子,如果目标字母target = 'z' 并且有序数组为 letters = ['a...
2f0c26b6c18182bf072d378b240b915aa9ee1e8c
daisyzl/program-exercise-python
/Binarysearch/sqrtx.py
1,136
4.09375
4
#-*-coding:utf-8-*- ''' x 的平方根 题目:https://leetcode-cn.com/explore/learn/card/binary-search/209/template-i/836/ 答案:https://www.cnblogs.com/NPC-assange/p/9362756.html 实现 int sqrt(int x) 函数。 计算并返回 x 的平方根,其中 x 是非负整数。 由于返回类型是整数,结果只保留整数的部分,小数部分将被舍去。 示例 1: 输入: 4 输出: 2 示例 2: 输入: 8 输出: 2 说明: 8 的平方根是 2.82842..., 由于...
39e9cde5d290af851b6078d25d94978e23de5393
daisyzl/program-exercise-python
/Sort/5shellsort.py
1,800
3.625
4
#-*-coding:utf-8-*- ''' 希尔排序(相比于堆排序第二难) 基本思想:希尔排序(Shell Sort)是插入排序的一种。也称缩小增量排序,是直接插入排序算法的一种更高效的改进版本。 希尔排序是非稳定排序算法。该方法因DL.Shell于1959年提出而得名。 希尔排序是把记录按下标的一定增量分组, 对每组使用直接插入排序算法排序;随着增量逐渐减少,每组包含的关键词越来越多,当增量减至1时,整个文件恰被分成一组, 算法便终止。 https://blog.csdn.net/qq_35164554/article/details/79142939 https://www.runoob.com/python3/pyth...
c8fe78ac66a216e310b6889106ea78bc2708924e
daisyzl/program-exercise-python
/StringDeal/fanzhuanzifuchuan2.py
1,446
3.9375
4
#-*-coding:utf-8-*- ''' 反转字符串 II 这道题可以好好复习一下切片和一部分迭代 题目:https://leetcode-cn.com/problems/reverse-string-ii/ 答案:https://blog.csdn.net/weixin_40449300/article/details/81048871 给定一个字符串和一个整数 k,你需要对从字符串开头算起的每个 2k 个字符的前k个字符进行反转。如果剩余少于 k 个字符, 则将剩余的所有全部反转。如果有小于 2k 但大于或等于 k 个字符,则反转前 k 个字符,并将剩余的字符保持原样。 示例: 输入: s = "abcdef...
080a07ae41620f5f8af50f681046e23bb698e125
daisyzl/program-exercise-python
/Interview/guazi.py
678
3.875
4
#-*-coding:utf-8-*- ''' A = [0, 1, 2, 3, 4] B = [5, 6, 7, 8, 9] 求A+B的偶数列 zip函数接受任意多个可迭代对象作为参数,将对象中对应的元素打包成一个tuple,然后返回一个可迭代的zip对象. 这个可迭代对象可以使用循环的方式列出其元素 若多个可迭代对象的长度不一致,则所返回的列表与长度最短的可迭代对象相同. https://www.cnblogs.com/renpingsheng/p/7755312.html ''' class Solution(): def test(self, A, B): result = [sum(i...
3b848a03a86b5e409bd266d06e55998791035a9d
daisyzl/program-exercise-python
/BinaryTree/zuidashendu.py
1,373
4.1875
4
# -*- coding:utf-8 -*- ''' function:二叉树的最大深度 给定一个二叉树,找出其最大深度。 二叉树的深度为根节点到最远叶子节点的最长路径上的节点数。 说明: 叶子节点是指没有子节点的节点。 示例: 给定二叉树 [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7 返回它的最大深度 3 。 题目:https://leetcode-cn.com/explore/learn/card/data-structure-binary-tree/3/solve-problems-recursively/12/ 答案:https:...
5eb41a4c6f4f7d6b97ee2111f80024455990abda
daisyzl/program-exercise-python
/ArrayDeal/changduzuixiaozishuzu_ver2.py
1,566
3.890625
4
#-*-coding:utf-8-*- ''' 长度最小的子数组 思想:二分法 先完成ver3后再执行ver2 时间复杂度:O(n log n) 题目: https://leetcode-cn.com/explore/featured/card/all-about-array/233/sliding-window/971/ 答案: https://blog.csdn.net/qq_17550379/article/details/80540430 给定一个含有 n 个正整数的数组和一个正整数 s ,找出该数组中满足其和 ≥ s 的长度最小的连续子数组。 如果不存在符合条件的连续子数组,返回 0。 示例: 输入: s ...
2b94e4b2c9dfc3fc5232be9570f1e07f3a388ce4
daisyzl/program-exercise-python
/Other/xingjichuanyue.py
962
3.90625
4
#-*-coding:utf-8-*- ''' 题目描述 航天飞行器是一项复杂而又精密的仪器,飞行器的损耗主要集中在发射和降落的过程,科学家根据实验数据估计,如果在发射过程中,产生了 x 程度的损耗,那么在降落的过程中就会产生 x2 程度的损耗,如果飞船的总损耗超过了它的耐久度,飞行器就会爆炸坠毁。问一艘耐久度为 h 的飞行器,假设在飞行过程中不产生损耗,那么为了保证其可以安全的到达目的地,只考虑整数解,至多发射过程中可以承受多少程度的损耗? 输入描述: 每个输入包含一个测试用例。每个测试用例包含一行一个整数 h (1 <= h <= 10^18)。 输出描述: 输出一行一个整数表示结果。 示例1 输入 10 输出 2 ''...
97255e0693b6f6d69e85b195c383587d98b7d0d2
vinusha-git/python-session1
/collections.py
401
3.875
4
# names=['vinusha','nireesh','avinash'] # print('names were' + len(names)) # names.insert(0,'madharavena') # names.sort() # print(names) #Dictionary names={} names['first']='vinusha' names['last']='john' print(names) names1={} names1['first']='vinu' names1['last']='jo' print(names1) people=[] people.append(names) p...