blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
72158bbc11c0969d6f2ed50f3695ca6afcd044f3
SiddheshKhedekar/Python-Foundations
/2.Turtle, messaging and Profanity checker/bigCircleSquare.py
752
4.5
4
""" The program that allows user to make a big circle out of big squares using a function. """ import turtle def draw_square(meow): # declare function to draw square meow.forward(200) # move 100 distance meow.right(90) # turn 90 degree meow.forward(200) meow.right(90) meow.forward(20...
fdf4b979e58869f2d85a35ad303e4bacabb51d40
SmolkaAnton/lyricScraperPython
/lyricscraper.py
1,935
3.5
4
from bs4 import BeautifulSoup import requests import csv def the_artist(): artist = input("Enter an artists name: ") new_artist = clean_up_string(artist) return new_artist def the_song(): song = input("Enter the artist's song: ") new_song = clean_up_string(song) return new_song def clean_up_s...
b63236fcdd9d1bc576509892cb0b6a950e282c66
gregtampa/Wargames
/ProjectEuler/complete/004.py
483
4.25
4
#!/usr/bin/env python # A palindromic number reads the same both ways. The largest palindrome made # from the product of two 2-digit numbers is 9009 = 91 x 99. # Find the largest palindrome made from the product of two 3-digit numbers. largest = 0 def ispalindrome( n ): return str(n)[::-1] == str(n) for i in range...
1906297186e6384bfa15d50c04fb8fe45806f156
gregtampa/Wargames
/ProjectEuler/complete/016.py
275
4
4
#!/usr/bin/env python # 2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. # What is the sum of the digits of the number 2^1000? power = 2**1000 powerstr = str( power ) sum = 0 for i in range( len( powerstr ) ): sum += int( powerstr[i] ) print sum # passed
5e2cfadc29baef73369ffbb62a1d88e0ddd67365
gregtampa/Wargames
/PythonChallenge/07.py
474
3.53125
4
#!/usr/bin/env python # For this challenge, we have an image with a greyscale barcode looking thing # across it. The file is 629x95 import Image im = Image.open("tmp/oxygen.png") pix = im.load() ans = '' for i in range(1,608,7): ans = ans + chr(pix[i,47][0]) print ans # smart guy, you made it. the next level is ...
f393a0a9653d555635c67c71fb3a574923ce1f78
k1oShd/WEB2021SPRING
/lab7/for/j.py
67
3.609375
4
cnt=0 for x in range(0,5): a = int(input()) cnt+=a print(cnt)
ecc3bcfcdf4ce2d77346226c7358bcb206a66fa4
k1oShd/WEB2021SPRING
/lab7/CodingBat/warmup_1/12.py
129
3.71875
4
def front3(str): if(len(str)<3): front = str[0:] return front*3 else: front = str[0:3] return front*3
25e170f77b87a75d3c90a59c149e3ef61249eb4e
k1oShd/WEB2021SPRING
/lab7/while/e.py
92
3.546875
4
n = int(input()) i = 0 while i<n: if(2**i>=n): print(i) exit() i+=1 print("NO")
2a86932837e6fa1849f234960fa884ba4874a6aa
PingouinsECL/application
/classes/player.py
490
3.703125
4
from pawn import * class Player: """ Class defining a player. It can have multiple modes: 0 -> human 1 -> random 2 -> minimax """ number_player = 0 def __init__(self, mode, total_number): self.score = 0 self.owned = 0 self.mode = mode self.number = Pla...
e09c617d29c144d3f601600ff8f9f0762f8732ed
isensen/PythonBasic
/Tutorials/18_定制类.py
8,316
3.578125
4
#coding=utf-8 ''' 看到类似 __slots__ 这种形如 __xxx__的变量或者函数名,就要注意,这些在Python中有特殊用途的. __slots__我们已经知道怎么用了, __len__()方法 ,我们也知道为了让能class作用于len()函数 除此之外,Python中的class中还有许多这样有特殊用途的函数,可以帮助我们定制类. ''' __author__ = "i3342th" #----------------__str__---------------------------------------------- #我们先定义一个Student类,打印一个...
3517472c1e1e3874af2a05f8f6d436c83354c71c
isensen/PythonBasic
/Tutorials/29_4_常用内建模块(itertools).py
2,910
4.03125
4
#coding=utf-8 """ Python的内建模块itertools提供了非常有用的用于操作迭代对象的函数。 """ __author__ = 'isenen' #首先,我们看看itertools提供的几个“无限”迭代器: #因为count()会创建一个无限的迭代器,所以上述代码会打印出自然数序列,根本停不下来,只能按Ctrl+C退出 import itertools natuals = itertools.count(1) for n in natuals: print n #cycle()会把传入的一个序列无限重复下去: cs = itertools.cycle('ABC') # 注意字符串也是序列的...
fc85b1b6cbc0f3b91ac9caa224e48b4dbf6bdea5
OUGREIN/chipscoco-python-learning
/chenzhan/print_debug.py
287
4.1875
4
def accumulate(*args): value = 0 print('for loop start,value:{}'.format(value)) for arg in args: print('value is:{} arg is:{}'.format(value,arg)) value += arg print('for loop end,value:{}'.format(value)) return value result = accumulate(1,2,3)
6df2fe28e3efdc89a091f66e2ac9837be02cdc22
OUGREIN/chipscoco-python-learning
/liaohaipeng/CalculatingTheExtremumOf10NumericalVariables.py
404
3.84375
4
''' @author:liaohaipeng @date: 2020-8-16 @desc: 计算10个数值型变量的极值 ''' # 思路:量量之间进行比较 numbers=[3,4,5,6,7,13,7,110,33,-7] max=min=numbers[0] for number in numbers: max = max if max > number else number min = min if min < number else number else: print("最大值:%d\n最小值:%d" % (max, min)) numbers=[3,4,5,6...
c8f8a38ccc88eb39c82a9c6a7ae8f8e71ef5d305
OUGREIN/chipscoco-python-learning
/chenzhan/compare_performance.py
785
3.609375
4
''' @author:chenzhan @date:2020-08-16 des:比较字典与列表的执行性能 ''' #导入time模块,执行time模块中的perf_counter方法来获取程序的执行时间 import time numbers = [] container = {} #使用for循环结构,分别往列表和字典中,添加1百万个数据 for _ in range(1,1000000): numbers.append(_) container[_]=_ #获取查找前的时间 start = time.perf_counter() _ = 1000000 in numb...
45747013cc83903ccbe5e50c94fd68d4d49e1d9f
OUGREIN/chipscoco-python-learning
/liaohaipeng/Cycle_Comparison_Size.py
190
4.03125
4
numbers = [2,13,5,88] max = numbers[0] for _ in numbers : if _ > max: max = _ print(max) min = numbers[0] for _ in numbers : if _ < min: min =_ print(min)
816c27eb037718eaba13eb4b332a0896024d13a8
Reactionz/TerminalSnake
/Snake.py
482
3.8125
4
class Snake: def __init__(self, init_body, init_direction): self.body = init_body self.direction = init_direction def take_step(self, position): # Will add position to the front of the snake from the back. self.body = self.body[1:1] + [position] def set_direction(self, dire...
d62ee2585292df096fd046f2d2f8689b094690a5
nashor2000/IntroductionToPython
/src/m5_your_turtles.py
1,764
3.71875
4
""" Your chance to explore Loops and Turtles! Authors: David Mutchler, Dave Fisher, Valerie Galluzzi, Amanda Stouder, their colleagues and Xuechen Bai. """ ######################################################################## # TODO: 1. # On Line 5 above, replace PUT_YOUR_NAME_HERE with your own name. ##...
5f3d55963e07c495977d3e679c665f2ed04f6057
ramyaramy/ramya
/holiday.py
170
3.953125
4
list=['monday','tuesday','wednesday','thursday','friday'] list1=['sunday','saturday'] day=input() if day in list: print("no") elif day in list1: print("yes")
8685c013f14a5757127b2a18d4c85725d87a689d
ramyaramy/ramya
/8.py
180
4.15625
4
num=int(input("enter a number:")) if num<0: print("enter positive number") else: sum=0 while(num>0): sum=sum+num num=num-1 print("the sum is ",sum)
e71f293298ca702e6daf4c08805c1d9df2a62348
emmy-kech/learningmap
/display.py
130
3.671875
4
skills = {} while True: k = input("add skills:") val =input("have you done this skill?") skills[k] = val print(k)
11555a3dd98af81235874e83d7156403ed97c965
hjkim015/Sudoku
/sudoku.py
25,822
4.53125
5
#https://stackoverflow.com/questions/45471152/how-to-create-a-sudoku-puzzle-in-python from random import sample import numpy as np from itertools import combinations base = 3 # Will generate any size of random sudoku board in O(n^2) time side = base*base nums = sample(range(1,side+1),side) # random numbers ...
89453a0a79674d2d92f02f8a78bfdd16115716f1
elkbrsathuji/goosebumps
/junction.py
4,525
3.5
4
""" This class simulates a junction, which is a collection of lanes """ from base_lane import base_lane class junction(object): def __init__(self,lanes_array,gen_array=None,probs=None): #initialize lanes self._lanes = [[None for _ in range(4)] for _ in range(4)] self._lights = [[[0,0] for _...
c587520e8b33e9897a833a3f536d1f0f2970979d
si-hall/matematica-speciala
/Graph.py
12,803
3.734375
4
import sys def enter_list(x,number): m = 0 for l in range(number): print('Enter the number of directions for the',l+1,'point') k = input() while True: if not k.isdigit() or int(k) > number: print("Pls enter the correct number! Try again: ") k = input() else:...
2e7c53ebc9da2fd2dbaca8e08875f6e3415386fe
pavi1998/python
/106pl.py
215
3.65625
4
i=int(input()) duplicate =list(map(int,input().strip().split()))[:i] final_list = [] for num in duplicate: if num not in final_list: final_list.append(num) for i in final_list: print(i,end=" ")
d507d147de46572a2a6f5aa2ff0f900edbccca78
pavi1998/python
/43.py
74
3.65625
4
p=int(input()) if(1<=p and p<=10): print("yes") else: print("no")
3b17e9ef3c79d2954c302299033583c18c5fbcd1
pavi1998/python
/repeating.py
326
3.671875
4
def printRepeating(arr, size): for i in range (0, size): for j in range (i + 1, size): if arr[i] == arr[j]: print(arr[i], end = ' ') # Driver code s=int(input()) arr=list(map(int,input().strip().split()))[:s] arr_size = len(arr) printRepeating(arr, arr_size...
a300caa194a1504ff109ea55ef734280876c7e9d
MandipThapa/Python
/Addition.py
639
3.8125
4
import LogicalGates as gates # It imports the functions from LogicalGates def byte_adder(x, y, z): result = "" #sum value for i in range(len(y)-1,-1,-1): #does loop for the 8 times xs = gates.xor_Gate(int(x[i]),int(y[i])) add_val = gates.xor_Gate(xs, z) result += str(add_va...
7afd95a4ab55ff948cc237cbbeba38bfdf31c2ce
jiangw0419/python_way
/python_day_04/p01.py
640
3.71875
4
#!/usr/bin/env python # -*- encoding: utf-8 -*- ''' @文件 :p01.py @说明 :输入一个正整数判断是不是素数。 提示:素数指的是只能被1和自身整除的大于1的整数。 @时间 :2020/08/26 17:46:30 @作者 :江伟 @版本 :1.0 ''' number = int(input("请输入一个正整数:")) if(number <= 0): print("请输入一个正整数!") elif (number ==1): print("%d不是素数"%number) temp = number while True: ...
83d5e369681906cc8e748ef27b96764390f7f95a
jiangw0419/python_way
/python_day_07/p05.py
1,776
4.15625
4
#!/usr/bin/env python # -*- encoding: utf-8 -*- ''' @文件 :p05.py @时间 :2020/09/04 16:30:24 @作者 :江伟 @版本 :1.0 @说明 :使用列表 字符串类型(str)和之前我们讲到的数值类型(int和float)有一些区别 数值类型是标量类型,也就是说这种类型的对象没有可以访问的内部结构; 而字符串类型是一种结构化的、非标量类型,所以才会有一系列的属性和方法。 接下来我们要介绍的列表(list),也是一种结构化的、非标量类型, 它是值的有序序列,每个值都可以通过索引进行标识,定义列表可以将列表的元素放在[]中, 多...
88f48ef90cda2c848c55399231d0f79e4019e11b
jiangw0419/python_way
/python_day_07/p07.py
1,799
3.859375
4
#!/usr/bin/env python # -*- encoding: utf-8 -*- ''' @文件 :p07.py @时间 :2020/09/04 17:11:26 @作者 :江伟 @版本 :1.0 @说明 : 和字符串一样,列表也可以做切片操作,通过切片操作我们可以实现对列表的复制或者将列表中的一部分取出来创建出新的列表, 代码如下所示。 ''' fruits = ['grape','apple','strawberry','waxberry'] fruits += ['pitaya','pear','mango'] # 列表切片 fruits2 = fruits[1:4] prin...
4bcb6e578ad6fcff8cce8594a82d90ece0eadbd1
jiangw0419/python_way
/python_day_09/d02.py
1,988
3.828125
4
#!/usr/bin/env python # -*- encoding: utf-8 -*- ''' @文件 :d02.py @时间 :2020/09/09 09:48:01 @作者 :江伟 @版本 :1.0 @说明 :__slots__魔法 ''' """ 我们讲到这里,不知道大家是否已经意识到,Python是一门动态语言。通常,动态语言允许我们在程序运行时给对象绑定新的属性或方法, 当然也可以对已经绑定的属性和方法进行解绑定。但是如果我们需要限定自定义类型的对象只能绑定某些属性, 可以通过在类中定义__slots__变量来进行限定。需要注意的是__slots__的限定只对当前类的对象生效, 对子类...
cd7ef5f9197ea38d251957335aa9b91f95f0c98d
Dadinel/pt.stackoverflow.com
/python/444999/class_gettter_setter.py
611
3.515625
4
class Nome: def __init__(self,nome,sobrenome): self.__nome = nome # variável privada self.__sobrenome = sobrenome # variável privada self.nome_completo = nome + ' ' + sobrenome # variável pública def get_nome(self): return self.__nome def get_sobrenome(self): return...
be8c9a5c22bb96c6a5edbf86795ce53825a3831e
vkgnandhu177/Day-7-Temperature-Predictions---HackerRank-
/Temperature Predictions Result.py
4,344
3.65625
4
Python 3.6.2rc1 (heads/3.6:268e1fb, Jun 17 2017, 18:21:01) [MSC v.1900 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> ==================== RESTART: C:/Users/user/Desktop/Hi.py ==================== ['Day 7: Temperature', '', '', '', ''] ['Predictions', '', '', '', '']...
8364e11f8f26bd2a42bf868050689404714d2f25
hu-666-yue/gy-1908A
/demo/day01/if-demo.py
421
3.953125
4
''' if((条件): 代码块 else: 代码块 ''' # a = 1 #1代表有钱,0 代表没钱 if(a == 0): print ('我有钱') else: print ('回家睡觉') ''' '''#80分优秀 60-80良好 60分及格 60分以下不及格 小明考了70分 s = 70 if (s >= 80): print('小明成绩优秀') if (s >= 60 and s< 80): print ('小明成绩为良好') if (s < 60): print ('小明成绩不及格')
4c330e8e43c0497eec1011479984ccd108df2af0
amoy007/groceries-exercise
/groceries.py
5,256
3.84375
4
# groceries.py from pprint import pprint def to_usd(my_price): return "${0:,.2f}".format(my_price) #curly braces tell you it's a dictionary. each one is a dictionary. Read about dictionaries here: https://github.com/prof-rossetti/nyu-info-2335-201905/blob/master/notes/python/datatypes/dictionaries.md products =...
ca23aa1140f0fde5ec93159239c44098b769b0fc
dawsboss/Math471
/ch3/NewtonsMethod.py
2,903
4.03125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Nov 9 08:46:09 2020 Do 3 iterations of Newton's method for f(x) = 3 - e^x, using x0 = 1. Repeat, using x0 = 2, 4, 8, 16. Comment on your results """ import math import numpy as np import matplotlib.pyplot as plt def derivatice_approx( f, x, h ): ...
b8c6b27559341b99bcd99497985b327636e7dd44
dawsboss/Math471
/ch1/Machine_Epsilon.py
927
3.671875
4
# -*- coding: utf-8 -*- """ Grant Dawson Problem 1.3.10 "Using the computer and language of you choice. write a program to estimate the machine epsilon." """ import math import sys #Loop over successively smaller 2-adic numbers: for i in range(70): # 2-adiv fractions for approximating epsilon s...
059bb29e902859cd1f09b14c7b2a5c40d2c2b59b
devscheffer/Book-Algoritmos-Programacao-Afonso-Inacio-Orth
/Algoritmos e Programacao (Afonso Inacio Orth)/P25/11.py
118
3.546875
4
# a = 3 b = 4 c = 5 s = (a + b + c)/2 area = (s*(s-a)*(s-b)*(s-c))**0.5 print("Area do triangulo: {}".format(area))
97e35e803243947a9cff8d4d2acfce7aeebb2459
devscheffer/Book-Algoritmos-Programacao-Afonso-Inacio-Orth
/Algoritmos e Programacao (Afonso Inacio Orth)/P51/47.py
1,026
3.75
4
# from random import randint def create_date(nt, lista1): c = 0 while c < nt: c += 1 year1 = randint(1990, 2020) year2 = randint(1990, 2020) if year2 < year1: year1, year2 = year2, year1 dyear = year2 - year1 month1 = randint(1, 12) month2 = randint(1, 12) if month2 < month1...
f199ef1a9314bba705e7e051c13a4455fe926dd9
devscheffer/Book-Algoritmos-Programacao-Afonso-Inacio-Orth
/Algoritmos e Programacao (Afonso Inacio Orth)/P25/20.py
142
3.609375
4
# h_start = int(input("Hora de inicio: ")) h_end = int(input("Hora de termino: ")) h = h_end - h_start print("Duracao {} min".format(h*60))
742bbf4fd1cc4130ba976e6189eb96ef95f09093
devscheffer/Book-Algoritmos-Programacao-Afonso-Inacio-Orth
/Algoritmos e Programacao (Afonso Inacio Orth)/P51/1.py
142
3.65625
4
# c = 0 cw = 0 while cw < 5: cw += 1 a = int(input("Valor: ")) if a < 0: c += 1 print("Qtd de numeros negativos: {}".format(c))
23c76a4cabca365588f515e14b4deeacc82ff053
devscheffer/Book-Algoritmos-Programacao-Afonso-Inacio-Orth
/Algoritmos e Programacao (Afonso Inacio Orth)/P51/3.py
244
3.6875
4
# lista_in = [] lista_out = [] c = 0 while c < 10: c += 1 value = float(input("Valor {}: ".format(c))) if (value >= 10) and (value <= 20): lista_in.append(value) else: lista_out.append(value) print(lista_in) print(lista_out)
ad5407838dd97015820e6a3304d3ec5ee64e926e
devscheffer/Book-Algoritmos-Programacao-Afonso-Inacio-Orth
/Algoritmos e Programacao (Afonso Inacio Orth)/P39/3.py
82
3.671875
4
# a = 3 b = 2 if a%b == 0: print("E multiplo") else: print("Nao e multiplo")
a85178a3f1cca94f0cc17fb4c63f5bcaf6a33aef
devscheffer/Book-Algoritmos-Programacao-Afonso-Inacio-Orth
/Algoritmos e Programacao (Afonso Inacio Orth)/P51/22.py
918
3.546875
4
# from random import randint def create_lista_input(t, lista_input): c = 0 while c < t: salario = randint(500,2000) total_vendas = randint(2000,15000) c += 1 lista_input.append([salario,total_vendas]) lista_input = [] create_lista_input(5,lista_input) print(lista_input) def vendedor(lista_in...
4de0cf8c151850d1cbff5da3b60e2d68fa2ff567
Marvive/Smart_Calculator
/Problems/Matching brackets/task.py
390
3.5
4
# put your python code here from _collections import deque deq = deque() check = input() out_message = "" for i in check: try: if i == "(": deq.append(i) elif i == ")": deq.pop() except IndexError: out_message = "ERROR" break if len(deq) > 0: out_mess...
64b682a55d445a9be29f56c1f97ae77c8b489875
Marvive/Smart_Calculator
/Problems/We Are What We Eat/task.py
537
3.8125
4
meals = [ {"title": "Oatmeal pancakes with apple and cinnamon", "kcal": 370}, {"title": "Italian salad with fusilli and ham", "kcal": 320}, {"title": "Bulgur with vegetables", "kcal": 350}, {"title": "Curd souffle with lingonberries and ginger", "kcal": 225}, {"title": "Oatmeal w...
22c73d788ec58b754e3f048ae0420e143a762ddd
Marvive/Smart_Calculator
/Problems/Oral exam/task.py
289
3.546875
4
from _collections import deque n = int(input()) deq = deque() for _i in range(n): operation = input().split() if operation[0] == "READY": deq.append(operation[1]) elif operation[0] == "PASSED": print(deq.popleft()) else: deq.append(deq.popleft())
6e910d4f514096fbad0eaa269096cf9d250ff92b
AndreDMarins/Python
/Aula8passagemArg.py
323
3.546875
4
import sys argumentos = sys.argv #arg1 metod //arg2 -n1 // arg3 - n2 def soma(n1,n2): return n1 +n2 def sub(n1,n2): return n1-n2 if argumentos[1]=="soma": resp = soma(float(argumentos[2]),float(argumentos[3])) elif argumentos[1]=="sub": resp = sub(float(argumentos[2]),float(argumentos[3])) print(res...
63312992cff8bf64650c7f9c62195d349cb0b105
AdityaSaigal2000/Emotion-Recognition
/baseline.py
1,686
3.515625
4
#####THE FACE RECOGNITION################################### #source: http://gregblogs.com/computer-vision-cropping-faces-from-images-using-opencv2/ # Importing the libraries import numpy as np import cv2 import cv2 def facechop(image): facedata = "haarcascade_frontalface_default.xml" cascade = cv2.Cascade...
4e8e3be7b1d1ff5f35ca5c2f2806a60acfaaa254
pi2017/lessons
/home_task5/home5_dz01.py
631
3.953125
4
# Задача 1 # Написать функцию, которая генерирует список списков (двухмерный массив) размерности NxN # заполненный случайными числами от 100 (A) до 999 (B) import random def generate_list_of_lists(size, min_value, max_value): array = [[[] for j in range(size)] for i in range(size)] for i in range(0, size): ...
ce1698e509efb7568875e2f8f6ed0197ba91003f
pi2017/lessons
/lesson2/lesson2_dz05.py
955
3.96875
4
f_name = input('Введите фамилия студента ') name = input('Введите имя студента ') o_name = input('Введите отчество студента ') group_st = input('Введите номер группы студента ') konst = 1 separator = "*" data_group_1 = len(separator + f_name + name + o_name + separator) data_group_2 = len(separator + 'Выполнил студен...
a1f4c3ce759d3d6fe900cbf1e88431892b1c56d0
pi2017/lessons
/lesson3/lesson3_dz04.py
627
4.03125
4
# Решение домашней задачи 4 # Вывести на экран 10 первых простых чисел используя функцию задания 3 # Вывести на экран, из диапазона, простые числа используя функцию задания 3 def is_prime(lower, upper): for i in range(lower, upper + 1): if i > 1: for j in range(2, int(i / 2)): ...
9c2cf1d5c1b8e850c4530ed325168ca76c2c35a4
pi2017/lessons
/lesson4/ex_05.py
451
3.796875
4
# coding=utf-8 # Example code # задачи для закрепления теории ''' x<0 0<x<100 x>100 ''' numbers = [12, 12515, -12412] def f(numbers): for i in range (len(numbers)): if numbers[i] < 0: numbers[i] = 'меньше нуля' elif 0 < numbers[i] < 100: numbers[i] = 'меньше 100' e...
26ffecdb345b6403d9ab56bf781be194ec5779fe
pi2017/lessons
/lesson1/lesson1_dz04.py
390
3.703125
4
# Zadacha 04 name = input('введите имя до 13 символов ') separator = '-' konst = 15 full_name = separator + name + separator # склеивание строк len_name = len(full_name) # длинна строки line_1 = '-' * konst # повторение строки print(line_1) print("{0:<1}{1:^13}{2:>1}".format(separator, name, separator)) print(l...
bf27e3e9ad9332d000e928b752dec1111dfb60a3
pi2017/lessons
/lesson4/lesson4_dz02.py
305
4.0625
4
# Задача 2 # Заменить каждый элемент на следующий, последний на первый # [1, 2, 3, 4] -> [2, 3, 4, 2] numbers = [1, 2, 3, 4] for i in range(len(numbers) - 1): numbers[i] = numbers[i + 1] numbers[len(numbers) - 1] = numbers[0] print(numbers)
1dc08c2a2f3f82057921996521c81e3ea6215212
pi2017/lessons
/home_task10/home10_dz03.py
676
4.03125
4
""" задача 3 Определите размер файла имя которого вводит пользователь. Выведите его на экран. Выведите его в байтах, мегабайтах, гигабайтах. """ import os cwd = os.getcwd() print(cwd) file_path = input("Введите путь к файлу: ") if os.path.exists(file_path): if os.path.exists(file_path): size = os.path.ge...
cbee32a0f8e9df49db2b787cb459f0c9c93f65d6
semosso/lpthw
/4ex.py
1,367
4.03125
4
# Single equal (=) attributes name "cars" to data "100" # In Zed's words: "assigns the value on the right to the variable on the left" # Double equal (==) tests if two things are equal cars = 100 # Attributes the name "space_in_a_car" to the data "4" # You can do space_in_a_car=4 with no space between variable, equal, ...
9c0d5a949e2e86448cddae4f4a19562079cd58e8
semosso/lpthw
/6brk.py
685
3.9375
4
# BREAKING CODE types_of_people = 10 x = f'There are {types_of_people} types of people.' # BRK: no FORMAT would print literal {}, not call the variable binary = 'binary' do_not = 'don\'t' # BRK: not having \ would end string prematurely y = f'Those who know {binary} and those who {do_not}.' print(x) # BRK: having qu...
ee070edcf28a82c4b62dd5a845f3eb49f20b94e3
semosso/lpthw
/21ex.py
2,265
4.0625
4
# using = and RETURN to set variable to be a VALUE FROM A FUNCTION def add(a, b): print(f'ADDING {a} + {b}') # this (and other below) doesn't actually do the math because numbers are within a string return a + b # RETURN "sums up" the "result" of the function being applied to its parameters, in a format tha...
502db7faefa1bcb4933be1e5f7692228274c95d9
semosso/lpthw
/3drill.py
522
3.984375
4
# Find something you need to calculate and write a new .py file that does it # Golden rule calculator M_age = 31 W_age = 25 # one alternative print("Am I compliant with the golden rule?") print(M_age / 2 + 7 < W_age) # another alternative print("Am I compliant with the golden rule?", M_age / 2 + 7 < W_age) # ?? # s...
43ab2ab643eb2218af0e74d384b3facdd1a10019
semosso/lpthw
/old/old-hello.py
361
3.859375
4
# Simple print statement print("hello world") # Now testing multistrings in triple quotes print(""""hello world", is what I'd say if I knew how to program. Can I make multi string work?""") # What about multistrings with normal quotes and \n (escape sequence) print("\"hello world\", is what I'd say if I knew how to p...
047bf95fcd7c8a57f1075a2161d2864e94d990f6
semosso/lpthw
/11ex.py
1,180
4.03125
4
# Input prompts user to input some data and stores it as whatever variable you assign it to print('How old are you?', end = ' ') age = input() print('How tall are you?', end = ' ') height = input() print('How much do you weigh?', end = ' ') weight = input() print(f'So you\'re {age} old, {height} tall and {weight} heav...
2b00732e6de81373861c14edbab224b385bf0f96
Lee-suncheol/python-study
/level2/ex2.py
400
3.78125
4
# 클래스 class User: username = "leesunchul81" password = "1234" u = User() print(u.username) print("="*50) class Person: def __init__(self,username,password): self.username = username self.password = password def __str__(self): return f"username:{self.username},password:{self....
37b09f0f9cfba358749be336437ea6a074284fe8
michaelos5/ProjectEuler
/Solutions/Problem_1.py
432
4.21875
4
''' Name: Multiples of 3 and 5 Description: If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. Answer: 233168 ''' def sumMultiplesThreeAndFive(num_below): return sum(i...
dd2f3016037b36ea11844a1f00dea3a5185cb702
daveharmon/random
/numpy_simple_neuralnet/simple_nn.py
2,223
4.09375
4
import numpy as np # sigmoid function to run on every input to our neural net def nonlin(x, deriv=False): if deriv == True: return x * (1 - x) return 1 / (1 + np.exp(-x)) # input data X = np.array([[0,0,1], [0,1,1], [1,0,1], [1,1,1]]) # output data Y = np.array([[0], [1], [1], [1]...
4eaf39f671c1feea2dc058711ccb0164ae970b07
kodfactory/SangitaDas-WB
/LambdaFunction.py
636
3.9375
4
# sum of 2 variables # Lambda function: it's an 1 liner function # def sum(a,b): # return a+b # sum = lambda a,b : a+b # print(sum(10,20)) # x = lambda num : num**2 # print(x(9)) # filter # listA = [80, 85, 79, 93, 77, 67, 69, 99] # listB = list(filter(lambda a: a>=80, listA)) # print(listB) # listNumber ...
04b8eee2a0fa2dc90b1d9544c45f606ec420c42a
kodfactory/SangitaDas-WB
/VariablesNaming.py
609
4.15625
4
# Rules to declare variables # 1: Variable name should not start with uppercase # 2: Variable name must not start with digit or contains special character (including space) #2name = 'Sangita' #name2 = 'Sangita' #Name = 'Sangita' #firstname #first name = 'Sangita' #print(name2) # Camlecase naming convention : # Fir...
b68fcc1b93e1cca4d34acf5b74954a8dce2a3667
kodfactory/SangitaDas-WB
/WhileLoopExample.py
190
3.828125
4
# while <CONDITION>: # print(i) # for i in range(10): # print(i) i = 2 while i <= 10: print(i) i += 10 # i = i + 1 # i = 0 # while i < 10: # print(i) # i += 1
e705bcd93fd77526e637e484c640b88011983c2e
shaunlai1983/driving
/driving.py
694
3.640625
4
contries = input ('請問你的國家: ') age = input('請問你的年齡') age = int(age) if contries == '台灣': # if age >= 18: print('你可以開車喔') else: print('你還不可以開車喔') elif contries == '美國': #I條件沒符合上面的If 需求就檢查是否符合這一行 if age >= 16: print('你可以開車喔') else: print('你還不可以開車喔') else : #if and elif ...
0b55210ec1207fdf9e497a186b56b6681ce8ce28
dhamilton47/advent_of_code_2019
/src/cpu.py
3,653
3.515625
4
# -*- coding: utf-8 -*- """ Created on Mon Dec 30 00:05:21 2019 @author: Dan J Hamilton """ import sys # %% CPU Class class CPU: """ The CPU is where the Instructions are executed. class CPU Properties instruction name print_flag Methods ...
f0c341c0efbf4be9ceaa44b5aeba63ce2d7182e0
hong-hanh-dang/tkt4140
/src/src-ch3/TRIdiagonalSolvers.py
3,314
3.65625
4
# src-ch3/TRIdiagonalSolvers.py import numpy as np def tdma(a, b, c, d): """Solution of a linear system of algebraic equations with a tri-diagonal matrix of coefficients using the Thomas-algorithm. Args: a(array): an array containing lower diagonal (a[0] is not used) b(array): an arr...
e647aa601c2bf5c934df501f4242b49fee7315f4
hong-hanh-dang/tkt4140
/src/src-ch5/laplace.py
6,733
3.5625
4
import numpy #from numpy import arange import matplotlib.pyplot as plt import matplotlib.mlab as ml from scipy import weave import scipy as sc import scipy.linalg import scipy.sparse import scipy.sparse.linalg class Grid: """A simple grid class that stores the details and solution of the computational gr...
11479fbbc3d5fdbf71bdedbeaed5e5a4e8b0179e
zloether/Python-Playground
/working_with_lists.py
1,152
4.15625
4
#!/usr/bin/env python # lists.py # https://docs.python.org/2/tutorial/datastructures.html # Files to work with file1 = 'list1.txt' file2 = 'list2.txt' outfile = 'output.txt' # take "file1" and "file2" and read them in as seperate lists # the rstrip() method is used to remove newline characters from the end ...
2eefc388ffa49405c138a1547330079bbde87a19
mattdbrown17/BootCamp2018
/ProbSets/Comp/ProbSet3/QR_Decomposition.py
2,858
3.59375
4
#QR_Decomposition import numpy as np from scipy import linalg A = np.random.randn(3, 8) def QR(A): ''' Function accepts arrays of floating-point objects and outputs the QR decomposition, using the modified gram-schmidt algorithm. ''' #Store dimensions of A dimA = (A.shape) # Create copy o...
b30f1635a1e82fce8535fa4304293ea014dcb9b2
amitmtm30/PythonCode
/Function/Example1.py
484
3.984375
4
########################## Function ############################ # Function is nothing but a group of code that required executed muliple time... ## Example 1 def wish(name): print("Hello", name,"Good Evening") wish("Amit") print("*" * 30) #### Example 2 def sum(a,b): sum = a + b print("The Sum of two number i...
6ff1a102fde3576cdabbf08b7e6a17d2f601e49d
eikegermann/indeed-scrape
/src/scrape/scrape.py
5,234
3.625
4
import requests_cache import requests import re import pandas as pd import numpy as np from bs4 import BeautifulSoup from typing import Tuple def query_website(base_url: str, no_cache: bool) -> object: """ Query a website for scrape results Args: base_url: str website url ...
ef8f183616302fb51f243be20ddbffc257f0eae9
kganczuk/Stratego
/Player.py
2,321
3.65625
4
from copy import deepcopy class HumanPlayer: def __init__(self, id, color, name): self.id = id self.name = name self.color = color self.points = 0 def get_id(self): return self.id def get_name(self): return self.name def get_points(self): retu...
42062fc23b6538c4f0e9255b604dcaa477575836
rs105/JetBrains-Projects
/Hangman.py
1,482
3.640625
4
# -*- coding: utf-8 -*- """ Created on Thu Jun 11 00:20:15 2020 @author: Romit """ import random chosen = list(random.choice(['java','javascript','python','kotlin','matlab'])) hidden = list('-' * len(chosen)) already_typed = [] print('H A N G M A N') while input('Type "play" to play the game, "exit"...
dff30947837291ccccc276f044cac3a1bac94b2f
sahana-github/Scripting_Lang
/sl lab/part a sl/part a sl/prog1.py
630
4.03125
4
a=[] size=int(input("Enter size of list")) for i in range(0,size): ele=int(input("enter elements of list")) a.append(ele) print("The list contains",a) mini=min(a) maxi=max(a) print("Minimum and maximum elements are :", mini, maxi) ele=int(input("Enter new element to be inserted")) pos=int(input("Enter position of th...
2a16605a3c696cbb1ffac384f3281288c6151726
iTrixPro/N-Queens
/soluce/queen.py
1,488
4.34375
4
########################################## # author: MEZROUI Marwan, BULTEZ Victor # modified: 11/01/2020 ########################################## class Queen: """A class to represent a queen. Attributes: positionX (int) : its horizontal position on the board positionY (int) : it...
af88d6b14a8c8db4bc19b0cf106473094f533ee9
gtkacz/Edabit-Challenges
/Very Hard/Identity Matrix.py
898
4
4
# An identity matrix is defined as a square matrix with 1s running from the top left of the square to the bottom right. The rest are 0s. The identity matrix has applications ranging from machine learning to the general theory of relativity. # Create a function that takes an integer n and returns the identity matrix of...
51be5670382a9eba54486f2a772e5c08aab9daf0
erikbatista42/Tweet-Generator
/dictonary_words.py
877
3.984375
4
import sys import random def get_num_of_rand_words_from(given_list, num_of_words_wanted): '''take console argument num and get num of random words''' randWords = random.sample(given_list, num_of_words_wanted) #return a "sentence" return " ".join(randWords) + "." if __name__ == "__main__": fish_...
be2c865b2520446210bf75374665b87ec92ed244
christopherdavideh/curso-profesional-python
/sets_diferencia.py
251
3.65625
4
my_set1 = {3, 4, 5} my_set2 = {5, 6, 7} #my_set3 = my_set1.difference(my_set2) my_set3 = my_set1 - my_set2 print(f'Set resultante 3: {my_set3}') #my_set4 = my_set2.difference(my_set1) my_set4 = my_set2 - my_set1 print(f'Set resultante 4: {my_set4}')
a62f01da13db99f61faf80227227227be28681f0
naomimcmurchie/MY-FIRST-PROJECT
/Archive/consult_BMI.py
1,749
4.5
4
# this is my second program # This program will get input on the users. # This program will also convert their height # get the user name name = raw_input('please input your name ') full_name = str(name) print ('Hello ' + full_name) # get the user height height = raw_input('please input your height in cm: ') height =...
414558ac75aa3533d809b234c92bda32d971a9c5
amol-a-kale/exersicepython
/medium/palindrome.py
375
4.375
4
# 7. Write a code that helps to find whether the string is palindrome or not def check_palidrome(): string =input('enter the string for check palindrome: ') string1 = string[:: -1] print(string1) if string == string1: print("the {} is palindrome".format(string)) else: print("the {} ...
28b5fe2a9ddc6d60de8a4848845270149b5a548f
amol-a-kale/exersicepython
/basic_coding/reverse_1_to_n.py
515
4.0625
4
# Design a code that helps to display number 1 to N in reverse order # n=20 # no=[ # no_reverse_list=[] # for i in range(1, 21): # # print(i) # no.append(i) # no.reverse() # # print(no) # for i in no: # print(i) def find_reverese_no(N): for i in range(1, N + 1): # print(i) print(N + 1 ...
5511ba70827d0235666b967902cc14cb0d41777f
Kazzle619/Project_Euler
/project_euler_50.py
1,617
3.734375
4
# -*- coding: utf-8 -*- ''' Problem50 「Consecutive prime sum」 The prime 41, can be written as the sum of six consecutive primes: 41 = 2 + 3 + 5 + 7 + 11 + 13 This is the longest sum of consecutive primes that adds to a prime below one-hundred. The longest sum of consecutive primes below one-thousand that adds to a ...
dd6dee86c1948d38eebd3dfe83a4b0cc792f5f8b
Kazzle619/Project_Euler
/project_euler_38.py
2,134
3.75
4
# -*- coding: utf-8 -*- ''' Problem38 「Pandigital multiples」 Take the number 192 and multiply it by each of 1, 2, and 3: 192 × 1 = 192 192 × 2 = 384 192 × 3 = 576 By concatenating each product we get the 1 to 9 pandigital, 192384576. We will call 192384576 the concatenated product of 192 and (1,2,3) The same can be...
ba03c4dc032a91551368e22fbea7df51beac4155
Kazzle619/Project_Euler
/project_euler_51.py
4,483
4.25
4
# -*- coding: utf-8 -*- ''' Problem51 「Prime digit replacements」 By replacing the 1st digit of the 2-digit number *3, it turns out that six of the nine possible values: 13, 23, 43, 53, 73, and 83, are all prime. By replacing the 3rd and 4th digits of 56**3 with the same digit, this 5-digit number is the first exampl...
d1b42220c7073e90a91ee0671144d921a907ac39
Kazzle619/Project_Euler
/project_euler_39.py
2,082
3.53125
4
# -*- coding: utf-8 -*- ''' Problem39 「Integer right triangles」 If p is the perimeter of a right angle triangle with integral length sides, {a,b,c}, there are exactly three solutions for p = 120. {20,48,52}, {24,45,51}, {30,40,50} For which value of p ≤ 1000, is the number of solutions maximised? (直角三角形の周の長さpを1000以...
218641d93ba74caaa5c1d6d3fdded2aae3053bf4
Kazzle619/Project_Euler
/project_euler_60.py
3,345
4.125
4
# -*- coding: utf-8 -*- ''' Problem60 「Prime pair sets」 The primes 3, 7, 109, and 673, are quite remarkable. By taking any two primes and concatenating them in any order the result will always be prime. For example, taking 7 and 109, both 7109 and 1097 are prime. The sum of these four primes, 792, represents the lowe...
37df10aa6c0549bb4063b18c8fd4c18380e42fdd
Kazzle619/Project_Euler
/project_euler_63.py
999
3.8125
4
# -*- coding: utf-8 -*- ''' Problem63 「Powerful digit counts」 The 5-digit number, 16807=7^5, is also a fifth power. Similarly, the 9-digit number, 134217728=8^9, is a ninth power. How many n-digit positive integers exist which are also an nth power? (n乗数になっているn桁の数字はいくつあるか。) ''' # 10^(b-1) ≦ a^b < 10^bを満たせばよく、この不等式か...
03cb933773e7407dde94eeaec0304df21d03e6ab
Aydndmrcn/Data_Structures_inKTU
/ds_inPython_Book/ch01/02_objects_inPython.py
1,708
4.21875
4
# same memory address temp = 95 t2 = temp print(id(temp)) print(id(t2)) temp = 95.0 t2 = temp t2 = 100 # a new dynamic variable print(temp) print(t2) print(id(temp)) print(id(t2)) b1 = bool() # an empty bool variable (value is False) print(b1) n1 = int() # an empty int variable (value is 0) n1 = int(20) # an empt...
4c1ab98e5a945119e2cb0946ac21756b259285b8
Aydndmrcn/Data_Structures_inKTU
/course_codes/7-02-recursive.py
846
3.734375
4
# -*- coding: utf-8 -*- """ Created on Sat Nov 14 14:19:39 2020 @author: zafer 1) a^n 2) 1-n arası toplam sayılar 3) fibonacci 4) fact, 5) dec2bin """ # a^n = a * a^(n-1) def mypow(a,n): if(n==0): return 1 else: return a * mypow(a,n-1) print(mypow(5,4)) # S(1...n) = 1 + S(1...(n-1)) def my...
44410909a0cc356eb3c8dd0135df6979d8480d33
Aydndmrcn/Data_Structures_inKTU
/ds_inPython_Book/ch01/06_scale.py
235
4.03125
4
# -*- coding: utf-8 -*- """ Created on Sun Oct 4 14:12:48 2020 @author: zafer """ def scale(data, factor): for j in range(len(data)): data[j] *= factor mylist = [2,3,5,2,3,6,8] print(mylist) scale(mylist,2) print(mylist)
606c8742c39f914e589052d79096a765d5336be5
riabov-vladimir/homework_context_manager
/example_a.py
2,634
3.609375
4
def get_ingredient_dict(ing_line): """Функция, которая принимает строку с ингридиентами из файла и возвращает словарь""" ing_line = ing_line.split(' | ') dict = {'ingredient_name': ing_line[0], 'quantity': int(ing_line[1]), 'measure': ing_line[2].strip()} return dict def txt_to_dict(file_name): '''Основная функц...
e743683f28e68e567616a9759a5192f7e950cc65
egaban/Uri
/strings/1239.py
549
3.71875
4
def processar_string(s): i = 0 italico = False negrito = False while i < len(s): if s[i] == '_': if italico: print('</i>', end='') italico = False else: print('<i>', end='') italico = True elif s[i] == '*': if negrito: print('</b>', end='') ...
199867fc1f5cf5ca8d0159cd11e4026764b8d3a2
bergscott/ff-scripts
/divisions.py
4,477
3.71875
4
class League(object): def __init__(self, name): self.name = str(name) self.teams = {} self.divisions = {} def get_name(self): return self.name def add_team(self, team): self.teams[str(team)] = team def remove_team(self, team_name): t...
0a95c29f6212f430e7632e49fc629b65aad78e23
kotalbert/learnpython
/coursera/a_5_2_finding_numbers.py
678
3.859375
4
""" Programming for Everybody (Python) Assignment 5.2 Input a series of numbers until "done" string is encountered. Print maximum and minimum of entered numbers. """ largest = None smallest = None while True: txt = raw_input("Enter a number: ") if txt == "done" : break try: num = int(txt)...
52151617e11084a11f53096508f1ae64a16127da
kotalbert/learnpython
/codecademy/bitwise.py
651
3.765625
4
print int("1",2) print int("10",2) print int("111",2) print int("0b100",2) print int(bin(5),2) print int("0b11001001", 2) shift_right = 0b1100 shift_left = 0b1 # Your code here! shift_right = shift_right >> 2 shift_left = shift_left << 2 print bin(shift_right) print bin(shift_left) def check_bit4(input): m...