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
7b45b9ec6db2bb38a940967cf8a18af4e0d7d802
parthasmart/jillu
/camel.py
137
3.78125
4
def string to camel(word): import re return ''.join(x.Capitalize() or '_' for x in word.split('_') print(string to camel('partha_smart))
8a7ceb97877b824fd8da6e9940cb5b5cc3678603
parthasmart/jillu
/eveninterval.py
124
3.984375
4
low=int(input("enter the number:")) hig=int(input("enter the number:")) for i in range(low,high+1) if(i%2==0): print(i)
1fc5d33224dbccfd7fde52e8d589b0467dcb30ff
parthasmart/jillu
/hello.py
70
3.953125
4
num=int(input("enter the number") for i in range(num): print("hello")
bc513e258888fed273dc08c99a66722811b0f529
nidjaj/python-basic-codes
/areaoftriangle.py
155
4.03125
4
#calculate area of triangle b=input("enter base of triangle") h=input("enter height of triangle") a=1/2*float(b)*float(h) print("area of triangle",a)
7fd8d5fa17e95775f7fe83d7e1259259555bf4e0
nidjaj/python-basic-codes
/noispositive.py
503
4.15625
4
# if function x=int(input("enter a no.")) if x>0: print("%d is positive"%x) if x<0: print("%d is negative"%x) if x==0: print("%d is zero"%x) # if else function x=int(input("enter a no.")) if x>0: #we also use paranthesis'()' print("%d is positive"%x) else: print("...
73dfdf2d7ccd6fb6c675bb4a86a3053beff30499
nidjaj/python-basic-codes
/squareofno.py
101
3.84375
4
#square of given no x=input("enter any no") s=float(x)*float(x) print("square of given no is",s)
d848227dd2033e383081215debdc3cefe8876a68
rednithin/Spoj
/Fctrl2.py
192
3.65625
4
# http://www.spoj.com/problems/FCTRL2/ def fact(n): if n == 1: return 1 return n * fact(n-1) t = int(input()) while t != 0: n = int(input()) print(fact(n)) t -= 1
279947ceb6158b605f056295c8482db35c5f80e8
rednithin/Spoj
/Army.py
317
3.625
4
# http://www.spoj.com/problems/ARMY/ t = int(input()) while t != 0: t -= 1 input() input() god = [int(x) for x in input().strip().split(' ')] mech = [int(x) for x in input().strip().split(' ')] if max(god) >= max(mech): print('Godzilla') else: print('MechaGodzilla')
950fb0e048a560043577605d9642d69808f974da
Rohitha92/Python
/Sorting/BubbleSort.py
774
4.1875
4
#Bubble sort implementation #multiple passes throught the list. ##Ascending order def bubble_sort(arr): swapped = True while(swapped): swapped = False for i in range(len(arr)-1): if arr[i] > arr[i+1]: temp = arr[i] arr[i] = arr[i+1] arr[i+1]= temp swapped = Tr...
7216c73c1532bb08e436447f01903f98e7be6660
Rohitha92/Python
/StacksQueuesDeques/Queue.py
578
4.21875
4
#Implement Queue #First in First out #insert items at the First (zero index) #delete from first (zero index) class Queue(object): def __init__(self): self.items=[] def enqueue(self,val): #add to the rear self.items.insert(0,val) def size(self): return len(self.items) def isempty(self):...
52388083bd8aa8d4c96898e59e3814705b278f2a
erikhabb/solitaire_MVC
/python/solitairemodel.py
7,097
3.546875
4
from cardmodel import Card import random class SolitaireModel: class OutOfRangeError(Exception): pass def __init__(self): pass def newGame(self): """Reshuffle and deal cards to start a new game.""" self.foundation = [[], [], [], []] self.tableau = [[], [], [], [], [], [], []] self.stock = ...
91ff34d5b1b49d711cf48abcd578d033cc5a229b
finallyegg/Leetcode_py
/973_K_Cloest_Points_to_Origin.py
1,609
3.515625
4
# May 21 2021 # TODO: divide and conqure import math from typing import List class Solution: # Normal solution, compute distance for all, and store them into a Array def distance(self, point:List[int]): return math.sqrt(point[0]**2 + point[1]**2) def kClosest(self, points: List[List[int]], K: int) ->...
e012ac9354f0e1d7ede9def50f7f23eb3a0bdfd4
nolanbconaway/DS18B20
/src/thermometer/__init__.py
5,874
3.53125
4
"""Utils to read temperatures off of a raspberry pi thermometer.""" import statistics import time import typing from pathlib import Path # defaults for my raspi DEVICE_FOLDER = Path("/sys/bus/w1/devices/") DEVICE_SUFFIX = "w1_slave" WAIT_INTERVAL = 0.05 class DeviceNotFoundError(Exception): """Raised when the d...
8a7f01ada281d600380f8932164eb69f3abed5e0
lopesofrin28/INFYTQ
/PROGRAMMING FUNDAMENTALS USING PYTHON/Day1/Assignment/assignment3.py
750
3.5625
4
#PF-Assgn-3 #This verification is based on string match. # mileage=12 # amount_per_litre=72 # distance_one_way=102 # per_head_cost=0 # divisible_by_five=False mileage=12 amount_per_litre=65 distance_one_way=96 per_head_cost=0 divisible_by_five=False #Start writing your code from here #Populate the variables: per_he...
025e768a1dac7042e5e7e073c78258df1b9cb5da
luiz158/Advent-of-Code
/2015/day1/Problem1.py
264
3.59375
4
#http://adventofcode.com/2015/day/1 #First Problem puzzle = input() floors = list(puzzle) currentFlorr = 0 for nextFloor in floors: if nextFloor == '(': currentFlorr += 1 elif nextFloor == ')': currentFlorr -=1 print(currentFlorr)
87e4ca9f19aaed0d8887aa608a10638711fd17b9
luiz158/Advent-of-Code
/2015/day5/Problem1.py
1,006
3.578125
4
#http://adventofcode.com/2015/day/5 import sys vowels = ['a', 'e', 'i', 'o', 'u'] nogoods = ['ab', 'cd', 'pq', 'xy'] niceWordCont = 0 howManyNice = 0 def checkVowels(characterArray): vowelCont = 0 for character in characterArray: if character in vowels: vowelCont += 1 if vowelCont ==...
84a55e5a7eb8e2a10ae0b5ed03620094951dfb58
KudzanaiGomera/Data_Science_Bootcamp
/Investment Calculator/financialAdvisor/Investment_Calculator.py
1,173
3.890625
4
''' Created on 4 Oct 2018 @author: Kudzanai Gomera Write a function investment(PMT,n,i) that calculates your custormer's savings at some point in the future if -an amount is invested at END of every year, starting with amount of PMT at the end of this year -at an interest rate of i% per year,compounded annually -the ...
a0a55924ca07dfd4ce69acf0f0e0ddd9445a2cad
youxirenjianqiubuhui/testcode
/demo001.py
155
3.859375
4
print("hello world!") print("1234"+ "5678") # 拼接 print("111"+"222") print(111*222) print("1234"*10) a = 1234 b= str(a) print(type(b))
fa35e28712b76318be6b0a34f2b148e1f66bf67e
tymurKoltunov/raspberryPI_foundation
/drawings/turtle_race.py
488
3.90625
4
from random import randint from turtle import Turtle t1 = Turtle() t1.color('red') t1.shape('turtle') t1.penup() t1.goto(-100, 100) t1.pendown() t2 = Turtle() t2.color('green') t2.shape('classic') t2.penup() t2.goto(-100, 80) t2.pendown() t3 = Turtle() t3.color('yellow') t3.shape('circle') t3.penup() t3.goto(-100, 60)...
dbab87656743bc392657697bd944b8df9e1fea4d
duarte15/exercicioProva4
/Questão3- Letícia Duarte.py
353
4.125
4
#QUESTAO3 print("Funes recursivas so funes que chamam a si mesma de forma que, para resolver um problema maior, utiliza a recurso para chegar as unidades bsicas do problema em questo e ento calcular o resultado final.\n Exemplo:") def fatorial(n): if (n==1): return (n) return fatorial(n-1)*n-1 prin...
4c20dfff205160a3cfc0e9f3ad5cc2cdaf6e6821
ak159011/demo
/字典.py
97
3.671875
4
a = {'xx': 1, 'hh': 2, 'vv': 4} # 查找 # for i in a.keys(): # print(a[i]) print(a.items())
1b872bb788774fb6677719007ad53ed0ff4a6bde
MsMalcolm/INF308
/Spring2021/programs/bib_draft.py
6,285
4.21875
4
# The following program is a tool for handling bibliographies in APA (7th Edition). # Basic format for books in APA: # Author, A. A. (Year of publication). Title of work: Capital letter also for subtitle. Publisher Name. # Basic format for articles in APA: # Author, A. A. (Year). Title of article. Name of journal, vo...
a894fc0962b7ea4ea8dcad14c32bc0edf8c20b75
MsMalcolm/INF308
/Spring2021/programs/recipeCollection.py
3,629
4.46875
4
# The following program is a tool for saving and accessing recipes. recipes = dict() # A dictionary that will hold all recipes file = None # global variable that is used when a user saves a file def addANewRecipe(): new_recipe = dict() # Creating a dictionary to hold new recipe info ...
91ffb7c9029f7c31397548886d35306dabf3fec6
balasarjeeth/arul
/digit of an integer.py
126
3.90625
4
n=int(input(enter number:")) count=9 while(n>0): count=count+1 n=n//10 print("the number of digits in the number are:",count)
fd65d391db797e8f9514560b8e6a5cff32ef3806
sid2412/spacy_projects
/ml_flow/_4_update_labels.py
904
3.6875
4
def update_labels(train_label_values, test_label_values, test_data): """ This function is used when the test/valid sets have missing labels compared to the train set train_label_values: List of label names in train set test_label_values: List of label names in test set test_data: test data in the spacy format re...
f21a97b3668b753bf76a68d13186791b3264f7df
shreyaskshatriya/Python
/Face Detection.py
776
3.59375
4
#Libraries import import cv2 import numpy as np import matplotlib.pyplot as plt %matplotlib inline #Create Classifier face_classifier=cv2.CascadeClassifier('Haarcascades/haarcascade_frontalface_default.xml') #Open Image image=cv2.imread('Images/eye_face.jpg') fix_img=cv2.cvtColor(image, cv2.COLOR_BGR2RGB) plt.imshow...
0116cb37167d0874dd1a1c859b7af9e9e3a3a304
LevZaplatin/problem-solving
/leetcode/283-move-zeroes/test_283_move_zeroes.py
922
3.890625
4
"""Move Zeroes URL: https://leetcode.com/problems/move-zeroes/ """ from typing import List class Solution: @staticmethod def move_zeroes(numbers: List[int]) -> None: length = len(numbers) non_zero_position = 0 for index in range(length): if numbers[index] != 0: ...
13de670b5cfe1a19e253152e53ff78a771fb5732
LevZaplatin/problem-solving
/leetcode/1137-n-th-tribonacci-number/test_1137_n_th_tribonacci_number.py
1,204
3.703125
4
"""N-th Tribonacci Number URL: https://leetcode.com/problems/n-th-tribonacci-number/ """ class Solution: @staticmethod def tribonacci(n: int) -> int: if n < 2: return n if n == 2: return 1 first = 0 second = 1 third = 1 for i in range(n...
7ce81867a4ab4fbd5724e360976228da17ed110c
patsancu/scripts
/put_files_in_date_structure_folder
2,110
4.09375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from datetime import datetime import os import sys def move_file_to_its_date_folder_from_ctime(filename): """ Moves a file into a folder structure named after the year, month and day values of its ctime (obtained from os.stat and st_mtime) value If the...
a8436d7546d6c04fdf1682c3e31a62d8e9eda54a
kiheyunkim/pythonStudy
/tuple.py
562
3.84375
4
# 튜플은 리스트와 다르게 1개의 요소만을 가질때는 콤마를 붙이고, 괄호를 생략해도 된다 # 투플은 변경이 안됨 (삭제, 변경) # 튜플 선언 tuple1 = () tuple2 = (1,) tuple3 = (1, 2, 3) tuple4 = 1, 2, 3 tuple5 = ('a', 'b', ('ab', 'cd')) # 삭제 편집은 불가 # del tuple3[3] # 삭제 불가 # tuple3[3] = 5 # 편집 불가 # 인덱싱 print(tuple4[2]) # 슬라이싱 print(tuple5[1:3]) # 투플 더하기 print(tuple3 + tuple4...
35c8b367ba9255458e14631d49fc55a59400df11
kiheyunkim/pythonStudy
/fileIO.py
719
3.703125
4
# 파일 생성 f = open("newFile.txt", "w", encoding="UTF-8") # w는 쓰기 r는 읽기 a는 이어쓰기 for i in range(1, 111): # 파일에 쓰기 f.write("{0}번째 입력.\n".format(i)) f.close() # 파일 줄 단위로 읽기 f = open("newFile.txt", "r", encoding="UTF-8") # w는 쓰기 r는 읽기 a는 이어쓰기 while True: line = f.readline() if not line: break p...
f45f0460262965c96a44444fc342c907aa285948
KeeganW/challenges
/community_party.py
3,375
4.15625
4
#! /usr/bin/python3 """ Community Party You are hosting a party, and people keep arriving in pairs. You want to know how everyone knows one another, so people with no common communities can get to know one another. The pairs are defined as couples with names, ie ("Amanda", "Ben"). Can you be the party matcher? """ #...
4a2cab3a2f6b8e0e4a003fc35473d4bb11b093f5
RandyOfosu/Python-Basic
/3-control-flow/taak01 -if en else/ifelseOpdracht.py
330
3.96875
4
a = 0 if a == 0: print("Hey, dat klopt variabel a is gelijk aan 0!") elif a == 1: print("Nee, maar a is wel gelijk aan 1.") elif a == 2: print("Nee, maar a is wel gelijk aan 2.") elif a == 3: print("Nee, maar a is wel gelijk aan 3.") else: print("Het is groter dan 3, kleiner dan 0 of helemaal geen ...
88f6fda444fbe8ee82e1c3d1119c19e129d04f29
GladDaniels/Git
/балталогия.py
873
3.96875
4
x = input("Привет, как тебя зовут") print("Привет, ", x) f = input("Как дела?") print("У меня тоже") k = input("Че делать будешь?") print("Ну идея",k ,"так себе") input() # r = input("Слууууушай а можешь рассказать как жарить картошку?") # x = input("Спасибо") # q = input("Хорошая сегодня погода?") # m = input("Говорят...
2decca9c52862f63ebf355efab54d0446c2147b8
Shubhamditya36/python-pattern-programs
/a.7.1.py
267
4.40625
4
# PROGRAM TO PRINT FLOYD'S TRIANGLE (PRINTING NUMBERS IN RIGHT TRIANGLE SHAPE) # EXAMPLE : # # 1234 # 567 # 89 # 10 n=int(input("enter a number:")) num=1 for row in range(n,0,-1): for col in range(0,row-1): print(num,end="") num+=1 print()
7aeba56b0611f7db71a27daf3cb8f007273cdbc2
Shubhamditya36/python-pattern-programs
/a13.py
391
4.1875
4
# PROGRAM TO PRINT PATTERN GIVEN BELOW. # 1 # 2 1 2 # 3 2 1 2 3 # 4 3 2 1 2 3 4 # 5 4 3 2 1 2 3 4 5 num=int(input ("enter a number of rows:")) for row in range(1,num+1): for col in range(0,num-row+1): print(end=" ") for col in range(row,0,-1): print(col,end=" ") ...
68d99566855facd7d1fb225b65ec1a72ba804178
Shubhamditya36/python-pattern-programs
/a22.py
757
4.125
4
# PROGRAM TO PRINT PATTERN GIVEN BELOW. # 5 5 5 5 5 5 5 5 5 # 5 4 4 4 4 4 4 4 5 # 5 4 3 3 3 3 3 4 5 # 5 4 3 2 2 2 3 4 5 # 5 4 3 2 1 2 3 4 5 # 5 4 3 2 2 2 3 4 5 # 5 4 3 3 3 3 3 4 5 # 5 4 4 4 4 4 4 4 5 # 5 5 5 5 5 5 5 5 5 N=int(input(" enter a number of rows;")) k=(2*N)-1 low=0 high=k-1 value=N matrix=[[0 for i in ran...
08d99b35839efd8d0b9ff279d5286b5649b32c7f
PablOCVi/Mastery
/Mastery16.py
255
4.0625
4
def Fibonacci(z): if (z==0 or z==1): return z else: a=0 b=1 c=1 for i in range (1,z): c=a+b a=b b=c return c z=int(input("Ingresa el numero a ser Fibonacciado: ")) fib=Fibonacci(z) print("El Fibonacci de: "+str(z)+" Es: "+str(fib))
9f97fbb34629d070267aa2506441221b5b2845a3
swsvlwillim/web-caesar
/caesar.py
862
4.03125
4
def alphabet_position(letter): """returns the positon number of a letter""" alphabet = 'abcdefghijklmnopqrstuvwxyz' letter = letter.lower() for i in alphabet: return alphabet.index(letter) def rotate_character(char, rot): """ Returns character at rotated position """ if not ...
6ba5b897a9743de4aeadc26426d418ec2b24953f
bheltzel/hourtime
/first.py
2,157
3.640625
4
#from Tkinter import *mk # import the Tkinter GUI interface import Tkinter import pymongo from pymongo import MongoClient # create a class while inheriting the base Tkinter GUI class time_entry(Tkinter.Tk): # create a hierarchy of elements def __init__(self, parent): Tkinter.Tk.__init__(self, parent) ...
b828e13495c37762e8a0eebbea72f85b7759aacd
MistTheRain/app
/flask1/location_weather.py
1,166
3.6875
4
import json import urllib2 def find_weather(lat, lon, api_key): # url for API query url = 'http://api.openweathermap.org/data/2.5/' \ 'forecast?lat={0}&lon={1}&APPID={2}&units=imperial'.format(lat, lon, api_key) data = json.load(urllib2.urlopen(url)) # only grab the first pred = data['...
008b777912e9f87eaae73fadc3e296a1bdf920a5
aninditacse/python
/Advance Communication and TCP_IP/1_des.py
405
3.640625
4
# -*- coding: utf-8 -*- """ Created on Tue Aug 10 10:30:44 2021 @author: Anindita """ inp=input("Enter the string: ") while(len(inp)!=8): print('please enter 8 character string.') inp=input() k=''.join(format(ord(i), '08b') for i in inp) arr1=[] n=len(k) for i in range(n): if((i+1)%8!=0): arr1...
2108ed372835ddd910fda0e4a38d76a315b2af47
aninditacse/python
/Advance Communication and TCP_IP/35.py
1,791
3.78125
4
# -*- coding: utf-8 -*- """ Created on Mon Jun 28 22:25:11 2021 @author: Anindita """ test_str =input("Enter the string: ") block=[] sub_block=[] print("The original string is : " + str(test_str)) res = ''.join(format(ord(i), '08b') for i in test_str) print("The string after binary conversion ...
b305f78c3ef143808abc3d8a6d1094aa2934319d
aninditacse/python
/Soft Computing Code/gaussian.py
423
3.5
4
# -*- coding: utf-8 -*- """ Created on Sat Mar 13 16:27:49 2021 @author: Anindita """ import matplotlib.pyplot as plt import numpy as np #import math c=np.zeros((120), np.float) c1=np.zeros((120), np.float) mu=-1 sig=1 x_values=np.linspace(-3, 3, 120) c[0:120]=x_values[0:120] for x in range (120)...
7204b125733680baa4068de11dd85bff042b4309
aninditacse/python
/Advance Communication and TCP_IP/38.py
955
4
4
# -*- coding: utf-8 -*- """ Created on Mon Jun 28 16:45:35 2021 @author: Anindita """ test_str = input("Enter the string: ") print("The original string is : " + str(test_str)) res = ''.join(format(ord(i), '08b') for i in test_str) print("The string after binary conversion : " + str(res)) a=[]...
5abc3384cf0e290b702ab773bed4cdb5cf2d4cc8
xochitlmagm/REPWebCrawler
/user.py
5,283
3.828125
4
import tkinter as tk from tkinter import * # for the user interface from tkinter import ttk from tkinter.ttk import * def getparameters(): numbathrooms = int(numbath.get()) # getting the numbedrooms = int(numbed.get()) sqfoot = int(sq.get()) garage = garopt.get() garage_yn = "" backyard = ...
9c980a31b2b6cec61ef7addd7b1cc26dc3061433
PaiZuZe/MAC0460-machineLearning
/FirstAssignment/util.py
2,758
3.53125
4
import numpy as np import matplotlib.pyplot as plt def get_hausing_prices_data(N, verbose=True): """ Generates artificial linear data, where x = square meter, y = house price :param N: data set size :type N: int :param verbose: param to control print :type verbose: bool :return: desig...
f4c811a053d380586a209c920ac5a42a6376986e
DiyazY/datascience-study
/src/statistic/median.py
240
3.71875
4
def median(v): n=len(v) sorted_v=sorted(v) midpoint=n//2 if n%2==1: return sorted_v[midpoint] else: hi = midpoint lo = midpoint - 1 return (sorted_v[lo]+sorted_v[hi])/2 x = [12,23,22,43,57,84,23,11,66,24] print(median(x))
c3d35fa46fe883a702731f4c1aa6de64129900ea
PnS2018/group_5_exercises
/session_03/conv-net-with-keras-layers-template.py
4,048
4.125
4
"""Convolutional Neural Network for Fashion MNIST Classification. Team #name """ from __future__ import print_function, absolute_import import numpy as np import matplotlib.pyplot as plt from keras.layers import Input, Dense, Conv2D, MaxPooling2D, Flatten, Activation from keras.models import Model from keras.utils i...
7058d157d515b1fd64ee97ce53a3cbd84e6f9dbf
MXProgrammingClub/Math-Calculator
/prism.py
141
3.671875
4
def prism(radius, sides, lenght, height): area = (sides/2)*lenght*radius volume = area*height print(volume) prism(4,4,3,6)
071f707bf4a9f95f07030120cadd5270bed4e42c
ChenshuXu/Computational-Photography
/pyramid blending/blending.py
14,508
3.765625
4
""" Pyramid Blending This file has a number of functions that you need to fill out in order to complete the assignment. Please write the appropriate code, following the instructions on which functions you may or may not use. References ---------- See the following papers, available on the course website under Reading...
fe5955e9dec3dc2c86ca2d54d32eac50dba312c3
Johnnywang92/python-learning
/Number_Guess.py
887
4
4
##This script is write for Number Guess from random import randint from time import sleep def get_user_guess(): guess = int(raw_input("Guess a number: ")) return guess def roll_dice(number_of_sides): first_roll = randint(1, number_of_sides) second_roll = randint(1,number_of_sides) max_val = number_of_side...
32bd679d8e406d283c0de3b9d70626e1f9bd6567
rhythmehta/Genetic-Regression-Algorithm
/Genetic-Regression-Algorithm.py
9,067
3.96875
4
#!/usr/bin/env python # coding: utf-8 # # Genetic Regression Algorithm # In[1]: ### Genetic algorithm to fit a regression line of the form y=ax+b to a 2-variable dataset #importing required libraries import random import numpy as np from scipy import stats import matplotlib.pyplot as plt import math #loading t...
6539173b858b23d1e0ce6daa4431edc7c0c8761b
svigstol/100-days-of-python
/days-in-a-month.py
1,522
4.21875
4
# 100 Days of Python # Day 10.2 - Days In A Month # Enter year and month as inputs. Then, display number of days in that month # for that year. # Sarah Vigstol # 5/31/21 def isLeap(year): """Determine whether or not a given year is a leap year.""" if year % 4 == 0: if year % 100 == 0: if ye...
02350014103279d5c3d072b18cae6a3e0798de75
teddyk251/alx-higher_level_programming-1
/0x07-python-test_driven_development/2-matrix_divided.py
1,289
4.28125
4
#!/usr/bin/python3 """ divides all elements of a matrix """ def matrix_divided(matrix, div): """ divides all elements of a matrix Args: matrix: matrix to be divided div: number used to divide Return: matrix with divided elements """ if not all(is...
5d6a27b7fc25c02bb89f28914bc06ebf5c02a8aa
teddyk251/alx-higher_level_programming-1
/0x0B-python-input_output/12-pascal_triangle.py
417
3.96875
4
#!/usr/bin/python3 """ 12-pascal_triangle: def pascal_triangle """ def pascal_triangle(n): """ returns a list of lists of integers reps Pascal's triangle of n Args: n(int): to be repped """ triangle = [] inner_list = [] if not n <= 0: for i in range(n):...
3f95ab07d6b1dd404717b11bd0fd62f3e0fcfb3b
teddyk251/alx-higher_level_programming-1
/0x07-python-test_driven_development/5-text_indentation.py
568
4.09375
4
#!/usr/bin/python3 """ prints text with 2 lines after '.', '?' and ':' """ def text_indentation(text): """ prints text with 2 lines after '.', '?' and ':' Args: text: the text to be printed """ if not isinstance(text, str): raise TypeError('text must be a string') i...
b534f3bbf8aea211bd8097005bb195248eae595f
teddyk251/alx-higher_level_programming-1
/0x03-python-data_structures/4-new_in_list.py
198
3.609375
4
#!/usr/bin/python3 def new_in_list(my_list, idx, element): if idx >= 0 and idx < len(my_list): output = my_list[:] output[idx] = element return output return my_list
d47a74b9c1cc77b6116a03627fb4fec88138651a
vincenttuan/Ntnu_202007
/d06/TreeViewDemo.py
811
3.734375
4
import tkinter from tkinter import ttk # 匯入資源 win = tkinter.Tk() tree = ttk.Treeview(win) #表格 tree["columns"]=("姓名", "年齡", "身高") tree.column("姓名", width=100) # 欄位 tree.column("年齡", width=100) tree.column("身高", width=100) tree.heading("姓名", text="姓名-name") # Title tree.heading("年齡", text="年齡-age") tree.heading("身高", t...
4e68ae4ee69d4a3b56ed286b3ca3e2d316173c08
vincenttuan/Ntnu_202007
/d02/Fibnoacci.py
157
3.8125
4
def f(n): if(n < 2): return n else: return f(n-1) + f(n-2) # 主程式(程式進入點) if __name__ == '__main__': print(f(6))
be5f1716464da66d81bec5a9eb25af892ae60640
vincenttuan/Ntnu_202007
/d03/WhileGame.py
464
3.546875
4
import random as r ans = r.randint(1, 99) min, max = 0, 100 while True: guess = int(input('請輸入數字 %d ~ %d : ' % (min, max))) # 1.確認所猜的數字是否合理 ? if not (guess > min and guess < max): print("輸入錯誤, 請重新輸入") continue # 2.確認是否有答對 ? if(guess < ans): min = guess elif(guess > ans):...
dc7ec3113307e63fac1df957299b3f0cb3ce3d5f
vincenttuan/Ntnu_202007
/d05/OO8.py
1,037
4.03125
4
class Human: name = '' age = 0 sex = '' def __init__(self, name, age, sex) -> None: self.name = name self.age = age self.sex = sex def __str__(self) -> str: return "%s age:%d sex=%s" % (self.name, self.age, self.sex) class Student(Human): number = 0 grade =...
86891e09872bb5558961ec57d2d5ad588c034e0a
vincenttuan/Ntnu_202007
/d01/Hello8.py
229
3.984375
4
# 互動式 BMI 計算機 h = float(input('請輸入身高(cm):')) # str -> float w = float(input('請輸入體重(kg):')) # str -> float print(h, w) print(type(h), type(w)) # 請問 BMI = ? h = h / 100 bmi = w / h**2 print(bmi)
2e57e29decc9fece94e664c07ca866ab7bf0b0f6
give333/UnivLic
/PIntegrado/Euler.prat37.py
786
3.5
4
def numero_primo(n): if n <= 1: return False elif n == 2: return True elif n % 2 == 0: return False else: d = 3 while d * d <= n: if n % d == 0: return False d += 2 return True def retirar_Esque...
1ea7a5a4ecb8d8a9326042803dc0b3f4d1062bfa
give333/UnivLic
/P1/pratica4.py
1,888
3.9375
4
#1 def numero_par(n): if n%2==0: return True else: return False #2 def um_algarismo(n): if len(str(n))==1: return True else: return False #3 def portas_logica(x,y,z): if x == ('and'): return (y and z) else: ...
c2fadfd5f22da90cde561bb03e44d80a483cb7fd
give333/UnivLic
/PIntegrado/Euler.prat53.py
433
3.671875
4
import time start = time.clock() def factorial(x): if x == 0: return 1 else: return x * factorial(x-1) def combination(n, r): return (factorial(n))/(factorial(r)*factorial(n-r)) count = 0 for i in range(2, 101): for j in range(2, i): if combination(i, j) > 1000000...
4b3df3fdf28d903d7d6c9d93ff645f6661067339
give333/UnivLic
/P1/prática5.py
650
3.6875
4
#1 def compara(x,y): if x>y: print (1) elif x==y: print (0) else: print (-1) #2 import math def hipotenusa(cateto1, cateto2): print ('O valor da hipotenusa é: ', (math.sqrt(round((cateto1**2)+cateto2**2)))) #5 def palindromo(s): if str(len(s[0]))==str(len(s[...
4cc2979eabf1f579c36a52e8cd028c11062ccf8f
huci12/python
/01.숫자맞추기게임/start.py
908
3.671875
4
import random import os def input_check(msg,casting=int): while True : try : user_input = casting(input("몇 일까요")) return user_input except: continue os.system("cls") chance = 10 count = 0 number = random.randint(1,99) print("1부터 99까지의 숫자를 10번 안에 맞추어 주세요.") ...
eced02bdcb0137885e64b25b26ed00e36325c349
kevingabayan/216-python-oop
/KnightErrant.py
6,707
3.703125
4
from Fighter import Fighter from Warrior import Warrior import random class KnightErrant(Warrior): """This is a class that defines a Knight Errant. Attributes: name(str): The name of the Knight. age(int): The age of the Knight. wealth(int): The wealth of the...
86996b35143bdc91bacce179d78473fbbffe3231
ElenaKv/otus-qa-course
/test_tuples.py
296
3.828125
4
""" Проверить, что обе переменных ссылаются на один и тот же объект Вывести результат на печать """ def test_tuples(tuples): print(id(tuples[0]), id(tuples[1])) assert id(tuples[0]) == id(tuples[1])
78b177e4ace3f7e3508a4eab668cbcd97b15217e
nakashi120/PythonLectureKame
/oop/inheritance.py
356
3.890625
4
class Animal: def __init__(self, name): self.name = name print('Animal init is called') def breath(self): print(f"{self.name} is breathing.") class Dog(Animal): def __init__(self, name): super().__init__(name=name) print("Dog init is called") pochi = Dog("pochi...
ddb1d7ac32be95b0d8acce4268bfaaff68a62cd2
nakashi120/PythonLectureKame
/basic/dictionary_challenge.py
725
3.859375
4
# while challenge問題 age = int(input("何歳ですか?:")) casino_age = 18 game_dict = { "1": "ルーレット", "2": "ブラックジャック", "3": "ポーカー", } if age >= casino_age: while True: print('プレイするゲームを選択してください') for num, game_name in game_dict.items(): print(f"{num}: {game_name}") game = input...
978c28bee7b92224cd284c2bb9259b7f880f9b9e
nakashi120/PythonLectureKame
/basic/while.py
416
3.765625
4
# whileループ # count = 0 # while count < 10: # print(count) # count += 1 # brakeとcontinue while True: age = int(input("あなたは何歳ですか?:")) if not 0 <= age < 120: print("入力された値は正しくありません。") continue else: print(f"あなたは{age}歳です。") # print("あたなは{}歳です。".format(age)) brea...
96e21cd4e506e878aee23b56c0b0ce4f6acf5ec4
nakashi120/PythonLectureKame
/basic/enumerate.py
166
4.03125
4
fruits = ['apple', 'peach', 'grapes', 'banana'] # for idx, fruit in enumerate(fruits): # print(idx) # print(fruit) for x in enumerate(fruits): print(x)
a0384b2fad92d24ceabe9d0d3ac1306091d60455
nakashi120/PythonLectureKame
/basic/if_challenge.py
277
3.671875
4
balance = 1000 withdraw = 10000 withdrawal_limit = 1000000 if withdraw >= withdrawal_limit: print(f"Maximum withdraw is {withdrawal_limit}") elif balance >= withdraw: balance -= withdraw print(f"Your balance is {balance}") else: print("You don't have money")
a4b17d50fcc0e1c5ff7bc85f4315217397529ea9
nakashi120/PythonLectureKame
/basic/dictionary_func.py
535
4.1875
4
fruits_colors = {'apple': 'red', 'lemon': 'yellow', 'grapes': 'purple'} if 'peach' in fruits_colors: print(fruits_colors['peach']) else: print('the key is not found') # .get(): dictionaryから値を取得する→なくてもエラーにならない # fruits_colors.get('peach', 'nothing') fruit = input("フルーツの名前を指定してください:") print(fruits_colors.get(fr...
c50d56c52c0a4b7c106abf365dccf609029e4792
nakashi120/PythonLectureKame
/basic/if_non.py
216
4.125
4
# if文でのNoneの取り扱い a = None # 「なにも値が入っていない」が入っている # if a is None: # print("a is None!") # else: # print("a has value!") if not a: print("a is None")
efffb79ef2ec7c6b3d7cb28d6189cfff48739de9
adilshah1994/ics-work
/pythonbasics/day3.py
3,391
3.828125
4
# Scripts and Libraries # 1 # 2 # 3 # Sets and Dictionaries # 1 a = set([0, 1, 2, 3, 4, 5]) b = set([2, 4, 6, 8]) print a.union(b) print a.intersection(b) # 2 band = ["mel", "geri", "victoria", "mel", "emma"] counts = {} for name in band: if name not in counts: counts[name] = 1 else: ...
f985d9e6090dbad28ae05c31afd4732b85dab3dd
brit13-meet/MEET-YL1
/Lab4/number.py
395
3.671875
4
class Integer(object): def __init__(self, n, posneg): self.n = n self.posneg = posneg def display(self): print self.posneg + str(self.n) class NegatineInteger(Integer): def __init__(self, n) super(NegatineInteger, self) self.NegativeInteger = negint def negativeinteger(self): return "-" + self.n #i...
acfaa9854fbc804c54ca1a06ecd2308dc3c5da71
SongLepal/baekjoon.py
/14916.py
318
3.53125
4
from sys import stdin n = int(stdin.readline().rstrip()) if n == 1 or n == 3: print(-1) else: cnt = 0 cnt += n // 5 n %= 5 if n == 0: print(cnt) elif n % 2 == 0: cnt += n // 2 print(cnt) elif n % 2 != 0: n += 5 cnt += n // 2 - 1 print(cnt)
f56743b8bab7627d98b255c7d9005855342fa20c
loranne/codility
/missing_int.py
1,074
3.703125
4
def solution(A): # write your code in Python 3.6 """Takes in array (list) of ints of len N, returns smallest int that does not appear in A""" small_int = 1 sorted_a = sorted(A) for x in sorted_a: if x == small_int: small_int += 1 elif x < small_int: ...
758b8709a3d0133fa00beb506b662cb00bd51129
rkgitvinay/python-basic-tutorials
/3-control_flow.py
714
4.21875
4
""" Control Flow Statements """ """ uses an expression to evaluate whether a statement is True or False. If it is True, it executes what is inside the “if” statement. """ """ If Statement """ if True: print("Hello This is if statement!") """ Output: Hello This is if statement! """ if 5 > 2: print("5 is greate...
56276051a0eadce4e374d97c93323260b8ddfce4
DCR10/Diccionario
/classes/MyGUI.py
6,213
3.546875
4
from tkinter import * from tkinterhtml import HtmlFrame from tkinter import messagebox from tkinter import font #to be able to underline label import math from classes.RAE import * class MyGUI: def __init__(self,mywindow,titulo,size='850x860',icon='',bg='#CCCCCC'): # This method create a Window s...
498b87a46df4d10cf82e2134a44cb71b236072bf
ybettan/ElectricalLabs
/electrical_lab_3/aws_experiment/part2/preliminary/q2.py
104
3.75
4
name_str = "My fist name is {} and my last name is {} !!!".format("Yonathan", "Bettan") print name_str
06e0b06b985e0ac48cfe3ecd6c1ca1de69334424
ybettan/ElectricalLabs
/electrical_lab_3/aws_experiment/part2/preliminary/q4.py
279
4.3125
4
grades = {"python": 99, "java": 90, "c": 90} grades_list = [x for _, x in grades.items()] max_grade = max(grades_list) min_grade = min(grades_list) print "My lowest grade this semester was {}".format(min_grade) print "My highest grade this semester was {}".format(max_grade)
2ae1805c30e1cd239eb3ad1884f6f351aaaaa5e6
EvanJAR/Karaoke_Homework
/tests/song_tests.py
385
3.53125
4
import unittest from src_code.song import Song class TestSong(unittest.TestCase): def setUp(self): self.song = Song("Hit Me Baby One More Time", "Britney Spears") def test_song_has_name(self): self.assertEqual("Hit Me Baby One More Time", self.song.name) def test_song_has_artist(se...
f2f381a05ed82787ebd55a5d7c930892bf56b61a
claudiaalozano/Warm-up
/ejercicio 8.py
459
4
4
bitcoin_amount= float(input("Introduzca su cantidad de Bitcoin que presenta: ")) bitcoin_value_euros= 25000 def bitcoin_to_euros(bitcoin_amount, bitcoin_value_euros): euros_value= bitcoin_amount * bitcoin_value_euros return euros_value euros_value= bitcoin_to_euros(bitcoin_amount, bitcoin_value_euros) if euros...
6df5441321d2cf2d1a266b064ed6f2b6a66a7e4b
Poelsa/advent_of_code_2016
/3/3_2.py
708
3.609375
4
def isValidTriangle(nums): maxS = max(nums[0], max(nums[1], nums[2])) nums.remove(maxS) if maxS < nums[0] + nums[1]: return 1 else: return 0 #read input list f = open("3_input.txt") nrOfCorrectTriangles = 0 all = f.read() all = all.splitlines() for i in range(0, len(all), 3): row...
20a2f327a53961475e8835925ef269f9b8efa9ac
emushtaq/ds-lib
/ranjith_assignment.py
4,732
4.0625
4
import sys import re class Expression(): ALLOWED_OPERATOR = ['+', '-', '*', '/'] PARANTHESIS = ['(', ')'] PRECEDENCE = ['*', '/', '+', '-'] def is_existing_greater_precedence(self, token): top = self.operator_stack[-1] if (top in self.PARANTHESIS or token in self.PARANTHESIS)...
a74fe3c7b113669363c646b5837b3f7f56111f0e
Nduwal3/python-Basics
/function-Assignments/soln8.py
445
4.0625
4
""" Write a Python function that takes a list and returns a new list with unique elements of the first list. Sample List : [1,2,3,3,3,3,4,5] Unique List : [1, 2, 3, 4, 5] """ def remove_duplicates(input_list): unique_num_list = [] for num in input_list: if num not in unique_num_list: un...
2d11b7b1d939f6be364dc2394728fe2a21b99e95
Nduwal3/python-Basics
/function-Assignments/soln16.py
377
4.125
4
""" Write a Python program to square and cube every number in a given list of integers using Lambda. """ def calc_square_and_cube(input_list): square_list = map(lambda num: num * num, input_list) cube_list = map(lambda num: num ** 3, input_list) print(list(square_list)) print(list(cube_list)) sample...
f4fd513b8f8706e0339d7da3284b5f22364b5d04
Nduwal3/python-Basics
/soln43.py
374
4.25
4
""" Write a Python program to remove an item from a tuple. """ # since python tuples are immutable we cannot append or remove item from a tuple. # but we can achive it by converting the tuple into a list and again converting the list back to a tuple my_tuple = ('ram', 37, "ram@r.com") my_list = list(my_tuple) my_l...
345edbeac2503084fbbff2517bdab5db2fe1437a
Nduwal3/python-Basics
/soln6.py
1,187
3.984375
4
""" Write a Python program to find the first appearance of the substring 'not' and 'poor' from a given string, if 'not' follows the 'poor', replace the whole 'not'...'poor' substring with 'good'. Return the resulting string. Sample String : 'The lyrics is not that poor!' 'The lyrics is poor!' Expected Result : 'Th...
10047fa0561ecf373381ce8abed48587402952b3
Nduwal3/python-Basics
/function-Assignments/soln7.py
825
4.21875
4
""" Write a Python function that accepts a string and calculate the number of upper case letters and lower case letters. Sample String : 'The quick Brow Fox' Expected Output : No. of Upper case characters : 3 No. of Lower case Characters : 12 """ def count_string_lower_and_upper_case(input_string): count_up...
4af30bc0c5fa913415ad507c23232f86a20fad8a
Nduwal3/python-Basics
/function-Assignments/soln9.py
591
4.15625
4
""" Write a Python function that takes a number as a parameter and check the number is prime or not. Note : A prime number (or a prime) is a natural number greater than 1 and that has no positive divisors other than 1 and itself. """ def check_prime(num): is_prime = False if num > 1: for i in range...
515a4847f1592a5d8329f075cf40506c63350f82
Nduwal3/python-Basics
/soln25.py
548
4.1875
4
""" Write a Python program to check whether all dictionaries in a list are empty or not. Sample list : [{},{},{}] Return value : True Sample list : [{1,2},{},{}] Return value : False """ def check_empty_dictionaries(sample_list): is_empty = False for item in sample_list: if item: is_...
f524aed9a2f5230d4e96c8d16eae5b84f19ba707
Nduwal3/python-Basics
/soln35.py
184
4.53125
5
""" Write a Python program to iterate over dictionaries using for loops. """ dict_1 = {1 : "one", 2 : "two", 3 :"three"} for key, value in dict_1.items(): print(key, ':' , value)
7658a89d46cb419b50002a6561c13f6c1662b349
Agile-Charities/python-specialization
/getting-started-with-python/function_ex.py
9,414
4.78125
5
""" Getting Started With Python - Functions This is a set of exercises to help you become more comfortable with writing functions in Python. It is not part of the Coursera course. It exists only as an optional supplement. To test your work as you progress, load this file into Python (IDLE or PyCharm) and use your fun...
50af82586c8f0e7e864d1537b5319db93ee8033f
sktalati/talatisk_GitHub_Sample
/ParsingClinicalFile_toCreateSampleAttributes/parsing_clinical3.py
1,024
3.578125
4
import argparse parser = argparse.ArgumentParser(description="This program parses the Clinical Excel File") ##add arguments to our parser which are the two files the first is the genebank file and the second is the output file name parser.add_argument('sample_attributes', type=file, help="sample_attributes_file") arg...
80150e7bd4b2b4575580577307001fadf8d2e703
gfeiden/DSETools
/star/binary.py
3,530
3.71875
4
# # from ..utils.dtype import checkTuple class Binary(object): def __init__(self, star1, star2, period=(None, None), Teff_diff = (None, None)): """ Instance of binary system from two star objects. Creates a binary star system from two single star objects that orbit w...