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
e7e9000953c85bd553a9275043102b8a4d1eae17
nghiadhd/classifier-builder
/sample_run/csv_writer.py
766
3.75
4
import argparse import csv import os def write(fileName, data): if fileName is None: print ('ERROR! Need csv file. Please add --file <path_to_csv>') exit(1) if os.path.isfile(fileName): fileEmpty = os.stat(fileName).st_size == 0 else: fileEmpty = True with open(fileName, "a") as csvFile: ...
1a8801f26fe7596188ad5ebe20a9bcd8384b3f3a
MahmoudHegazi/challenge-1MAC-
/challenge1.py
24,912
3.9375
4
#!/usr/bin/env python3 import random """File name: challenge.py How It Works: 0. this applaction depend on Path (every recomend has it's path and also new recommends) 1. The user will enter three inputs: age, gender and type of recommendation 2. The program sort the user based on their age into 3...
0844afed653ec7311aa6e269867e2723f131deca
atg-abhijay/Fujitsu_2019_Challenge
/EReport.py
1,374
4.34375
4
import pandas as pd def main(): """ main function that deals with the file input and running the program. """ df = pd.DataFrame() with open('employees.dat') as infile: """ 1. only reading the non-commented lines. 2. separating the record by ',' or ' ' into 3 ...
ee28490f31c3459f6bd2099ffb5fb20c31956c2a
patsonev/Python_Basics_Exam_Preparation
/football_results.py
451
3.6875
4
counter_wins = 0 counter_loses = 0 counter_drawns = 0 for i in range(0, 3): result = input() first = int(result[0]) second = int(result[2]) if first == second: counter_drawns += 1 elif first > second: counter_wins += 1 elif first < second: counter_loses += 1...
c82b4a17af5c477a711bfb98668e74f53f675da0
patsonev/Python_Basics_Exam_Preparation
/film_premiere.py
804
3.671875
4
projection = input() packet = input() count_tickets = int(input()) if projection == 'John Wick': if packet == 'Drink': price = 12 elif packet == 'Popcorn': price = 15 elif packet == 'Menu': price = 19 elif projection == 'Star Wars': if packet == 'Drink': pri...
4cc98cd1b15c607efa15a5c47ad3f51cab551b06
patsonev/Python_Basics_Exam_Preparation
/football_games.py
353
3.8125
4
count_w = 0 count_d = 0 count_l = 0 for i in range(3): result = input() if int(result[0]) > int(result[2]): count_w += 1 elif int(result[0]) < int(result[2]): count_l += 1 else: count_d += 1 print(f'Team won {count_w} games.') print(f'Team lost {count_l} games.') ...
c893f71922b1f5afe0c3309473b349764cd651b9
patsonev/Python_Basics_Exam_Preparation
/easter_trip_exam.py
806
3.921875
4
destination = input() date_reservation = input() count_nights = int(input()) if destination == "France": if date_reservation == "21-23": price = 30 elif date_reservation == "24-27": price = 35 elif date_reservation == "28-31": price = 40 elif destination == "Italy": ...
692efea5365e887af21271f924ec55e86d1b4aeb
patsonev/Python_Basics_Exam_Preparation
/spaceship.py
507
4
4
import math width = float(input()) length = float(input()) high = float(input()) mean_high = float(input()) volume_per_astronaut = 2 * 2 * (mean_high + 0.4) volume_spaceship = width * length * high count_rooms = volume_spaceship / volume_per_astronaut if 3 <= count_rooms <= 10: print(f'The spacec...
e26bfd5573bf8a5818efb3f8714c983272ae129e
patsonev/Python_Basics_Exam_Preparation
/bachelor_party.py
559
3.765625
4
money_for_singer = int(input()) command = input() counter_guests = 0 income = 0 while command != 'The restaurant is full': count_guests = int(command) counter_guests += count_guests if count_guests < 5: price = 100 else: price = 70 income += count_guests * price c...
d05c5c8998b0bfe35c67f2458deab7d10dea01b0
flaresky/stock
/hsi.py
1,338
3.5
4
import urllib2 import datetime import argparse month_str_map = { 1 : 'Jan', 2 : 'Feb', 3 : 'Mar', 4 : 'Apr', 5 : 'May', 6 : 'Jun', 7 : 'Jul', 8 : 'Aug', 9 : 'Sep', ...
866885d68775274358bf18d12eb6621e6748c742
hansen487/CS-UY1114
/Fall 2016/CS-UY 1114/HW/HW4/hc1941_hw4_q1b.py
220
3.953125
4
""" Name: Hansen Chen Section: EXB3 netID: hc1941 Description: Print first n number even numbers using for loops. """ pos_int=int(input("Please enter a positive integer: ")) for i in range(0,pos_int): print(2*(i+1))
3ea0870135e87fea3435772de28741f707ec096b
hansen487/CS-UY1114
/Fall 2016/CS-UY 1114/HW/HW6/hofai/q2.py
191
3.953125
4
string=input("Enter an odd length string: ") print("Middle character:",string[len(string)//2]) print("First half:",string[0:(len(string)//2)]) print("Second half:",string[len(string)//2+1::])
268b43b10c954c52885c643f3d588f066ddb27a1
hansen487/CS-UY1114
/Fall 2016/CS-UY 1114/HW/HW6/hc1941_hw6_q7.py
742
3.859375
4
# -*- coding: utf-8 -*- """ Created on Mon Oct 31 15:10:48 2016 @author: hansen487 """ def firstword(sentence): words=sentence.split() return words[0] def removefirst(sentence): words=sentence.split() removed="" for i in range(1, len(words)-1): removed+=words[i]+" " removed+=words[i+1...
6f889a082c5164813e00be638ce06c9d40977336
hansen487/CS-UY1114
/fall 2016/CS-uy 1114/Labs/Lab 8.py
2,656
3.71875
4
def prob1(): string=input("Please enter a string: ") print("Your string has: ") one=0 zero=0 for digit in string: if (digit=="0" and one!=0): print(one,"1's") zero+=1 one=0 elif (digit=="0"): zero+=1 if (digit=='1' and z...
02d453b80c142ad4b130fd5c3f9748a588e4c49d
hansen487/CS-UY1114
/Fall 2016/CS-UY 1114/HW/HW6/hc1941_hw6_q4.py
460
4.25
4
""" Name: Hansen Chen Section: EXB3 netID: hc1941 Description: Read and evaluate a mathematical expression. """ expression=input("Enter a mathematical expression: ") array=expression.split() operand1=int(array[0]) op=array[1] operand2=int(array[2]) output=0 if (op=='+'): output=operand1+operand2 elif (op=='-'): ...
586dbb201219d44ad086b8095f8424a2ad784dae
hansen487/CS-UY1114
/Fall 2016/CS-UY 1114/HW/HW7/hc1941_hw7_q3.py
409
3.921875
4
# -*- coding: utf-8 -*- """ Created on Sat Nov 5 00:11:08 2016 @author: hansen487 """ string=input("Please enter a string of lowercase letters: ") previous='`' decrease=False for letter in string: if (ord(letter)>ord(previous)): increase=True else: decrease=True previous=letter if decrea...
c3e6a8a88cce32769e8fe867b8e0c166255a8105
hansen487/CS-UY1114
/Fall 2016/CS-UY 1114/HW/HW6/hofai/q6.py
488
4.25
4
password=input("Enter a password: ") upper=0 lower=0 digit=0 special=0 for letter in password: if (letter.isdigit()==True): digit+=1 elif (letter.islower()==True): lower+=1 elif (letter.isupper()==True): upper+=1 elif (letter=='!' or letter=='@' or letter=='#' or letter=='$'): ...
d82eafc8998a0a3930ee2d868158da93fca0329b
hansen487/CS-UY1114
/Fall 2016/CS-UY 1114/HW/HW2/hc1941_hw2_q5.py
844
4.15625
4
""" Name: Hansen Chen Section: EXB3 netID: hc1941 Description: Calculates how long John and Bill have worked. """ john_days=int(input("Please enter the number of days John has worked: ")) john_hours=int(input("Please enter the number of hours John has worked: ")) john_minutes=int(input("Please enter the number of minu...
5d7fb44cfd022e6f96e7fc081b4c194ec943e44a
gravitytrope/pyladies-pandas
/wrangling/environment-canada/ecweather.py
4,266
3.609375
4
import numpy as np import pandas as pd import requests def download_hourly_raw(env_canada_id, year, month, savefile='test.csv', verbose=True): """Download csv file of hourly data for selected station, year, and month""" # URL endpoint and query parameters url_endpoint = 'http://climate.weather.gc.ca/c...
39778001872b1ae5dfb6c66e001efda60ddeaf6d
syasky/python
/day06/04_参数类型与参数传递.py
1,111
4.03125
4
# 不可更改的数据类型 str1='abc' num1=123 tuple1=1,2,3 #可更改的 list1=[1,2,3] list1[0]=10 dict1={'a':3,'b':4} dict1['b']=40 def funcA(x): x[-1]=1000 funcA(list1) print(list1) # 如果传 不可更改的数据 # funcA(str1) 会报错 # 可以在定义的时候顺便知名一下 参数的类型,传值的时候会方便不少 #def xxx(a:int,b:str,c:list) # 定义一个函数,返回 这个 年份 是不是 闰年 def ...
ea16fe23bb2dde089ed1a063dad25969cfa34a13
syasky/python
/day04/06_while循环.py
661
3.984375
4
# while 循环: ''' while 条件: dosthing ''' #使用if判断num<5 并输出num,每次num+=1 # num=1 # while(num<5): # print(num) # num += 1 # demo1: a=1,用while 输出20以内的奇数 a=1 while(a<=20): if a%2!=0: print(a) a+=1 #demo2: 输出100内3的倍数 b=1 while b<100: if b%3==0: print(b,end...
252e629263ab4295b2bb5cfaf34efd5998df2274
syasky/python
/day03/03_python元组-tuple.py
998
4.25
4
#tuple 不可更改的数据类型 #语法 xxx=(1,2,3) tuple1=(1,2,3) print(tuple1) #而且可以省略括号 tuple2=4,5,6 print(tuple2) #注意: 单元素的元组创建时要注意,加一个逗号 tuple3=('aa',) print(type(tuple3)) tuple4='bb', print(type(tuple4)) #元组可以放多种数据 tuple5=('a',1,True,None,[1,2,3],tuple4) print(tuple5) #元组可以多变量一次赋值 a,b,c=100,200,300 pr...
e943578942972a2d9502f03fb6d1da653c3a571f
utra/PongBot
/old/physics/trajectory.py
5,125
3.984375
4
''' This program computes the firing angle above the horizontal needed to hit a target a given distance away, subject to the constraint of firing speed. ''' import math import numpy as np from scipy.optimize import minimize import matplotlib.pyplot as plt import sys # Constants CUP_HEIGHT = 0.12 # metres DRAG_FORCE =...
333e2444f9e9156fcf3fe805d20252239a365df4
lindsaymarkward/cp1404_2018_2
/week_01/hello.py
423
3.9375
4
import math from random import randint print("Hello, world") # print(math.pi) # x = randint(1, 10) # print(x) # x += 1 # print(x) # number = int(input("Number: ")) # while number > 0: # print(number * number) # print() # # print("Thanks") # number = int(input("Number: ")) # # print("Done") # for cha...
a7e9f749651d491f1c84f088ea128cbeaf18d9a5
lindsaymarkward/cp1404_2018_2
/week_05/dictionaries.py
505
4.125
4
"""CP1404 2018-2 Week 05 Dictionaries demos.""" def main(): """Opening walk-through example.""" names = ["Bill", "Jane", "Sven"] ages = [21, 34, 56] print(find_oldest(names, ages)) def find_oldest(names, ages): """Find oldest in names/ages parallel lists.""" highest_age = -1 highest_age_...
919af0ea57c2fa82187a012d8a5ff4fe9635bb40
paiacademy202003/functions_and_classes_assignment
/c1answer.py
1,887
3.921875
4
class Cafe: def __init__(self, menu, stock, money = 0): self.menu = menu self.stock = stock self.money = money def add_menu_item(self, item, price): self.menu[item] = price def add_stock(self, newstock): for x in newstock: if x in self.stock: ...
c85ca6fbb98403af8a3e98c93a19d987924cc270
paiacademy202003/functions_and_classes_assignment
/class1.py
6,112
4.5
4
""" In this program, we are going to write a class that manages a cafe that sells products such as coffee and bagels to consumers. More specifically, we are going to track the menu of the cafe which will show the prices of each item, the stock of the cafe items which will list the quantity of each item currently in sto...
c4d91205e9b230fead6440c73f8622b9f7d88061
AgFeather/EOPL_Reading
/SchemePy.py
5,401
4.0625
4
#type defination SYMOBL = str # scheme symbol is implemented by python str NUMBER = (int, float) # scheme number is implemented by python int and float ATOM = (SYMOBL, NUMBER) # scheme atom is the basic conponent implemented by . LIST = list # scheme list is implemented by python list EXP = (ATOM, LIST) ...
b5a04628c4e30dcd4990d7dc3d4530f0f9878432
eFilipexCode/usp-coursera
/lista 2/fizzbuzz2.py
112
3.84375
4
number = int(input("Digite qualquer número: ")) if number % 5 == 0: print("Buzz") else: print(number)
b1e93dd9fd8667254cd9fef40591c20f9f292a0c
eFilipexCode/usp-coursera
/pratica/fatorial.py
181
4.0625
4
number = int(input("Digite um numero: ")) index = 0 produtoFinal = 1 while index < number: produtoFinal = produtoFinal * (index + 1) index = index + 1 print(produtoFinal)
001769d25c2cdcc22cba298afbbf1a4e5598922f
eFilipexCode/usp-coursera
/lista 2/fizzbuzz.py
111
4.0625
4
number = int(input("Digite qualquer número: ")) if number % 3 == 0: print("Fizz") else: print(number)
96df163a93ed47fc84ed50b65857d9efa23d69ab
lhmisho/Data-Structure---Python-3
/insertionSort.py
341
4.15625
4
def insertion_sort(L): n = len(L) for i in range(1, n): item = L[i] j = i - 1 while j >= 0 and L[j] > item: L[j+1] = L[j] j = j-1 L[j+1] = item if __name__=="__main__": L = [6,1,4,9,2] print("Before sort: ", L) insertion_sort(L) pri...
d0b18dd59833733b72f5ef43a9b3d53ea0d1d429
Abarna13/Floxus-Python-Bootcamp
/ASSIGNMENT 1/Inverted Pattern.py
278
4.21875
4
''' Write a python program to print the inverted pyramid? * * * * * * * * * * * * * * * ''' #Program rows = 5 for i in range(rows,0,-1): for j in range(0,rows-1): print(end="") for j in range(0,i): print("*",end= " ") print()
8efe3483566e026185da87b4a92eb7d651b6aff9
erikhernandezv/python
/file.py
527
3.875
4
"""Manejo de archivos en Python""" def createFile(): file = open('/home/erik/data.txt', 'w') file.close() def writeFile(): file = open('/home/erik/data.txt', 'a') file.write('Escribiendo en el archivo con Python..\n') file.write('Fin escritura.. \n') file.close() def readingFile(): ...
d9918e166dc1f669bed7f96b01cce30470f0a85a
nealsabin/CIT228
/Chapter5/hello_admin.py
599
4.21875
4
usernames = ["admin","nsabin","jbrown","arodgers","haaron"] print("------------Exercise 5-8------------") for name in usernames: if name == "admin": print("Hello, admin. Would you like to change any settings?") else: print(f"Hello, {name}. Hope you're well.") print("------------Exercise 5-9---...
5cb2c54b43328cacc5c64ec685e53ac14c048bd0
nealsabin/CIT228
/Chapter5/weekend.py
950
4.09375
4
import datetime weekDays = ("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday") now = datetime.date.today() dayOfWeek = now.weekday() today = weekDays[dayOfWeek] daysToWeekend = 6-dayOfWeek print("There are ", daysToWeekend-1, " days until the weekend.") quotePrinted = "false" for left in wee...
3e8de8edc40362601902ec2681f45845d010996c
nealsabin/CIT228
/Chapter11/city_functions.py
239
3.703125
4
#Hands on 1 #Exercise 11-1 def city_country(city,country,population=""): if population: combined = f"{city}, {country} - Population: {population}." else: combined = f"{city}, {country}." return combined.title()
91b9c22b31d14918d8ee636ec8d5b5a330e81590
nealsabin/CIT228
/Chapter8/album.py
1,292
4.0625
4
#Hands On #2 #Exercise 8-7 print("-----Exercise 8-7-----\n") def make_album(artist_name,album_name,number_songs=None): album = {'artist':artist_name, 'album':album_name} if number_songs: album['number_songs']=number_songs print(f"Artist: {artist_name}") print(f"Album: {album_name}") if n...
31d8a9230ed12e4d4cb35b2802a9c721c1d23d15
nealsabin/CIT228
/Chapter9/restaurant_inheritance.py
1,049
4.21875
4
#Hands on 2 #Exercise 9-2 print("\n----------------------------------------------------------") print("-----Exercise 9-6-----\n") class Restaurant: def __init__(self, restaurant_name, cuisine_type): self.restaurant_name = restaurant_name self.cuisine_type = cuisine_type self.number_served =...
1fb22d7aca20c533cab4f59c62e8d2a777f0aea8
HypenauticPulse/HypeCAS
/archive/Before May rewrite/polyutil/polyinput.py
401
3.75
4
def get_input(): equation = input("Enter the polynomials: ") variable = input("Enter the variable of the polynomials: ") return equation, variable def get_input_dual(): variable = input("Enter the variable of both polynomials: ") equation1 = input("Enter the first polynomials: ") equation2 = i...
d7a28215d072728eea616021ca34926a10414b52
kaz-yos/learning-to-program-with-python
/advanced.py
2,555
3.90625
4
### Advanced session ## OOP in Python ## Inheritance syntax class Template(ParentClassName): def __init__(self, arg1, arg2): self.arg1 = arg1 self.arg2 = arg2 def getArg1(self): return self.arg1 ## Parent class class Monster: counter = 0 # belongs to the class def __init__(sel...
a21face14661162dfce8c589a2cce569f236b07b
kaz-yos/learning-to-program-with-python
/2014-04-27.advanced.py
3,047
4.3125
4
### 2014-04-27 Learning to program in Python: Advanced class ### ### interactive shell print("Hello World!") ### ### types type(1) type(1.0) type(True) type("hello") ### ### Math ## division 3 / 2 3 // 2 ## increment n = 3 n += 1 n user_input = input("this is the prompt!") user_input ## Boolian conversion ...
4007236d9fa620e60028301202a63e39b0ae189a
ljl2018012793/2020_Python
/刘嘉龙2018012793/作业2(修饰方法调用).py
2,488
4.09375
4
# coding: utf-8 # @Author : Liujl # @FileName: 作业2(修饰方法调用).py # @Software: PyCharm import random import string def MainData (type, value, num, strlen=10): try: key = set() if type is float: while True: temp = iter(value) count = random.uniform...
b2c9eda40be587bdf58e5161a5ebca5fde248422
NealWhitlock/Sprint-Challenge--Data-Structures-Python
/names/names.py
1,676
3.6875
4
import time from binary_search_tree import BSTNode start_time = time.time() f = open('names_1.txt', 'r') names_1 = f.read().split("\n") # List containing 10000 names f.close() f = open('names_2.txt', 'r') names_2 = f.read().split("\n") # List containing 10000 names f.close() duplicates = [] # Return the list of ...
0463aade8cfdd4bfec71fefee0635f362a2b9aca
maniCitizen/-100DaysofCode
/Concepts/Python As A Calculator.py
300
4.09375
4
print(2+3) #addition print(9-8) #subtraction print(4*6) #multiplication print(8/4) #float division print(8//4) #floor division print(5/2) #float division print(5//2) #floor division print(2**3) #exponentiation print((8+2)*3) # Use of Brackets print(3%2) #Getting remainder only using Modulus
57a567e83ce135b84b03b2e6d5dd3c65b778d80d
maniCitizen/-100DaysofCode
/Concepts/Break Continue Pass.py
395
3.90625
4
av = 5 x = int(input("How many candies do you want ?")) i = 1 while i <= x: if i > av: print("Out of Stock") break print("Candy") i += 1 for i in range(1,101): if i%3 == 0 or i%5 ==0: continue print(i) print("Bye") for i in range(1, 101): ...
2182030049abf9bd8d360588470d71d675db9993
maniCitizen/-100DaysofCode
/W3Schools Exercises/List/Counter.py
220
3.609375
4
def counter(lst): count = 0 for i in lst: if len(i) >= 2: if i[0]==i[-1]: count += 1 return count result = counter(['abc', 'xyz', 'aba', '1221']) print(result)
153816f1af0fd866abec66bb65e23fb14a04fc19
maniCitizen/-100DaysofCode
/W3Schools Exercises/Strings/Replace string.py
418
3.953125
4
def replace_string(sentence): not_word = sentence.find("not") poor_word = sentence.find("poor") if not_word==-1 or poor_word==-1: result = sentence else: if not_word<poor_word: result = sentence[:not_word]+"good" return result result1 = replace_string("The lyrics i...
9e173d2b9daadb6c86cce403ee754400d2e315e8
maniCitizen/-100DaysofCode
/W3Schools Exercises/Strings/String manipulation.py
526
4
4
# My solution def add_string(text): length = len(text) if length <3: return text elif text[-3:]!="ing": return text+"ing" elif text[-3:]=="ing": return text+"ly" print(add_string("abc")) print(add_string("string")) #W3schools Solution def add_string(text): length...
fc463453ee7ac62c2555e6ad8b92252bac081787
mhawkins18790/laughing-spork
/Chapter Eight(b).py
1,069
4
4
def build_person(first_name, last_name, age=''): """Return a dictionary of information about a person.""" person = {'first': first_name, 'last': last_name} if age: person['age'] = age return person musician = build_person('jimi', 'hendrix', age=27) print(musician) def print_models(unprinted_...
302a770b676300061dbf30681a7d3e171cf9242e
mhawkins18790/laughing-spork
/Chapter Seven.py
653
4.09375
4
# message = input("Tell me something, and I will repeat it back to you") # print(message) prompt = "\nTell me something, and I will repeat it back to you:" prompt += "\nEnter 'quit' to end the program." # active = True # message = "" # while active: # message = input(prompt) # if message == 'quit': # ...
215f1992caee60ff1b229ad186281c31de30778d
zhangcc22277/LearnPython
/10-17/map11.py
898
3.53125
4
#coding =utf-8 #利用map和reduce编写一个str2float函数,把‘123.456’转换成浮点123.456!!!!!!!!!!!!!!!!!!!!!!! from functools import reduce def str2float(s): DIGITS = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9} # 取得小数点的位置 p = s.index('.') # 把小数点前后分成2个字符串 s1 = s[0:p] s2 = s[(p ...
356b95bee274fe725c147a3cd29e83f7e2b2bb57
zhangcc22277/LearnPython
/10-17/tiaoJian.py
505
3.90625
4
#coding =utf-8 #小明身高1.75,体重80.5 请根据BMI公式(体重处以身高的平方)帮小明计算他的BMI指数 #并根据BMI指数: # 低于18.5:过轻 # 18.5-25:正常 # 25-32:肥胖 # 高于32 :严重肥胖 height = 1.75 weight = 80.5 bmi = weight/(height*height) print(bmi) if bmi<18.5: print("过轻") elif bmi<25: print("正常") elif bmi<25: print("过重") elif bmi <32: print("肥胖") else: ...
d9a4b1d58268b72a7ef52ca130578746a80141d2
obi-wan-shinobi/Competitive-Coding
/Leet Code/Vertical Order Traversal of a Binary Tree/Solution.py
1,637
3.828125
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def verticalTraversal(self, root: TreeNode) -> List[List[int]]: # Initiate an empty dict that will s...
5e2463436e602ab6a8764adee0e48605f50a7241
Jay07/CP2404
/billCalc.py
252
4.125
4
print("Electricity Bill Estimator") Cost = float(input("Enter cents per kWh: ")) Usage = float(input("Enter daily use in kWh: ")) Period = float(input("Enter number of billing days: ")) Bill = (Cost*Usage*Period)/100 print("Estimated Bill: $", Bill)
13f685e678fb52d54b20d64068b0fdf1248d6b05
Amit-CBS/Machine-Learning-with-Python
/Day1/Assignment/Program4.py
399
3.765625
4
class Student: def __init__(self): self.name=input("Enter student name: ") #replace self with Student self.roll=eval(input("Enter roll number: ")) self.stream=input("Enter stream: ") def Show(self): print("Student- ", self.name) #replace self with Student print("Roll numb...
d6f2ce2b5e578ca702c9e6856b2235eecca7568b
Amit-CBS/Machine-Learning-with-Python
/Day6/P1234.py
1,441
3.84375
4
from tkinter import* from tkinter import messagebox as msg class MyText: def __init__(self, root): self.f=Frame(root, height=200, width=300) self.f.pack() self.b1=Button(self.f, text="Button1", width=15, height=2, activeforeground="red", command=self.buttonclick1) self.b1.grid(row=0,...
1f83b26725df66e1f210a043f80ca06462fc9f86
Amit-CBS/Machine-Learning-with-Python
/Day6/P3_Lable.py
837
3.78125
4
from tkinter import* from tkinter import messagebox as msg class MyButton: def __init__(self, root): self.f=Frame(root,height=200,width=300) self.f.pack() self.b1=Button(self.f, text="Text Button", width=15,height=2,activeforeground="red",command=self.buttonclick) self.b1.grid(row=0,...
bb0f5165adb9d05119ef5417646922da5049b668
afoix/advent-calendar-2020
/Day15/day15.py
1,564
4.09375
4
# Starting numbers input = [1,0,15,2,10,13] # lastSpokenAt is a map from each number to 'what the turn number was the last time this number was spoken' lastSpokenAt = {} # lastLastSpokenAt is a map from each number to 'what the turn number was the time before the last time this number was spoken' lastLastSpokenAt = {...
f2ff20b944b57773d7162a7d08ad63467f3dffed
afoix/advent-calendar-2020
/Day18/day18part2.py
1,431
3.5
4
import re sum = 0 parensTerm = re.compile(r'\(([^\(\)]+)\)') singleTerm = re.compile(r'(\d+)\s*$') additionTerm = re.compile(r'(\d+) \+ (\d+)') multiplicationTerm = re.compile(r'(\d+) \* (\d+)') def evaluate(line): parensMatch = parensTerm.search(line) while parensMatch is not None: line = line[:paren...
1835daec1c41386a2c22e77eb22364880896f2b7
mfrodrig/Weather-Forecast
/seven_day_forecast.py
2,355
3.734375
4
#!/usr/bin/env python # coding: utf-8 # In[25]: import requests import json from pprint import pprint # In[26]: api_key = "Enter API Key here from OpenWeatherMap" lat = input("please enter latitude") #"35.776" lon = input("please enter longitude") #"-78.6382" exclude = "minutely,hourly,alerts" units = "imperial"...
ba4ac84fb4452c2bb4beee8a5437641c8f7272c0
dantleech/code-kata-berlin-1
/python/example/example.py
143
3.515625
4
from typing import Dict, List def do_nothing(input: Dict[int, List[str]]) -> int: if not input: raise ValueError() return 42
ffe49cc44672683753127b9b95d991f4985b83f2
Adeajakaye/python-codes
/functionloop.py
320
3.953125
4
Temperature=[10,-20,-289,100] def celsius_to_fahrehient(celsius): fahrehient = celsius * 9/5 + 32 return fahrehient if c < -273.15: print("that temprature is impossible") else: fahrehient = celsius * 9/5 + 32 print(fahrehient) for t in Temperature: print(celsius_to_fahrehient(t))
3988d0fab1e75e9bd585ffe5cc4c5d0555f6a1ee
thompsondragon546/lockheed-cgc
/bitwise_xor_solver.py
584
3.515625
4
import sys import random import string arr = [106, 255, 184, 238, 0, 32, 77, 255, 37, 60, 23, 101, 47] compArr = [57, 180, 225, 195, 69, 108, 14, 182, 8, 11, 39, 87, 25] answer = "" #b r u t e f o r c e def find_match(x): global answer while 1 > 0: #all possible characters test_letter = random...
f32ce4b238825ac50ec91a8f8d99fdb394f97a98
Plain-ST/python_practice_55knock
/39.py
381
3.921875
4
""" 39. split 変数に文字列'C C++ // python java'を代入し,この文字列を空白で区切った後のリストを出力してください,また,同じことを'/'でも行い,出力してください. 期待する出力:['C', 'C++', '//', 'python', 'java'],['C C++ ', '', ' python java'] """ Str='C C++ // python java' print(Str.split(' '),Str.split('/'))
99b994a1a3993b055d5006f27eb6191cd3be22fc
Plain-ST/python_practice_55knock
/47.py
368
4
4
""" 47. 内包表記 変数にリスト[5,4,3,2,1]を代入し,要素と添字の値(先頭を0とする)を足し合わせた数値を要素に持つリストを新たに作成してください. 内包表記を使うと便利です. 期待する出力:[5,5,5,5,5] """ List=[5,4,3,2,1] AnsList=[idx + elem for idx,elem in enumerate(List)] print(AnsList)
c7dfa455c559c0e9c0379f03bd985908c6a3342f
Plain-ST/python_practice_55knock
/29.py
668
4.3125
4
""" 29. 辞書(キーの存在確認) 今,以下のように辞書が作成済みです. d = {'apple':10, 'grape':20, 'orange':30} この辞書に対して,'apple'というキーが存在するかを確認し,存在しなければ,'apple'というキーに対して-1という値を追加してください. また,同様のことを'pineapple'でも行なってください.その後,最終的な辞書を出力してください. 期待する出力:{'apple': 10, 'grape': 20, 'orange': 30, 'pineapple': -1} """ d = {'apple':10, 'grape':20, 'orange':30} ...
9a36f72f53a3266eaabd985ba38b08c7e24c3fab
Plain-ST/python_practice_55knock
/23.py
308
3.875
4
""" 23. リスト,if(存在確認) リスト[11,22,33,44,55]に,値44が存在するかどうかをifを用いて判定してください.存在すればTrue,そうでなければFalseを出力します. 期待する出力:True """ List=[11,22,33,44,55] print(True if 44 in List else False)
ad324cf610ba29790318738a17444f37985d08c3
Plain-ST/python_practice_55knock
/17.py
259
3.828125
4
""" 17. リスト(結合) 変数li1に[1,2,3]のリストを代入,変数li2に[4,5]のリストを代入し,2つのリストを結合して出力してください. 期待する出力:[1,2,3,4,5] """ list1,list2=[1,2,3],[4,5] print(list1+list2)
616edea2e2d529ec3f9960703c86f7d7e8f3e3a3
soulsetsunday/web-caesar
/caesar.py
511
3.75
4
def encrypt(text, rot): message = '' for c in text: message+= rotate_character(c, rot) return message def rotate_character(char, rot): lowlist = 'abcdefghijklmnopqrstuvwxyz' uplist = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' if not char.isalpha(): return char position = alphabet_position(char) if char.isupper(): ...
6a53ae73f3b7de1dc452cb6b48015323f2f18932
morales-gregorio/pinturillo
/maspalabras.py
959
3.65625
4
#!/usr/bin/python import sys import utils if __name__ == '__main__': argumentos = sys.argv if len(argumentos) == 1: print("Por favor, dame una lista de palabras a añadir") sys.exit(0) elif len(argumentos) > 2: print("Por favor, dame las listas de palabras de una en una") sy...
76fac8576e09ca2a3f6049f0a302ea5db9474307
ShamikG17/Data-Structure-Assignments
/Group_A/assgn1.py
3,822
4.40625
4
""" FDS Assignment 1 Group A Name: Shamik S Ghadge Roll no.: SECOA159 Problem Statement:In second year computer engineering class, group A student’s play cricket, group B students play badminton and group C students play football. Write a Pyth...
2b996f75e89d87b376e9e019d146cc7dde9d59ed
triton2997/Algorithms-submissions-MAQ
/Course 1- Divide and conquer, sorting and searching and randomized algorithms/Week 2/Programming_Assignment_Count_Inversions.py
1,212
3.8125
4
def sort_and_count_inversions(ip_list, left, right): if left < right: middle = int((left+right)/2) sort_and_count_inversions(ip_list, left, middle) sort_and_count_inversions(ip_list, middle+1, right) merge_and_count_split_inversions(ip_list, left, right, middle) elif left ==...
42c4caab27c4cdd3afc59c6270f372c6e388edb3
mvanneutigem/cs_theory_practice
/algorithms/quick_sort.py
1,936
4.40625
4
def quick_sort(arr, start=None, end=None): """Sort a list of integers in ascending order. This algorithm makes use of "partitioning", it recursively divides the array in groups based on a value selected from the array. Values below the selected value are on one side of it, the ones above it on the ...
1c7605d505ea2a2176883eaba72cfc04ff2fb582
knowledgewarrior/adventofcode
/2021/day1/day1-p1.py
1,590
4.40625
4
''' As the submarine drops below the surface of the ocean, it automatically performs a sonar sweep of the nearby sea floor. On a small screen, the sonar sweep report (your puzzle input) appears: each line is a measurement of the sea floor depth as the sweep looks further and further away from the submarine. For exampl...
70293531d1ece4ccb8284a3f191b7be897f46838
dharunsri/Python_Journey
/Seclection_Sort.py
460
4.0625
4
# Selection sort # it takes 1st value and compare with all other value. if it is greater than other value it swaps def sort(x): for i in range(len(n)-1): # outer loop - set min value as 0,1,2,... min = i for j in range(i,len(n)): # inner loop - compare all value with min ...
2c05503575eccf27161b3217d13da4027c91affb
dharunsri/Python_Journey
/Inheritance.py
738
4.3125
4
# Inheritance # Accessing another classes is calles inheritance class Songs: # Parent class / super class def name(self): print("People you know") def name2(self): print("Safe and sound") class selena(Songs): # Child class/ sub class - ...
845b35bfcce40a05e0fc8ce81a46df546f511974
dharunsri/Python_Journey
/Factorial.py
170
4.25
4
# Factorial of a number n = int(input("Enter the number for factorial: ")) def fact(n): f = 1 for i in range(1,n+1): f = f*i print(f) x = n fact(x)
aabb79dc9eb7d394bf9a87cd51d9dacde5eabf3e
dharunsri/Python_Journey
/Python - Swapping of 2 nums.py
1,286
4.3125
4
# Swapping of two numbers a = 10 # 1010 b = 20 # 10100 # Method 1 temp = a a = b b = temp print(" Swapping using a temporary variable is : " ,'\n',a, '\n',b) # Method 2 a = a+b # 10 + 20 = 30 b = a-b # 30 - 20 = 10 a = a-b # 30 - 10 = 20 pr...
e5dff4de1c0f459af7a12ae7aab5747f896e46da
dharunsri/Python_Journey
/for_loop.py
408
3.78125
4
# for loop lst = [200, "selena", 219.23] for i in lst: print(i) name = "Selena Gomez" for j in name: print(j) # printing and sum of n numbers sum = 0 for i in range(5): print(i) sum+=i print("Total ",sum) # in reverse order for j in range (25,10,-2): print(j) # printing perfect square between...
1fd727e98f7f66dd14778953f36b62fe8a39d582
dharunsri/Python_Journey
/Constructors_in_Inheritance.py
576
4.0625
4
# Constructors in inheritance class A: def __init__(self): print("In A init") def something(self): print("In Class A") class B: def __init__(self): print("In B init") def Something(self): print("In Class B") class C(A,B): # ...
e52ca9bb79e4aeaa12d97eb64f8e3a7beac21d16
MinGyeongTae/Python
/0907_리스트/0907_리스트/_0907_리스트.py
2,640
3.8125
4
data = ['a','b','c',['abcd','efg']] print(data[1]) print(data[-1][-1]) # 데이터가 들어갈때 데이터 타입이 결정됨. # 리스트 초기화가 필요할 땐 data = []로 해놓고 값을 변경시키거나 할 수 있음. b = [1,2,3] c = ['Life', 'is', 'too', 'short'] d = b*3 e = b+c print('b*3') print(d) print('b+c') print(e) G = ['a','b','c','d'] print(G) G[0]='greenjoa' print(G) G[1...
ddee0c8a7fac580afafb951b5439c87004884985
emilytran99/GWC_TA2018
/datavizstarter.py
1,249
3.953125
4
''' In this project, you will visualize the feelings and language used in a set of Tweets. This starter code loads the appropriate libraries and the Twitter data you'll need! ''' import json from textblob import TextBlob import matplotlib.pyplot as plt #TO DO: Get the JSON data #Create list for polarity polarityLi...
a38a86d454a1202bc3b471046d33a28e37eb1f40
alnmb/Big-Data-Academy
/dictionary2.py
206
4
4
word = input('Hi,\nPlease give me a word and I will count each letter occurrence in it: ') wordDict = {} for c in word.lower(): count = word.count(c) wordDict[c] = count print(wordDict)
2c8d2aab830a34b6ef6f04cffba78af566db4f65
alnmb/Big-Data-Academy
/perimetro.py
1,144
4.09375
4
def prompt(): while True: print("Hi!\nI will calculate the perimeter of a polygon\n") response = int(input("\nPlease press \n1 for triangle\n2 for square\n3 for quit\n")) try: if response == 1: perimeter("triangle") elif re...
2dd468406342dc6e8f767ba6d469613b19eed0ad
samanthamirae/Journey
/Python/OrderCostTracking.py
2,862
4.25
4
import sys totalOrders = 0 #tracks number of orders in the batch batchCost = 0 #tracks the total cost across all orders in this batch # our functions def orderprice(wA,wB,wC): #calculates the cost total of the order cTotal = 2.67 * wA + 1.49 * wB + 0.67 * wC if cTotal > 100: cTotal = cTota...
aaf2599254b30115f369825f90a1e003df790466
shirisha24/function
/main.py
189
3.734375
4
def add(a,b): c=a+b return c def sub(a,b): d=a-b return d def mul(a,b): e=a*b return e def main(): print(add(1,2)) print(sub(4,3)) print(mul(1,2)) main()
788e78bede5679bcb0f93f4642602520baead921
shirisha24/function
/global scope.py
372
4.1875
4
# global scope:-if we use global keyword,variable belongs to global scope(local) x="siri" def fun(): global x x="is a sensitive girl" fun() print("chinni",x) # works on(everyone) outside and inside(global) x=2 def fun(): global x x=x+x print(x) fun() print(x) # another example x=9 def fun() : ...
f18a56aab3c03460ab0157c9cb06509dedfd372f
shirisha24/function
/fun_split.py
300
3.859375
4
def break_into_words(sentence): a=sentence.split() return a sentence="navgurukul is an alternative to higher education reducing the barriers of current formal education system" print(break_into_words(sentence)) words="navgurukul is great" c=0 while c<len(words): print(words[c]) c=c+1
9332d185e61447e08fc1209f52ae41cecdc90132
mchoimis/Python-Practice
/classroom3.py
701
4.3125
4
print "This is the grade calculator." last = raw_input("Student's last name: ") first = raw_input("Student's first name: ") tests = [] test = 0 #Why test = 0 ? while True: test = input("Test grade: ") if test < 0: break tests.append(test) total = 0 ...
7fb16ee09b9eb2c283b6e6cd2b2cabab06396a58
mchoimis/Python-Practice
/20130813_2322_len-int_NOTWORKING.py
1,302
4.1875
4
""" input() takes values raw_input() takes strings """ # Asking names with 4-8 letters name = raw_input("Choose your username.: ") if len(name) < 4: print "Can you think of something longer?" if len(name) > 8: print "Uhh... our system doesn't like such a long name." else: print 'How are you, ', nam...
ced2693c2b98adf5b8b2b906a3dc2526b8c71aed
Jake-Duffy855/flood-it
/board.py
3,278
3.671875
4
import square as s import random class Board: possible_colors = [(255, 0, 0), (255, 128, 0), (255, 255, 0), (0, 255, 0), (0, 0, 255), (127, 0, 255)] def __init__(self, size=14, colors=6): self.solved = False self.moves = 0 self.size = size self.colors = colors self.squ...
edeac59dab1607c797c2bc2f87f793f1cf3c7fa9
comprog-cde-uinsa-2020/D2-Week4-volumekerucutdalamtabung
/kerucut dalam bola.py
1,246
3.640625
4
#funcion def kerucut(rk): return 1/3*22/7*rk**2*t def bola (r): return 4/3*22/7*r**3 if __name__ == "__main__": print("Menghitung Volume Kerucut dalam Bola \n") r = int(input("Masukkan jari-jari bola: ")) rk = int(input("Masukkan jari-jari alas kerucut: ")) t = int(input("Masukkan tinggi k...
85009ecac2bcdaeaf0b4ccf8cc715151574d28bd
rom4ikrom/Practical-session-5
/last4.py
417
4.25
4
import math print ("x^1 \t x^2 \t x^3") print ("----------------------") for num in range(1,6): for power1 in range(1,2): for power2 in range(2,3): for power3 in range(3,4): result1 = math.pow(num, power1) result2 = math.pow(num, power2) r...
52d0758ddc3ee65b0c82f0680e56f283829dfbf8
bsb01/programming
/0617/draw01.py
466
3.515625
4
import turtle as t t.shape('turtle') for i in range(4): t.pensize(5) t.penup() t.goto(0,0) t.pendown() t.color( 'black' ) t.circle(50) t.penup() t.goto(110,0) t.pendown() t.color( 'red' ) t.circle(50) t.penup() t.goto(-110,0) t.color( 'blue' ) t.pendown() t.circle(50) t.penup() t...
a5072eefade735b97cf7652a2f48fee2a5e629cf
idc4K/vol_infos
/main.py
584
3.59375
4
from module import * import os while True: menu() choix = int(input(">")) if choix == 1: main() print("\tAppuyer sur 0 pour continuer et 3 pour quitter") reponse = int(input(">")) if reponse == 3: break elif reponse == 0: os.system("cls") continue elif choix == 2: main2() print("\tA...
500bb4c1302ce52e9fd48fdf747cb16515b699ee
Tejas-Naik/Text-disappering-app
/main.py
1,902
3.546875
4
from tkinter import * from tkinter import messagebox TITLE_FONT = ('Aesthetic Violet', 40) LABEL_FONT = ('Manjari', 16) TEXT_FONT = ('Manjari', 12) WAIT_TIME = 5000 timer = None def clean_text(): text.delete('1.0', END) text.focus() start_timer() def start_timer(*_ignore): global t...
61928e29db0271e19955275659020331ab4d50ba
sstryjak/Project-Euler
/problem03.py
837
3.59375
4
# The prime factors of 13195 are 5, 7, 13 and 29. # What is the largest prime factor of the number 600851475143 ? prime_factors = list() def FindPrimeFactors(target_num, current_smallest_prime): # print(target_num) # print (target_num, current_smallest_prime) while (current_smallest_prime <= target_num): ...
48de00dd42f21168199ece2781044fe936f027de
willassad/ram
/syntaxtrees/expressions.py
3,454
3.96875
4
""" Overview and Description ======================== This Python module contains expression subclasses. Copyright and Usage Information =============================== All forms of distribution of this code, whether as given or with any changes, are expressly prohibited. This file is Copyright (c) 2021 Will Assad, Za...
f91a713fff27f167f0c6e9924a2f8b39b5d99cd3
Manuferu/pands-problems
/collatz.py
919
4.40625
4
# Manuel Fernandez #program that asks the user to input any positive integer and outputs the successive values of the following calculation. # At each step calculate the next value by taking the current value and, if it is even, divide it by two, but if it is odd, # multiply it by three and add one. Have the program...