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
c2fbd24d7c4efc16cb8b2ce178482511234394ab
rdvnkdyf/codewars-writing
/python/sum-of-odd-numbers.py
569
4.21875
4
""" Given the triangle of consecutive odd numbers: 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 Calculate the row sums of this triangle from the row index (starting at index 1) e.g.: row_sum_odd_numbers(1); # 1 row_sum_odd_numbers(2); # 3 + 5 = 8 """ import ...
ac92accb67c212b5ef1e34052b5115cde9ae94ab
JimStockman/Code-wars
/Jayden case/jayden.py
627
4.03125
4
""" First the split will seperate each word contained in the quote. Then for each word, it's going to capitalize it. Finally it will join them back into a quote and return it """ quote = "How can mirrors be real if our eyes aren't real" # Personnal code def ToJaydenCase(string): charList = list(string) ch...
4019639a3f1bc89f66e6b405587f850b971b686d
ppsirg/gl_tryout
/e6.py
1,224
3.546875
4
""" There is an e-commerce system where you have information about users, products, categories, shopping carts of each user and products reviews too. You were asked to develop a widget to include it in the e-commerce’s webpage, in the shopping cart screen specifically, that widget would show product recommendations to ...
c3f34f21a44215e05a69e644a21a6391712325ae
LoveShooter/Python-Lessons
/L13-Input.py
362
3.921875
4
name = input("Please Enter your name: ") print("Helo " + name) num1 = input("Enter X: ") num2 = input("Enter Y: ") sum = int(num1) + int(num2) print(sum) message = "" while message != 'sekret': message = input("Enter password: ") if message == 'sekret': break print(message + " Password not c...
0e760de931e1dfb0e76ac8a26fa5412f7cc7837e
Environmental-Informatics/06-graphing-data-with-python-CharlesWorgen
/lab6.py
1,890
4
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ 2020/4/20 by Charles Huang Lab6 - Graphing Data with Python The program should accept command line options with both complete input and output filenames, then import data from the given file, generating three plots in one figure, then ouput it as a pdf file with given...
ff62721d85a5c9b35884819079c9c9832520523c
szr-root/workfast
/guessnum.py
1,974
3.734375
4
import random Num_Digits = 3 Max_Guess = 0 def getsecretnum(): numbers = list(range(10)) random.shuffle(numbers) secretnum = '' for i in range(Num_Digits): secretnum += str(numbers[i]) return secretnum def getclues(guess, secretnum): if guess == secretnum: return '你赢了!' ...
9b0c01b46d9a11d76059d1a55f06760069f6c509
derek-garner/5110Project
/agent.py
1,377
3.5
4
import abc class Agent(object): __metaclass__ = abc.ABCMeta @abc.abstractmethod def __init__(self): self.bidsToBuy =[] self.bidsToSell =[] self.numOwnedShares =500 self.funds = 100000 self.maxBuyPrice =5000 def getBidsToBuy(self): return self.bidsT...
0bed93426d83ed50a1dfb8df94b2fee2e6dd1963
Nusrat-H/python-for-everybody
/MyownfunctionD.py
793
4.40625
4
""" Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Pay should be the normal rate for hours up to 40 and time-and-a-half for the hourly rate for all hours worked above 40 hours. Put the logic to do the computation of pay in a function called computepay() and use the f...
94b0c3059086f01eba23dfd215344abf11f85555
hfiaz/Week-4-Python
/Python_DB_Operations.py
714
3.59375
4
from day1.Northwind_OOP import Northwind, Region # create a new Northwind object using the init method and save result in my_northwind_object variable # () This is called a constructor my_region_object = Region("Region") operation = input("Please enter your character for your CRUD operations: ") if operation...
93611a75432c277a700c55edc510fd3901b90a63
shreshta2000/function_questions
/vote_saral_question.py
207
4.03125
4
def eligible_for_vote(age): if age>=18: result="you are eligible for vote" else: result= "you are not eligible for vote" return (result) age=int(input("entre any age ")) print(eligible_for_vote(age))
1e4d8628ba3cbe86f1475f1091f6a5c6c5c09bb1
BetsyVisconti/CSEC-731
/hw1/importsocket.py
2,423
3.609375
4
import socket import sys import ssl #import urllib data="" conn_type = sys.argv[1].split("://")[0] url = sys.argv[1].split("//")[1] host = url.split("/")[0] page = url[len(host):] if page == "": page = "/" req = "GET " + page + " HTTP/1.1 \r\n" req += "Accept-Encoding: identity \r\n" req += "Host: " + host + "\r\n"...
33dbf5f0202791297b20a6548e4eb70d5ee209d9
Bavertas/Clarod
/(if-Statements) Assignment - 1.py
170
4
4
name = input("Waht is your name?") if (name == "Joseph") : print("Hello, Joseph! The password is : W@12") else : print("Hello, Amina! See you later.")
00e38572c0dc4d8880f43007653d935d2a53e41f
Souhail47/Mini-projects
/mini projects.py
3,510
3.953125
4
#YES OR NO . from random import randint answer=["Yes","No"] for i in range(3): print(answer[randint(0,1)]) #daytime: from datetime import datetime now = datetime.now() print (now.strftime("%Y-%m-%d %H:%M:%S")) #number guesser #a game to guess a number from 0 to x import random def number...
8aa4d1cdf100630328d1f910ec7da929bc9918b0
celineyuwono/simple-blackjack
/blackjack-main.py
4,453
3.9375
4
__author__ = 'Celine Yuwono, yuwono@live.unc.edu, Onyen = yuwono' # import random import random # implement get_player_score function def get_player_score(): card1 = deal_card() card2 = deal_card() total_score = card1 + card2 print('Your hand of two cards has a total value of ', total_scor...
9e9b497f145a1ded7ae593179e52741981e3d3d3
JimiStephen/tutorial
/PY-tutorials/com/py/test/file/FileRenameOrDelTest.py
255
3.5625
4
#!/usr/bin/python # -*- coding: UTF-8 -*- import os fo = open("test1.txt","w"); fo.write("111"); fo.close(); #重命名文件test1.txt到test2.txt os.rename("test1.txt","test2.txt"); # 删除一个已经存在的文件test2.txt os.remove("test2.txt")
a772e5e67263f7d6206b0f9c981bb4d264e983a6
GypsyyCode/LPTHW
/ex4.py
1,318
3.765625
4
# cars equal 100 Int cars = 100 # spac in a car is float 4.0 space_in_a_car = 4 # drivers quals 30 drivers = 30 # passengers shoudt be 90 passengers = 90 # cars_not_driven equals the value of cars 10 minus the value of drivers 30 -20 cars_not_driven = cars -drivers # cars_driven gets the value of drivers cars_driven =...
6c37d13cee59c97a8732cc5b8227335aad5af0eb
hilary-scharton/Data-Science-School
/garden.py
1,731
3.640625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Jun 19 09:17:43 2020 @author: hilaryscharton """ # Create the file garden.py for this task. # Use some Garden Path sentences or think up your own (at least 5). # Here, tokenize and perform Entity recognition for each of the sentences # after you have...
7be590aab950c1c6278838a97c30b990f4101d94
ksharma75/MLPreprocessingTool
/imputation.py
5,080
3.6875
4
import numpy as np import pandas as pd class Imputation: def __init__(self,dataframe): self.dataframe=dataframe def get_dataframe(self): return self.dataframe def set_dataframe(self,x): self.dataframe=x def getOption(self): print('\nTasks(Data Imputation)\n') ...
ae278aaa095ee6e20002e95e0e24af75cf36ac58
kellybren39/SudokuSolver
/graphics.py
4,509
3.65625
4
import Tkinter import sys import math import random import string import time import types from Tkinter import Frame, Tk, Text, E, W, S, N, BOTH, Canvas, Button, TOP, BOTTOM import board class Graphics(Frame): def __init__(self, parent, board): self.MARGIN = 20 # Pixels around the board self...
f6a555bb8191ed9f969793247810259c6e809d41
aycelacap/py_playground
/Fundamentals/Basics i/041_list_slicing.py
394
4.375
4
string = "hello" string[0:2:1] # string[start:stop:step] # we can apply the concept of string slicing to lists # lists are mutable # with list slicing, we create a new copy listlists are mutable amazon_cart = new_cart # these two variable would point on the same place in memory # if instead we want to copy a li...
6cf892b2d5ca9fe205c819ba3487f60a30c400b1
aycelacap/py_playground
/Fundamentals/Basics i/053_dictionary_methods_ii.py
1,076
4.5
4
# how else can we look for items in a dictionary? user = { 'basket': [1, 2, 3] 'greet': 'hello' } print('basket' in user) #True print('hello' in user.keys()) #False print('greet' in user.keys()) #True # how can we grab items print(user.items()) #this prints out a list of the key/value pairs, in tuple form prin...
a29f118e72afd2fea0af99e51e1133487de93a94
aycelacap/py_playground
/Fundamentals/Basics i/037_type_conversion.py
608
4.25
4
name = "Ayce" age = 100 relationship_status = "complicated" relationship_status = "single" # create a program that can guess your age birth_year = input("What year were you born?") guess = 2020 - int(birth_year) print("your age is: {guess}") # string interpolation and input from user as seen in video # if confuse...
ba72fca931e8b2a5ede4b22ac56504bf2ed71fd3
campbellmarianna/Code-Challenges
/python/facebook_abcs/strings_and_arrays/2d_array_prob.py
3,377
3.71875
4
''' Prompt: Given a 2D Array, : 1 1 1 0 0 0 0 1 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 We define an hourglass in to be a subset of values with indices falling in this pattern in 's graphical representation: a b c d e f g There are hourglasses in , and an hourglass sum is the sum of an hourglass...
ba3fdd64577ceb4a842bd5e9968d27559c6bd562
campbellmarianna/Code-Challenges
/python/facebook_abcs/strings_and_arrays/makingAnagrams.py
5,530
4
4
''' Prompt: We consider two strings to be anagrams of each other if the first string's letters can be rearranged to form the second string. In other words, both strings must contain the same exact letters in the same exact frequency. For example, bacdc and dcbac are anagrams, but bacdc and dcbad are not. Alice is taki...
435f09a949e10d5926b47462513ec6a935159a57
campbellmarianna/Code-Challenges
/python/facebook_abcs/graphs/bfs_short_reach.py
3,585
3.84375
4
''' Prompt: Consider an undirected graph where each edge is the same weight. Each of the nodes is labeled consecutively. You will be given a number of queries. For each query, you will be given a list of edges describing an undirected graph. After you create a representation of the graph, you must determine and report...
a47d4bbe65a53d615c1cd5cfe1920527fac92d39
campbellmarianna/Code-Challenges
/python/facebook_abcs/stacks/simpleTextEditor.py
1,559
3.90625
4
# Problem Link: https: // www.hackerrank.com/contests/sf-abcs19-stacks-and-queues/challenges/simple-text-editor # create the stack s = '' # string in text editor # create a state stack state_stack = [] # get user input Q = input() for i in range(int(Q)): parts = input().strip().split(' ') if len(parts) == 2: q...
c28ecc40b7d15eda2b2e51ed3e596bb3e47a0f68
campbellmarianna/Code-Challenges
/python/interview_cake/find_intersecting_rectangles.py
3,905
3.703125
4
''' Return the reactangle intersection within two rectangles my_rectangle = { # Coordinates of bottom-left corner 'left_x' : 1, 'bottom_y' : 1, # Width and height 'width' : 6, 'height' : 3, } ''' # Input: 2 Rectangles (format: dictionary with four key value pairs that are coordinates...
cab33179161f7e62efc1d856bb570c780ad29ac8
campbellmarianna/Code-Challenges
/python/facebook_abcs/stacks/maximunElement.py
6,578
4.09375
4
''' You have an empty sequence, and you will be given queries. Each query is one of these three types: 1 x -Push the element x into the stack. 2 -Delete the element present at the top of the stack. 3 -Print the maximum element in the stack. Input Format The first line of input contains an integer, . The next ...
a84121589e11790997d109b3ed5ed5a1da1cef4c
campbellmarianna/Code-Challenges
/python/interview_cake/string_compression.py
4,478
4.28125
4
''' Given an array of characters, compress it in-place. The length after compression must always be smaller than or equal to the original array. Every element of the array should be a character (not int) of length 1. After you are done modifying the input array in-place, return the new length of the array. Follow...
3ec531367f1e906f1ac3954e860e0d9ba558c41e
campbellmarianna/Code-Challenges
/python/spd_2_4/binary_search_tree.py
2,701
4.1875
4
# Binary Search Tree in Python Credits: Joe James https://youtu.be/YlgPi75hIBc class Node: def __init__(self, val): self.value = val self.leftChild = None self.rightChild = None def insert(self, data): if self.value == data: return False elif self.value > d...
3116c0421bfbcc3827c90609870b9969d3f882fc
campbellmarianna/Code-Challenges
/python/spd_2_4/t9_recursion.py
1,243
4.03125
4
''' Prompt: Given a string of digits 2 to 9 a user has pressed on a T9 telephone keypad, return a list of all letter combinations they could have been trying to type on the keypad ''' # create a dictionary (numbers to letters) # create comb list # find first number letters # find second number letters # loop first numb...
1b68a8e7dda9a6d812c4f6c2407797177ad9c621
campbellmarianna/Code-Challenges
/python/spd_2_4/two_sum_solutions.py
1,426
3.921875
4
''' Two Sum Problem: Given an array a of n numbers and a target value t, find two numbers whose sum is t. Example: a=[5, 3, 6, 8, 2, 4, 7], t=10 => [3, 7] or [6, 4] or [8, 2] There are multiple ways to solve Two Sum. What is described below: - solution ideas - code implementations ''' # Solution Idea #1 # - cr...
f8ae411f3e308a338bfc477e07ccbd4633264404
campbellmarianna/Code-Challenges
/python/crackingCodingInterview/optimizeAndSolveTechnique.py
190
3.75
4
for a in range(1, 50): for b in range(1, 50): for c in range(1, 50): for d in range(1, 50): if a**3+b**3 == c**3+d**3: print(f"a: {a}, b: {b}, c: {c}, d: {d}")
2158e35c2a2534a2f9aa03bc8e816df6821edecf
campbellmarianna/Code-Challenges
/python/facebook_abcs/heaps/find_running_median.py
3,810
4.34375
4
''' Prompt: The median of a set of integers is the midpoint value of the data set for which an equal number of integers are less than and greater than the value. To find the median, you must first sort your set of integers in non-decreasing order, then: If your set contains an odd number of elements, the median is the...
41fb90f9cbf8a56e1dbf130889d0ba9771c5631c
deep-anchor/python-assignment-1
/name.py
97
3.8125
4
a= input("Input user's First Name : ") b= input("Input user's Last Name : ") print (b+ " "+a)
b3fa3f0684277a93891c449ba5e6b12337a92326
prakritikharel/Reinforcement-Learning
/main.py
6,991
3.984375
4
#Prakriti Kharel-- A3 #Goal: using simple Learning Automata, learn the best floor for the car to be waiting using the Tsetlin, Krinsky, Krylov and LRI Schemes, #in each case, use a suitable value for the "memory" and learning parameter import random import math import queue import heapq from collections import deque ...
a1c44782030b5c58ed26b43ff111bf3ed3d5e79c
woodward4422/CS1.3_Data_Structures_Algorithms
/set/sets.py
5,538
4.1875
4
from hashtable import HashTable class Sets(object): def __init__(self, elements=None): # Impement the set with a hashtable since we will have unique keys self.items = HashTable() self.size = 0 if elements is not None: for item in elements: self.add(it...
993a9744b37d49334d20c84ede615f643cd04472
josemiche11/rotationofmatrix
/rotation of matrix.py
499
4.0625
4
num=int(input("Enter the number of rows or column :")) i=num j=num x=num y=num list1=[[0 for u in range(i)]for v in range(j)] list2=[[0 for a in range(x)]for b in range(y)] for i in range(num): for j in range(num): list1[i][j]=int(input("Enter the number for string[{0}][{1}] :".format(i,j))) for x...
65f91220ffcbf25c289a329c0bd3ecc189bfc014
AxelSeg/course-material
/exercices/203/solution.py
214
4.15625
4
# -*- coding: utf-8 -*- """ Created on Mon Sep 22 22:37:07 2014 @author: Axel """ def is_multiple(value1, value2): if value2 % value1 == 0: print(True) else: print(False) is_multiple(2, 6)
6112091d7eb742bab71a3a8e20544100beee3279
AxelSeg/course-material
/exercices/019/solution.py
234
3.5
4
# -*- coding: utf-8 -*- """ Created on Mon Sep 22 15:26:16 2014 @author: Axel """ import sys if len(sys.argv)>1: a = int(sys.argv[1]) b = int(sys.argv[2]) print(a + b) else: print("usage: python3 solution.py OP1 OP2")
ce25e0191e6b2d20dfd7ea90a49f6e319e2f4a38
pawlodkowski/advent_of_code_2020
/day_01/part1.py
548
3.765625
4
""" Find the two entries (from input.txt) that sum to 2020; what do you get if you multiply them together? """ TARGET = 2020 with open("input.txt", "r") as f: data = f.read().split("\n") data = [int(num) for num in data] # wonder if there's a way to do this upon reading for num in data: complement = TARGET ...
32c6f64d1e217606395daf5cdcdc82e0a10cc589
pawlodkowski/advent_of_code_2020
/day_05/part1.py
1,107
3.90625
4
""" Part 1 of https://adventofcode.com/2020/day/5 As a sanity check, look through your list of boarding passes. What is the highest seat ID on a boarding pass? """ import numpy as np def read_data(filename: str) -> list: with open(filename, "r") as f: data = f.read().split("\n") return data def spl...
3f7dd2e108ad2bd674d6f8483e30e6e70750f0c0
pawlodkowski/advent_of_code_2020
/day_12/part1.py
2,139
4.28125
4
""" Part 1 of https://adventofcode.com/2020/day/12 """ # TO-DO: Is it possible to contain the navigation information in a single data structure? CARDINALS = {"E": (1, 0), "S": (0, -1), "W": (-1, 0), "N": (0, 1)} BEARINGS = [(1, 0), (0, -1), (-1, 0), (0, 1)] # maps to current bearing def read_data(filename: str) ->...
8d6431b9674b882a60c76673392e104fbda280c9
Patrico2906/PwSJ_projekt_python-2-
/PROJEKT/baza.py
921
3.53125
4
# -*- coding: utf-8 -*- """ Created on Tue Jun 2 11:23:57 2021 @author: patry """ import sqlite3 if __name__ == "__main__": conn = sqlite3.connect('database.db') print("DB is open") conn.execute('CREATE TABLE pracownicy (imienazwisko TEXT, nrpracownika TEXT, adres TEXT)') print(...
e9630a579a438b3ef60c1848abc70ca129915f70
Echoosx/Steganography
/src/register.py
1,084
3.6875
4
# -*- coding: utf-8 -*- import csv def readcsv(csvfilepath): user_list = list() with open(csvfilepath, 'r',encoding='utf-8') as f: f_csv = csv.reader(f) headers=next(f_csv) for row in f_csv: user_list.append(row) return user_list # 将新的注册用户信息写入csv文件 def writecsv(csvf...
f1750717c4ab4de71da28d8ddc670c1d6207005b
AP-MI-2021/lab-4-simona-sidau
/main.py
4,397
3.65625
4
from collections import Counter def citire_lista(): """ Citeste o lista de numere intregi cu n elemente :param lst: :return: """ lst=[] n = int(input("Introduceti numarul de elemente: ")) for i in range(n): lst.append(int(input("l[" + str(i) + "]="))) return lst def gaseste...
206ffc39af7b0023ca558d69b703d59af4fcf401
adixsharma/IntroPython
/IntroPythonAssignments/print_me_first.py
861
3.890625
4
# This program prints out my name and course as well as the current timestamp # The purpose of the program is to get familiar with our local IDE, create and run a .py file, and print w/ formatting # @param - name # @return - msg # @author - Aditya Sharma # import library to get current time function from datetime imp...
b7795e30836237d41ce2772bcadd806f754b8f66
adixsharma/IntroPython
/IntroPythonAssignments/myDictionary.py
5,100
3.984375
4
# Program Name: myDictionary.py # Program Description: The purpose of this program is to create an address book of contacts stored in a dictionary. Then # a .json file is created and the dictionary contents are appended to it. Next the program reads from the .json file and # then we perform a search for "Ron" and "Sha"...
bb46a7fd5c5b409a8f000ad3bd5cd91f8998a120
fengeric/LearnPythonProject
/hello.py
1,199
4.28125
4
print("hahaha") # 被双引 号包括的字符串 和被单引 号括起的字符串 其工作机制完全相同 # 你可以通过使用 三个引 号—— """ 或 ' ' ' 来指定多 行字符串 。 你可以在三引 号之间 自 由 地使用 单引 号与 双引 号。 # -------------------------------------------- # format的用法,Python 中 format 方法所做的事情便是将每个参数值替换至格式所在的位置 name = "feng" age = 20 print("1{0} was {1} years old when he wrote this book".format(name, ag...
91237cba853ce4bdb5f4c0ae71db8a7ef7a9a636
hilalsidhic/python_basics
/whilesample.py
186
3.765625
4
# i=0 # while i<10: # i += 1 # print(i) row = int(input("input a number")) i = 1 line = row while i <= line: print((row * ' ') + i * " * ") row = row - 1 i = i + 1
3f08437ac2c28aee6f3f07a4ff516d120c86dbda
aman1011/python_basics
/star_pattern2.py
88
3.703125
4
i=1 while(i<=4): print(i*"*") i=i+1 i=3 while(i>=1): print(i*"*") i=i-1
e8f13bee04b6fb4429b88aec9325255007c31c11
2464326176/python
/datatype/2.py
1,492
3.671875
4
#位运算符 # & 按位与运算符:参与运算的两个值,如果两个相应位都为1,则该位的结果为1,否则为0 (a & b) 输出结果 12 ,二进制解释: 0000 1100 # | 按位或运算符:只要对应的二个二进位有一个为1时,结果位就为1。 (a | b) 输出结果 61 ,二进制解释: 0011 1101 # ^ 按位异或运算符:当两对应的二进位相异时,结果为1 (a ^ b) 输出结果 49 ,二进制解释: 0011 0001 # ~ 按位取反运算符:对数据的每个二进制位取反,即把1变为0,把0变为1。~x 类似于 -x-1 (~a ) 输出结果 -61 ,二进制解释: 1100 0011, 在一个有符号二进制数的补码形式。...
6af6d9fec6c25056769ccdab96c95232a3ce5c3c
PIUphil/project_euler
/001~025/problem01.py
305
3.609375
4
# 10보다 작은 자연수 중에서 3 또는 5의 배수는 3, 5, 6, 9 이고, 이것을 모두 더하면 23입니다. # 1000보다 작은 자연수 중에서 3 또는 5의 배수를 모두 더하면 얼마일까요? num = [] for i in range(1000): if i%3==0 or i%5==0: num.append(i) print(sum(num))
4e24285b2d249e027315e08051d1fbb962778995
cbare/data-science-from-scratch
/chapter_07/hypothesis_testing.py
7,557
4
4
""" Hypothesis Testing Code from Chapter 7 of Data Science from Scratch """ from normal import normal_cdf, inverse_normal_cdf from central_limit_theorem import binomial import math, random import matplotlib.pyplot as plt def normal_approximation_to_binomial(n, p): """finds mu and sigma corresponding to a Binomia...
ae41f11502dfb4f44489494ed9023fee9df5a9e8
cbare/data-science-from-scratch
/chapter_05/test_stats.py
1,446
3.59375
4
""" Tests for stats functions """ import random from stats import * def approx(a, b, epsilon=1e-6): return abs(a-b) < epsilon def test_find_bin(): # one big bin for all real numbers assert find_bin(123, []) == 0 # divide into + and - assert find_bin(123, [0]) == 1 assert find_bin(0.0, [0])...
a47cbf1fef327b5ff5e6d5e571f307f907c83f4e
OswinOswalt/lesson1
/fifth_task.py
934
3.796875
4
import os print("\tЗдравствуйте! Что бы вы хотели сделать?\n") print("\t1 -- Вывести Hello, World!") print("\t2 -- Вывести информацию обо мне") print("\t3 -- Вывести информацию о системе") print("\t4 -- Вывести приветстие с вашим именем") number = int(input("\tЧто выбираете?\t\t")) if number == 1: print("\n\tHell...
867c58f1bef940d3ea93f06e7ce3b793e18dbc03
yuntianming0613/learnpython
/条件判断.py
1,147
4.25
4
# -*- coding: utf-8 -*- age = 20 if age >= 18: print('your age is ', age) print('adult') age = 3 if age >= 18: print('your age is ', age) print('adult') else: print('your age is ', age) print('teenager') age = 4 if age >=18: print('your age is', age) print('adult') elif age >= 6: ...
687d5cc5c622e0310e08c7bfae0183683fb1f81c
kaleumelo/Lista-de-exercicio
/Questao 03.py
1,299
4.03125
4
salario_horas= float( input('Quanto voce ganha por hora ?\n ')) horas = float(input('E quantas horas trabalhou no mes ?\n')) salario_bruto = salario_horas * horas sindicato = 3 calculo_sindicato = salario_bruto * (sindicato/100) FGTS = 11 calculo_fgts= salario_bruto * (FGTS/100) if(salario_bruto <= 900): salario =...
4bb35ca28df8601219214669c0b8740947952821
theamritanair/Cryptography
/Assignment-1/primtiveelements.py
524
3.53125
4
import math def gcd(a, b): if b==0: return a else: return gcd(b, a%b) def primitive_elements(a, outfile): for i in range(a+1): if(gcd(i,a)==1): outfile.write(str(i) + " ") print() # primitive_elements(39877) with open('output.txt', 'w+') as f: primitive_elemen...
02301984b7cf81be680136da913bf3696c16cab6
Farah-H/python_classes
/class_task.py
1,808
4.34375
4
# Task # create a Cat class class Cat: # Create 2 class level variables coward = False cute = True fluffy = True # one function which returns 'MEOWWWWWWW', added some details :) def purr(self,cute,coward,fluffy): if cute and fluffy: print('You approach this adorable cat..') ...
11690e023e8d5544757fb14773d67f52cdb8cd0a
GUG11/SVM
/svm.py
8,362
3.578125
4
import numpy as np class SVM: """ min 1/2 ||w||^2 + C \sum_{i=1}^N xi_i s.t. y_i(w^T x_i - b) >= 1 - xi_i xi >= 0 """ def __init__(self, C, kernel=('linear',)): """ initialize SVM :param C: cost of misclassification :param kernel: kernel ('linear...
7681ca9ded4d706f81e9f75fddc76cc4eff4094e
kamikazeem1/Pettiness
/petty.py
947
3.75
4
from random import randint as r def main(): print("\nPETTY TEXT CONVERTER") print("type or copy and paste text into terminal, then type 'commit' to convert\n") while True: try: text = '' run = True print(">> ", end='') while run: ...
3fbba0b056c2aa515949f6be884331401a6d71ad
G8A4W0416/Module6
/more_functions/validate_input_in_functions.py
921
4.34375
4
def score_input(test_name, test_score=0, invalid_message='Invalid test score, try again!'): """ This takes in a test name, test score, and invalid message. The user is prompted for a valid test score until it is in the range of 0-100, then prints out the valid input as 'Test name: ##'. :param test_name: Str...
dc5331247cf29f1f827e080251c861ddd6515dd9
HeatherOrtegaMcMillan/python-exercises
/data_types_variables_exercises.py
1,615
4.09375
4
data_types_variables_exercises.py type(99.9) # float type("False") # str type(False) # bool type('0') # str type(0) # int type(True) # bool type("True") # str type([{}]) # list type({'a': []}) # dict # A term or phrase typed into a search box? - string # If a user is logged in? - bool # A discount amount to a...
594f1fb22efbc882624db6dcc69370d0a820ab8d
ShigekiKarita/rl-book-gym
/rl_book_gym/envs/racetrack.py
7,443
3.703125
4
import numpy from enum import IntEnum class Action(IntEnum): up = 1 keep = 0 down = -1 class Reward(IntEnum): finish = 1 not_finish = -1 class Map(IntEnum): out_side = 0 in_side = 1 start = 2 finish = 3 car = 4 class Env: """Exercise 5.10: Racetrack (programming) Con...
9a37cd9d27891606f312600ea0ae43aa6111cecd
BernhardKonrad/swcKiel
/intro.py
1,251
3.828125
4
mystring = "Let's do this" print dir(mystring) print mystring.swapcase() a= 1 b =2 c = a+b print type(a), type(b), type(c) a = 1 b = 2.0 c = a + b print type(a), type(b), type(c) a = 1 b = 2 c = a / b print c, type(c) a = 1.0 b = 2.0 c = a / b print c, type(c) a = 1 b = 2 c = float(a) / b print c, type(c) volt...
75475a88abfc47f5808ba6578734d21a9710e948
Hearmit14/machine_learning
/code/newton_method.py
2,004
3.75
4
import numpy as np import matplotlib.pyplot as plt def f(x): return 100 * (x[1] - x[0] ** 2) ** 2 + (1 - x[0]) ** 2 def gradient(x): return np.array([-400 * x[0] * (x[1] - x[0] ** 2) - 2 * (1 - x[0]), 200 * (x[1] - x[0] ** 2)]) def hessian(x): return np.array([[-400*(x[1]-3*x[0]**2)+2, -400*x[0]], [-4...
c6092a6f3de76ec1869fda4249a2a761eaa2dd0f
joydeep181992/data_structure
/sum_up_nums.py
329
3.625
4
def two_sum(listi, k): two_sum_nums = [] for i in range(len(listi)): number = listi[i] for j in range(i+1, len(listi)): if number + listi[j] == k or number - listi[j] == k: two_sum_nums.append([number, listi[j]]) return two_sum_nums print(two_sum([4,7,1,-...
646a23328dc025fb02b275d78d4984c5610a51d8
djalexram/python
/filter.py
9,786
3.5625
4
import json class Harfilter: def __init__(self,har): self.har = har def test_match(self, url, criterions=[], har=None): """ Returns True if a request with given url and matching given criterions has been captured. :param url: URL substring the request URL has to cont...
f81cc187d251a995fa81d7852d074fe958061c06
adecool/FUNCTIONalgoritm
/kineticEnergy.py
304
3.875
4
def main(): mass = int(input('enter the mass in kilogram: ')) velocity = float(input('enter the velocity of tht body: ')) kinetic_e = kinetic_energy(mass,velocity) print(f'the kinetic Energy is {kinetic_e}J') def kinetic_energy(x,y): KE = 0.5 * x * (y)**2 return KE main()
7f005356a3b9b350dc13d1151020d7d720c64c13
adecool/FUNCTIONalgoritm
/foot_to_inches.py
332
4.03125
4
def main(): number_in_ft = get_num_feet() number_in_inches = calc_no_in_inches(number_in_ft) print(f'{number_in_ft}ft is equivalent to {number_in_inches}inches') def get_num_feet(): feet = int(input('enter the number in feet: ')) return feet def calc_no_in_inches(x): inches = x * 12 return i...
3ae9601eabc5ee237c894f362ebec05b3f651045
adecool/FUNCTIONalgoritm
/monthlySalesTax.py
581
3.796875
4
def main(): num = int(input('enter the total sales for the month: ')) states_tax = calc_states_tax(num) country_tax = calc_county_tax(num) total_tax = total_monthly_tax(states_tax, country_tax) print(f'the following are the states tax,' + f'country tax and the total tax for the months resp.' ...
1a2333a7a5f3ee3857be20b347696da1cf738ff0
rajsingh7/Project-WQU-MarketsComovement
/Panko_Aliaksandr-Project_2-Nov_13_2017.py
6,034
4.15625
4
# Python 2.7 Windows 7 #1. Write a python program that prompts the user to choose # any five stock exchanges of the world # (whose data is available on Yahoo Finance) # #2. For each such market, let the program automatically choose the relevant # Market Index (say S&P500 for USA, CNXNIFTY for India etc...
11257e0908becf0aadcf8d0373cb6d5b906cda05
Bosnomer/100-days-of-HackerRank
/Python/day2.py
489
3.703125
4
# Python If-Else import math import os import random import re import sys if __name__ == '__main__': n = int(input().strip()) if (n>=1 and n<=100): if(n%2!=0): print("Weird") if((n%2==0) and (n in range(2,6))): print("Not Weird") if((n%2==0)...
2c74642447f85a3df034bfcc539fe494c93c9dc4
Bosnomer/100-days-of-HackerRank
/Python/day47.py
251
3.84375
4
# Detect Floating Point Number n = int(input()) for i in range(n): try: check=input() check=float(check) if (check==0): print("False") else: print("True") except: print("False")
0b118112b1968afa8afc577026285acac0ee621e
svwriting/StudyStudyNight
/Python基礎/homeworks/1105_os/1105_os.py
3,752
3.546875
4
import os def PrintAndInput(menu): global menuList menuList=[] for option in menu: menuList.append(option) for i in range(len(menuList)): print(f" ({i}) {menuList[i]}") return int(input("操作:")) def MENU(): global menu menu={"離開程式":EXIT, \ "列出檔案"...
11ed4d6c13c6340f562f313f71d75bf72e7f5db4
Buryat312/2.5--Sultanbek-Asakeev
/DZ_25_Python_Sultanbek_Asakeev2.py
602
3.515625
4
#Задание 2 import random names = ['dhhgfjjhsa.txt', 'hhdsdahffh.txt', 'afdgdhjsds.txt', 'sggjghddss.txt', 'fjdjgdghdf.txt', 'sjssahjfga.txt', 'agsgdjhhfj.txt', 'gafadhadda.txt', 'hdagajfhhj.txt', 'fhjhafhdfa.txt'] new_name = random.choice(names) l = len(names) with open(new_name, 'w') as f: f.write('Hallo strang...
6832afafc0f5c16e3222c3ce6051b5585bd7710d
General-Gouda/PythonTraining
/Training/Lists.py
713
4.25
4
student_names = [] # Empty List variable student_names = ["Mark","Katarina","Jessica"] # List variable with 3 entries print(student_names) student_names.append("Homer") # Adds Homer into the List print(student_names) if "Mark" in student_names: # Checks to see if the string "Mark" is in the List student_names ...
ac743ad6bd03bedb544e59d2d1797fc3ff2b7a9e
General-Gouda/PythonTraining
/Training/ForLoops.py
975
4.4375
4
student_names = ["Mark", "Katarina", "Jessica"] for name in student_names: print("Student name is {0}".format(name)) # Interates through each element in the List. There is no ForEach in Python. For does it automatically. x = 0 for index in range(10): # Range(10) if it were printed would look like [0,1,2,3,4,5...
df05bbb841a4142ff87889cce1e1f014de49987c
ad-egg/holbertonschool-higher_level_programming
/0x0A-python-inheritance/100-my_int.py
583
4.1875
4
#!/usr/bin/python3 """ this module contains a class MyInt which inherits from int """ class MyInt(int): """ this class MyInt inherits from int but has == and != operators inverted """ def __init__(self, value=0): """ instantiates an instance of MyInt with value """ self...
b7849c1c75bd8ae24fbe9c4d8b136b4b1c5bcd19
ad-egg/holbertonschool-higher_level_programming
/0x08-python-more_classes/4-rectangle.py
2,717
4.59375
5
#!/usr/bin/python3 """ This module contains an empty class that defines a rectangle. """ class Rectangle: """an empty class Rectangle that defines a rectangle a rectangle is a parallelogram with four right angles """ def __init__(self, width=0, height=0): """ instantiates a rectangle w...
8cb43bd9fe9e3110afdbf1baa1fc5d246d692e94
Bapan0814036/First-Repository
/test102.py
642
3.796875
4
from functools import total_ordering @total_ordering class Student: def __init__(self,name,rollnumber): self.name=name self.rollnumber=rollnumber def __le__(self,other): if isinstance(other,Student): return self.rollnumber<other.rollnumber def __eq__(self,other):...
dc8a4283430e1f64cd30f7d5232dde943f0a57b3
umarfarooq4/Project
/Chess game.py
7,866
4.4375
4
# ============================================================ # # Student Name (as it appears on cuLearn): Umar Farooq # Student ID (9 digits in angle brackets): <101094104> # Course Code (for this current semester): COMP1405A # # ============================================================ ''' This function set the ...
fe509c567d5b9ab36da3f50ee7f17ae92f0f0b0d
SmiteLi/python-note
/base/7-filter-sorted.py
1,431
4.125
4
# filter()也接收一个函数和一个序列。和map()不同的是,filter()把传入 # 的函数依次作用于每个元素,然后根据返回值是True还是False决定保留还是丢弃该元素。 # filter()函数返回的是一个Iterator,也就是一个惰性序列,所以要强迫filter()完成计算结果, # 需要用list()函数获得所有结果并返回list。 def is_odd(n): return n % 2 == 1 list(filter(is_odd, [1, 2, 4, 5, 6, 9, 10, 15])) def not_empty(s): return s and s.strip(...
f28c9f7153e3a9a69e19e7452e400bdd4a784ad0
SmiteLi/python-note
/base/11-class-object.py
1,106
3.953125
4
class Student(object): # # 方法的第一个参数永远是self,表示创建的实例本身 # 如果要让内部属性不被外部访问,可以把属性的名称前加上两个下划线__,在Python中, # 实例的变量名如果以__开头,就变成了一个私有变量(private),只有内部可以访问,外部不能访问 def __init__(self, name, score): self.__name = name self.__score = score def print_score(self): print('%s %s' % (...
030d32c1d9e1f809046976a7e1bb2aea87736aed
NixonRosario/crytography-using-Fernet
/main.py
2,419
4.21875
4
# This is a sample Python script. # Press Shift+F10 to execute it or replace it with your code. # Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings. from cryptography.fernet import Fernet # install cryptography and import Fernet key = Fernet.generate_key() # gen...
ec823e35ba2387cca400cea55d8916034f0123d1
RayWLMo/Eng_89_Python_Collections
/dict_sets.py
2,064
4.8125
5
# Dictionaries and Sets are both data collections in Python # Dictionaries # Dict are another way to manage data but can be a little more Dynamic\ # Dict work as a KEY AND VALUE # KEY = THE REFERENCE OF THE OBJECT # VALUE + WHAT THE DATA STORAGE MECHANISM YOU WISH TO USE # Dynamic as it we have Lists, and anot...
7314b6b95f0d375b390e557253de19edee9e30f6
sid22/deeplearning-api
/models/tf_utils.py
1,992
3.578125
4
import math import numpy as np import tensorflow as tf def predict(X, parameters): W1 = tf.convert_to_tensor(parameters["W1"]) b1 = tf.convert_to_tensor(parameters["b1"]) W2 = tf.convert_to_tensor(parameters["W2"]) b2 = tf.convert_to_tensor(parameters["b2"]) W3 = tf.convert_to_tensor(paramet...
771c5180550764cdb86bd428113a70550b318b7f
ZeitQ/tres_raya
/Back_Propagation_prueba.py
10,856
3.734375
4
# Red Neuronal Back-Propagation import math import random import string random.seed(0) # Calcula un numero aleatorio donde: a <= rand < b def rand(a, b): return (b-a)*random.random() + a # Crea una matriz def makeMatrix(I, J, fill=0.0): m = [] for i in range(I): m.append([fill]*J) return m ...
d8517379b7a80adb16ab147a600cfea197c5dec5
VidhiPS/Vidhi
/homework 2.py
445
3.703125
4
number1=input("number of Corona virus deaths in USA ?") number2=input("number of Corona virus deaths in Italy ?") number3=input("number of Corona virus deaths in the UK ?") number4=input("number of Corona virus deaths in the rest of the world ?") addition=(int(number1)+ int(number2)+int(number3)+int(number4)) ...
7e54c685032679e4efa061bc31b036c48378d014
VidhiPS/Vidhi
/converting 2.py
121
3.859375
4
gram=input (" Enter your gram amount") kilograms=(int(gram)/1000) print ("your grams in kilograms " + str(kilograms))
11e967e357fbb71b41e1b9caa6861a57ab15d767
VidhiPS/Vidhi
/11.05.20 revision 2.py
142
4.03125
4
name=input("What is your name ?") age=input("What is your age ?") print (" Oooh your name is "+ str(name) + " and your age is "+ str(age))
130591b44a009f17112d0172e4dfb395c04ceed4
group1BSE1/BSE-2021
/src/chapter2/exercise7.py
1,026
3.84375
4
num = float(input("Enter amount to change: ")) # 100 dollar notes num1 = num//100 # remainder after 100d num2 = num%100 #50 dollar note num3 = num//50 # remainder after 50 num4 = num2%50 # 20 dollar notes num5 = num4//20 #remainder after 20 num6 = num4%20 #notes by 10 num7 = num6//10 #remainder after 10 num8 = num6%10 ...
a0f92bce63434f6dd8690d17ebe585c0146e011b
group1BSE1/BSE-2021
/src/chapter3/exercise4.py
262
4.09375
4
try: age = int(input('Enter your age: ')) if age >= 18: print('You can vote') elif age > 0 and age <= 17: print('Too young to vote') else : print("Your a time traveller") except: print('Please enter age as an integer')
374a8d5bbe59f30f7d8b1a6b9f02c9be92120e91
group1BSE1/BSE-2021
/src/chapter5/exercise2.py
292
4.15625
4
largest = None smallest = None while True: num = input('Enter a number: ') if num =='done': break elif largest is None or num > largest: largest = num elif smallest is None or num < num: smallest = num print('maximum',largest) print('minimum',smallest)
d974e78ca248bb2322da4ca150b523610bdb67df
AranzaCarolina/Primerrepo
/evidenciaWhile.py
763
4.125
4
#Menu Ciclico while True: print("operaciones: [1]suma, [2]resta, [3]multitplicacion, [4]division, [5]salir") eleccion = input("Selecciona una de las opciones anteriores: ") if eleccion == "1" or eleccion == "2" or eleccion == "3" or eleccion == "4": n1 = int(input("introduce el primer numero: ")) ...
9250e0bab7e1c634b3aa416c66bce8cddd5ec048
timurkurbanov/firstPythonCode
/firstEx.py
463
4.46875
4
# Remember, we get a string from raw_input, but we need an int to compare it weather = int(25); # if the weather is greater than or equal to 25 degrees if weather >= 25: print("Go to the beach!") # the weather is less than 25 degrees AND greater than 15 degrees elif weather < 25 and weather > 15: print("Go ho...
7bc262beb842765e249819a987fd68c68f3bd0b1
MTaylorfullStack/flex_lesson_transition
/jan_python/week_one/playground.py
1,191
4.15625
4
print("Hello World") ## Data Types ## String collection_of_characters="hrwajfaiugh5uq34ht834tgu89398ht4gh0q4tn" collection_of_characters+="!!!!!!!!!!!!!" name="Adam" stack="Python" # print(f"The student {name} is in the {stack} stack") ## Numbers ## Operators: +, -, /, *, % ten=10 one_hundred=100 # print(one_hu...
80f8395efeb108395a9d599b5a340458c86fa964
SkyLined/mWindowsAPI
/fsHexNumber.py
751
3.53125
4
def fsHexNumber(iNumber, u0BitsPerBlock = 16): # Show a number as either "0"-"9" or "0x##`####" # Hex digits are grouped in multiples of u0BitsPerBlock # bits (e.g. 8 == 0x#`##`##, 16 = 0x###`####, 32 = 0x###`########) # if u0BitsPerBlock is None, no grouping is done (e.g. 0x#############) sSign = "-" if iNum...
aafe5df1d6c5063c0a0cb0c4fd11397856745820
hg19991220/myproj
/day4/quest1/exception.py
447
3.640625
4
if __name__ == '__main__': print("输入两个数计算除法") print("输入q退出") while True: print("\t") fnum=input("First number:") if fnum=="q": break snum=input("Second number") if snum=="q": break try: res=int(fnum)/int(sum) except ZeroDivision...