blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
5e204a443e3b9f351b676d9f41a2358f2590ac21
ThanitsornMsr/Programming-for-Everybody
/Chapter/Chapter_6.py
2,132
3.796875
4
str1 = 'Hello' str2 = "there" bob = str1 + str2 print(bob) str3 = '123' x = int(str3) + 1 print(x) name = input('Enter: ') print(name) apple = input('Enter: ') x = int(apple) - 10 print(x) fruit = 'banana' letter = fruit[1] print(letter) x = 3 w = fruit[x - 1] print(w) x = len(fruit) print(x) ...
85175fd2beadd66c25e275671d701c13b2961b0b
ThanitsornMsr/Programming-for-Everybody
/Chapter/Chapter_5.py
1,972
3.84375
4
# Chapter 5 n = 5 while n > 0: print(n) n = n - 1 print('Blastoff!') print(n) while True: line = input('> ') if line == 'done': break print(line) print('Done!') while True: line = input('> ') if line[0] == '#': continue if line == 'done': bre...
abccf9b34b1f331b6714bbf84491691eef4e6b12
ThanitsornMsr/Programming-for-Everybody
/Exercise/Exercise_7.py
989
3.8125
4
fname = input('Enter a file name: ') ofname = open(r"C:/Users/User/PycharmProjects/Python_for_EveryOne/"+fname) for line in ofname: line = line.rstrip().upper() print(line) fname = input('Enter a file name: ') ofname = open(r"C:/Users/User/PycharmProjects/Python_for_EveryOne/"+fname) count = 0 sum = 0...
113535781dd630c4dd4ed35d73e7506969d8c6f1
hiepbkhn/itce2011
/StandardLib/parallel/sum_primes_no_parallel.py
1,213
3.859375
4
''' Created on Dec 27, 2012 @author: Nguyen Huu Hiep ''' #!/usr/bin/python # File: sum_primes.py # Author: VItalii Vanovschi # Desc: This program demonstrates parallel computations with pp module # It calculates the sum of prime numbers below a given integer in parallel # Parallel Python Software: http://www.parallelp...
2c20b1594b4e36e383abd525c33c382b4ad83fce
hShivaram/pythonPractise
/ProblemStatements/CountTheChocolates.py
692
3.734375
4
# Description : Sanjay loves chocolates. He goes to a shop to buy his favourite chocolate. There he notices there is an # offer going on, upon bringing 3 wrappers of the same chocolate, you will get new chocolate for free. If Sanjay has # m Rupees. How many chocolates will he be able to eat if each chocolate costs c Ru...
0824e7d93385a87358503bc289e984dfeae38f8c
hShivaram/pythonPractise
/ProblemStatements/EvenorOdd.py
208
4.4375
4
# Description # Given an integer, print whether it is Even or Odd. # Take input on your own num = input() # start writing your code from here if int(num) % 2 == 0: print("Even") else: print("Odd")
7f77696fcdae9a7cef174f92cb12830cde16b3cb
hShivaram/pythonPractise
/ProblemStatements/AboveAverage.py
1,090
4.34375
4
# Description: Finding the average of the data and comparing it with other values is often encountered while analysing # the data. Here you will do the same thing. The data will be provided to you in a list. You will also be given a # number check. You will return whether the number check is above average or no. # # -...
8134e9b86592e07cf1cd0da048c825ca28038332
hShivaram/pythonPractise
/Practice/practice5.py
207
3.71875
4
n=int(input()) sum=0 digits = [int(x) for x in str(n)] #print(digits) for i in range(len(digits)): sum+=(digits[i]**3) #print(i,sum) #print(sum) if(sum==n): print("True") else: print("False")
ea9f715320a8b82965a8f9a5057eaf6dd2a00470
pmartincalvo/tick-tack-refactor
/solutions/requirements_group_1_solution/rendering.py
1,116
3.84375
4
""" Functions for presenting the state of the game visually. """ from typing import List from solutions.requirements_group_1_solution.board import Board, Cell def render_board(board: Board) -> str: """ Build a visual representation of the state of the board, with the contents of the cells being their m...
91c3151db15aff8be38a477f70dab75f6db92e0b
1180301001SHEN/HIT_evolutionary_computation
/Utils/Distance.py
2,553
4
4
''' @ auther Sr+''' import math class Distance(): '''Some methods to compute the distance''' def compute_EUC_2D(node1, node2): '''EUC_2D distance''' node1_x, node1_y = node1.get_coordinate() node2_x, node2_y = node2.get_coordinate() distance_x = abs(node1_x-node2_x) di...
88b0bb352312bcc91504585873afb726428d2e8c
valours/sandbox-python
/main.py
743
3.734375
4
# coding: utf-8 from random import randint first_names = ["Valentin", "Melanie", "Mathilde"] last_names = ["Bark", "Four", "Quick"] def get_random_name(names): random_index = randint(0, 2) return names[random_index] print(get_random_name(first_names)) freelancer = { "first_name": get_random_name(firs...
5b54d69790c6d524c1b253b8bec1c32ad83c4bf8
LoktevM/Skillbox-Python-Homework
/lesson_011/01_shapes.py
1,505
4.25
4
# -*- coding: utf-8 -*- # На основе вашего кода из решения lesson_004/01_shapes.py сделать функцию-фабрику, # которая возвращает функции рисования треугольника, четырехугольника, пятиугольника и т.д. # # Функция рисования должна принимать параметры # - точка начала рисования # - угол наклона # - длина стороны ...
8e0b377e80418e6ff51ddc1a5394544c1423dabf
LoktevM/Skillbox-Python-Homework
/lesson_005/02_district.py
1,413
3.609375
4
# -*- coding: utf-8 -*- # Составить список всех живущих на районе и Вывести на консоль через запятую # Формат вывода: На районе живут ... # подсказка: для вывода элементов списка через запятую можно использовать функцию строки .join() # https://docs.python.org/3/library/stdtypes.html#str.join import district.c...
f5689f9880f64dd2b65bfd4035b34287388f7a3d
LoktevM/Skillbox-Python-Homework
/lesson_004/practice/02_fractal.py
1,162
3.5625
4
# -*- coding: utf-8 -*- import simple_draw as sd sd.resolution = (1000,600) # нарисовать ветку дерева из точки (300, 5) вертикально вверх длиной 100 point_0 = sd.get_point(300, 5) # написать цикл рисования ветвей с постоянным уменьшением длины на 25% и отклонением на 30 градусов angle_0 = 90 length_0...
ada930e3b25e2523238eea7cb49b332b60da7f7d
madanmeena/python_hackerrank
/Built-Ins/python-sort-sort.py
449
3.703125
4
#https://www.hackerrank.com/challenges/python-sort-sort/problem #!/bin/python3 import math import os import random import re import sys if __name__ == '__main__': nm = input().split() n = int(nm[0]) m = int(nm[1]) arr = [] for _ in range(n): arr.append(input()) ...
19798513e26fdf780beab48cb257b9c1fac3b903
madanmeena/python_hackerrank
/set/py-set-add.py
220
3.84375
4
#https://www.hackerrank.com/challenges/py-set-add/problem # Enter your code here. Read input from STDIN. Print output to STDOUT stamps = set() for _ in range(int(input())): stamps.add(input()) print(len(stamps))
dd1602abd3d3c7f238c29f9f74e53ef6372549f6
dianazmihabibi/Case1_Basic
/assessment.py
1,275
3.640625
4
import re from collections import Counter word_list = [] file = 'sample_text.txt' #Read file Words = open(file, 'r').read() #Removing delimiter and replace with space for char in '\xe2\x80\x93-.,\n\"\'!': Words=Words.replace(char,' ') Words = Words.lower() #Split the words word_list = Words.split() #Find how much...
9e9b8426a682a43c61c770039736edf5437b86a3
nandap1/foodCourtOrder
/foodCourt.py
4,061
4.15625
4
''' Displays DeAnza's food court menu and produces a bill with the correct orders for students and staff. ''' #initialize variables food_1 = 0 food_2 = 0 food_3 = 0 food_4 = 0 food_5 = 0 flag = True item = ("") staff = ("") exit_loop = False def display_menu(): print("DEANZA COLLEGE FOOD COURT MENU:") print(...
63a055bb9ee454b6c6ad68defb6b540b6cb74323
Hosen-Rabby/Guess-Game-
/randomgame.py
526
4.125
4
from random import randint # generate a number from 1~10 answer = randint(1, 10) while True: try: # input from user guess = int(input('Guess a number 1~10: ')) # check that input is a number if 0 < guess < 11: # check if input is a right guess if guess == answ...
1b1432b1123ef3781466f454e1b04fca7134dd4f
kvsingh/lyrics-sentiment-analysis
/text_analysis.py
1,277
3.515625
4
import nltk from nltk.corpus import stopwords # Filter out stopwords, such as 'the', 'or', 'and' import pandas as pd import config import matplotlib.pyplot as plt artists = config.artists df1 = pd.DataFrame(columns=('artist', 'words')) df2 = pd.DataFrame(columns=('artist', 'lexicalrichness')) i=0 for artist in artis...
233b8e8cc6295adad5919285230971a293dfde80
abhaydixit/Trial-Rep
/lab3.py
430
4.1875
4
import turtle def drawSnowFlakes(depth, length): if depth == 0: return for i in range(6): turtle.forward(length) drawSnowFlakes(depth - 1, length/3) turtle.back(length) turtle.right(60) def main(): depth = int(input('Enter depth: ')) drawSnowFlakes(depth, 100)...
51558f22e5262038813d7f4ce3e5d2ad2836e6d9
Creativeguru97/Python
/Syntax/ConditionalStatementAndLoop.py
1,372
4.1875
4
#Condition and statement a = 300 b = 400 c = 150 # if b > a: # print("b is greater than a") # elif a == b: # print("a and b are equal") # else: # print("a is greater than b") #If only one of statement to excute, we can put togather # if a == b: print("YEAHHHHHHHHH !!!!!!!!!!!") # print("b is greater than...
d988912a14c4fe3d6bb41458d10898d6cddc991a
fairypeng/a_python_note
/leetcode/977有序数组的平方.py
825
4.1875
4
#coding:utf-8 """ 给定一个按非递减顺序排序的整数数组 A,返回每个数字的平方组成的新数组,要求也按非递减顺序排序。   示例 1: 输入:[-4,-1,0,3,10] 输出:[0,1,9,16,100] 示例 2: 输入:[-7,-3,2,3,11] 输出:[4,9,9,49,121]   提示: 1 <= A.length <= 10000 -10000 <= A[i] <= 10000 A 已按非递减顺序排序。 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/squares-of-a-sorted-array 著作权归领扣网络所有。商业转载...
f3ea4fb3de5655c3732e57eb23b625ec6903d210
fairypeng/a_python_note
/leetcode/908最小差值I.py
1,818
4.0625
4
#coding:utf-8 """ 给定一个整数数组 A,对于每个整数 A[i],我们可以选择任意 x 满足 -K <= x <= K,并将 x 加到 A[i] 中。 在此过程之后,我们得到一些数组 B。 返回 B 的最大值和 B 的最小值之间可能存在的最小差值。   示例 1: 输入:A = [1], K = 0 输出:0 解释:B = [1] 示例 2: 输入:A = [0,10], K = 2 输出:6 解释:B = [2,8] 示例 3: 输入:A = [1,3,6], K = 3 输出:0 解释:B = [3,3,3] 或 B = [4,4,4]   提示: 1 <= A.length <= 10000 ...
67a57fa1510b08374f7e0401a3f86e9963318652
fairypeng/a_python_note
/leetcode/961重复N次的元素.py
863
3.953125
4
#coding:utf-8 """ 在大小为 2N 的数组 A 中有 N+1 个不同的元素,其中有一个元素重复了 N 次。 返回重复了 N 次的那个元素。   示例 1: 输入:[1,2,3,3] 输出:3 示例 2: 输入:[2,1,2,5,3,2] 输出:2 示例 3: 输入:[5,1,5,2,5,3,5,4] 输出:5   提示: 4 <= A.length <= 10000 0 <= A[i] < 10000 A.length 为偶数 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/n-repeated-element-in-size-2n-array...
7b8c35c4f8a982eca181334b692273f15fdcb0f1
fairypeng/a_python_note
/cookbook/1.2解压可迭代对象赋值给多个变量.py
536
3.59375
4
def drop_first_last(grades): first,*middle,last = grades return sum(middle) / len(middle) gra = (100,99,89,70,56) print(drop_first_last(gra)) line = 'nobody:*:-2:-2:Unprivileged User:/var/empty:/usr/bin/false' uname,*fields,homedir,sh = line.split(":") print(uname,fields,homedir,sh) uname,*_,homedir,sh = lin...
c484b80169ea63e5b7df08d01f2433421786ad6e
hhweeks/Mandelbrot
/Mandelbrot.py
2,813
3.875
4
import numpy as np from PIL import Image, ImageDraw """ True/False convergence test """ def test_convergeance(c, maxiter): n = 0 # count iterations z = c while (abs(z) <= 2 and n < maxiter): z = z * z + c n += 1 if (abs(z) > 2): # catch diverging z on n=maxiter return False ...
ec7d0173a8eb106805370b4a596256b1c8ac1342
gurmehakk/CO_Assignment_1
/CO_M21_Assignment-main/Simple-Assembler/assembler.py
13,877
3.890625
4
def spaceerror(): for i in statements.keys(): for j in statements[i][0]: x=len(j) j=j.strip() y=len(j) if(x!=y): print("More than one spaces for separating different elements of an instruction at line "+str(statements[i][1])) ex...
ddaaf31b0c7fe36cbf57e17a20f188c276a9f075
jefte23/Python
/Operadores
668
4.0625
4
print ("Test Equality and Relational Operators") number1 = input("Enter first number:") number1 = int(number1) number2 = input("Enter second number:") number2 = int(number2) if number1 == number2 : print("%d is equal to %d" % (number1, number2)) if number1 != number2 : print("%d is not equal to %d" % (numbe...
17f3d115d3764b69ebb8cdc9ae70c6a255ffc223
EvidenceN/DS-Unit-3-Sprint-1-Software-Engineering
/sprint-challenge - answers/acme_report.py
1,870
3.75
4
import random from random import randint, sample, uniform from acme import Product import math adjectives = ['Awesome', 'Shiny', 'Impressive', 'Portable', 'Improved'] nouns = ['Anvil', 'Catapult', 'Disguise', 'Mousetrap', '???'] def generate_products(num_products=30): ''' generate a given number o...
5d3bb4e438cf010e62b2fe97cf05ce191a65d29c
samuelmutinda/leetcode-practice
/palindrome.py
827
3.875
4
def isPalindrome(x): """ :type x: int :rtype: bool """ def split(word): return [char for char in word] if x < 0: return False digitarray = split(str(x)) xstring = str(x) if len(digitarray)%2 == 0: b = int((len(digitarray)/2) - 1) right = "" le...
dee57a6ebf2ca0350a8449f9cb4474ab93811dce
AleksC/bioskop
/src/provere.py
1,557
4.0625
4
def unos_stringa(ciljana_provera): ''' Provera namenjena pravilnom unosu imena i prezimena novih korisnika. ''' provera = False while not provera: string_za_proveru = input("Molimo unesite " + ciljana_provera + " novog korisnika: ") pom_prom = string_za_proveru.split() if len...
a867f7c5bc43e29c40a6ad5b475c43ce447217b8
leo10816/practice-git
/bubblesort.py
427
3.90625
4
def bubblesort(data): print('原始資料為:') listprint(data) for i in range(len(data)-1,-1,-1): for j in range(i): if data[j]>data[j+1]: data[j],data[j+1]=data[j+1],data[j] print('排序結果為:') listprint(data) def listprint(data): for j in range(len(data)): prin...
663ac97205d487837d27cd973cb1a91bdf9b8702
Antoniel-silva/ifpi-ads-algoritmos2020
/Fabio 2b/Questão 7.py
1,890
4.25
4
#7. As Organizações Tabajara resolveram dar um aumento de salário aos seus colaboradores e lhe #contrataram para desenvolver o programa que calculará os reajustes. Escreva um algoritmo que leia o #salário de um colaborador e o reajuste segundo o seguinte critério, baseado no salário atual: #o salários até R$ 280,00 ...
9921976bf20825da1a5ce71bf4ba52d01ee5f106
Antoniel-silva/ifpi-ads-algoritmos2020
/App celular.py
2,066
4.15625
4
def main(): arquivo = [] menu = tela_inicial() opcao = int(input(menu)) while opcao != 0: if opcao == 1: listacel = cadastrar() arquivo.append(listacel) elif opcao == 2: lista = listar(arquivo) ...
ed36575ff8fa252383163fa040ec476df213a1de
Antoniel-silva/ifpi-ads-algoritmos2020
/Questão Alongamento.py
743
3.625
4
num = int(input("Digite a quantidade de números que você pretende digitar: ")) v = [-1] * num v2 = [] par = 0 impar = 0 pos = 0 neg = 0 for i in range(len(v)): for i in range(len(v2): v[i] = int(input("valor: ?")) if v[i] % 2 == 0 and v[i] >=0: #v2[i] = v[i]*2 pos+=1 ...
2a49008676cac7c25bc0914644706f5056798ef5
Antoniel-silva/ifpi-ads-algoritmos2020
/Fabio 2a/Questão 4.py
357
3.8125
4
#4. Leia 1 (um) número de 2 (dois) dígitos, verifique e escreva se o algarismo da dezena é igual ou diferente #do algarismo da unidade. #entradas a = int(input("Digite um número inteiro de 2 algarismos: ")) num1 = a // 10 num2 = a % 10 if num1 == num2: print("Os algarismos são iguais.") else: print("Os...
4bb55dfeb2640ca2ba99d32ff68d1c1440126898
Antoniel-silva/ifpi-ads-algoritmos2020
/Fabio 2b/Questão 13.py
1,567
4.21875
4
#13. Faça 5 perguntas para uma pessoa sobre um crime. As perguntas são: #a) "Telefonou para a vítima ?" #b) "Esteve no local do crime ?" #c) "Mora perto da vítima ?" #d) "Devia para a vítima ?" #e) "Já trabalhou com a vítima ?" #O algoritmo deve no final emitir uma classificação sobre a participação da pessoa no ...
351bc82a4422af759022c5f84c26a7f35d266f59
Antoniel-silva/ifpi-ads-algoritmos2020
/semana 4 Exploração de marte.py
205
4.09375
4
#Exploração de marte palavra = str(input("Digite a palavra: ")) con = 0 qtdpalvras = con / 3 for i in palavra: con +=1 print("A quantidade de palavras recebidas foi: ", con/3, "palavras")
46c32dc5a42d22168f750d26e8608afeb34390c7
Antoniel-silva/ifpi-ads-algoritmos2020
/Fabio 2a/Questão 3.py
396
3.875
4
#3. Leia 3 (três) números, verifique e escreva o maior entre os números lidos. a = float(input("Digite o primeiro valor: ")) b = float(input("Digite o segundo valor: ")) c = float(input("Digite o terceiro valor: ")) if a > b and a > c: print(f'O numero {a} é maior') if a < b and b > c: print(f'O numero {b} é...
5e9b4e2f255ea65059abfeb8a68658de961e9902
sudh29/Algorithms
/selectionSort.py
298
3.96875
4
# function to sort a list using selction sort def selectionSort(a): n = len(a) for i in range(n): for j in range(i + 1, n): if a[j] < a[i]: a[j], a[i] = a[i], a[j] # print(a) return a x = [5, 2, 6, 7, 2, 1, 0, 3] print(selectionSort(x))
63f54656115085c99710905f8ff2f020a382c1ef
odhran456/pythonComputationalPhysics
/blocks.py
4,571
3.609375
4
import pygame WIDTH = 640 HEIGHT = 480 FPS = 30 BLACK = (0, 0, 0) GREEN = (0, 255, 0) BLUE = (0, 0, 255) WHITE = (255, 255, 255) counter = 0 class Square(pygame.sprite.Sprite): def __init__(self, x, y, size, mass, velocity, color): self.mass = mass self.velocity = velocity pygame.spri...
4ff81247fecf557f505793e1d0e62bf1e420c4f8
mariakalfountzou/First-Coding-Bootcamb
/Python_Part_I/Exercise 3.py
457
3.953125
4
import math input_a=input("Give me the first side of the triangle:") input_b=input("Give me the second side of the triangle:") input_c=input("Give me the third side of the triangle:") r= (float(input_a)+ float (input_b)+ float (input_c))*(-float (input_a)+ float (input_b)+ float (input_c))*(float (input_a)- float (in...
47aaec0bae9d6547b03ba391cc316f101217ba93
mariakalfountzou/First-Coding-Bootcamb
/Python_Part_I/Exercise 4.py
567
3.984375
4
import math a = input("Enter the value for a, not 0!:") b = input("Enter the value for b:") c = input("Enter the value for c:") d= (float(b)**2-4*float (a)* float (c)) if (float (d) >=0): x1= (-float(b)+math.sqrt(d)) / (2*float (a)) x2= (-float(b)- math.sqrt(d)) / (2*float (a)) ...
5812c74bf9c585094496173797da68ef29aaad19
GuiMarion/Musical-Needleman
/functions.py
16,837
3.75
4
from __future__ import print_function # In order to use the print() function in python 2.X import numpy as np import math DEBUG = False def printMatrix(M, str1, str2): P = [] for i in range(len(M)+1): P.append([]) for j in range(len(M[0])+1): P[i].append('') for i in range(...
60aa3a51ff78c2b24027c2534e4e09f3b4f27bcd
anay-jain/PythonNotebook
/keywordArguments.py
515
3.921875
4
# passing a dictonary as a argument def cheeseshop(kind , *arguments ,**keywords): print("I would like to have " , kind , "?") print("Sorry ! OUT OF STOCK OF" , kind ) for arg in arguments : # *name must occur before **name print(arg) print('-'*50) for kw in keywords: # its a dictonary that is passed as a argu...
8399f69c52f360f57163477fdec3a96e40b9242d
Tsidia/FizzBuzz
/FizzBuzz.py
992
3.984375
4
import argparse parser = argparse.ArgumentParser(description="A program that plays FizzBuzz") parser.add_argument("-target", metavar="-t", type=int, default=100, help="The number to play up to") parser.add_argument("-fizz", metavar="-f", type=int, default=3, help="The number to print Fizz on") parser.add_argument("-bu...
d64bfea5f97a202ed2ae72e5aa7e3c9e0922a7b5
mourafc73/EclipsePython
/PyEclipseProj/Test/EPAM_SampleTest.py
934
3.765625
4
# Write a function: # def solution(A) # that, given an array A of N integers, returns the smallest positive integer # (greater than 0) # that does not occur in A. # For example, given A = [1, 3, 6, 4, 1, 2], the function should return 5. # Given A = [1, 2, 3], the function should return 4. # Given A = [−1, −3]...
8efa2c375ab800d39f8fb78569e22e4b869a2e72
xstaticxgpx/netsnmp-py3
/netsnmp/_hex.py
2,065
3.609375
4
import binascii, struct def snmp_hex2str(type, value): """ Helper func to convert various types of hex-strings, determined by length """ # Remove any surrounding quotes if value[0]=='"' and value[-1]=='"': # '"AB'" -> 'AB' _hexstr = value[1:-1] else: _hexstr = value ...
10ff6f69a2918ba5ca3ca0d6220f2441f894b500
Ege3/HELLO
/YL10.py
409
3.984375
4
puuvilja_list = ['pirn', 'kirss', 'ploom'] print(puuvilja_list[0]) puuvilja_list.insert(3,'apelsin') print(puuvilja_list[3]) #print(puuvilja_list) puuvilja_list[2] = 'õun' print(puuvilja_list) if "õun" in puuvilja_list: print("Jah, 'õun' on listis") print(len(puuvilja_list)) del puuvilja_list[0] print(puuvilja_list) ...
7d85621e7b0f989d3c1bca7b45e8a43ced8fed3b
Ege3/HELLO
/YL9.py
783
4.03125
4
esimene = float(input("Sisesta kolmnurga esimene külg: ")) teine = float(input("Sisesta kolmnurga teine külg: ")) kolmas = float(input("Sisesta kolmnurga kolmas külg: ")) #kaks lühemat külge peavad kokku andma kõige pikema külje: list = [esimene, teine, kolmas] if (max(list)) == esimene and teine + kolmas >= (max(list...
18cbdad0a3cfb067b08e9e4710a4bcc67cab413b
sachin-611/practicals_sem3
/fds/prac_4/file4.py
6,493
4
4
def input_matrix(): # function to take matrix as input row1=int(input("\nEnter no of rows in Matrix : ")) col1=int(input("Enter no of column in Matrix : ")) matrix=[[0]*col1]*row1 for i in range(row1): ls=list(map(int,input().split())) while(len(ls)!=col1): ...
77385aa72ad3f52dee6494bea4570320d89c4cbb
tmaxe/labs
/Lab_1/spider.py
194
3.796875
4
import turtle turtle.shape('turtle') c=12 x=0 a=100 n=360 b=180-n/c while x<c: turtle.forward(a) turtle.stamp() turtle.left(180) turtle.forward(a) turtle.left(b) x +=1
cc33612f8e1f927c1ed1108e5bd3271792b925d7
EDDChang/Junyi-2021
/2.py
682
3.59375
4
import unittest import math class TargetCalculator: def count(self, x): return x - math.floor(x/3) - math.floor(x/5) + 2*math.floor(x/15) class TargetCalculatorTest(unittest.TestCase): def test_example_testcase(self): TC = TargetCalculator() self.assertEqual(TC.count(15), 9) def...
9bda1a952f1ae43c3abb1c02df2a54f943be97aa
arpitmx/PyProjectFiles
/Prog11.py
1,201
3.6875
4
def PUSH(l): ll = savelist.l ll.append(l) savelist(ll) return ll def POP(): ll = savelist.l if not(l.__len__() == 0): ll.pop() savelist(ll) return ll else: print("Can't Pop, No Items in the list.") def PEEK(n): ll = savelist.l return ...
5f7d1a176d30334fff1acd74acd30443ee63fcbc
malaikaandrade/BOA
/OriObjetos.py
662
3.59375
4
class Perro: #molde de obejetos def __init__(self, nombre, raza, color, edad): self.nombre = nombre self.raza = raza self.color = color self.edad = edad self.otro = otra_persona #metodos def saludar(self): print('Hola {nombre}, cómo estás? '.format(nombre=self.nombre)) def saludar_a_otra_persona(sel...
a42ed5941d4c983e667a840cc59b74087b0aba7b
thodge03/CD_Python
/ScoresAndGrades.py
691
3.96875
4
import random def scores(num): for i in range(0,num): random_num = random.randrange(60,101,1) if random_num >= 60: if random_num >= 70: if random_num >= 80: if random_num >= 90: print 'Score: ' + str(random_num) + '; Y...
423c89bd1b2284cbe7ae7ca1588990f99690f602
CrazyBinXXX/Stock-Project-X
/test.py
1,026
3.953125
4
class ListNode: def __init__(self, x): self.val = x self.next = None def oddEvenList(head): # write code here odd = True cur = head head2 = ListNode(-1) cur2 = head2 last = None final = None while cur: print(cur.val) if odd: if not cur.nex...
6ae10197706b1ade4728287d8c80f19081a62b46
GingerWW/turtle
/spiral.py
591
4.0625
4
import turtle turtle.color('purple') #设置画笔颜色 turtle.pensize(2) #设置画笔宽度 turtle.speed(5) #设置画笔移动速度 t=turtle.Screen() def draw(turtle, length): if length>0: #边长大于0递归,画到最中心停止 turtle.forward(length) turtle.left(90) #每次画线后,画笔左转90度 draw(turtle,length-4) #利用递归再次画线,设置离上一圈的画...
32a4d948882e3266e9d27bdb147c2b5234ef55e3
adykumar/Grind
/module3.py
1,158
3.8125
4
#------------------------------------------------------------------------------- # Name: module3 # Purpose: # # Author: Swadhyaya # # Created: 17/12/2016 # Copyright: (c) Swadhyaya 2016 # Licence: <your licence> #------------------------------------------------------------------------------- def ...
1bbc9011bd011a7f80be71042f27fb4ebebf4171
adykumar/Grind
/py_MergeSortedArrays.py
854
3.75
4
#------------------------------------------------------------------------------- # Name: module11 # Purpose: # # Author: Swadhyaya # # Created: 25/12/2016 # Copyright: (c) Swadhyaya 2016 # Licence: <your licence> #------------------------------------------------------------------------------- def ...
77ad0d661f7eace3987f0b8c1d6ba2b037862474
Phoenix951/LabsForMSU
/Exc_4.py
789
3.9375
4
def exercise_one(search_number): """ В упорядоченном по возрастанию массиве целых чисел найти определенный элемент (указать его индекс) или сообщить, что такого элемента нет. Задание 3. Страница 63. :param search_number: искомое число :return: индекс искомого числа """ list_of_numbers = ...
430a7b1e252b2b4dd93b638b72570599f46828ca
anhpt1993/generate_number
/generate_number.py
1,772
3.828125
4
# generate numbers according to the rules def input_data(): while True: try: num = int(input("Enter an integer greater than or equal to 0: ")) if num >= 0: return num break else: print("Wrong input. Try again please") ...
4b7303be78949893da7503bb769445ca372be4b2
xxmatxx/orvilleVM
/examples/power.py
244
3.921875
4
def print_int(max_int): i = 0 while (i < max_int): print(i) i = i + 1 print_int(3) def power(x,p): i = 0 temp = 1 while(i < p): temp = temp * x i = i + 1 return temp print(power(3,4))
8cecdbd7fa5f734297d5668e3d047f7418899023
dkurchigin/gb-py-lesssons
/lesson6/kd_lesson6_medium.py
2,709
3.734375
4
import random def programm_title(): print("**************************") print("*GB/Python/Lesson6/MEDIUM*") print("**************************") class Person: def __init__(self, name="Person"): self.name = name self.health = 100 self.damage = 25 self.armor = 10 ...
dddc3e4b90c6260f9b6e0726ebda2063062760d3
yegeli/Practice
/Practice(pymsql)/exercise01.py
1,557
3.703125
4
""" pymysql使用流程: 1. 创建数据库连接 db = pymsql.connect(host = 'localhost',port = 3306,user='root',password='123456',database='yege',charset='utf8') 2. 创建游标,返回对象(用于执行数据库语句命令) cur=db.cursor() 3. 执行sql语句 cur.execute(sql,list[])、cur.executemany(sql,[(元组)]) 4. 获取查询结果集: cur.fetchone()获取结果集的第一条数据,查到返回一个元组 ...
3ebcdb40617f4f0628d4329c652a288b009a160a
yegeli/Practice
/Review/day13_exercise01.py
824
3.9375
4
""" 手雷爆炸,伤害玩家生命(血量减少,闪现红屏),伤害敌人得生命(血量减少,头顶爆字) 要求: 可能还增加其他事物,但是布恩那个修改手雷代码 体会: 封装:分 继承:隔 多态:做 """ class Granade: """ 手雷 """ def explode(self,target): if isinstance(target,AttackTarget): target.damage() class AttackTarget(): """ ...
373d5194589ea6da392963fa046cb8478a9d52c4
yegeli/Practice
/第16章/threading_exercise02.py
483
4.15625
4
""" 使用Thread子类创建进程 """ import threading import time class SubThread(threading.Thread): def run(self): for i in range(3): time.sleep(1) msg = "子线程" + self.name + "执行,i=" + str(i) print(msg) if __name__ == "__main__": print("------主进程开始-------") t1 = SubThre...
e48b8c38a7a871f60a541a850fb58a177425adbe
hupeipeii/sf
/日历的算法.py
2,124
3.875
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Thu Nov 2 09:49:04 2017 @author: hupeipei8090 """ def is_leaf_years(year): if year%400==0 or year%4==0 and year%100!=0: True else: False def get_num_of_days_in_month(year,month): if month in [1,3,5,7,8,10,12]: ...
38d91e9da11c1e369a56fa4034362cdfe300e258
jionchu/Problem-Solving
/BOJ/10001~11000/10996.py
140
3.859375
4
num = int(input()) for i in range(num*2): for j in range(num): if j%2 == i%2: print('*',end='') else: print(' ',end='') print()
a31c2c79b1f13f4a24f8b3fb9e3b7f48f7860b38
wkqls0829/codingprac
/baekjoonnum/9506.py
368
3.59375
4
def divisorsum(): n = int(input()) while(n!=-1): div = [] for i in range(1, n): if not n%i: div.append(i) if sum(div) == n: print(f'{n} = ' + ' + '.join(map(str, div))) else: print(f'{n} is NOT perfect.') n = int(input()...
95aa1c3ba7723fe3accc9183b884d0ed188f2cb9
wkqls0829/codingprac
/baekjoonnum/camoflage.py
462
3.5625
4
import sys from collections import defaultdict def solution(clothes): result = 1 clothes_dict = defaultdict(list) for c in clothes: clothes_dict[c[1]].append(c[0]) for _, cd in clothes_dict.items(): result *= len(cd)+1 return result-1 if __name__ == '__main__': num_clothes = in...
800f664cf6cd49ef40573f67f0c945971a70fb09
raekhan1/pythonpractice
/bfsmoles.py
2,988
3.515625
4
class Board: def __init__(self, moles): self.board = [] * 6 for i in range(0, 6): self.board.append([0] * 6) for mole in moles: column = (mole - 1) % 4 row = (mole - 1) // 4 self.board[row + 1][column + 1] = 1 def print(self): for ...
3fb2f1666a744d8d2c08ac8492d2025f3f6f7c9f
raekhan1/pythonpractice
/catchthefruit4.py
3,714
3.5
4
class gameObject(): def __init__(self, c, xpos, ypos, velocity): self.c = c self.xpos = xpos self.ypos = ypos self.vel = velocity class Basket(gameObject): # using inheritance for the object # drawing the basket def display(self): ...
d896c5ed8d00d633d4cfd6fc2b83484440d482ef
tan-adelle/hacktoberfest-entry
/myapp.py
1,665
3.921875
4
print("Title of program: Exam Prep bot") print() while True: description = input("Exams are coming, how do you feel?") list_of_words = description.split() feelings_list = [] encouragement_list = [] counter = 0 for each_word in list_of_words: if each_word == "stressed": feelings_list.appe...
c385a9dfffedbd0794a4775937ca642a3510d7d3
Cyberfallen/Latihan-Bahasa-Pemrograman
/python/File/dasar.py
408
3.953125
4
print("Baca Tulis File") print("Menulis Sebuah Teks Nama Ane Ke Txt Ngeh") f = open("ngeh.txt", "w") f.write("Aji Gelar Prayogo\n") f.write("1700018016") f.close() print("Mengakhiri Fungsi Tulis File") print() print("Membaca File Ngeh.txt") f = open("ngeh.txt", "r") for baris in f.readlines(): print(bari...
874b927a486d77e79b3797f610ebcf7daf0a082d
Cyberfallen/Latihan-Bahasa-Pemrograman
/python/random_angka.py
169
3.53125
4
import random print("Program Untuk Menampilkan Angka Sembarang") print("Batas = 20") print("Pembatas = 50") for x in range(20): print (random.randint(1,10)) print
2391e9662e168d79c6021d15b27af3411d56cb33
Cyberfallen/Latihan-Bahasa-Pemrograman
/python/kondisi.py
485
3.78125
4
print "Program Untuk Membuat Suatu Kondisi Sekaligus Meneima Inputan" print "Apa Tipe Gender Anda : " a = raw_input("L/P : ") if a == "L" or a == "l" : print "Anda Laki-Laki" elif a == "P" or a == "p" : print "Anda Perempuan" else : print "Inputan Tidak Sesuai" print "Bentuk Logika" print " " print "Apakah Anda Sia...
a0cc1bb2589478949fa5ebf250857dda8c9ce464
Cyberfallen/Latihan-Bahasa-Pemrograman
/python/Memotong_List.py
266
3.625
4
finisher = ["aji", "gelar", "pray"] first_two = finisher[1:3] print(first_two) """ Kepotong Sebelah Kiri 1: --> gelar, pray 2: --> pray 3: --> Memotong Dari Sebelah Kanan :1 --> aji :2 --> aji, gelar :3 --> aji, gelar, pray 1:3 -->gelar, pray """
ff2c02e52a904c563aaf56b47e8ef57bd921a4a1
Cyberfallen/Latihan-Bahasa-Pemrograman
/python/While.py
107
3.703125
4
print("Contoh Program Untuk Penggunaan While") print("Batas = 20") a=0 while a<=20: a = a+1 print(a)
df273e0b1a4ec97f7884e64e0fe1979623236fb2
bdjilka/algorithms_on_graphs
/week2/acyclicity.py
2,108
4.125
4
# Uses python3 import sys class Graph: """ Class representing directed graph defined with the help of adjacency list. """ def __init__(self, adj, n): """ Initialization. :param adj: list of adjacency :param n: number of vertices """ self.adj = adj ...
16753f583825a4a04c044a314ade735202b7076d
ggrecco/python
/basico/zumbis/surfSplitNomeNotas.py
310
3.59375
4
f = open("surf.txt") #maior = 0 notas = [] for linha in f: nome, pontos = linha.split() notas.append(float(pontos)) #if float(pontos) > maior: #maior = float(pontos) f.close() #print(maior) notas.sort(reverse = True) print("1º - {}\n2º - {}\n3º - {}".format(notas[0],notas[1],notas[2]))
e3161b35c014b11888d835507c3eb8de8105b426
ggrecco/python
/basico/zumbis/imprimeParSemIF.py
135
3.953125
4
#imprimir pares de 0 ao digitado sem o if n = int(input("Digite um número: ")) x = 0 while x <= n: print(x, end = " ") x += 2
d8fe9b832e0927a1fe6d869bb10854b4c2d53bee
ggrecco/python
/basico/coursera/verifica_ordenamento_lista.py
198
3.78125
4
def ordenada(lista): b = sorted(lista) print(lista) print(b) if b == lista: return True #print("Iguais") else: return False #print("Diferente")
8c35008e3eafc6f0877dd65325ee051cea3afaf3
ggrecco/python
/basico/zumbis/jogo_2.py
291
3.734375
4
from random import randint secreta = randint(1, 100) while True: chute = int(input("Chute:")) if chute == secreta: print("parabéns, vc acertou o número {}".format(secreta)) break else: print("Alto" if chute > secreta else "Baixo") print("Fim do jogo")
e3d7c97584d737e341caae29dc639be446b80159
ggrecco/python
/basico/zumbis/trocandoLetras.py
311
3.75
4
#ler uma palavra e trocar as vogais por "*" i = 0 troca = "" palavra = input("Palavra: ") j = input("Letra: ") t = input("trocar por: ") while i < len(palavra): if palavra[i] in str(j): troca += t else: troca += palavra[i] i += 1 print("Nova: {}\nAntiga:{}".format(troca,palavra))
3542c66b49e08f505395c9f76b2bbee070677991
ggrecco/python
/basico/coursera/calculadoraVelocidadeDownload_importando_funcao_tempo.py
401
3.75
4
import fun_Tempo def calcVel(k): return k/8 i = 1 while i != 0: n = int(input("Velocidade contratada[(zero) para sair]: ")) t = (float(input("Tamanho do arquivo em MegaBytes: "))) segundos = t / calcVel(n) fun_Tempo.calcTempo(segundos) print("Velocidade máxima de Download {} MB/s\...
b49c3aaa2c6ba16a47729c07471b6ca18795fa56
ggrecco/python
/basico/zumbis/latasNecessarias.py
526
3.828125
4
''' usuário informa o tamanho em metros quadrados a ser pintado Cada litro de tinta pinta 3 metros quadrados e a tinta é vendida em latas de 18 litros, que custam R$ 80,00 devolver para o usuário o numero de latas necessárias e o preço total. Somente são vendidas nº inteiro de latas ''' m = float(input("Metros²: ")) if...
bd2dbd08dfd85e478fd10e6416536ac6490bdf62
ggrecco/python
/basico/coursera/imprime_retangulo_vazado.py
317
4.03125
4
n = int(input("digite a largura: ")) j = int(input("digite a altura: ")) x = 1 while x <= j: print("#", end="") coluna = 0 while coluna < (n - 2): if x == 1 or x == j: print("#", end="") else: print(end=" ") coluna = coluna + 1 print("#") x = x + 1
59d1bf3ee1afee7ebd9c03797a779f4beae41c18
sohanur-it/programming-solve-in-python3
/cricket-problem.py
476
3.640625
4
#!/usr/bin/python3 T=int(input("Enter the inputs:")) for i in range(1,T+1): RR,CR,RB=input("<required run> <current run> <remaining balls> :").split(" ") RR,CR=[int(RR),int(CR)] RB=int(RB) balls_played=300-RB current_run_rate=(CR/balls_played)*6 current_run_rate=round(current_run_rate,2) print("current run rate:...
7971c61b321c45254f4d74d20494dba9b172c5b2
uchicagotechteam/HourVoice
/workbench/data_collection/combine_data.py
2,335
3.71875
4
import json from collections import defaultdict def combine_databases(databases, compared_keys, equality_functions, database_names): ''' @param databases: a list of dicts, where each dict's values should be dictionaries mapping headers to individual data points. For example, [db1, db2] with db1 = {'1': , '...
9390fdf52e3768a4828ded73fefccd059537eb22
nguyenl1/evening_class
/python/notes/python0305.py
1,088
4.03125
4
""" Dictionaries Key-values pairs dict literals (bracket to bracket) {'key': 'value' } [ array: list of strings ] Immutable value (int, float, string, tuple) List and dicts cannot be keys """ product_to_price = {'apple': 1.0, "pear": 1.5, "grapes": 0.75} print(product_to_price['apple']) # print(product_to_price...
a90e7646813c7645935894105d63434178909703
nguyenl1/evening_class
/python/labs/lab15.py
1,779
3.9375
4
""" Convert a given number into its english representation. For example: 67 becomes 'sixty-seven'. Handle numbers from 0-99. Hint: you can use modulus to extract the ones and tens digit. x = 67 tens_digit = x//10 ones_digit = x%10 Hint 2: use the digit as an index for a list of strings. """ noindex = [0,1,2,3,4,5,...
e39edeb39458969cef046410d03535f2f5d8a64a
nguyenl1/evening_class
/python/notes/python0225.py
851
4.0625
4
''' def my_add(num_1, num_2): a_sum = num_1 + num_2 return a_sum sum = my_add(5, 6) #the contract between the users and the function print(sum) ''' """ #variables x = 5 print (x) greeting = "hello" print (greeting) bool = 5 > 10 print (bool) """ ''' # my_string = "ThIs Is A StRiNG" # print(my_string.lo...
4b3922cdedf4f4c7af87235b94af0f763977b191
nguyenl1/evening_class
/python/labs/lab23final.py
2,971
4.25
4
import csv #version 1 # phonebook = [] # with open('lab23.csv') as file: # read = csv.DictReader(file, delimiter=',') # for row in read: # phonebook.append(row) # print(phonebook) #version2 """Create a record: ask the user for each attribute, add a new contact to your contact list with the attr...
6e52d2a6e99a95375e37dace8a996a9f10ca87cd
nguyenl1/evening_class
/python/notes/python0227.py
647
3.796875
4
# x = 5 # y = 5 # print(x is y) # print(id(x)) #returns ID of an object # truthy falsey # empty lists, strings, None is a falsey value x = [] y = [1,2,3] i = "" j = "qwerty" z = None if x: print(x) if y: print(y) # [1,2,3] if i: print(i) if j: print(j) # qwerty if z: print(z) # my_flag = Tru...
3bd0c70f91a87d98797984bb0b17502eac466972
nguyenl1/evening_class
/python/labs/lab18.py
2,044
4.40625
4
""" peaks - Returns the indices of peaks. A peak has a lower number on both the left and the right. valleys - Returns the indices of 'valleys'. A valley is a number with a higher number on both the left and the right. peaks_and_valleys - uses the above two functions to compile a single list of the peaks and valleys i...
208f0481f2b86a5487202000de30700f754ad873
rxbook/study-python
/06/12.py
125
3.796875
4
def power(x,n): if n == 0: return 1 else: return x * power(x,n-1) print power(2,3) print power(2,5) print power(3,4)
ca672ad960d02bc62c952f5d8bab44670fa03c24
rxbook/study-python
/05/t02.py
115
3.75
4
score = input('Enter your score:') if score >= 85: print 'Good' elif score < 60: print 'xxxxx' else: print 'OK'
530effec6984850539b440dc14870a2bd4af2f71
rxbook/study-python
/05/t13.py
133
3.796875
4
names = ['zhang','wang','zhao','li'] ages = [12,46,32,19] zip(names,ages) #for name,age in zip(names,ages): # print name,'-----',age