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 |
|---|---|---|---|---|---|---|
7c66dc5b376db6ccfc088da9366f364e8482e42d | hr1day/Sem4-PracticalExams | /Q7.py | 608 | 3.78125 | 4 | class X(object):
def __init__(self):
print("X Class Constructor")
super().__init__()
class Y(object):
def __init__(self):
print("Y Class Constructor")
super().__init__()
class Z(object):
def __init__(self):
print("Z Class Constructor")
super().__init__()
class A(X,Y):
def __init... |
7df218023262b52b2f34d6fc0700debb4579b7e7 | samirdave1992/Learn-Python-3-the-hard-way | /Dictionaries.py | 1,073 | 4.25 | 4 | person={'name':'Noma','Age': 37,'height':5*12+5 }
print(person['name'])
print(person['Age'])
person['city']="DFW"
print(person['city'])
print(person)
##Lets do some dictionaries for states
states={
'Oregon':'OR',
'Florida':'FL',
'Texas':'TX',
'California':'CA',
'New York':'NY'
}
#Cities
cit... |
2b6f7b081c73ecb051bb84824194785707d07b7c | lujiaxuan0520/Python-exercise | /python课后习题/4.5.py | 174 | 3.828125 | 4 | #4.5
#!/usr/bin/python
#coding=utf-8
import re
def main():
x=input("Please input a paragraph:")
print(re.findall(r'\b\w{3}\b',x))
if __name__=='__main__':
main() |
55cb9b959fa7572ad30667fe79557d47ebb64313 | lujiaxuan0520/Python-exercise | /python课后习题/3.9.py | 291 | 4.0625 | 4 | #3.9
#!/usr/bin/python
#encoding=utf-8
def main():
x=input('Please input x')
x=eval(x)
if x<0 :
y=0
elif 0<=x<5:
y=x
elif 5<=x<10:
y=3*x-5
elif 10<=x<20:
y=0.5*x-2
else:
y=0
print(y)
if __name__=='__main__':
main() |
6892beadc531cdea2504242ae9db0400ffb20f65 | lujiaxuan0520/Python-exercise | /python课后习题/5.3.py | 400 | 4.09375 | 4 | #5.3
#!/usr/bin/python
#encoding=utf-8
def _count(str):
upper=lower=digit=other=0
for c in str:
if c.isupper():
upper+=1
elif c.islower():
lower+=1
elif c.isdigit():
digit+=1
else:
other+=1
return (upper,lower,digit,other)
if _... |
71c85e9d01874ff4fe5c36eb5b8eb95e2e84814e | A-Giordano/Library_system_backend | /Code/Books_module.py | 2,751 | 3.84375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Oct 20 22:39:15 2018
@author: SDis
"""
from Code.Resources_parent_module import Resources
class Books(Resources):
"""Son class of Resources, inherit main data fields, setters and getters from that. Plus, other data and methods."""
def __init__(self, title, author, ... |
a47908baf91fad4982439dfd1c66059761aa92e4 | catliaw/hb_coding_challenges | /concatlists.py | 1,054 | 4.59375 | 5 | """Given two lists, concatenate the second list at the end of the first.
For example, given ``[1, 2]`` and ``[3, 4]``::
>>> concat_lists([1, 2], [3, 4])
[1, 2, 3, 4]
It should work if either list is empty::
>>> concat_lists([], [1, 2])
[1, 2]
>>> concat_lists([1, 2], [])
[1, 2]
>>> con... |
a5e67a6191180c6f111b3417375d731d0e148814 | knockkncok/Python-class-projects | /simple UNO/client2.py | 3,239 | 3.5625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu May 17 13:45:41 2018
@author: test
"""
import socket
import random
from threading import Thread
class card():
def __init__(self,color,represent):
self.color=color
self.represent=represent
def see_mycard():
with open("c2.txt",'r') as f:
... |
b1bc50200b6b607ba5a9e03f26784453e1adb30d | jimbray/python_learning | /growing_python/py_00012/py_00012.py | 494 | 3.78125 | 4 | # -*- coding: utf-8 -*-
__author__ = 'jimbray'
def is_in_words(input_str):
word_list = []
result_str = str(input_str)
with open('filtered_words.txt', 'r', encoding='utf-8') as file:
for line in file.readlines():
line = line.strip()
if result_str.find(line) > -1:
... |
c27bb88eee4de8152ee805a614563973bee39115 | liugnggh71/dba_code | /Books/Python/LearnPythonInOneDay(2ndEd)/Sample Code/Chapter 6.py | 3,374 | 4.21875 | 4 | #------------if Example-----------------
print("\n\nif Example")
print("---------------------")
userInput = input('Enter 1 or 2: ')
if userInput == "1":
print ("Hello World")
print ("How are you?")
elif userInput == "2":
print ("Python Rocks!")
print ("I love Python")
else:
print ("You did not en... |
cab6f521796d376e042818de5752eff75e136ba1 | liugnggh71/dba_code | /Books/Python/LearnPythonInOneDay(2ndEd)/Sample Code/Chapter 10/classdemo.py | 1,839 | 3.8125 | 4 | class Staff:
def __init__ (self, pPosition, pName, pPay):
self._position = pPosition
self.name = pName
self.pay = pPay
print('Creating Staff object')
def __str__(self):
return "Position = %s, Name = %s, Pay = %d" %(self._position, self.name, self.pay)
de... |
fb218791404f9ab8db796661c91e1ab0097af097 | yu-shin/yu-shin.github.io | /downloads/code/LeetCode/Array-Introduction/q977_MergeSort.py | 1,533 | 4.5 | 4 | # Python3 program to Sort square of the numbers of the array
# function to sort array after doing squares of elements
def sortSquares(arr, n):
# first dived array into part negative and positive
K = 0
for K in range(n):
if (arr[K] >= 0 ):
break
# Now do the same process ... |
ec3476e8a945afe9873dd0b57ff46d449c2caadd | PrithviSathish/School-Projects | /LabActivity11.py | 165 | 3.859375 | 4 | def ispalindrome(item):
temp = item
item = item[::-1]
if temp == item:
return True
else:
return False
print(ispalindrome("hello"))
|
f063661003366dcd4a6038aecd597fe3376daf88 | PrithviSathish/School-Projects | /AscendingOrder.py | 745 | 4.21875 | 4 | num1 = int(input("Enter num1: "))
num2 = int(input("Enter num2: "))
num3 = int(input("Enter num3: "))
if num1 < num2:
if num1 < num3:
print(num1, end=" << ")
if num2 < num3:
print(num2, end=" << ")
print(num3)
else:
print(num3, end= " << ")
pr... |
ae8a8fe70d16bd05d33c7f85b399699f737c2cba | PrithviSathish/School-Projects | /LargestNumber.py | 292 | 4.21875 | 4 | x = float(input("Enter the value of x: "))
y = float(input("Enter the value of y: "))
z = float(input("Enter the value of z: "))
if x > y and x > z:
print("x is the greatest number")
elif y > x and y > z:
print("Y is the greatest number")
else:
print("z is the greatest number")
|
b27b2162fa8a2ebc5441f3829941e39a86eb00f6 | bindumarmaid/bindu | /even.py | 82 | 3.65625 | 4 | #write a program to get even numbers from 1to 20
n=2
while n<21:
print (n)
n+=2
|
e6f31e9f376c13d7d931387a680fec5524783ecf | reachdevikas/SpaceJam | /hackathon.py | 1,536 | 4.0625 | 4 | print("Enter the quantity of available items: ")
item1 = int(input("Enter the quantity of item 1: "))
item2 = int(input("Enter the quantity of item 2: "))
item3 = int(input("Enter the quantity of item 3: "))
item4 = int(input("Enter the quantity of item 4: "))
item5 = int(input("Enter the quantity of item 5: "))
... |
fb9f96fd4b3a3becd84531f4d07748c13bf6706d | kawing-ho/pl2py-ass1 | /test01.py | 268 | 4.53125 | 5 | #!/usr/bin/python3
# Use of "#" character in code to mimic comments
for x in range(0,5):
print("This line does't have any hash characters :)") #for now
print("but this one does! #whatcouldgowrong ? ") #what happens here ?
print("I love '#'s") and exit(ord('#'))
|
9aa2050b8d5baf2a411c6455e2347dbe590543f3 | Sashulik/Detroit-Autonomous-Vehicle-Group | /client-car/setIP.py | 267 | 3.84375 | 4 | print ("Enter IP of the server:")
server_ip = input()
file = open('server_ip.txt','w')
file.write(server_ip)
file.close()
# this code reads the IP from file
file = open('server_ip.txt','r')
sIP = file.read()
file.close()
print ("IP set to: [",sIP,"]")
|
dce68c74e03beafb1a09ab64c88effacef546c82 | Sashulik/Detroit-Autonomous-Vehicle-Group | /lane-finding/davg/lanefinding/LaneMath.py | 4,265 | 3.84375 | 4 | import numpy as np
import cv2
class LaneMath:
@staticmethod
def get_curve_radius(eval_value, fit_coef):
'''
Return the radius of the curve at the specified point.
Using f(y) = Ay^2 + By + C
Where y = eval_value and [A,B,C] are the fit_coef values
Radius = [1 + (dx/dy)^2... |
fd11885d2dc084b730566c9241a80b05af1afd1f | Kenil12/AI | /Assignment2/a_star_graphB.py | 3,004 | 3.859375 | 4 | from collections import deque
import datetime
class Graph:
print("Traversal path is : ")
def __init__(self, adjacency_list):
self.adjacency_list = adjacency_list
def get_neighbors(self, v):
return self.adjacency_list[v]
# heuristic function with equal values for all nodes
... |
9fef4fa41d0d815f67b7dad695488283f461d75d | happysmile27/Dev_progfundam2 | /Task9.py | 162 | 4.125 | 4 | x = {'key1': 1, 'key2': 3, 'key3': 2}
y = {'key1': 1, 'key2': 2}
for key, value in x.items() & y.items():
print(f"{key}: {value} is present in both x and y") |
71b552431f56fea84e1062924a6c1782449fe976 | PrechyDev/Zuri | /budget.py | 1,882 | 4.1875 | 4 | class Budget:
'''
The Budget class creates budget instances for various categories.
A user can add funds, withdraw funds and calculate the balance in each category
A user can also transfer funds between categories.
'''
##total balance for all categories
total_balance = 0
@classmethod
... |
3007256e65726d8fe245497fae51f87734965710 | kevinwkt/Elements-of-Programming-Interviews | /4/bitSwap.py | 211 | 3.625 | 4 | #! /usr/bin/python3
def bitSwap(a, i ,j):
if (a>>i)&1 != (a>>j)&1:
a^=((1<<i)|(1<<j))
return a
print('Please give "a i j":')
a, b, c = [int(x) for x in input().split()]
print(bitSwap(a, b, c))
|
f562a7c09c990fc7c62ca93b18c5b7cc60362c60 | kmykoh97/Basic-Programming-SJTU | /Own/numberReassignment.py | 1,237 | 3.953125 | 4 | #Number Reasignment Project
#Created by MyKoh
#2017-09-18
#Telling purpose and requesting user's input
print 'Hello, this is a number reassignment in assending order program'
userInput = input('Please give numbers separated by comma')
x = list(userInput)
print 'Your given numbers are', x
#Create functin by loop
def n... |
9a955bc2c877517c36eac86b21d599822593bd8f | kmykoh97/Basic-Programming-SJTU | /Own/numbersReverse.py | 432 | 3.875 | 4 | #Program to reverse numbers entered in list
##Created by MyKoh
#2017-10-20
def main():
oldList = []
newList = []
numberInList = input('Please enter the amount of numbers u wish to insert:')
a = numberInList - 1
for i in range(numberInList):
oldList.append(input('Please enter number:'))
... |
888a0d06fb5a36c4695f7f55b06f0e72da223d3c | kmykoh97/Basic-Programming-SJTU | /School/python/1st lesson/2.py | 512 | 4.0625 | 4 | #Second Shangji Practice
#Meng Yit Koh
#517030990022
def main():
userInput = input('Please insert a positive integer:')
resultList = [userInput]
condition = True
while condition:
if userInput % 2 == 0:
userInput /= 2
resultList.append(userInput)
else:
... |
7a388fbf659c835944d019b2740575cbe00957c3 | kmykoh97/Basic-Programming-SJTU | /Own/dividedByThreeUndividedByFive.py | 252 | 3.796875 | 4 | #Numbers that can be divided by 3 and cannot be divided by 5
#Created by MyKoh
#2017-10-18
def main():
result = 0
for i in range(1, 1001):
if i % 3 == 0 and i % 5 != 0:
result += i
print 'The total is', result
main()
|
87705d389810665c857eac525969e03a0cdc0097 | bhavya-error404/Beginner-Project-Solution | /Menu_Calc.py | 761 | 3.96875 | 4 | ch = 'y'
while(ch=='y'):
print("""RATE LIST:
1)Chicken Strips - $3.50
2)French Fries - $2.50
3)Hamburger - $4.00
4)Hotdog - $3.50
5)Large Drink - $1.75
6)Medium Drink - $1.50
7)Milk Shake - $2.25
8)Salad - $3.75
9)S... |
4f0921785214ea003c8fec18e5978e72a86d81f9 | asnid/ml-intro | /ml9_kmeans.py | 3,279 | 3.625 | 4 | # -*- coding: utf-8 -*-
"""
K-MEANS ALGORITHM using sklearn
Titanic passenger dataset: https://www.youtube.com/redirect?redir_token=dezKm_7h6sxvzBxFuDq6bcRe0XV8MTUxMzEwNzYyMUAxNTEzMDIxMjIx&q=https%3A%2F%2Fpythonprogramming.net%2Fstatic%2Fdownloads%2Fmachine-learning-data%2Ftitanic.xls&event=video_description&v=8p6XaQSI... |
f6722238973a5b4a90904cb8d3c050bc480d2c22 | tezrivera10/Python-Code-Samples-1 | /listof5.py | 194 | 3.84375 | 4 | #Raul Rivera
#3/7/19
#Takes a list and checks for a value
def listCheck(n):
for x in n:
if x== 5:
print("True")
numberlist = (1,3,5,4,4)
listCheck (numberlist)
|
3a8518ec7c1d3c45abeeb22dcd01cf81cbef9ae0 | tezrivera10/Python-Code-Samples-1 | /Raul.py | 175 | 4.1875 | 4 | name=str(input("what is your name? "))
if name == "Raul":
print ("hello " + name)
elif name == "robyn":
print ("hello " + name)
else:
print ("Wrong name ")
|
ad8b3f3eb9f7dd847efd62386606bbcda926e7e4 | vvweilong/PythonTest | /test001.py | 520 | 3.546875 | 4 | import itertools
count = 0
sourceArray = [1, 2, 3, 4]
for i in range(0, 4):
for j in range(0, 4):
for k in range(0, 4):
if (sourceArray[i] != sourceArray[j]) \
and (sourceArray[j] != sourceArray[k]) \
and (sourceArray[i] != sourceArray[k]):
... |
224861f9b26eec372da10d1dd884e9ef68cb646f | talithaprnst/Talitha-Pranastiti_I0320099_Aditya-Mahendra_Tugas5 | /I0320099_soal1_tugas5.py | 369 | 3.828125 | 4 | # MENYAPA TAMU HOTEL
nama = input("Masukkan nama Anda: ")
print("\nJenis Kelamin:"
"\n1. Laki-laki"
"\n2. Perempuan")
jenis_kelamin = int(input("Masukkan jenis kelamin Anda: "))
print("-------------------------------------")
if jenis_kelamin == 1:
print("\nSelamat datang, Tuan", nama, "!")... |
1065ba641225166a4da4c2cd7a02aeeb5d01cbc3 | zain2703/Kattis | /PolishNotation.py | 934 | 3.859375 | 4 | import sys
def is_numeric(num):
if len(num) > 1:
return num.lstrip("-").isnumeric()
return num.isnumeric()
def sum(op,operand1,operand2):
if(op=='+'):
return str(int(operand1)+int(operand2))
elif(op=='-'):
return str(int(operand1)-int(operand2))
elif(op=='*'):
... |
aa8070b1bd56b5fcc4b8f7aee70319c193ce1727 | slow-J/leetcode | /easy/125.valid_palindrome.py | 348 | 3.625 | 4 | import re
class Solution(object):
def isPalindrome(self, s):
"""
Regex needed to remove non-alphanumeric characters.
:type s: str
:rtype: bool
"""
if s == '':
return True
s = s.lower().replace(' ', '')
s = re.sub(r'[^a-zA-Z0-9]', '', s)
... |
7756f06d0a0bfc0a38a53069cc233a02c091c9a2 | MaxVlasov68/python.kampus | /probA.py | 270 | 3.671875 | 4 | def f():
import random
a=['1','2','3']
while True:
b=random.choice(a)
c=input()
if b == c :
print('WIN')
elif b != c:
print('Game Over')
|
c6d42c4b71ff23b766ba511a8d808176b33dc442 | sebdelas/Alyra-Excercice-1.1.3 | /1.1.3.py | 570 | 4.1875 | 4 | #!/usr/bin/env python3
def is_palindrome(mot):
inverse = '';
for i in reversed(range(0,len(mot))):
if (mot[i] != " "):
inverse = inverse + mot[i]
saisie_sans_espace = mot.replace(" ", "")
if (inverse == saisie_sans_espace):
return True
else:
return False
saisie ... |
9a1654ccdf6a7464d05aa9ab4f2278df17e0fb83 | bulelantutu/python-exercise | /day1_exercise.py | 172 | 4.34375 | 4 | name = input("type your name\n")
h= "hello "
g= " how are you ?"
print(h + name + g)
radius=int(input("enter radius"))
circumference=2*radius*3.1415
print(circumference )
|
7b7c9747abf948ab25f883ff0de7fdfefc40df21 | Computerproject10/proj | /50%.py | 9,554 | 3.890625 | 4 | import tkinter as tk
from tkinter import ttk
import random
root = tk.Tk()
root.title("The Maze")
entry = tk.Entry(fg="Blue", bg="Red", width=50)
entry.pack()
T = False
global lst_of_choices
def click_to_continue():
action = ttk.Button(root, text="Click To Continue")
T = True
action.pack()
def intro():... |
d30896b9eb8a8bf8f73d05439906a5fd1a5c1973 | Weyinmik/pythonDjangoJourney | /dataTypeNumbers.py | 581 | 4.21875 | 4 | """
We have integers and floats
"""
a = 14
print(a)
b = 4
print(b)
print(a + b) # print addition of a and b, 18.
print(a - b) # print subtraction of a and b, 10.
print(a * b) # print multiplication of a and b, 56.
print(a / b) # print division of a and b in the complete decimal format, -... |
d2acb1523555e673db29c50d45a0b3a2cfd77d03 | Weyinmik/pythonDjangoJourney | /pythonBasis.py | 739 | 4.09375 | 4 | print('Hello World')
#Python Naming Rules
#1. Must start with a letter or underscore. Cannot start with a number
#2. Consist of letters, numbers or understand.
#3. Python variables are case sensitive.
# Variable name with just letters in lowercase
car = "Mercedes"
print(car)
# Variable name starting with underscore
_... |
93e662570bd85f6eb822ad22506baaf341273f22 | RobinNunkesser/HeadFirstDesignPatterns | /python/headfirst/factory/pizza0.py | 2,382 | 3.71875 | 4 | from __future__ import print_function
import sys
def main(sysargs=sys.argv[:]):
factory = SimplePizzaFactory()
store = PizzaStore(factory)
for pizza_type in ('cheese', 'veggie'):
pizza = store.order_pizza(pizza_type)
print('We ordered a ' + pizza.name + '\n')
return 0
class PizzaS... |
3ccf5b53110bacc0004bc22f8f2323ec898cfe7c | keila2k/ass1 | /task_2.py | 2,830 | 3.765625 | 4 | def encrypt_caesar_cipher(plaintext):
return ''.join([chr((ord(char) + 3-65) % 26 + 65) if (64 < ord(char) < 91) else char for char in plaintext])
def decrypt_caesar_cipher(ciphertext):
return ''.join([chr((ord(char) - 3-65) % 26 + 65) if (64 < ord(char) < 91) else char for char in ciphertext])
print(encryp... |
b9f53a9eaf938ed0de6725fb0f5f546876fd6e71 | katecpp/PythonExercises | /18_cows_and_bulls.py | 1,411 | 3.890625 | 4 | #! python3
import random
def readIntegerAsString(length):
value = ""
accepted = False
while accepted == False:
value = input(">>>> ")
if value.isdigit() == False:
print("This is not a number!")
elif len(value) != length or len(set(value)) != length:
print("Nu... |
f7e5cd52ac7324617717081db83c6b849f5fab32 | katecpp/PythonExercises | /24_tic_tac_toe_1.py | 546 | 4.125 | 4 | #! python3
def readInteger():
value = ""
while value.isdigit() == False:
value = input("The size of the board: ")
if value.isdigit() == False:
print("This is not a number!")
return int(value)
def printHorizontal(size):
print(size * " ---")
def printVertical(size):
prin... |
c6ff43950f21b27f9c3dd61cf3d6840748ad2864 | katecpp/PythonExercises | /11_check_primality.py | 515 | 4.21875 | 4 | #! python3
import math
def readInteger():
value = ""
while value.isdigit() == False:
value = input("Check primality of number: ")
if value.isdigit() == False:
print("This is not a number!")
return int(value)
def isPrime(number):
upperBound = int(math.sqrt(number))
for ... |
77205a0c20912d551cf810020a5662b2d87f7a0d | jcrinfo/securityinsider | /parse_jwt.py | 2,443 | 3.5625 | 4 | #!/usr/bin/python
import sys
import base64
import argparse
import json
import hmac
import hashlib
def decode_base64(data):
"""Decode base64, padding being optional.
:param data: Base64 data as an ASCII byte string
:returns: The decoded byte string.
Source : http://stackoverflow.com/questions/2941995/... |
d849a589929e610b588067d845bfcf182ca5b3b5 | Legoota/PythonAlgorithmTraining | /Sorts/mergesort.py | 572 | 4.125 | 4 | def mergesort(array):
if len(array) < 2:
return array
center = len(array)//2
left, right = array[:center], array[center:]
left = mergesort(left)
right = mergesort(right)
return mergelists(left, right)
def mergelists(left, right):
result = []
while len(left) > 0 and len(right) >... |
1a76893e4c43f750bc68c1f023c65f013a919035 | muslinovsultan/ekzamen | /zadachi.py | 2,291 | 4.21875 | 4 | class CoffeeMachine:
def __init__(self, milk,coffee,sugar):
self.milk = milk
self.coffee = coffee
self.sugar = sugar
def make_coffee(self,milk,coffee,sugar):
if milk > self.milk and coffee > self.coffee and sugar > self.sugar:
min = milk - self.milk
min2 = coffee - self.coffee
min3 = sugar - self... |
c259f0ffa59521d99fedeb791ba05ec02ba0bedf | yuvam2017/Database | /Databases_in_Tkinter.py | 3,995 | 3.90625 | 4 | # 21th video
from tkinter import *
from PIL import Image,ImageTk
from tkinter import filedialog
import sqlite3
root= Tk()
root.title("")
root.geometry("400x400")
# Databases
# Create a Database or connect to one
conn = sqlite3.connect('address_book.db')
# Create a Cursor
c = conn.cursor()
#Create table
try:
c.exec... |
c7466e3c9126dcc22ed1ac6fae609320c2cab4ae | oldcast1e/Python | /class/2M1W/13강/연습문제/Q1.py | 373 | 3.546875 | 4 | from matplotlib import pyplot
month = ('1','2','3','4','5','6','7','8','9','10','11','12')
avg_temp = [0.5,2.0,6.7,12.7,18.6,21.7,24.4,25.2,20.5,15.0,10.0,3.5]
pyplot.bar (month,avg_temp,width=0.4,color = 'blue',label = 'Average Tempt')
pyplot.xlabel('Month')
pyplot.ylabel('Temp')
pyplot.title('Transform of Temperatu... |
d0a6b9602a1c9bd0f8f31015068f50e186e40fa4 | oldcast1e/Python | /Python Lecture/assignment/1.28/Q1.py | 381 | 3.609375 | 4 | total = 0
total_1 = 0
total_2 = 0
for i in range(2):
for j in range(3):
n = int(input())
if i == 0:
total_1 += n
else:
total_2 +=n
print('Sejong :',total_1)
print('Daeyang :',total_2)
r1 = total_1%3
r2 = total_2%3
if r1>r2:
print('Winner : Sejong')
elif r1<r2:
... |
93881e453777a5396c4b1c60bd843a8c52ac238a | oldcast1e/Python | /Python Lecture/assignment/1.19/Q1.py | 698 | 3.875 | 4 | """ 임의의 자연수 n을 입력 받고
n의 약수의 개수를 구하여 반환하는 함수를 작성하고
테스트 프로그램을 작성하라.
# 호출 프로그램 (함수 호출 예시)
n = int(input())
result = count_factors(n)
print("The number of factors of %d is %d." % (n, result))
[입력 예시 1]
12
[출력 예시 1]
The number of factors of 12 is 6.
[입력 예시 2]
30
[출력 예시 2]
The number of factors of 30 is 8.
"""
n = in... |
f72f47bccaa7aa1ca8b5bf7a40a74ef4bcfcfbcc | oldcast1e/Python | /class/1M2W/1.17/e5_while.py | 134 | 3.6875 | 4 | s= 1
n = int(input("숫자를 입력하세요: "))
while s <=9:
print(n,"x",s,"=",n*s)
s += 1
#while문을 이용한 반복문 |
b6426deb3197f688e73e8c6c1a1c3af536c94599 | oldcast1e/Python | /class/1M2W/1.17/e2.py | 137 | 3.609375 | 4 | s= 0
while s <10:
n = int(input("번호를 입력하세요: "))
if n ==0:
continue
s = s + n
print("s = ",s)
|
8cb1aae2bdcbd5525b23f8fb8298f953934f152a | oldcast1e/Python | /class/1M5W/7강/e6.py | 300 | 3.90625 | 4 | """ a = (1,2,3,4,5)
n = int(input())
b = a*n
print("b = ",b)
print(b.count(3)) """
#튜플 슬라이스
""" mt = (1,2,3,4,5,6,7,8,9)
n1 = int(input())
n2 = int(input())
print(mt[n1:n2]) """
#튜플 오름차순 정렬
mt = (1,9,7,3,2,4,8,5,6)
ml = list(mt)
ml2 = ml.sort()
mt2 = tuple(ml2)
print(mt2) |
b4f2d3970fa10d79eb90f4a2a8247f6f61f417c6 | oldcast1e/Python | /Python Lecture/1.28/e7.py | 452 | 3.671875 | 4 | sbj = {}
n = int(input())
for i in range(n):
s = input().split(" ")
sbj[i] = s
total_SW= 0
total_OS = 0
total_DB = 0
for k in range(3):
for j in range(n):
if k == 0:
total_SW += int(sbj[j][k])
elif k == 1:
total_OS += int(sbj[j][k])
elif k == 2:
... |
455d81419efeded1163e05f6fd9ef87239fc571a | oldcast1e/Python | /Python Lecture/1.28/e2.py | 280 | 4.03125 | 4 | user_info = { 'name':'David', 'age':21, 'address':'Gwangjin-gu, Seoul' }
u = input()
if u == 'age':
print('age :',user_info[u])
elif u== 'name':
print('name :',user_info[u])
elif u == 'adress':
print('adress :',user_info[u])
else:
print("The info does not exist!") |
4977cf1f90f6233556e70c5666fed52c421c30ee | oldcast1e/Python | /Python Cording/중간고사/Q6.py | 637 | 3.84375 | 4 | #주사위를 꺼냈는데 빨강색이면 종료
#파랑색이면 다시 넣고
#다른 색이면 숫자를 확인해 6이면 꺼내는 횟수를 1 증가
leave = 0 #잔돈
k = 0 #꺼낸 횟수
m = int(input()) #입력한 돈
leave += m
while leave>0:
col = input()
if ("RED" != col):
num = int(input())
if ("BLUE"
== col):
leave -= 500
elif (... |
80a6baa0e40d63e742c0c1d35af9fb41ee2e0816 | oldcast1e/Python | /class/1M2W/1.20/e1.py | 440 | 3.921875 | 4 | dic = {
"today work" : "python cording",
"time limit" : "today 12PM",
"success or failure." : ['O','X']
}
print("today list: ",dic["today work"])
print("limit of time: ",dic["time limit"])
print( "success or failure:",dic[ "success or failure."][0])
print()
dic["tomorrow wake up time"] = ["9:00","9:30","... |
4b01b76a1fda147e0aeecab10bfb11a914d2d62d | oldcast1e/Python | /Python Lecture/1.26/t8.py | 102 | 3.640625 | 4 | a = (1,2,3,4,5)
n = int(input())
b = a*n
print("b =",b)
k = b.count(3)
print("Number of 3 in b :",k) |
71010f9e567f01206b1cd9d03e02b8293f6240b6 | oldcast1e/Python | /Python Lecture/1.19/T7.py | 500 | 3.96875 | 4 | """ 정수를 전달 받아 양수이면 1만큼 증가시키고,
음수이면 1만큼 감소시켜 반환하는
함수 enlarge(n)를 작성하고 테스트 프로그램을 작성하라.
# 호출 프로그램 (함수 호출 예시)
n = int(input())
print(enlarge(n))
[입력 예시 1]
3
[출력 예시 1]
4
[입력 예시 2]
-7
[출력 예시 2]
-8 """
n= int(input())
def enlarge(n):
if n>0:
c = n+1
return c
else:
d = n-1
retur... |
a7fb1ae1b27761508db860b162f67557a5308219 | poojapi/synchro | /factory.py | 2,404 | 3.59375 | 4 | from threading import Thread
from threading import Lock, Condition
import time
CHASSIS, ENGINE, TIRES, BODY = 0, 1, 2, 3
class FactoryFloor():
def __init__(self):
self.lock = Lock()
self.floor = []
self.chassisDone = Condition(self.lock)
self.engineDone = Condition(self.lock)
self.tiresDone = Condition(sel... |
e81a02ef0e12b9d71e63559071aa242b9cc9dae0 | tlima1011/python3-curso-em-video | /ex023_vs02.py | 277 | 3.625 | 4 | def particionar(n):
u = n // 1 % 10
d = n // 10 % 10
c = n // 100 % 10
m = n // 1000 % 10
return f'Analisando o número... {n}\nUnidade: {u}\nCentena {d}\nCentena {c}\nMilhar {m}'
num = int(input('Digite um número.: '))
print(particionar(num))
|
ecb423d563cf0eaeb6dd59f382870e6185a385c0 | tlima1011/python3-curso-em-video | /ex007.py | 216 | 3.625 | 4 | def media(n1, n2):
media = (n1 + n2) / 2
return f'A média de {n1} e {n2} = {media}'
nota1 = float(input('Informe a nota1.: '))
nota2 = float(input('Informe a nota2.: '))
print(media(nota1, nota2))
|
9aa6ab61a223aa4adcc2e920713713e58ac1bef3 | tlima1011/python3-curso-em-video | /calculadora.py | 382 | 3.703125 | 4 | def somar(n1=0, n2=0):
return f'A soma do número {n1} e {n2} é = {n1 + n2}'
def subtrair(n1=0, n2=0):
return f'A subtração do número {n1} e {n2} é = {n1 - n2}'
def mutliplicar(n1=0, n2=0):
return f'A mulitiplicação dos número {n1} e {n2} é = {n1 * n2}'
def dividir(n1=0, n2=0):
return ... |
faf58f9ec528738860c366e2eb8d8b3d8122b906 | tlima1011/python3-curso-em-video | /factor_x_vs1.py | 382 | 4 | 4 | from math import factorial
def fatorial(inicial, final):
for inicial in range(inicial, final+1):
#f.append('O fatorial de {}! = {}'.format(inicial, factorial(inicial)))
print(f'O fatorial de {inicial}! = {factorial(inicial)}')
return True
inicial = int(input('Número Inicial: '))
final = i... |
3000155a5bcec7629d763c00c4372b6c5a732a4f | tlima1011/python3-curso-em-video | /ex053.py | 144 | 3.546875 | 4 | from ex053_palindrome import verificarPalindromo
frase = input('Informe uma frase.: \n').strip().upper()
print(verificarPalindromo(frase))
|
1b18afd10d82d5bb80162afa0274b0c336482bcc | tlima1011/python3-curso-em-video | /ex063_fibonacci_packages.py | 508 | 3.859375 | 4 | #Sequencia do Fibonacci
def fibo_for(n1, n2, n3, termos):
print(n1, end=' -> ')
print(n2, end=' -> ')
for i in range(n1, termos-2):
n3 = n1 + n2
n1 = n2
n2 = n3
print(n3, end=' -> ')
return 'FIM'
def fibo_while(n1, n2, n3, termos):
print(n1, end=' -> ' ... |
8d42b48047fa49b956547b36a0ac234fe73a79e6 | tlima1011/python3-curso-em-video | /ex063.py | 624 | 4.1875 | 4 | from ex063_fibonacci_packages import fibo_while, fibo_for
print('-=' * 10)
print(' FIBONACCI VS. 1.0')
print('-=' * 10)
while True:
n1 = n3 = 0
n2 = 1
termos = int(input('Quantos termos: '))
op = int(input('''[ 1 ] - FIBONACCI COM FOR
[ 2 ] - FIBONACCI COM WHILE
[ 3 ] - SAIR
Opção.: '''))... |
88f8dce30a89299c7d870cfdee90feafefdbbfa8 | tlima1011/python3-curso-em-video | /ex050_vs1.py | 769 | 3.5625 | 4 | from random import randint
from validadores import leiaInt
soma = 0
cp = 0
numeros = []
inicial = leiaInt('Informe o número inicial.: ')
final = leiaInt('Informe o número final.: ')
inicio = leiaInt('Valor inicial.: ')
termino = leiaInt('Valor final.: ')
#randint(0,2)
for inicial in range(inicial, final):
... |
4b6bbe5e75f841baa4f299c2b6da8603c4e1c034 | tlima1011/python3-curso-em-video | /ex029.py | 361 | 3.90625 | 4 | def multa(km):
if km > 80:
multa = (km - 80) * 7
return '\033[1;31mCom a velocidade de {}km/h, valor da multa R${:.2f}'.format(km, multa)
else:
return '\033[1;32mEstá abaixo de {:.2f}km/h e dirija sempre com segurança!!!\033[m'.format(km)
kmh = float(input('\033[1;34mVelocidade... |
a8975157891baa4e46f80bb03477ff169afab141 | tlima1011/python3-curso-em-video | /ex115/modulos.py | 1,488 | 3.71875 | 4 | import csv
def cadastrar():
print('-' * 45)
print(f'{"*** NOVO CADASTRO ***":^45}' )
print('-' * 45)
pessoas = dict()
dados = list()
nomes = []
csvFile = open('dados.csv', 'at', newline='')
csvWriter = csv.writer(csvFile, delimiter=',', lineterminator='\n')
for e in dad... |
2e667dd49d91125c36a3fa72cf26f70f4b66e43d | tlima1011/python3-curso-em-video | /ex103.py | 672 | 3.671875 | 4 | def jogador(nome, gols):
if nome == '' and gols == '':
nome = '<desconhecido>'
gols = 0
return f'Nome do Jogador {nome} com gols {gols} marcados.'
elif nome != '' and gols == '':
gols = 0
return f'Nome do Jogador {nome} com gols {gols} marcados.'
elif gols != ... |
3e93fedfb40b08c16a9e3e886db77c50bcd446c9 | tlima1011/python3-curso-em-video | /teste_numeros.py | 171 | 3.59375 | 4 | numeros = []
from random import randint
for i in range(0, 6):
numeros.append(randint(1, 10))
for i, v in enumerate(numeros):
print(f'{i} com valor {v}')
|
b049223701734430187cfa5775e0bee7deebd317 | nitinawathare/RenoirExperiment | /formatAddress.py | 823 | 3.515625 | 4 | def formatAddress(fileName):
matrixAddress = []
sortAddress = []
emptyAddress = []
file = open(fileName, "r")
data = file.readlines()
for line in data:
info = line.rstrip().split(':')
if info[0] == 'matrix':
matrixAddress.append(info[1])
elif info[0] == 'sort':
sortAddress.append(info[1])
elif i... |
c5ed75caa0046dcf06284870e05a12e1e1370017 | niallmul97/Poker-Minigame | /poker-mini-game.py | 5,520 | 3.59375 | 4 | import random
class Card:
def __init__(self, value, suit):
self.value = value
self.suit = suit
#def faceCardSwitchCase(self, i):
#faceCards = {11: 'J', 12: 'Q', 13: 'K', 14: 'A'}
#return faceCards.get(i, str(i))
def show(self):
if self.value == 11 or self.value == ... |
85e805c14e8b7a3c966c67e06320c6e74c26b8cd | xialulee/WaveSyn | /wavesynlib/formulae/motion.py | 1,724 | 4.09375 | 4 | from math import sqrt, inf
class AToBConstAccel:
"""\
The model of movement from A to B.
The speed at point A and B is 0.
The rates of acceleration and deceleration
are constant."""
def __init__(self, dist, accel, decel, max_speed=inf):
"""\
dist: The distance between A to B;
accel: The rate... |
d83dd0c2b0640e535d84375ebb85c4051ccab8fe | jaco1982/PythonCourse | /ProgramFlow/greaterthan7.py | 106 | 3.875 | 4 | for i in range(0,21):
if i > 0:
if i%3 == 0 or i%5 == 0:
continue
print(i) |
a7777db4706c4501b7c2be8ac1c8f089147e39c5 | jaco1982/PythonCourse | /ProgramFlow/quizz.py | 123 | 3.875 | 4 | value = 8
answer = 0
for x in range(1, 13):
answer = value * x
print("{0} times {1} is {2}".format(x, value, answer))
|
8d2a2ca297e307ce475c3a5183cea37e98fcc393 | Parthdhir1/Image-Prediction | /dogs and cat.py | 2,547 | 3.5625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Jun 26 20:30:32 2018
@author: Parth
"""
#1 building convolutional network CNN
# Importing the Keras libraries and packages
from keras.models import Sequential
from keras.layers import Convolution2D
from keras.layers import MaxPooling2D
from keras.layers import Flatten
from k... |
af26e98b6f7ff81bcdd80f588129c3921f15837c | MatsobaneMokomane/DataScientist | /Using Python to Access Web/13Point2.py | 620 | 3.6875 | 4 | import urllib
from bs4 import BeautifulSoup
# ============================ #
import urllib.request
url = input('Enter - ')
count_num = int(input('Enter count: '))
pos = int(input('Enter position: '))
def parseHtml(url, pos):
html = urllib.request.urlopen(url)
s = html.read()
soup = BeautifulSoup(s)
... |
08399260f162812f948f37f64fc4358a2c6e7e58 | lrouter/sicp_python | /ch3_video/homework7.py | 2,609 | 3.90625 | 4 | #!/usr/bin/env python
# encoding: utf-8
def reduce2(f, s, initial):
"""Combine elements of s pairwise using f, starting with initial.
>>> reduce2(mul, [2, 4, 8], 1)
64
>>> reduce2(pow, [1, 2, 3, 4], 2)
16777216
"""
for x in s:
initial = f(initial, x)
return initial
class Fib:
... |
58451f498859eb61cd3e28d95915567432396483 | avigautam-329/Interview-Preparation | /OS/SemaphoreBasics.py | 842 | 4.15625 | 4 | from threading import Thread, Semaphore
import time
# creating semaphore instance to define the number of threads that can run at once.
obj = Semaphore(3)
def display(name):
# THis is where the thread acquire's the lock and the value of semaphore will decrease by 1.
obj.acquire()
for i in range(3):
... |
bcbc1543316771844f9d70472003ec1209e9f42a | laurebonfils/toolkitten | /summer-of-code/week-02/wk2-homework-submissions/soc_wk2_cert_Laure_Bonfils.py | 12,623 | 4.09375 | 4 |
#### Day 1 ####
## Exercise: Calculate a table for each letter in the alphabet from a-z, and count how many times each letter appears in alice_in_wonderland.txt (fancy word for counting stuff is "frequency distribution" - because you are counting the frequency of something)
filename = "/Users/Laure/Workspace/SummerO... |
71670200577bf2d1d9228f8e69164d210bd7bd18 | achutom/Helloprinterpackage | /__init__.py | 98 | 3.6875 | 4 | def add_word(word1, word2):
return word1 + word2
Default_word = "Hello"
print(Default_word) |
839181892842d62b803ab6040c89f29a2718514e | chuducthang77/Summer_code | /front-end/python/project301.py | 1,158 | 4.15625 | 4 | #Project 301: Banking App
#Class Based
# Withdraw and Deposit
# Write the transaction to a python file
class Bank:
def __init__(self, init=0):
self.balance = init
def deposit(self, amount):
self.balance += amount
def withdraw(self, amount):
self.balance -= amount
account = Bank()... |
56f87ab319d12cc440bd0e84cd287bec1c88331f | Seyona/HackerRankSol | /DictAndHashmaps.py | 4,280 | 3.921875 | 4 | # https://www.hackerrank.com/interview/interview-preparation-kit/dictionaries-hashmaps/challenges
# Problem: Ransom Note
# https://www.hackerrank.com/challenges/ctci-ransom-note/problem?h_l=interview&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=dictionaries-hashmaps
def checkMagazine(magazine, ... |
798f3df4e5b30737ace8d3071d048a59745494e8 | bjchu5/pythonSort | /insertionsort.py | 1,848 | 4.5 | 4 | def insertionsort_method1(aList):
"""
This is a Insertion Sort algorithm
:param n: size of the list
:param temp: temporarily stores value in the list to swap later on
:param aList: An unsorted list
:return: A sorted ist
:precondition: An unsorted list
:Co... |
f568346c21986bf5f4eb8eb9ff3c79f330b622a2 | laurenjack/ModularNN | /srcNN/problems/problem_domain.py | 2,975 | 3.765625 | 4 | import numpy as np
print np.version
class Observation:
"""An individual mapping of inputs to outputs:
Attributes:
inputs (numpy array)
outputs(numpy array)
eg1: 0, 0 -> 1
eg2: 0.5 -> 2
eg3: 1, 0, 1, 0 -> 1, 1
"""
def __init__(self, inputs, outputs):
self.inputs = ... |
cb9753260c432958692ae398e91dfa52fb573258 | amaurirg/aulas-python | /resolvidos/exercicios/exercicio01.py | 639 | 3.890625 | 4 | def maior_menor(numero1, numero2):
""" Deve retornar qual número é maior ou se são iguais em forma da mensagem 'O número <maior_numero> é maior' """
# Seu código aqui
return f'O número {numero1} é maior' if numero1 > numero2 else f'O número {numero2} é maior'
def tras_para_frente(palavra):
"""Crie uma... |
d981e170e8f976ea01d00b008934256c4d524c17 | erichuang2015/PythonNotes | /code/018_函数注释、嵌套和命名空间/作业8.py | 676 | 3.890625 | 4 | # -*- coding: utf-8 -*-
# @Time : 2019/12/26 23:01
# @Author : 童庆
# @FileName : 作业8.py
# @Software : PyCharm
'''
面试题:写出输出结果
'''
def calc(a,b,c,d=1,e=2):
return (a+b)*(c-d)+e
print(calc(1,2,3,4,5))
# print(calc(1,2))
print(calc(e=4,c=5,a=2,b=3))
print(calc(1,2,3))
print(calc(1,2,3,e=4))
# print(calc(1,2,3,d... |
1c22594561a1afb5be116573dbcfbdb7692c60f6 | erichuang2015/PythonNotes | /code/018_函数注释、嵌套和命名空间/作业7.py | 490 | 3.796875 | 4 | # -*- coding: utf-8 -*-
# @Time : 2019/12/26 23:00
# @Author : 童庆
# @FileName : 作业7.py
# @Software : PyCharm
'''
扑克牌,返回[('红心','2')·····(''黑桃','2')·······] 笛卡尔积
'''
def func():
result = []
huase = ['红心', '黑桃', '草花', '方片']
dianshu = [2, 3, 4, 5, 6, 7, 8, 9, 10, 'J', 'Q', 'K', 'A']
for hua in hua... |
760aed2a0b0d6f2e8bdbaa3007527905670290f4 | erichuang2015/PythonNotes | /code/023_常用模块/作业1.py | 1,216 | 4.21875 | 4 | # -*- coding: utf-8 -*-
# @Time : 2020/1/5 15:33
# @Author : 童庆
# @FileName : 作业1.py
# @Software : PyCharm
import random
# 数字验证码
def code(n=6):
s = ''
for i in range(n):
num = random.randint(0,9)
s += str(num)
return s
print(code(4))
print(code())
# 数字和字母验证码
def code(n=6):
s =... |
ed571b223307d9ccf5f43fcc1d1aa0469c213bbf | Dongmo12/full-stack-projects | /Week 5 - OOP/Day 3/exercises.py | 666 | 4.34375 | 4 | '''
Exercise 1 : Built-In Functions
Python has many built-in functions, and if you do not know how to use it, you can read document online.
But Python has a built-in document function for every built-in functions.
Write a program to print some Python built-in functions documents, such as abs(), int(), raw_input().
And... |
fcb2f3f5194583a7162a38322303ab2945c8de79 | Dongmo12/full-stack-projects | /Week 4 Python and web programming/Day 2/exercises.py | 1,705 | 4.5 | 4 | '''
Exercise 1 : Favorite Numbers
Create a set called my_fav_numbers with your favorites numbers.
Add two new numbers to it.
Remove the last one.
Create a set called friend_fav_numbers with your friend’s favorites numbers.
Concatenate my_fav_numbers and friend_fav_numbers to our_fav_numbers.
# Solution
my_fav_numbers... |
790e8b58ab3d9178d1468041d9f77b17c63fa8c1 | Dongmo12/full-stack-projects | /Week 4 Python and web programming/Day 1/exercises.py | 2,370 | 4.5 | 4 | '''
Exercise 4 : Your Computer Brand
Create a variable called computer_brand that contains the brand of your computer.
Insert and print the above variable in a sentence,like "I have a razer computer".
# Solution
computer_brand = "msi"
print('I have a {} computer'.format(computer_brand))
'''
'''
Exercise 5: Your Infor... |
d39bd6b19a937a63a07279e5f21446a388881363 | 0x10F8/PCrack | /crack/crack.py | 3,686 | 3.8125 | 4 | from abc import abstractmethod
from hashlib import md5, sha1, sha256, sha512
import bcrypt
UTF8 = "UTF8"
class Crack:
"""
Abstract Crack class, implements the basic constructor for all cracks. And ensures the test method exists in all
crack classes.
"""
def __init__(self, target_has... |
e68f67ca765ee129bcfa57c867ab4b01709351fb | ZPGuiGroupWhu/Human-Mobility-Analysis | /Driver-Personality-Analysis/model/utils/io.py | 709 | 3.96875 | 4 | import pandas as pd
def read(file_name):
"""
Read a comma-separated values (csv) file into DataFrame.
:param file_name: str
the path and name of file.
:return: dataframe
A comma-separated values (csv) file is returned as two-dimensional data structure with labeled axes.
"""
csv... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.