blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
0de86afe526b95b606992bb17a0a8f783cda1970 | luisfelipeguevaraa/datacademy_platzi | /Curso basico de Python/Retos/reto1_area_triangulo.py | 550 | 3.875 | 4 | ## ################################
## RETO 1 - AREA DE UN TRIANGULO
## ################################
def run():
#Ingreso de datos
print("-- Calculo del area de un triangulo")
base = input("ingrese la base: ")
assert base.isnumeric(), "Base debe ser un numero"
altura = input("ingrese la altura: "... |
14f9345c477d78e25df2c896a266542a6677382b | lachlanpearse-mclaren/NovemberWorkshop | /calculator.py | 528 | 3.6875 | 4 | import sys
if len(sys.argv) != 4:
print('You must provide 3 parameters')
else:
x = sys.argv[2]
y = sys.argv[3]
if sys.argv[1] == '+':
z = int(x) + int(y)
elif sys.argv[1] == '-':
z = int(x) - int(y)
elif sys.argv[1] == 'x':
z = int(x) * int(y)
elif sys.argv[1] == '... |
95f777cadde6812bb8be185374256e9f3fa32a60 | greengatz/PracticeProblems | /leetcode/50_pow.py | 596 | 3.703125 | 4 | # I did this one because i was curious what the actual problem was
# the answer is that a simple iterative approach wasn't fast enough
class Solution(object):
def myPow(self, x, n):
"""
:type x: float
:type n: int
:rtype: float
"""
if (n == 0):
... |
333eab854867a8439f4fee8c73fd4b8f977c45cf | clubofcodes/python_codes | /Ass 1.3/CountWordsChar.py | 429 | 4.03125 | 4 | fname = input("Enter file name : ")
fh = open(f"F:\\uni\RKU\\5th Sem\Python Programming II - CE523\ASS Py Files\{fname}")
number_of_words = 0
number_of_characters = 0
for line in fh:
line = line.strip("\n")
words = line.split()
number_of_words += len(words)
number_of_characters += len(line)
fh.close()
... |
ff24910c2fbc3df417e4ab029bd78bed3d52c535 | clubofcodes/python_codes | /Ass 3.1 Numpy/Matrix_3x3.py | 285 | 4.125 | 4 | import sys
import numpy as np
# Initialize matrix
lst = []
print("Enter the value row-wise : ")
# For user input
for i in range(0,9):
lst.append(int(input()))
def matrix(lst):
matrix = np.array(lst).reshape(3,3)
return matrix
print(matrix(lst))
dim = matrix(lst)
|
5374ed7477e67bae1635917441ca27e278deff5a | clubofcodes/python_codes | /Unit - 2 Mini Project Ass/connect.py | 1,412 | 3.984375 | 4 | import sqlite3
class myconnect:
def __init__(self):
#4
self.connection = sqlite3.connect("emp.db")
#5
try:
self.connection.execute('''create table if not exists employee(
emp_name text,
email t... |
c35a3528ec77f609092d0a8e3d68ccf8e5514d11 | clubofcodes/python_codes | /Ass 1.1/StrongNumber.py | 607 | 4.15625 | 4 | def factorial(number):
if(number==0 or number==1):
fact = 1
else:
fact=number*factorial(number-1)
return fact
def strong_number(list):
new_list = []
for x in list:
temp = x
sum = 0
while(temp):
rem = temp%10
sum += factorial(rem)
... |
f2710b5ea367894dde897d5bdc888f508d349666 | clubofcodes/python_codes | /Ass 1.2/SumOfMultiples_3&5.py | 238 | 4.1875 | 4 | def sumOfMul(limit):
sum=0
for n in range(0,limit+1):
if n%3==0 or n%5==0:
sum +=n
print("The sum of multiples of 3 & 5 till {} is {}.".format(limit,sum))
sumOfMul(int(input("Enter the limit : "))) |
08e85e889efee63cb9e3c4e917387fa21092659e | clubofcodes/python_codes | /Ass 3.9 pandas sort & row_col Operations/AddRemove_ColRows.py | 622 | 4.21875 | 4 | import pandas as pd
stud = {
'name': ['RJ', 'DJ', 'DS'],
'en_no.': ['18SOEIT11009', '19SOEIT13001', '18SOEIT11006'],
'email': ['rjagetiya780@rku.ac.in', 'dj3750@rku.ac.in', 'dshukla780@rku.ac.in']
}
# df = pd.DataFrame(stud)
# print(df.email)
df = pd.DataFrame(stud)
print("Default Dataframe :\n",df)
df... |
2b8aafb88ea4d0ef5aa9a6fe63e6aafb4d3ef62f | JamesMudidi/bst | /bst.py | 387 | 3.5 | 4 | import node
import utils
root = node.Node(201, node.Node(100, node.Node(20, None, None), node.Node(110, None, None)), node.Node(300, node.Node(205, None, None), node.Node(305, None, None)))
n = utils.find(root, 205)
if n == None:
print("205 not found")
else:
print("205 found!")
n = utils.find(root, 206)
if n... |
081cc9a578c93dbba5af6316177df358d00a76fa | kmussar/Battleship_CodeAcademy | /Battleship_Project.py | 1,604 | 4.15625 | 4 | """ """
# Instructions for the game.
print("Hello!")
print("Welcome to Battleship! Your objective is to guess my ship's location on a 5x5 grid (starting at 0). My ship takes up only 1 space. You have 4 guesses. Your guesses will show up as X's on the board. Here is the board. Good luck! ")
# Import things and se... |
cfd0c747d5a66ee15a34a551293efa83e5d36c2e | GiantSweetroll/Computational-Mathematics | /assignment/finite_diff/finite_difference.py | 1,491 | 3.71875 | 4 | from numpy import *
from sympy import *
import sympy as sp
import matplotlib.pyplot as plt
def central_difference(function, x, h=1.0E-4):
return (function(x + h) - function(x - h)) / (2 * h)
def forward_difference(function, x, h=1.0E-4):
return (function(x + h) - function(x)) / (h)
def backward_difference(f... |
d60de073223afd11b9a3a3bac21480012449ce61 | GiantSweetroll/Computational-Mathematics | /final_exam/taylor_series_calculator.py | 1,512 | 4.125 | 4 | import sympy as sp
def calc_taylor_series(equation, xInit, a, n:int):
"""
Method to estimate a function using taylor series
Parameters:
equation: The equation f(x)
xInit: Initial value of x
a: Another value of x
n: number of derivatives
"""
#Variables and settings
x = sp.Sy... |
0da7721ec855074abfc024700db81e731235433a | alex75042/les5 | /les5_job3.py | 1,235 | 3.640625 | 4 | #3. Создать текстовый файл (не программно).
#Построчно записать фамилии сотрудников и
#величину их окладов (не менее 10 строк).
#Определить, кто из сотрудников имеет оклад менее
#20 тысяч, вывести фамилии этих сотрудников.
# Выполнить подсчёт средней величины дохода
# сотрудников.
#Пример файла:
#Иванов 2... |
66bc11570b722cdb960a84f1421462338ee9aa41 | mialskywalker/PythonAdvanced | /Comprehensions/Exercises/Matrix_Modification.py | 543 | 3.59375 | 4 | n = int(input())
matrix = [(list(map(int, input().split()))) for _ in range(n)]
while True:
data = input()
if data == 'END':
break
command, row, column, value = data.split()
row = int(row)
column = int(column)
value = int(value)
if 0 <= row < n and 0 <= column < n:
if co... |
c6a5565f3ab6e2f854884b697be5ac8acc42ea85 | mialskywalker/PythonAdvanced | /Tuples and Sets/Lab/Parking_Lot.py | 260 | 3.53125 | 4 | n = int(input())
a = set()
for _ in range(n):
command, number = input().split(', ')
if command == 'IN':
a.add(number)
else:
a.remove(number)
if len(a) == 0:
print('Parking Lot is Empty')
else:
for el in a:
print(el)
|
7b2d9e4c936ffcf1fc03a087e10912e1a2e332a3 | mialskywalker/PythonAdvanced | /Exam/feb_14_21/Problem_1.py | 1,908 | 3.75 | 4 | from collections import deque
firework_effects = deque([int(el) for el in input().split(', ')])
explosive_power = [int(el) for el in input().split(', ')]
palm_fireworks = 0
willow_fireworks = 0
crossette_fireworks = 0
is_perfect_show = False
while firework_effects and explosive_power:
current_effect = firework... |
983473dcc4459338db70678e4c58cb854779f83f | mialskywalker/PythonAdvanced | /Lists As Stacks And Queues/Exercises/Fast_Food.py | 406 | 3.703125 | 4 | from collections import deque
q = deque()
asd = False
food_quantity = int(input())
orders = input().split()
for el in orders:
q.append(int(el))
print(max(q))
while len(q) > 0:
if food_quantity >= q[0]:
food_quantity -= q.popleft()
else:
asd = True
break
if asd:
q = list(map... |
f4064e4a5d621198421773516c404167c538f9c1 | mialskywalker/PythonAdvanced | /Lists As Stacks And Queues/Lab/Supermarket.py | 290 | 3.5 | 4 | from collections import deque
q = deque()
while True:
command = input()
if command == 'Paid':
for i in range(len(q)):
print(q.popleft())
elif command == 'End':
print(f'{len(q)} people remaining.')
break
else:
q.append(command)
|
00e373a15167c6aa8fe73a9cad003c8b711d636c | mialskywalker/PythonAdvanced | /Lists As Stacks And Queues/Lab/Water_Dispenser.py | 592 | 3.75 | 4 | from collections import deque
water_quantity = int(input())
q = deque()
while True:
command = input()
if command == 'Start':
break
q.append(command)
while True:
command = input().split()
if command[0] == 'End':
print(f'{water_quantity} liters left')
break
elif command... |
07e583cc2d667960975592f42a50782196de99ee | RainZoneO2/Zookeeper | /Problems/Update a list/task.py | 159 | 3.703125 | 4 | numbers = [4, 1, 0, 3, 2, 5]
# put your python code here
index = 0
while index != len(numbers):
numbers[index] = index
index = index + 1
print(numbers) |
24e3ec85bb0010af3ead97b266405ce339063ea5 | santhosh137/pythonpractices.org | /5. List overlap.py | 865 | 3.609375 | 4 | a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
c=[]
#list_comp=[c.append(b[x]) if b[x]==(a[i] for i in range(len(a))) for x in range(len(b)) else pass]
#print (list_comp)
# for i in range(len(a)):
# for j in range(len(b)):
# if a[i]==b[j]:
# ... |
ad45af1d8587feaba0863891eef978ca5dced6ef | ynuosoft/PythonMLStudy | /ML-CCTALK-01/01BasicPython/04def.py | 288 | 3.59375 | 4 | # -*- coding: UTF-8 -*-
def def01(name,age):
return (name,age)
def def02(name,age):
print name
print age
return
# print def02(1,2)
def def04(arg1, **vartuple ):
for (key,value) in vartuple.items():
print (key,value)
return
def04("123",a=1,b="b",c=[1,2,3]) |
937adedd4fd19b57db433f7b6fd063f14debab31 | kathytbui/udacity-fsnd-capstone | /api/database/models.py | 3,972 | 3.515625 | 4 | import bleach
from sqlalchemy import Column, String, Integer, Float
import json
from api import db
class EmptyClass(object):
pass
class User(db.Model):
"""
User Model
"""
__tablename__ = 'users'
# Auto-incrementing, unique primary key
id = Column(Integer, primary_key=True)
# unique ... |
d9a28221185b464ac0cc1df9c0044b268d2ed8ee | SairahAmuthan/ics3u | /Python Exercises/if.py | 833 | 4 | 4 | # If and Else statements
desserts = ["ice cream", "chocolate", "apple crisp", "cookies"]
favourite_dessert = "chocolate"
for dessert in favourite_dessert:
if dessert == favourite_dessert:
print("%s is my favourite dessert" % dessert.title())
else:
print("I like %s a bit" % dessert)
print("5 =... |
8e5b7f0421206e65d3180e130e3de6ddb0932529 | travisrobinson/coursera-specializations | /data-structures-and-algorithms/algorithmic-toolbox/week-2/fibonacci_last_digit.py | 459 | 3.5625 | 4 | # Uses python3
def calc_fib(n):
fibList=[]
for i in range(n):
if i == 0:
fibList.append(0)
elif i == 1:
fibList.append(1)
else:
fibList.append((fibList[i-1] + fibList[i-2]) % 10)
if len(fibList) == 0:
return 0
elif l... |
bbeabbe57e84cf07392f7bd72640baf24028ee5a | vksh224/DRN_Project | /computeHarvesine.py | 1,011 | 4 | 4 | from math import radians, cos, sin, asin, sqrt, inf
def funHaversine(lon1, lat1, lon2, lat2):
"""
Calculate the great circle distance between two points
on the earth (specified in decimal degrees)
"""
#print("lon1: " + str(lon1) + " lat1: " + str(lat1) + " lon2: " + str(lon2) + " lat2: " + str(la... |
7f80cc09205b84ca47933f06e74aa6542ac6145c | ACM-BarcelonaTech/dissemination | /hour-of-code/2017/src/HourOfCode.py | 6,992 | 3.828125 | 4 | from __future__ import unicode_literals
# coding: utf-8
# # ACM Hour of code - Introducció a Python
# Output
# In[ ]:
print 'Hello, world!'
# Input, assignment
# In[ ]:
name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
# For loop, enumerate, print, lists
# In[ ]:
friends = ['john', 'pat', 'ga... |
b65ee8033673a7be6ef1ee7fda1ce6f058ff18fc | Deepaksinghmadan/Project-1-Data-Wranglings | /threading2.py | 911 | 3.78125 | 4 | import threading,time
def function(t,d,number):
while True:
time.sleep(d)
lock.acquire()
print("current thread name is %s" %t)
lock.release()
class Dummy(threading.Thread):
def __init__(self,threadname,delaytime):
threading.Thread.__init__(self)
self.threadname=threadname
self.n=n
self.d... |
5abc6bcf6358fc9d3bdf3f6c2b6ac04f83ce2094 | Deepaksinghmadan/Project-1-Data-Wranglings | /xmastree.py | 814 | 3.96875 | 4 | def pattern():
a= int(input("Enter number of rows: "))
b = a-3
for k in range(b,0,-1):
for f in range(0,5):
print(" ",end="")
for j in range(0,k):
print("*",end="")
for h in range(0, 2*(b-k)+1):
print(" ",end="")
print("\r")
c=a-2
for k in range(c,0,-1):
for f in range(0,2):
pr... |
1800f10c70f9ff716cae1cf731e1c0cb0b94ecf9 | fistorres/progII | /node.py | 2,773 | 3.78125 | 4 |
class Node(object):
def __init__(self,name):
"""
Requires: name is a string
"""
self.name = name
def getName(self):
return self.name
def __str__(self):
return self.name
def __repr__(self):
return self.name
class Edge(object):
def __init__(... |
ddc3be1b653ad3d96ecd0889338519998a73e3d5 | aker99/RaspiWirelessCar | /car.py | 1,297 | 3.625 | 4 | import RPi.GPIO as GPIO #Import Raspberry Pi GPIOlibrary
class Motion():
"""docstring for ClassName"""
def __init__(self):
print("contructor")
GPIO.setwarnings(False) # Ignore warning for now
GPIO.setmode(GPIO.BOARD) # Use physical pin numbering
GPIO.setup(31, GPIO.OUT, initial=GPIO.LOW)#right
GPIO.setup(3... |
2640262888e1742936052c709fc5d8c7faba17c4 | Marcin-Marcinek/Python | /script3.py | 242 | 3.875 | 4 | #!/usr/bin/env python3
while True:
password = input("Please enter password:")
if password != "hellothere":
print("Invalid Password")
continue
print("Access granted")
break
print("All the data that you wanted!") |
fcfc189d4137e8907f710e6790eb5f974eb17a6f | prasun-biswas/robot2link | /venv/Lib/site-packages/spatialmath/DualQuaternion.py | 10,645 | 4.125 | 4 | import numpy as np
from spatialmath import Quaternion, UnitQuaternion, SE3
from spatialmath import base
# TODO scalar multiplication
class DualQuaternion:
r"""
A dual number is an ordered pair :math:`\hat{a} = (a, b)` or written as
:math:`a + \epsilon b` where :math:`\epsilon^2 = 0`.
A dual quatern... |
71b636098603bac104c9f3732ba285000c02e882 | nanchanyoung/Crypto | /vocabulary.py | 420 | 3.609375 | 4 | #변수 선언
english_word = ''
korean_meaning = ''
#파일 저장
out_file = open('vocabulary.txt', 'w', encoding='UTF-8')
while english_word != 'q':
english_word = input('영어 단어를 입력하세요:')
if english_word == 'q':
break;
korean_meaning = input('한국어 뜻을 입력하세요:')
out_file.write("%s: %s\n" % (english_word, korea... |
0afaec6c5bc8d8b8fb1ce58099a9a17d749929a7 | undergraver/Interdisciplinary | /numbers/general_test.py | 2,187 | 3.75 | 4 | import number_generator
class GeneralTest():
def __init__(self,name,num_challenges,max_value):
self.name = name
self.num_challenges = num_challenges
self.max_value = max_value
def handle_question(self,num1,num2,prefix=''):
"""
This function handles the operation between... |
b8fd9de1828ab96a61feb5e2f2e4847b6a012d52 | YingleiZhang/PythonStudy | /61A/03.py | 1,284 | 4.1875 | 4 | #Operators
from operator import add, mul
print(2+3)
print(add(2,3))
print(2+3*4+5)
print(add(add(2,mul(3,4)),5))
print((2+3)*(4+5))
print(mul(add(2,3),add(4,5)))
#Division
print('\nDivision')
print(2015//10)
print(2015/10)
print(2015%10)
from operator import truediv, floordiv, mod
print(floordiv(2015, 10))
print(trued... |
00099fc9db0803f9af2f488207cff0656e4dee82 | jiaola/usaco | /bronze/2021_01/prob2/prob2.py | 539 | 3.703125 | 4 | import sys
def main():
odd = 0
even = 0
n = int(input())
nums = [int(i) for i in input().split()]
for n in nums:
if n % 2 == 0:
even += 1
else:
odd += 1
if even > odd:
ans = odd * 2 + 1
elif even == odd:
ans = odd * 2
else:
... |
f40165f96e91f0ba5367a0a821b190b1e77633a3 | jiaola/usaco | /ccc/2019_Junior/prob4.py | 299 | 3.59375 | 4 | s = input()
h = 0
v = 0
for i in s:
if i == 'H':
h += 1
else:
v += 1
h %= 2
v %= 2
if h == 1 and v == 1:
print("4 3")
print("2 1")
elif h == 1:
print("3 4")
print("1 2")
elif v == 1:
print("2 1")
print("4 3")
else:
print("1 2")
print("3 4")
|
c26664d6f19e8514f2299301c88fd0ee4626ebd6 | Vasile-Daniel/ITPT_Project_Python1 | /itpt_task5_assign grades/main_assign_grades.py | 3,698 | 4.25 | 4 | """
Task 5
Implement and test a program to assign grades to exam marks for a class of 15
students, using the following criteria:
more than 70% is an A
more than 60% is a B
over 50% is a C
more than 45% is a D
less than 45% is a fail
The program requires the highest possible score for an exam, each s... |
6f415c5310711dc82fe1134b4226a365013f546e | PythonClubBoston/Plamen_Hristov | /lecture_2/Задача: 4. Средна цена, както се прави в белите държави.py | 308 | 3.90625 | 4 | prices = []
averagePrice = 0.0
while True:
price = input('Please add price: ')
if(price == 'stop'):
for price in prices:
averagePrice += float(price)
averagePrice = averagePrice/len(prices)
print(averagePrice)
break
else:
prices.append(price)
|
7c93200b6842fbb87bebe5722c32f5e3b19ddb4a | PythonClubBoston/Plamen_Hristov | /lecture_2/Задача: 3.Инициали.py | 228 | 3.953125 | 4 | name = input('You first and last name with space, pls')
if (len(name) == 0):
name = input('First Name and Last Name, pls!!! ')
initials = ''
n2 = name.split(' ')
for name in n2:
initials += name[0] + '.'
print(initials) |
2be690257b410d2bd61edfe8a06b44022a1e7324 | PythonClubBoston/Plamen_Hristov | /lecture_4/takovata.py | 1,563 | 3.875 | 4 | """
1 - Модули
Python файл се нарича 'module'. Дефинираните в него функции, класове и променливи можете да използвате с import.
Ако имаме Python module utils_module.py в същата директория, както и програмата, която стартираме - program.py:
https://stackoverflow.com/questions/4383571/importing-files-from-different-fo... |
9804e090fc8a7706c772769c472b3707bcde3f0c | diogo1790/inphinity | /rest_client/GetRest.py | 1,970 | 3.703125 | 4 | import requests
import os
class GetRest(object):
"""
This class manage the get requests
:param function: url of the function in the API
:type function: string
"""
def __init__(self, function):
"""
Initialization of the class
:param url_base: receive the endpoint of... |
51c843ead250c4092455c48c6983de2d0e12375e | gvazquez1993/python | /loops1.py | 138 | 3.671875 | 4 | names = ["Alice", "Bob", "Charlie"]
for name in names:
print(name) #name is like (i) in js, for i in names: print(i) its the same
|
1140b940e4f3bcc866fe1abb5e0fa77cb601e7f4 | Rony109/python-gui-tkinter | /matrix animation.py | 1,081 | 3.65625 | 4 | from tkinter import *
import time
from random import randint
root = Tk()
root.title("MATRIX")
root.geometry("1000x500")
root.configure(bg="black")
label = Label(root,text="The Matrix",bg="#000000",fg="#09ff00",font=("Algerian",40))
label.pack()
canvas = Canvas(root,height=500,width=1000, highlightthickne... |
284bddf36b210e382809f9be75a7cb3b20ebffe7 | Sarlianth/python-problems | /02-date-time.py | 488 | 4.375 | 4 | # Simple python program to display current date and time.
# Author: Adrian Sypos
# Date: 21/09/2017
# Imports
import time;
# Creating variable localtime that returns a time-tuple with all nine items valid
localtime = time.localtime(time.time())
# Printing localtime unformatted
print ("Local current time :", localtim... |
d7f481260d04f1ce898dca46fcfca2d2c8939817 | z4tz/adventOfCode2018 | /day1.py | 541 | 3.515625 | 4 | from inputreader import aocinput
from itertools import cycle
def freqSum(frequencies):
return sum([frequency for frequency in frequencies])
def findRepeat(frequencies):
currentFreq = 0
used = set()
for frequency in cycle(frequencies):
used.add(currentFreq)
currentFreq += frequency
... |
6404a1b05271ec92e2b2b6811c65a31de6b50d20 | n1i2i1v/ml_hw | /bash_test/vselect.py | 533 | 3.515625 | 4 | from argparse import ArgumentParser
import pandas as pd
import numpy as np
def parse_args():
parser = ArgumentParser(description='Select the first one')
parser.add_argument('-c', type = int, help='chooses a column')
parser.add_argument('d', type=str, help='give a csv')
args = parser.parse_args()
r... |
66030e65925e66e1eb80da0bfc0a263c19fba6fb | n1i2i1v/ml_hw | /bash_test/vfunc.py | 657 | 3.609375 | 4 | from argparse import ArgumentParser
import pandas as pd
import numpy as np
import sys
def parse_args():
parser = ArgumentParser()
parser.add_argument('-f', nargs ='+')
args = vars(parser.parse_args())
return args
arg = parse_args()["f"][0]
for x in sys.stdin:
str_x = str(x[:5])
x_flt = float(str_x)... |
c1407032176b2b1c0ced8dab91adf8b4c6ce0f49 | JaniceLove/Biocomputing | /Biocomputing/Week8 Scripting REGEX/Lecture15_ORF.py | 560 | 3.703125 | 4 | #Regex ORF Challenge in Python
#10/11/17, MMD
#Load module
import re
#Open fasta file to read
InFile=open("R.mendax.1.fasta","r")
#Loop through open file
for Line in InFile:
#Remove end of line character
Line = Line.strip()
#Operate only on lines that do not include >, skips header lines
if ">" not i... |
a1c211833062e9dda062725840be198a3fdda366 | Hasso2007/test_pycharm | /pkg/Test.py | 79 | 3.65625 | 4 | a = 2
b = 3
sum = a + b
print(sum)
num1 = 3
num2 = 5
sum = num1+num2
print(sum) |
06573cdd63ffa43e19dd4944e5cd0ae0c3455a7c | jaford/thissrocks | /Python_Class/py3intro3day/EXAMPLES/getting_dict_values.py | 736 | 3.671875 | 4 | #!/usr/bin/env python
d1 = dict()
airports = {'IAD': 'Dulles', 'SEA': 'Seattle-Tacoma',
'RDU': 'Raleigh-Durham', 'LAX': 'Los Angeles'}
d2 = {}
d3 = dict(red=5, blue=10, yellow=1, brown=5, black=12)
pairs = [('Washington', 'Olympia'), ('Virginia', 'Richmond'),
('Oregon', 'Salem'), ('California',... |
a34de767527fbf43476476120b1e7265d837419e | jaford/thissrocks | /daily_code/hp_daily_code_8.5.py | 2,658 | 3.96875 | 4 | """
Boolean Practice
The python boolean logic is simply put to be true or false.
The digital equal is either 1 or 0. From these basic elements we can
build upon complex programs!
The Boolean operator (aka booleans) are a core data type. xw
"""
"""
Super simple udnerstanding of what the results of comparing two val... |
fd4d5ba20a91a0a3c1422b588e29845eb212d76f | jaford/thissrocks | /daily_code/hp_daily_code_8:2b.py | 1,832 | 4.5 | 4 | """
Classes!
I wanted to make a page where I can practice OOP. This topic is hard
for me and I want to get better! I will use this file as an example!
"""
import re
print('-----------Practice 1-----------')
"""
Bellow is our class (AKA BLUEPRINT) of Parrot. An object(instance) is a instantiation of a class. When
c... |
e4b435ff7b4a102a9f3577ac5d080d9b436da34e | jaford/thissrocks | /programs/shortScripts/python_quiz.py | 304 | 4.25 | 4 | # Print a characters from a string.
# Only print the even number index.
user_string = input('Enter a string here: ' + '\n')
print('Here is your string: {}'.format(user_string))
length = len(user_string)
print(length)
for i in range(0, length - 1, 2):
print('index {}'.format(user_string[i]))
|
18bd3832433a6623e22272a125fd76ef794dee9e | jaford/thissrocks | /jim_python_practice_programs/36.60_sum_natural_numbers.py | 222 | 4.28125 | 4 | #Write a program to find the sum of N natural numbers by creating a function.
def find_sum():
n = int(input('Enter a number: '))
sum = 0
for i in range(1,n+1):
sum = sum + i
print(sum)
find_sum() |
7c5123cc3a2a7790fd3b1c5c65d66d1d2037ccf7 | jaford/thissrocks | /Python_Class/py3intro3day/EXAMPLES/nested_sequences.py | 700 | 3.890625 | 4 | #!/usr/bin/env python
people = [
('Melinda', 'Gates', 'Gates Foundation'),
('Steve', 'Jobs', 'Apple'),
('Larry', 'Wall', 'Perl'),
('Paul', 'Allen', 'Microsoft'),
('Larry', 'Ellison', 'Oracle'),
('Bill', 'Gates', 'Microsoft'),
('Mark', 'Zuckerberg', 'Facebook'),
('Sergey', 'Brin', 'Googl... |
95abc4c7a8115492b412f97986dbac48e05eb1ee | jaford/thissrocks | /Python_Class/py3intro3day 2/ANSWERS/set_sieve.py | 356 | 3.8125 | 4 | #!/usr/bin/env python
import sys
if len(sys.argv) == 2:
limit = int(sys.argv[1])
else:
limit = 50
flags = set()
print(2, end=' ') # we know 2 is prime
for num in range(3, limit, 2): # only test odd numbers
if num not in flags:
print(num, end=' ')
for x in range(num, limi... |
1b395b14876c943b23f58cd199d379bdb51406e0 | jaford/thissrocks | /programs/scaleGenerator/functions/chords.py | 1,490 | 3.53125 | 4 | def chordsList(scale, key):
chordAppending = '\n'.join('{} {}'.format(scale, key) for scale, key in zip(scale, key))
return chordAppending
def findChords(scale, intervals, userScaleInput, chordsInKeys):
keySignatures = userScaleInput.lower()
while True:
if keySignatures == 'major' or keySigna... |
668f85f1aee66b5430c85c536236522b235d4075 | jaford/thissrocks | /programs/weather/functions/weatherData.py | 3,238 | 3.546875 | 4 | import asyncio
import python_weather
import time
async def getWeather(city):
# Noticed program will disconnect. Re-run program until a connection is sucure?
# declare the client. the measuring unit used defaults to the metric system (celcius, km/h, etc.)
async with python_weather.Client(unit=python_weather.IMPER... |
3fb9a6bae0586890835d36a9bb5e2da74a409c18 | jaford/thissrocks | /daily_code/JF_Daily_Code_9:29_Regex.py | 414 | 3.90625 | 4 | #This program is intended to practice with regex
import re
pattern = "[\dreg]"
string = "This is a test of regex. blah blah blah. let's see what what letters I can pull out of this. Oh wait," \
"letters and numbers 6465. This is regex"
#
# if re.search(pattern, string):
# print("Found a match!")
# ... |
0746ee65fd39e8ea194302cf8e2cb79b536785cc | jaford/thissrocks | /Python_Class/py3intro3day 2/EXAMPLES/print_examples.py | 487 | 3.90625 | 4 | #!/usr/bin/env python
print("Hello, world")
print("#------------------------")
print("Hello,", end=' ') # <1>
print("world")
print("#------------------------")
print("Hello,", end=' ')
print("world", end='!') # <2>
print("#------------------------")
x = "Hello"
y = "world"
print(x, y) # <3>
pri... |
d76d6fbe225be7ab69fed4625efd1282e5f612be | jaford/thissrocks | /daily_code/JF_Daily_Code_11:2.py | 552 | 4.1875 | 4 | # thisdict = {
# "brand": "Ford",
# "model": "Mustang",
# "year": 1964
# }
#
# thisdict_list = list(thisdict.items())
#
# print(thisdict_list[1:2:])
#taking input from the user
string = input("Enter a String : ")
result = '' #empty string
ch = input("Enter a Character : ")
for i in string: #iterating using for... |
cc04c934e37e3f9ba89d033578ee9216e75ff2cb | jaford/thissrocks | /jim_python_practice_programs/20.60_multiplication_table.py | 346 | 4.53125 | 5 | #Write a program that will print the multiplication table of a number based on user input
def multiplication_table():
n = int(input('Enter your number: '))
# use for loop and range() function to loop from 1 to 5
for i in range(1, 6):
# multiply user input n with each value of i and print it
print(n*... |
ae23044824a4d0fc082f0ba1d011ed09667f5f1e | jaford/thissrocks | /jim_python_practice_programs/30.60_perfect_square.py | 604 | 4.375 | 4 | # Write a program that will calculate if a number is a perfect square or not
# import math module
import math
def perfect_square():
number = int(input('Enter a number to see if it is a perfect square: '))
# use sqrt() to find the square root of the number
square_root = math.sqrt(number)
# get remai... |
413cc9cfdb3af1a5008b315bca1c59ae56dfbc77 | jaford/thissrocks | /programs/scaleGenerator/testScripts/programTest/nested_loop.py | 1,411 | 4.3125 | 4 | # This was a test to try have ways to exit out of a nested loop!
while True:
# Use a break catch that is set to false and once true it can help you break out of a nested loop!
breakFlag = False
while True:
while True:
userInput = input('Pick a number: ')
if userInput == '1':... |
4e6eeb63cf9dac83238066696f7b9d330300e958 | jaford/thissrocks | /Python_Class/py3intro3day 2/EXAMPLES/fmt_misc.py | 324 | 3.625 | 4 | #!/usr/bin/env python
'''Demonstrate misc formatting'''
big_number = 2303902390239
print("Big number: {:,d}".format(big_number)) # <1>
print()
value = 27
print("Binary: {:#010b}".format(value)) # <2>
print("Octal: {:#010o}".format(value)) # <3>
print("Hex: {:#010x}".format(value)) # <4>
print... |
d3dfbb2288e85021eff798190e6e364836f16c07 | jaford/thissrocks | /jim_python_practice_programs/14.60_days_of_week.py | 532 | 4.4375 | 4 | #Write a program that will print the days of the week based on user input
def days_of_week():
# get an input integer for num
num = int(input('Enter a number 1-7: '))
# print the day of the week based on num
if num == 1:
print('Monday')
if num == 2:
print('Tuesday')
if num == 3... |
95a8b07802b7382ba207d601cce0f6be31b7f11a | jaford/thissrocks | /programs/shortScripts/callingFuctionsTest/module1.py | 101 | 3.5 | 4 | def addition(x, y):
z = x + y
return z
def subtraction(x, y):
z = x - y
return z
|
950d9f24df41321a04fcf36aac22b89c4309af1c | jaford/thissrocks | /jim_python_practice_programs/32.60_check_equal.py | 404 | 4.03125 | 4 | # Replace ___ with your code
# get two integers from user
num1 = int(input())
num2 = int(input())
# create a function my_function that accepts are two arguments arg1 and arg2
def my_function(arg1, arg2):
# compare arg1 and arg2 to see if they are equal
if arg1 == arg2:
print('True')
else:
... |
b106796bf097a0ef9f17a86e4b91e4a861e4f213 | jaford/thissrocks | /programs/weather/testFiles/weatherApiPython.py | 2,710 | 3.5 | 4 | import python_weather
import asyncio
import os
from datetime import datetime
async def getweather():
# declare the client. the measuring unit used defaults to the metric system (celcius, km/h, etc.)
async with python_weather.Client(unit=python_weather.IMPERIAL) as client:
# async with python_weather.Client(unit=... |
7f0d422c6d96cb1b03f48164c92292c0078020f6 | jaford/thissrocks | /daily_code/hp_daily_code_8:25a.py | 579 | 3.90625 | 4 | """
Python Modules
Consider a python module to be like a code libary.
A file containing a set of functions you want to include in your application.
To create a module, make a new file and import the code like so bellow.
"""
# Import sys
# import sys
# # adding directory to the system path
# sys.path.append('/Volu... |
7c06d5dfbeded6f809e3fe1dec119715cc5d5329 | jaford/thissrocks | /daily_code/hp_daily_code_8:4a.py | 4,790 | 4.46875 | 4 | """
Dictionary Practice
Python dictionaries stores data in key:value pairs.
"""
import this
print('-----------Practice 1-----------')
thisdict = {
"brand" : "Ford",
"model" : "Mustang",
"year" : 1964
}
print(thisdict)
print('-----------Practice 2-----------')
thisdict = {
"brand" : "Ford",
"m... |
51b9e19b6e5008b8f7242a13b243434e686a3758 | jaford/thissrocks | /programs/shortScripts/projectExample/functions/module1.py | 401 | 3.875 | 4 | def addition(userNumber1, userNumber2):
result = userNumber1 + userNumber2
return result
def subtraction(userNumber1, userNumber2):
result = userNumber1 - userNumber2
return result
def multiply(userNumber1, userNumber2):
result = userNumber1 * userNumber2
return result
def divide(userN... |
4ece66485397f47e2051e10a863aeb4a726d68d8 | jaford/thissrocks | /daily_code/JF_Daily_Code_11:1.py | 548 | 4.4375 | 4 | print('Question 3: Write a code snippet to reverse a string.')
str = 'Reverse this string'
print(str[::-1])
print('Question 4: Write a code snippet to sort a list in Python.')
list_a = [2,3,5,4,3,7,8,9,0]
list_a.sort()
print(list_a)
print('Question 5: What is the difference between mutable and immutable?')
print('Ans... |
af79997c0f60458568226f454127e47eaf545168 | jaford/thissrocks | /Python_Class/py3intro3day 2/EXAMPLES/basic_sorting.py | 386 | 4.125 | 4 | #!/usr/bin/env python
"""Basic sorting example"""
fruits = ["pomegranate", "cherry", "apricot", "date", "Apple", "lemon", "Kiwi",
"ORANGE", "lime", "Watermelon", "guava", "papaya", "FIG", "pear", "banana",
"Tamarind", "persimmon", "elderberry", "peach", "BLUEberry", "lychee",
"grape"... |
bb7b537ebcf6c1e056d7e5b7b2efabfe4f945182 | jaford/thissrocks | /jim_python_practice_programs/8.60_average_of_three.py | 465 | 4.375 | 4 | #Write a program that will find the average of three numbers
def average_numbers():
# take three float input for number1, number2, number3 respectively
a = float(input('Enter the first number: '))
b = float(input('Enter the second number: '))
c = float(input('Enter the third number: '))
# find the average... |
203a9ae578008406049a91f4b34c36724a0322b9 | jaford/thissrocks | /Python_Class/py3intro3day/EXAMPLES/while_loop_examples.py | 402 | 4.03125 | 4 | #!/usr/bin/env python
print("Welcome to ticket sales\n")
while True: # <1>
raw_quantity = input("Enter quantity to purchase (or q to quit): ")
if raw_quantity == '':
continue # <2>
if raw_quantity.lower() == 'q':
print("goodbye!")
break # <3>
quantity = int(raw_quantity) #... |
857a01a11b60bf972ad6c5f97a045310f1bdcac2 | kapingafrancis/health-checks | /test_code.py | 188 | 3.875 | 4 | def max_num(x, y):
max = x if x > y else y
return max
def print_name_age(name, age):
print(name, 'is', age, 'years old')
print(max_num(24,89))
print_name_age('Francis', 42)
|
fc0aa8dc7c3c7a79aa946095d09efc70b748884b | ozgurhepsag/Graph-Centrality-Measures | /graph.py | 1,405 | 3.875 | 4 | import vertex as Vertex
class graph:
def __init__(self):
self.vertices = {}
def add_vertex(self, key):
if key not in self.vertices:
vertex = Vertex.vertex(key)
self.vertices[key] = vertex
def remove_vertex(self, key):
self.vertices.pop(key)
... |
6e411d7735126155557ce84a141ec9c3fb0990c0 | thxxx/computerVision | /Project1/task1/noise.py | 8,078 | 3.703125 | 4 | import numpy as np
import cv2
import math
def task1(src_img_path, clean_img_path, dst_img_path):
"""
This is main function for task 1.
It takes 3 arguments,
'src_img_path' is path for source image.
'clean_img_path' is path for clean image.
'dst_img_path' is path for output image, where your re... |
6b4974a49b0fb99a8ff7839ab166439948cc9ba7 | Chonticha-S/CED59-5902041620075 | /assignment3/practise.py | 192 | 3.53125 | 4 | my_list = [25, 25, 50]
print(sum(my_list))
my_tuple = (2, 3, 5, 6)
print(my_tuple)
set1 = {1, 5, 9, 12, 15, 18, 77, 88}
set2 = {3, 5, 7, 9, 12, 20, 77, 100}
print(set1.intersection(set2))
|
d27cf9fdc171b14ed0899164d342f8606377fa21 | grantnicholas/pancakeSort | /pancakesort.py | 1,160 | 4.1875 | 4 | from random import randrange
#Make a function to flip the passed array between the start and stop indices [inclusive]
#Actually a useful function outside this exercise.
def flip(a, start, stop):
b = a[start:stop+1];
b = b[::-1];
b = a[0:start]+b+a[stop+1:len(a)];
return b;
#Perform the pancake sort! Can only sor... |
711f01e356f59471bdf709676f87a0b6e0684963 | 1603073/python | /stack.py | 1,381 | 3.984375 | 4 | a = []
class Stack:
def __init__(self):
self.a = []
def push(self,item):
return self.a.append(item)
def size(self):
return len(self.a)
def is_empty(self):
if self.size() > 0:
return False
else:
return True
def ... |
862631f45fc8a57e2bbfd328743f3ee9eed8968c | DavidSilady/ZenGardenGenerative | /frick_chamber.py | 4,646 | 3.75 | 4 | import random
from copy import deepcopy
from math import floor
from typing import List
from monk import Instruction, Monk
def generate_random_indexes(width, height):
indexes = range(2 * (width + height))
indexes = [int(i) for i in indexes]
random.shuffle(indexes)
return indexes
def generate_random_strategy(num... |
bcfb4f8ea48383f74b8563b160d0c9fca7c3910e | heyfei7/hamlethero | /lumberjack.py | 5,756 | 3.5625 | 4 | #-------------------------------------------------------------------------------
# Name: LumberJack
# Purpose: Mini game where player uses arrows to fell a tree
# Author: Anya
# Created: 28/04/2015
#-------------------------------------------------------------------------------
#!/usr/bin/env python... |
1ec8bfb00fd1dbb693674154fe99e6823b336005 | pulkitmadaanit/food_site | /users/code.py | 298 | 4.28125 | 4 | # 1.l1=['John','Ram','Sham','John','John','Ram','Rahul'] find the most occuring name and how many times it occurs
l1=['John','Ram','Sham','John','John','Ram','Rahul']
def most_frequent(l1):
return max(set(l1), key = l1.count)
List = [2, 1, 2, 2, 1, 3]
print(most_frequent(l1))
print(key)
|
5906ddb13dbaab2885e476f9cf3cfdbfb1c8698d | anderson-duarte/Exemplos_de_Arquivos_e_Excessoes_Python | /Arquivos_e_Excessoes/Exemplos (7).py | 470 | 3.765625 | 4 | '''
Created on 27 de dez de 2019
@author: Valentina
'''
prosseguir = True
while prosseguir:
try:
numero = int(input("Primeiro numero. "))
numero1 = int(input("Segundo numero. "))
except ValueError:
print("Desculpe nao e possivel fazer o calculo utilizando algarismos alfabetico")
el... |
7c3d98d20b6fead2b1b06ec15bd5a9fb4e1df5ab | shashwatsehgal/ToLop | /scoreComputer.py | 1,010 | 3.5625 | 4 | # Class to compute suspician score of an an item.
import math
class ScoreComputer:
# TODO: Use an abstract class ScoreComputer with different speciailizations
# corresponding to different platforms (eBay, Craigslist, etc.).
def __init__(self, listPrice):
# TODO: Read these values from a config file... |
63ba705ff2edafc60c9534e27d29c256fc3d996b | RiflerRick/codemonk2017 | /NumberTheory/PermutationAgainThirdPartySol.py | 1,829 | 3.765625 | 4 | """
This is undoubtedly the best solution for this problem, it again uses proper math to solve the problem. It is observation actually. For instance consider the number 5, how do we get the answer for the number 5.
Our original solution was actually pretty close to the real solution. Only thing that was remaining was ... |
a33179d022e5f9d27130b962deb423a2110fd4dc | harryDr/leetcode-python- | /leetcode/107. 二叉树的层次遍历 II.py | 872 | 3.90625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2018/5/21 10:05
# @Author : DR
# @File : 107. 二叉树的层次遍历 II.py
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solut... |
80b69ccc77929e169f267105b34a1c399ea8e28d | harryDr/leetcode-python- | /leetcode/160相交链表.py | 739 | 3.546875 | 4 | #coding=utf-8
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def getIntersectionNode(self, headA, headB):
"""
:type head1, head1: ListNode
:rtype: ListNode
... |
3d5cc84c97818eeea0ef1ef0fa77312faee701b7 | harryDr/leetcode-python- | /leetcode/500. 键盘行.py | 1,174 | 3.578125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2018/5/22 17:19
# @Author : DR
# @File : 500. 键盘行.py
class Solution(object):
def findWords(self, words):
"""
:type words: List[str]
:rtype: List[str]
"""
# 暴力解法 代码可以优化
h1, h2, h3 = ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p'... |
50286cc0d76938d3211283cd47832c1bde6afb32 | dannyarmand/anagrams-and-others | /panagram solution.py | 408 | 4.3125 | 4 | #CHECKING IF A STRING IS A PANAGRAM
import string
def ispanagram(str):
alphabet = "abcdefghijklmnopqrstuvwxyz"
for char in alphabet:
if char not in str.lower():
return False
return True
#Driver Code:
string = "the quick brown fox jumps over the lazy dog"
if(ispanagram(string) == ... |
aee97a31d64b60b8d4a2ed22427640fa7ed7130b | Purnima124/Json | /Question no.6.py | 376 | 3.8125 | 4 | # import json
# a='{"a": 1,"a": 2,"a": 3, "a": 4, "b": 1, "b": 2}'
# d=json.loads(a)
# print
# Q6.Python object key unique key value ko access karne ka program likho? Example: Input :-
import json
a={"a": 1,"a": 2,"a": 3, "a": 4, "b": 1, "b": 2}
print("original python object:")
print(a)
json_obj=json.dumps(a... |
677f5a37e2e382ad2e88733add8802caef7584eb | Everalda/python | /sets.py | 120 | 3.515625 | 4 | #sets em python
#empty set
s = set()
s.add(2)
s.add(3)
s.add(4)
print (s)
#starting full set
b = set ([3,6,9,4])
print b |
b4dceb59e91f39192f0f722b60a0029cd5e6b838 | MattChann/software-development | /fall/03_csv/Fleshwound_chenE-chanM.py | 1,426 | 3.78125 | 4 | # Matthew Chan
# SoftDev1 pd2
# K#02: NO-body expects the Spanish Inquisition
# 2019-9-16
import random
# Reading the file's data
file = open("occupations.csv", 'r')
file.readline() # remove first header line
occupationData = dict()
for line in file:
splitList = line.rsplit(',',1)
splitList[0] = splitList[0]... |
337f48502b513e6d82807bf55e4a72f33393a296 | yang7988/python-foundation | /data_structures/sequence/sequence_using.py | 1,368 | 4.59375 | 5 | # 序列
#
# 列表、元组和字符串可以看作序列(Sequence)的某种表现形式,可是究竟什么是序列,它
# 又有什么特别之处?
#
# 序列的主要功能是资格测试(Membership Test)(也就是 in 与 not in 表达式)和索引
# 操作(Indexing Operations),它们能够允许我们直接获取序列中的特定项目。
#
# 上面所提到的序列的三种形态——列表、元组与字符串,同样拥有一种切片(Slicing)运算
# 符,它能够允许我们序列中的某段切片——也就是序列之中的一部分。
shoplist = ['apple', 'mango', 'carrot', 'banana']
name = 'swaro... |
8617a4bb0a8eb8898b2117ce18e7fe4250e51ea6 | yang7988/python-foundation | /data_structures/tuple/ds_using_tuple.py | 2,762 | 4.28125 | 4 | # 元组
# #
# # 元组(Tuple)用于将多个对象保存到一起。你可以将它们近似地看作列表,但是元组不能提
# # 供列表类能够提供给你的广泛的功能。元组的一大特征类似于字符串,它们是不可变的,也
# # 就是说,你不能编辑或更改元组。
# #
# # 元组是通过特别指定项目来定义的,在指定项目时,你可以给它们加上括号,并在括号内部
# # 用逗号进行分隔。
# #
# # 元组通常用于保证某一语句或某一用户定义的函数可以安全地采用一组数值,意即元组内的
# # 数值不会改变。
# 我会推荐你总是使用括号
# 来指明元组的开始与结束
# 尽管括号是一个可选选项。
# 明了胜过晦涩,显式优于隐式。
zoo = ('pytho... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.