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 |
|---|---|---|---|---|---|---|
5207495ad7699318b8650d2f61272995fceecbc4 | aruncancode/wshsprojects | /002_AddingMachine/adding_machine.py | 3,062 | 4.03125 | 4 | from tkinter import *
def add():
# retrieves the value from the input box and assigns it to a variable
number1 = float(inpNumber1.get())
number2 = float(inpNumber2.get())
result = number1 + number2
# assigns the result variable to the text variable
lblResult.config(text=result)
def subtracti... |
c1f32f2060251d7e5b4349eafb98023bcaece3a0 | suryaaathhi/python | /vowel.py | 245 | 3.96875 | 4 | #enter the variable
variable=(input())
l=variable.isalpha()
if(l==True):
if( variable=="a" or variable=="e" or variable=="i" or variable=="o" or variable=="u"):
print("Vowel")
else:
print("Consonant")
else:
print("invalid")
|
b848f777182c2bce5c0a87a38b14608b39cc45fb | satishjasthi/CodeWar-Kata-s | /FindTheOddInt.py | 606 | 4.09375 | 4 | #Details:Given an array, find the int that appears an odd number of times.
#There will always be only one integer that appears an odd number of times.
#my first attempt code :)
def find_it(l):
return([number for number in l if (l.count(number)%2 != 0)][0])
#a = find_it([1,1,5,3,3,6,5,3,6,6,6]);print(a)
#other amaz... |
eb667a28193f5c61ffc489d15285584d0a34ae13 | D10D3/Battleship | /battleship.py | 10,098 | 3.90625 | 4 | import os
import random
os.system('cls')
""" Single Player BattleShip Game Info:
Boards have 100 cells in 10 rows numbered A0 through J9
(chose to use 0-9 instead of traditional 1-10 to simplify code)
Cells will have 3 states:
"-" = empty or unknown
"O" = filled
"X" = bombed
"@" = known hit
players h... |
cc86f40a36fb6e74dae178fa6e1fd7324c17703e | Matt-Zimmer/week-3-lab-Matt-Zimmer | /week-03-lab-Matt-Zimmer.py | 2,807 | 3.875 | 4 | ######################################
# IT 2750 - Spring 2021 - Week 3 Lab #
# Password Cracking #
# Author: Matt Zimmer #
# Student: S00646766 #
######################################
############################################
#### SCROLL DOWN #####################... |
eafef01f598c0b42b79646000b0e6355d56ded43 | keelymeyers/SI206-Project1 | /206project1.py | 5,635 | 3.96875 | 4 | import os
import csv
import filecmp
## Referenced code from SI 106 textbook 'Programs, Information, and People' by Paul Resnick to complete this project
def getData(file):
#Input: file name
#Ouput: return a list of dictionary objects where
#the keys will come from the first row in the data.
#Note: The column heading... |
2d69346d0d83057fd18eb28f51e9135b16f1a87f | juelianzhiren/python_demo | /alice.py | 236 | 3.640625 | 4 | filename="alice.txt";
try:
with open(filename) as f_obj:
contents = f_obj.read();
except FileNotFoundError:
msg = "Sorry, the file " + filename + " doesn't exist";
print(msg);
title = "Alice in Wonderland";
print(title.split());
|
9d2496045c0476bf19d4b3ce8f65894093f5083d | ynadji/scrape | /scrape-basic | 638 | 3.65625 | 4 | #!/usr/bin/env python
#
# Basic webscraper. Given a URL and anchor text, find
# print all HREF links to the found anchor tags.
#
# Usage: scrape-basic http://www.usenix.org/events/sec10/tech/ "Full paper"
#
# returns:
#
# http://www.usenix.org/events/sec10/tech/full_papers/Sehr.pdf
# ...
# http://www.usenix.org/events/... |
e775866737d6da83a8311e5eaa45df7dcee199ea | vigneshrajmohan/CharterBot | /CharterBot.py | 3,356 | 3.765625 | 4 | # PyChat 2K17
import random
import time
def start():
pass
def end():
pass
def confirm(question):
while True:
answer = input(question + " (y/n)")
answer = answer.lower()
if answer in ["y" , "yes", "yup"]:
return True
elif answer in ["n", "no", "nope"]:
... |
4819a44f44262619c27320ce0fab50351f5039d6 | urmomlol980034/GCALC-V.2 | /square.py | 419 | 3.796875 | 4 | from os import system, name
from time import sleep
from math import sqrt
def clear():
if name == 'nt':
_ = system('cls')
else:
_ = system('clear')
def square():
sleep(1)
clear()
print('You have chosen: Square Root')
f = eval(input('What number do you want to be square rooted?\n> '))
equ... |
0d9f1324ec8c52ff6f2639439d705e11f65a35be | prah23/Stocker | /ML/scraping/losers/daily_top_losers.py | 943 | 3.515625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 29 23:52:33 2020
@author: pranjal27bhardwaj
"""
# This function will give the worst performing stocks of the day
import requests
from bs4 import BeautifulSoup
import pandas as pd
import matplotlib.pyplot as plt
def daily_losers():
dfs = pd.read... |
d6aa861af8b2d53326a1dc779682273bb09ac52c | rlgustavo/DarkWord | /Dark-world/Dark_World_S1.py | 26,383 | 3.546875 | 4 | """
Grupo 4
Indice:
1. Definição de cores
2. Abertura do display, considerando altura e largura
3. Iniciado a função Clock
4. Carregando para a memória as músicas presentes./
definido a função para o som das teclas
5. Carregando imagens para memória/redimensionando B1,
referente a imagens, de setas e B3, ... |
ef8e05fe07b951ec8d95b0c64491616b227eb0a2 | bmanandhar/python-playground | /b.py | 233 | 3.734375 | 4 | n = 100
for i in range(100):
i = i + 2
print(i)
arr = [1,2,3,4,5]
for i in range(len(arr)):
for j in range(5):
print('i is :-', i)
print('j is: ', j)
x = [7,2,4,1,5]
for i in range(len(x) - 1):
for |
e0241ab69dbb1a40c43e0db5fdcd2f0cc545100b | BOURGUITSamuel/NmapScanner_Project | /Scanner.py | 2,154 | 3.71875 | 4 | # coding: utf-8
import sys
import nmap
import re
import time
# Using the nmap port scanner.
scanner = nmap.PortScanner()
# Regular Expression Pattern to recognise IPv4 addresses.
ip_add_pattern = re.compile("^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$")
# Display the program banner.
print("-------------------")
print("Nmap pyt... |
21791a22f0b353d69cf2f6ce03dff7a488cb2bbc | lazorfuzz/gameofde_rest | /ciphers/benchmark.py | 1,410 | 3.53125 | 4 | from Dictionaries import LanguageTrie, trie_search, dictionarylookup
import time
class Color:
PURPLE = '\033[95m'
CYAN = '\033[96m'
DARKCYAN = '\033[36m'
BLUE = '\033[94m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
RED = '\033[91m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
END = '\033[0m'
def t... |
159d935411dd314c544af263dc1edf7e5d9f8238 | ztoolson/Intro-to-Algorithms-and-Data-Structures | /LinkedList.py | 4,457 | 4.3125 | 4 | class List:
"""
Implementation of a Singely Linked List.
"""
def __init__(self):
""" (List) -> NoneType
Initialize the head and tail of the list
"""
self.head = None
self.tail = None
def __str__(self):
""" (List) -> str
"""
re... |
17911c3e3c9f130caeeddf9dc571068a25d7bf4b | ArnaudParan/stage_scientifique | /gestion_doonees/operations_vect.py | 1,890 | 3.5625 | 4 | #!/usr/bin/python3.4
#-*-coding:utf-8-*
from donnees import *
import math as Math
##
# @brief crée la moyenne d'un tableau
# @param tab le tableau qu'on moyenne
# @return la moyenne
def moy (tab) :
taille_tab = len (tab)
moyenne = 0.
for elem in tab :
moyenne += float(elem) / float(taille_tab)
return moyenne
d... |
177f4d54814f1f899d2ea119454b0d692dfff382 | AphelionGroup/Examples | /SampleBots/WeatherBot/getWeather.py | 2,199 | 3.578125 | 4 | import argparse
from flask import Flask
from flask_restful import Resource, Api, reqparse
import json
import urllib2
class getWeather(Resource):
def forecast(self, city):
answer = None
# calls the weather API and loads the response
res = urllib2.urlopen(weather_today + city)
data ... |
b13aa117b4f2bd0f0a04ce3b04ff9950c239a7f6 | wenjie711/Leetcode | /python/021_merge_2_sorted_lists.py | 909 | 3.953125 | 4 | #!/usr/bin/env python
#coding: utf-8
# Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
# @param {ListNode} l1
# @param {ListNode} l2
# @return {ListNode}
def mergeTwoLists(self, l1, l2):
l = ListNode(0)
... |
9cd76f9d4d60443cefc3cf495b67cade9ee06fba | wenjie711/Leetcode | /python/070_climbing_stairs.py | 538 | 3.9375 | 4 | #!/usr/bin/env python
#coding: utf-8
class Solution:
# @param {integer} n
# @return {integer}
def climbStairs(self, n):
c = n / 2
r = 0
for i in range(0, c + 1):
j = (n - i * 2) + i
r += self.C(i,j)
return r
def C(self, i, j):
return self.... |
5d105331052818558742bc74a88b8bc02978a40a | wenjie711/Leetcode | /python/137_single_Num2.py | 452 | 3.78125 | 4 | #!/usr/bin/env python
#coding: utf-8
class Solution:
# @param {integer[]} nums
# @return {integer}
def singleNumber(self, nums):
one = 0
two = 0
three = 0
for i in range(len(nums)):
two |= one & nums[i]
one ^= nums[i]
three = two & one
... |
39068a965cfff9d2ca75fdfe8135d25c52b13142 | jovicamitrovic/ori-2016-siit | /vezbe/01-linreg/src/solutions/linreg_simple.py | 1,645 | 3.578125 | 4 | """
@author: SW 15/2013 Dragutin Marjanovic
@email: dmarjanovic94@gmail.com
"""
from __future__ import print_function
import random
import matplotlib.pyplot as plt
def linear_regression(x, y):
# Provjeravamo da li su nam iste dimenzije x i y
assert(len(x) == len(y))
# Duzina liste x i... |
fd10e971ea57316b742f15932f0c0d17613e6e4f | jovicamitrovic/ori-2016-siit | /vezbe/01-linreg/src/bonus/birth_rate.py | 1,521 | 3.625 | 4 | # -*- coding: utf-8 -*-
"""
@author: Stefan Ristanović SW3/2013
@email: st.keky@gmail.com
- Description:
Birth Rates,
per capita income,
proportion (ratio?) of population in farming,
and infant mortality
during early 1950s for 30 nations.
- Conclusion:
In that period of... |
afe9f6bb6ba3598cb26b52432df699531c19d968 | ChihChiu29/ml_lab | /image_recognition/hotspot_on_noise_classification.py | 4,037 | 4.0625 | 4 | """Academical examples on image classifications.
This module is an experiment for classifying images. The goal is to train a
model that can successfully identify images annotated in certain way. The
annotation is a small image that's super-imposed on a background image.
"""
import keras
import numpy
from keras import ... |
12daf4f361701b49e3a14820d6bb91d337497de1 | bjskkumar/Python_coding | /test.py | 1,591 | 4.28125 | 4 | # name = "Jhon Smith"
# age = 20
# new_patient = True
#
# if new_patient:
# print("Patient name =", name)
# print("Patient Age = ", age)
#
# obtaining Input
name = input("Enter your name ")
birth_year = input (" Enter birth year")
birth_year= int(birth_year)
age = 2021 - birth_year
new_patient = True
if new_... |
6f582a234b2c9264a2bf877047ac7c9a66b22ae4 | dnackat/cs50x-intro-to-comp-sci | /sentimental/vigenere.py | 1,727 | 4.03125 | 4 | # vigenere.py
import sys
import string
# Define a main function to match C code
def main():
# Check if input is correct
if len(sys.argv) == 1 or len(sys.argv) > 2 or not str.isalpha(sys.argv[1]):
print("Usage ./vignere k")
sys.exit(1)
else:
# Convert key to lowercase
key ... |
487e1b65563ee4502403216662ee64a4f119d78b | DmytroLopushanskyy/lab11_part2 | /polynomial/polynomial.py | 5,656 | 4.34375 | 4 | """
Implementation of the Polynomial ADT using a sorted linked list.
"""
class Polynomial:
"""
Create a new polynomial object.
"""
def __init__(self, degree=None, coefficient=None):
"""
Polynomial initialisation.
:param degree: float
:param coefficient: float
""... |
ee30fcac54df14dc48870f687033ce02266bb5c9 | prasadnaidu1/django | /Adv python practice/QUESTIONS/14.py | 125 | 3.859375 | 4 | n=int(input("enter no :"))
lst=[]
for x in range(0,n):
if x%2!=0:
lst.append(x)
else:
pass
print(lst) |
cb25bb6cd9b6a5ef56ac747b131369787d0efa78 | prasadnaidu1/django | /Adv python practice/method override/KV RAO OVERRIDE2.py | 1,096 | 3.984375 | 4 | class numbers(object):
def __init__(self):
print("i am base class constructor")
def integers(self):
self.a=int(input("enter a value : "))
self.b=int(input("enter b value : "))
self.a,self.b=self.b,self.a
print("For swaping integers of a, b : ",self.a,self.b)
print... |
abb0668e938b64b6cf404a3d11aa50b2e4d1d463 | prasadnaidu1/django | /Adv python practice/OOPS/constructer.py | 798 | 3.78125 | 4 | class sample:
comp_name = "Sathya technologies"
comp_adds = "Hyderabad"
def __init__(self):
while True:
try:
self.employee_id = int(input("Enter a No : "))
self.employee_name = input("Enter a Name : ")
print("Company Name : ",sample.comp_na... |
d463732ff9853cf2872192e16a3ff1dda5ba763c | prasadnaidu1/django | /Adv python practice/OOPS2.py | 360 | 3.859375 | 4 | #Write a program on class example without creating any object.
class demo:
comp_name="Prasad Technologies"
Comp_adds="hyd"
@staticmethod
def dispaly(x,y):
print("Company Name:",demo.comp_name)
print("Company Adds :",demo.Comp_adds)
i=x
j=y
print("The sum of above ... |
e597d95e27d3968b8316fcb844a7ec26576dbca7 | prasadnaidu1/django | /Adv python practice/sisco3.py | 5,404 | 3.859375 | 4 | lst = []
while True:
name = input("Enter Name : ")
lst.append(name)
ans = input("Continue press y : ")
if ans == "y":
continue
else:
print(lst)
res = len(lst)
print(res)
break
class management:
def putdetails(self):
self.type=input("Enter Type Of I... |
7c4b8a424c943510052f6b15b10a06a402c06f08 | prasadnaidu1/django | /Adv python practice/QUESTIONS/10.py | 845 | 4.125 | 4 | #Question:
#Write a program that accepts a sequence of whitespace separated words as input and prints the words after removing all duplicate words and sorting them alphanumerically.
#Suppose the following input is supplied to the program:
#hello world and practice makes perfect and hello world again
#Then, the output s... |
ee21470f4fda9757bd0e754f2b3dceb80c6fe4af | prasadnaidu1/django | /Adv python practice/ASSIGNMENT2.py | 3,046 | 3.953125 | 4 | basic_salary = float(input("Enter Your Salary : "))
class employee:
def salary(self):
tax=input("If You Have Tax Expenses Press y/Y : ")
if tax=="y":
ta=float(input("Enter How much TaxExpenses You Have(In The Form Of Percentage): "))
ta_r=ta/100
self.taxes=basic_... |
56431060c05fe0ab91e9b1e4c6ac3939d3936b47 | prasadnaidu1/django | /Adv python practice/QUESTIONS/9.py | 474 | 4.03125 | 4 | #Question£º
#Write a program that accepts sequence of lines as input and prints the lines after making all characters in the sentence capitalized.
#Suppose the following input is supplied to the program:
#Hello world
#Practice makes perfect
#Then, the output should be:
#HELLO WORLD
#PRACTICE MAKES PERFECT
lst=[]
while ... |
f676db3d1fc4f349b7ddb2dec69723782cd4d1d2 | jakeloria02/Python_AI | /Main.py | 884 | 3.859375 | 4 | import requests, json
leave = {"exit", "leave", "end", "bye"}
GREETINGS = {"hello", "hey", "yo", "boi", 'hey man', 'hey boi', 'hey 117', 'hey [117]', "heyo", "heyy"}
GREETING_RESP = {"Hello", "Hey", "Hello, Sir!"}
WEATHER = {'whats the weather today?', "weather", 'whats the weather?', 'whats the weather today', 'w... |
32fdb667ad72b8d13d7d844bde4491b0955165d4 | thisislsj/smart-reservation | /logicpy.py | 695 | 3.578125 | 4 | msg=["02","07","3"]
msgSimple="batman"
print("msg is ",msgSimple)
seatsAvailable=50
referencecode=5
while True:
msgInput=input("Type the msg: ")
print(msgInput)
if msgInput=="superman":
if seatsAvailable >0:
referencecode=referencecode+1
seatsAvailable=seatsAvailable-1
... |
570740ed8b072e0b249309b15d33f27f2b94d158 | nupur24/python- | /untitled4.py | 592 | 3.5625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon May 21 14:16:32 2018
@author: HP
"""
while True:
s = raw_input("enter string : ")
if not s:
break
if s.count("@")!=1 and s.count(".")!=1:
print "invalid"
else:
s = s.split("@")
#print s
usr = s[0]
print usr... |
47f0ab0709c616b62f4871047f350b935cc1a6e2 | nupur24/python- | /nupur_gupta_12.py | 303 | 4.03125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue May 15 12:01:08 2018
@author: HP
"""
def br():
s,b,g=a
if g%5 > s:
return False
if s+b*5 >= g:
return True
else:
return False
a=input("enter numbers:")
print br()
|
11b760a6ae93888c812d6d2912eb794d98e9c3e0 | mohadesasharifi/codes | /pyprac/dic.py | 700 | 4.125 | 4 | """
Python dictionaries
"""
# information is stored in the list is [age, height, weight]
d = {"ahsan": [35, 5.9, 75],
"mohad": [24, 5.5, 50],
"moein": [5, 3, 20],
"ayath": [1, 1.5, 12]
}
print(d)
d["simin"] = [14, 5, 60]
d.update({"simin": [14, 5, 60]})
print(d)
age = d["mohad"][0]
print(age)
for k... |
76b21b47b0166c5a98529751abbba6323d8aef43 | JacquesAucamp/Factorial-Digits | /JAucamp_factorial_digits.py | 2,435 | 3.78125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Oct 8 12:41:16 2021
@author: User-PC
"""
import sys
#==========================================================
# CALCULATION FUNCTION
#==========================================================
def SumOfFactorialDigits(x):
digits_sum = 0
# Cr... |
0c4c7448b192fe9f90938a8e3bceae6b10844fd8 | henrylu518/LeetCode | /Best Time to Buy and Sell Stock III.py | 1,342 | 3.828125 | 4 | """
Author: henry, henrylu518@gmail.com
Date: May 23, 2015
Problem: Best Time to Buy and Sell Stock III
Difficulty: Medium
Source: http://leetcode.com/onlinejudge#question_123
Notes:
Say you have an array for which the ith element is the price of a given stock on day i.
Design an algorithm to f... |
e92b6ffddca5f7d7764278e8fca08da691e8da5c | henrylu518/LeetCode | /Combinations.py | 1,246 | 3.578125 | 4 | """
Author: Henry, henrylu518@gmail.com
Date: May 13, 2015
Problem: Combinations
Difficulty: Easy
Source: http://leetcode.com/onlinejudge#question_77
Notes:
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.
For example,
If n = 4 and k = 2, a solution is:... |
f7ced0cc2205948a24e69d0aaf2ec99d2fd8a09e | henrylu518/LeetCode | /Sqrt(x).py | 735 | 3.8125 | 4 | """
Author: Henry, henrylu518@gmail.com
Date: May 13, 2015
Problem: Sqrt(x)
Difficulty: Easy
Source: http://leetcode.com/onlinejudge#question_69
Notes:
Implement int sqrt(int x).
Compute and return the square root of x.
Solution: Binary search in range [0, x / 2 + 1].
There is also... |
a4dd4cde4800d2071a460bb53d0c8a26b1b1f4d8 | henrylu518/LeetCode | /Search Insert Position.py | 456 | 3.671875 | 4 | class Solution:
# @param {integer[]} nums
# @param {integer} target
# @return {integer}
def searchInsert(self, nums, target):
low, high = 0, len(nums) - 1
while low <= high:
middle = (low + high) / 2
if nums[middle] == target:
return middle
... |
66201819201c710b9bc3cb6b66eec783d1450b6b | henrylu518/LeetCode | /Remove Duplicates from Sorted List II.py | 1,139 | 3.5 | 4 | """
Author: Henry, henrylu518@gmail.com
Date: May 14, 2015
Problem: Remove Duplicates from Sorted List II
Difficulty: Easy
Source: https://oj.leetcode.com/problems/remove-duplicates-from-sorted-list-ii/
Notes:
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only... |
00da27e1e70bac78566304625fe1cec186b7a587 | henrylu518/LeetCode | /Jump Game II.py | 1,513 | 3.546875 | 4 | """
Date: May 18, 2015
Problem: Jump Game II
Difficulty: Easy
Source: http://leetcode.com/onlinejudge#question_45
Notes:
Given an array of non-negative integers, you are initially positioned at the first index of the array.
Each element in the array represents your maximum jump length at that positi... |
ce9f6b1070b57982cc521fbe9672d18fced43a58 | henrylu518/LeetCode | /Populating Next Right Pointers in Each Node.py | 1,915 | 4.0625 | 4 | """
Author: Henry, henrylu518@gmail.com
Date: May 16, 2015
Problem: Populating Next Right Pointers in Each Node
Difficulty: Easy
Source: http://leetcode.com/onlinejudge#question_116
Notes:
Given a binary tree
struct TreeLinkNode {
TreeLinkNode *left;
TreeLinkNode *right;
TreeLinkNod... |
d112900cddfe3b0bbef72efeeb697dfc6cbe86bb | zman0225/python_cryptography | /ciphers/detectEnglish.py | 1,294 | 3.546875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author: ziyuanliu
# @Date: 2014-02-07 18:12:47
# @Last Modified by: ziyuanliu
# @Last Modified time: 2014-02-07 21:23:50
UPPERLETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
LETTERS_AND_SPACE = UPPERLETTERS + UPPERLETTERS.lower() + ' \t\n'
def loadDictionary():
dictionar... |
b6ba17928cbcb5370f5d144e64353b9d0cd8fcbd | Mohsenabdn/projectEuler | /p004_largestPalindromeProduct.py | 792 | 4.125 | 4 | # Finding the largest palindrome number made by product of two 3-digits numbers
import numpy as np
import time as t
def is_palindrome(num):
""" Input : An integer number
Output : A bool type (True: input is palindrome, False: input is not
palindrome) """
numStr = str(num)
for i in range(len(numS... |
82aff3d2c7f6ad8e4de6df39d481df878a7450f7 | sree714/python | /printVowel.py | 531 | 4.25 | 4 | #4.Write a program that prints only those words that start with a vowel. (use
#standard function)
test_list = ["all", "love", "and", "get", "educated", "by", "gfg"]
print("The original list is : " + str(test_list))
res = []
def fun():
vow = "aeiou"
for sub in test_list:
flag = False
... |
8d6df43f43f157324d5ce3012252c3c89d8ffba4 | superyaooo/LanguageLearning | /Python/Learn Python The Hard Way/gpa_calculator.py | 688 | 4.15625 | 4 | print "Hi,Yao! Let's calculate the students' GPA!"
LS_grade = float(raw_input ("What is the LS grade?")) # define variable with a string and input, no need to use "print" here.
G_grade = float(raw_input ("What is the G grade?")) # double (()) works
RW_grade = float(raw_input ("What is the RW grade?"))
F... |
2de9b9b92b49f32c62e9d86b0c69985f8fb4bb85 | superyaooo/LanguageLearning | /Python/Learn Python The Hard Way/ex39.py | 1,069 | 3.953125 | 4 | ten_things = "Apples Oranges Crows Telephone Light Sugar"
print "Wait there's not 10 things in that list, let's fix that."
stuff = ten_things.split(' ') # need to add space between the quotation marks.
more_stuff = ["Day","Night","Song","Frisbee","Corn","Banana","Girl","Boy"]
while len(stuff) != 10:
nex... |
edfb7ae4988150d17c6fb84b68e44ecdc8d17806 | superyaooo/LanguageLearning | /Python/Learn Python The Hard Way/ex40ss.py | 322 | 3.609375 | 4 | # experiment version 2
cities = {'CA': 'San Francisco', 'MI': 'Detroit',
'FL': 'Jacksonville'}
cities['NY'] = 'New York'
cities['OR'] = 'Portland'
for city in cities.items():
print "City:", city
for state,city in cities.items():
print "Places to move:", (state,city)... |
a3ae3bea53a3b19012f0b93749ac8c8aaa6a2427 | superyaooo/LanguageLearning | /Python/Learn Python The Hard Way/ex14s.py | 649 | 4.0625 | 4 | from sys import argv
script, user_name = argv
prompt = 'What you say?' # prompt could be random things. it shows up at line 9,12,15.
print "Hi,%s!%s here :)" %(user_name,script)
print "Need to ask you some questions."
print "Do you eat pork,%s?" % user_name
pork = raw_input(prompt)
print "Do you ... |
66ec728580a3be763105fe44f399b5f98f3c449f | AndreyAD1/18_price_format | /format_price.py | 837 | 3.640625 | 4 | import argparse
def get_console_arguments():
parser = argparse.ArgumentParser()
parser.add_argument('price', type=float, help='Enter a price.')
arguments = parser.parse_args()
return arguments
def format_price(price):
if type(price) == bool:
return None
try:
real_num_price = ... |
62d2ca63e780982a75df63ebba2853fa1a3de150 | TylerGarlick/intermediate-python-course | /my_list.py | 218 | 3.5625 | 4 | def main():
r = [4, -2, 10, -18, 22]
print(r[2:6])
print(f'len list of {r[-1]}')
t = r.copy()
print(f'is t the same as r? {t is r}')
c = r[:]
print(f'is t the same as r? {t is c}')
main()
|
5476eab2b0b2834ebb789d623703fdded5e4fa3e | RomarioGit/AED_1 | /AED26.py | 1,351 | 4 | 4 |
class aluno:
def __init__(self,nome,cpf,nota):
self.nome = nome
self.cpf = cpf
self.nota = nota
def get_nota(self):
if not self.nota == 0:
return True
return False
def cadastrar_aluno(lista_alunos):
nome = input("Informe o nome: ")
cpf = input("Info... |
15e2d34d87b113c8f3b48ae4e0478541f8af8960 | chrisesharp/aoc-2018 | /day25/constellation.py | 1,682 | 3.609375 | 4 | import sys
def find_constellations(input):
points = {}
for line in input.split():
point = tuple(map(int, line.split(',')))
assimilated = False
linked = {}
for known_point in list(points.keys()):
if close_enough(known_point, point):
points, linked = as... |
9789e52489b57ddc65791d841e5f693c0e3924a4 | selinali2010/hello-world | /oneRoundYahtzee.py | 1,685 | 3.921875 | 4 | from random import choice
rolls = {
0:"None",
1: "Pair",
2: "Two Pairs",
3: "Three of a kind",
4: "Four of a kind",
5: "Yahtzee!",
6: "Full House",
7: "Large Straight"
}
dice = []
for x in range(5):
dice.append(choice([1,2,3,4,5,6]))
print "Dice %i: %i" % (x + 1, dice[x])
#find the number of rep... |
44f8726cd570bf4339a767dde3e62713463da2b5 | Vladyslav92/Python_HW | /lesson_6/4_task.py | 378 | 3.828125 | 4 | # Поиск минимума с переменным числом аргументов в списке.
# def min(*args): ....
enter = [10, 20, 35, 5, 6, 2, 7, 15]
def min(*args):
base_list = args
sorted_list = []
for i in base_list:
for j in i:
sorted_list.append(j)
result = sorted(sorted_list)
return result[0]
print(m... |
86902979397a947dd5d85874129c8d1aab949ac6 | Vladyslav92/Python_HW | /lesson_2/3_task.py | 536 | 4.21875 | 4 | # На ввод подается строка. Нужно узнать является ли строка палиндромом.
# (Палиндром - строка которая читается одинаково с начала и с конца.)
enter_string = input('Введите строку: ').lower()
lst = []
for i in enter_string:
lst.append(i)
lst.reverse()
second_string = ''.join(lst)
if second_string == enter_string:... |
3de9c9f7af71fd66a0b8336e9c0a4fdcbf538973 | Vladyslav92/Python_HW | /lesson_7/2_task.py | 616 | 3.625 | 4 | # Реализовать примеры с functools - wraps и singledispatch
from functools import singledispatch, wraps
def dec_function(func):
"""Function in function"""
@wraps(func)
def wrapps():
"""decorated function"""
pass
return wrapps
@dec_function
def a_function():
"""Simple Function"""
... |
1f84a5ede2aa4aa8d8fea4921dc1bc53e66e9d91 | Vladyslav92/Python_HW | /lesson_11/3_task.py | 1,024 | 4 | 4 | # Реализовать класс который будет:
# 3.a читать из ввода строку
# 3.b проверять, что строка состоит только из скобочек “{}[]()<>”
# 3.c проверять, что строка является правильной скобочной последовательностью - выводить вердикт
class Brackets:
def __init__(self):
self.line = ... |
6cefa99cdb92c9ed5738d4a40855a78b22e23b1b | Vladyslav92/Python_HW | /lesson_8/1_task.py | 2,363 | 4.34375 | 4 | # mobile numbers
# https://www.hackerrank.com/challenges/standardize-mobile-number-using-decorators/problem
# Let's dive into decorators! You are given mobile numbers.
# Sort them in ascending order then print them in the standard format shown below:
# +91 xxxxx xxxxx
# The given mobile numbers may have +91, 91 or 0 wr... |
d2f3d3b79ad81c34394ed3cfa336b07f5edaceff | viniandrd/Biodiesel-Simulator | /utils/logginprinter.py | 656 | 3.625 | 4 | import sys
class LoggingPrinter:
def __init__(self, filename):
self.out_file = open(filename, "w")
self.old_stdout = sys.stdout
# this object will take over `stdout`'s job
sys.stdout = self
# executed when the user does a `print`
def write(self, text):
self.old_std... |
3f5e5c7307e293db831a422f71e762d559edee95 | saravey2021/homework-week-11 | /Homework week 11/fri2.py | 347 | 3.96875 | 4 | def getPrice(fruitName):
if fruitName=="banana":
return 2
if fruitName=="apple":
return 5
if fruitName=="orange":
return 1
print("banana price is:"+str(getPrice("banana"))+" dolars")
print("Orange price is:"+str(getPrice("orange"))+" dolars")
print("apple price is:"+str(getP... |
1ac6e401e05a22f94610ceb0e2aee0d7350cd3c2 | Zoranc1/boggle | /boggle.py | 2,220 | 3.5625 | 4 | from string import ascii_uppercase
from random import choice
def make_grid(colums,rows):
return { (c,r) : choice(ascii_uppercase)
for r in range(rows)
for c in range(colums)}
def potencial_neighbours(position):
c, r = position
... |
3aa3b572f2561c795397cc40a3ee0e6eb522f036 | pranavvm26/RandomProblemCodes | /find_longest_palindrome.py | 1,488 | 4.09375 | 4 | import copy
palindrome_list = []
def find_palindrome(palindrome_string):
longest_current_palin = 0
list_p = list(palindrome_string)
for i in range(2, len(list_p), 1):
duplicate_string = copy.deepcopy(list_p)
del duplicate_string[0:i]
_set = list_p[0:i]
res = "".join(_set) i... |
66d4bc1aec1f41337454123409ef597b1ea9ae8d | timmywilson/pandas-practical-python-primer | /training/level-1-the-zen-of-python/dragon-warrior/peppy.py | 836 | 4 | 4 | """
This code (which finds the sume of all unique multiples of 3/5 within a
given limit) breaks a significant number of PEP8 rules. Maybe it doesn't even
work at all.
Find and fix all the PEP8 errors.
"""
import os
import sys
import operator
INTERESTED_MULTIPLES = [3, 5] # constants should be all caps ... |
554db1fd0a01073381a9877a33c4d1859e6e2915 | maralex2003/OlistDojo1 | /dojo/ativ_1e2/categories.py | 1,114 | 3.5 | 4 | class Category:
def __init__(self, id: int, name: str):
self.__id = id
self.__name = name
def set_id(self, id: int) -> None:
self.__id = int(id)
def get_id(self) -> int:
return self.__id
def set_name(self, name: str) -> None:
self.__name = name
def get_na... |
68ece26086a0fdc492e49949c1ca30df1a784ec2 | maralex2003/OlistDojo1 | /aula016/05_assert_classes.py | 1,304 | 4.09375 | 4 | # Com assert podemos testar as classes e seus métodos
# podendo verificar objetos da classe e
# o resultado de seus comportamentos
class Product:
def __init__(self, name:str, price:float)->None:
self.name = name
self.price = price
@property
def name(self)->str:
return self.__name... |
b19a1447ed25ec4da8414b703a3aa433394eeb36 | charliesan16/Python-Estudio-Propio | /cantidadFilasPiramide.py | 226 | 3.9375 | 4 | bloques = int(input("Ingrese el número de bloques de la piramide:"))
altura=0
while bloques:
altura=altura+1
bloques=bloques-altura
if bloques <= altura:
break
print("La altura de la pirámide:", altura)
|
b6a922d94e92769c5ab73e7fa0bb9d200147e17b | charliesan16/Python-Estudio-Propio | /Hola Mundo.py | 146 | 3.6875 | 4 | def suma(a,b):
return a+b
a=int(input("ingrese el valor de a="))
b=int(input("ingrese el valor de b="))
s=suma(a,b)
print("La suma es de=",s)
|
46bc1461ea1fa5794bfc6ec29b021550c54dc7d0 | Ashutoshcoder/python-codes | /Aggregation/groupAccordingToStateAndMatching.py | 1,741 | 3.78125 | 4 | """
Author : Ashutosh Kumar
Version : 1.0
Description : Grouping according to state and then finding state with population >100
Then we are finding the biggest city and smallest city in the State.
Email : ashutoshkumardbms@gmail.com
"""
import pymongo
import pprint
myclient = pymongo.MongoClient('mongodb://localhost... |
ce2e70a9d3734bacde1fd864de4ade2c53734d17 | Ashutoshcoder/python-codes | /user_nobash.py | 769 | 3.671875 | 4 | '''
Author : Ashutosh Kumar
PRN : 19030142009
Assignment: Read all the usernames from the /etc/passwd file and list users
which do not have bash as their default shell
'''
fp = ""
try:
# opening file in read mode
fp = open('/etc/passwd', 'r')
# extracting every user from the file
for line in fp:
... |
530bfb68b165b1948f17c85ad7853059150d4806 | Ashutoshcoder/python-codes | /Mongo-Example-Implementation/Bank/employeeManager.py | 2,770 | 3.609375 | 4 | '''
Author : Ashutosh Kumar
Version : 1.0
Description : Creating a Employee Management Functions(Insert,Update,Delete)
Email : ashutoshkumardbms@gmail.com
'''
import sys
import pymongo
myclient = pymongo.MongoClient('mongodb://localhost:27017/')
mydb = myclient['empolyeedata']
mycol = mydb['employees']
def main():... |
2c9d97b447fc0a3aaf464660c88ac4b9264023e7 | Ashutoshcoder/python-codes | /data-science/barGraph.py | 518 | 3.5 | 4 | """
Author : Ashutosh Kumar
Version : 1.0
Description : Plotting bar graph in Python
Email : ashutoshkumardbms@gmail.com
"""
import numpy as np
import matplotlib.pyplot as plt
city = ["Delhi", "Beijing", "Washingtion", "Tokyo", "Moscow"]
pos = np.arange(len(city))
Happiness_index = [60, 40, 70, 65, 85]
plt.bar(pos, ... |
2d9c35e286e33a57bb0a441324fa16fc1c9f9793 | kozl-ek/module_0 | /Kozlova.EV_1.py | 2,018 | 3.53125 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[6]:
import numpy as np
number = np.random.randint(1,100) # загадали число от 1 до 100
print ("Загадано число от 1 до 100")
def change(a): #Задаем функцию, изменяющую размер шага. Размер шага не должен быть меньше одного, чтобы избежать зацикливания.
if a!=1:
... |
89d6646ac4c27cbd605a3c4d3459eb2762875229 | ezefranca/hackerrank-30-days | /day6/day6.py | 368 | 3.65625 | 4 | #!/bin/python3
import sys
n = int(input().strip())
strings = []
for i in range(0, n):
string = input().strip()
strings.append(string)
arr = list(strings[i])
odd = []
even = []
for j in range(0, len(arr)):
if j % 2 == 0:
even.append(arr[j])
else:
odd.appen... |
3d2c01cd94f0aea380e3dd5605d501ab44a5fbaf | TR18052000/DAY-3-ASSIGNMENT | /list.py | 159 | 3.75 | 4 | list = [1, 2, 3, 4, 5, 6]
print(list)
list[2] = 10
print(list)
list[1:3] = [89, 78]
print(list)
list[-1] = 25
print(list)
|
0f65ea15f4845b8b3e5f5117af59444a5a666cbe | thomaskost17/QHWSDGNCB | /src/models/lorenz.py | 1,169 | 3.671875 | 4 | '''
File: lorenz.py
Author: Thomas Kost
Date: 08 August 2021
@breif function for lorenz chaotic system, and plotting script
'''
import numpy as np
import matplotlib.pyplot as plt
def lorenz(x :np.array, beta: np.array)->np.array:
'''
x: position state vector of lorenz system
beta: vector o... |
466900753c34afb3fb85f7a23563005515d2cd78 | jacobdanovitch/COMP1005_TA_Portal | /solutions/a4/soln.py | 3,269 | 3.578125 | 4 | #Author: Andrew Runka
#Student#: 100123456
#This program contains all of the solutions to assignment 4, fall2018 comp1005/1405
#and probably some other scrap I invented along the way
def loadTextFile(filename):
try:
f = open(filename)
text = f.read()
f.close()
return text
except IOError:
print(f"File {fi... |
781fc5a0241560371636b46c096d0a476fce622d | henrypalacios/transactions_account | /backend_api/src/foundation/write_lock.py | 1,196 | 3.875 | 4 | from threading import Thread, Condition, current_thread, Lock
class ReadersWriteLock:
""" A lock object that allows many simultaneous "read locks", but
only one "write lock." """
def __init__(self):
self._read_ready = Condition(Lock())
self._readers = 0
def acquire_read_lock(self):
... |
90be014b94c2b6a63f759e191759412965cc0acd | ModelPhantom/raspberrypython | /pygametest/hellopython.py | 367 | 3.59375 | 4 | import pygame
width=640
height=480
radius=100
stroke=1
pygame.init()
window=pygame.display.set_mode((width,height))
window.fill(pygame.Color(255,255,255))
while True:
pygame.draw.circle(window,pygame.Color(255,0,0),(width/2,height/2),radius,stroke)
pygame.display.update()
if pygame.QUIT in [e.type for e ... |
0b40c91c5a9f2316d0bb16155a00f77857d74df1 | soporte00/python_practice | /01_vacattion_system_for_rappi_employees.py | 2,172 | 3.703125 | 4 | import os
'''
sections
key section
1 A. clientes
2 Logística
3 Gerencia
employees
key time(years) vacations(days)
1 1 6
1 2-6 14
1 7 20
2 1 7
2 2-6 15
2 7 22
3 1 10
3 2-6 20
3 7 30
'''
while True:
os.system("clear")
prin... |
57c4893c2f0db4ad531c725146b92b5ee066f7ed | bmoser12/608-mod3 | /custom-object.py | 473 | 3.78125 | 4 | #use this to figure out a bill total including tip and tax
def tip_amount(total,tip_percent):
return total*tip_percent
def tax_amount(total, tax_percent):
return total*tax_percent
def bill_total(total,tax,tip):
return total+tip_amount+tax_amount
total = 100
tip_percent = .20
tax_percent = .075
tax = ... |
d21033c6e4ba17697dcbdf20072ab069d3e4779c | imrehg/coderloop | /missile/python/missile | 1,760 | 3.84375 | 4 | #!/usr/bin/python
import sys
def findlongest(nums):
"""
Dynamic programming: O(n^2)
based on:
http://www.algorithmist.com/index.php/Longest_Increasing_Subsequence#Dynamic_Programming
"""
n = len(nums)
if n == 0:
return 0
length = [1]*n
path = range(n)
for i in xrange(1, n):
... |
f3032a78f96bd74011401e625d5f20c263cad637 | TheGavinCorkery/BattleshipPythonGame | /Player.py | 1,570 | 3.828125 | 4 | from Board import Board
class Player():
def __init__(self):
self.my_board = Board()
self.guess_board = Board()
self.opponent_board = []
self.hits = 0
#Control all methods to guess a spot on opponents board
def guess_spot(self):
print('Here is your current guessing b... |
6dd2950189bb6d780432ea24b884b5a01b6406cd | Joghur/modbus-reader | /data/queries.py | 1,820 | 3.625 | 4 | import sys
from utils.files import import_config
"""Methods for manipulating a SQlite database
Create and insert methods
SQL queries are defined at top of file
"""
# getting database configurations
config = import_config('config_database.json')
# guard clause in case config file doesn't exist
if not config:
sy... |
6cd9cc1bb0048fc3414916d3da5652c816258ba6 | noah-daniel-mancino/algorithms-on-the-side | /max_line.py | 804 | 3.546875 | 4 | """
You can characterize each line by the m and b in y = mx + b. Do this for each
pair of lines, and see which ones pops up the most.
"""
def max_points(points):
lines = set()
lines_frequency = {}
for index, point in enumerate(points):
other_points = points[index + 1:]
print(other_points)
... |
198648ec4ed8b8019cbb6ce31ec4e561429f9600 | TheSliceOfPi/Practice-Questions | /sumSquareDiff.py | 551 | 4 | 4 | '''
The sum of the squares of the first ten natural numbers is,
The square of the sum of the first ten natural numbers is,
Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is .
Find the difference between the sum of the squares of the first one hundred na... |
3ef4d753b1429f9cdb1ea4ed7a02fbe80387a3ac | Scarlett4431/LeetCode | /150.py | 901 | 3.515625 | 4 | #150. Evaluate Reverse Polish Notation
class Solution(object):
def evalRPN(self, tokens):
"""
:type tokens: List[str]
:rtype: int
"""
stack= []
for t in tokens:
if t!='+' and t!='-' and t!='*' and t!='/':
stack.append(t)
else:
... |
27ea6e6eec457d29ee6f9cc7d147043649c9f5e8 | shami09/IvLabs | /conditionex3.1.py | 206 | 3.859375 | 4 | hrs = input("Enter Hours:")
h = float(hrs)
rate=input("Enter Rate:")
r=float(rate)
if h > 40:
nom=h*r
ep=(h-40)*(r*0.5)
pay=nom+ep
else:
pay=h*r
print("Pay:",pay) |
231f69494ca4939e8d1d698aa49559a526f7cc8a | DHSZ/igcse-pre-release-summer-2021-22 | /task2.py | 6,778 | 4.21875 | 4 | """
Summer 2021 - Pre-release material
Python project to manage a electric mountain railway system
Author: Jared Rigby (JR)
Most recent update: 19/03/2021
"""
# Task 1 - Start of the day
train_times_up = [900, 1100, 1300, 1500] # Train times for going up the mountain
train_seats_up = [480, 480, 480, 480]... |
f4a47627b293951f8f6c408628b7034809e5c68a | emildoychinov/Talus | /loader/cogs/ttt.py | 6,769 | 3.671875 | 4 | from discord.ext import commands
import time
#a util function that will be used to make a list into a string
makeStr = lambda list : ''.join(list)
class tictactoe(commands.Cog):
def __init__(self, bot, comp_sign='x', p_sign='o'):
self.bot = bot
self.pos=0
self.p_move = -1
s... |
fb04a8d334283582cca10c9ae04126e97476f4f9 | wchi619/Python-Assignment-1 | /a1_wchi3.py | 6,844 | 4.53125 | 5 | #!/usr/bin/env python3
"""
OPS435 Assignment 1 - Fall 2019
Program: a1_wchi3.py
Author: William Chi
This program will return the date in YYYY/MM/DD after the given day (second argument) is passed. This program requires 2 arguments with an optional --step flag.
"""
# Import package
import sys
def usage():
"""Begi... |
4deb99f3c3c58525f632d85d77c748be62a7ce5b | juraj80/Python-Data-Stuctures | /10/romeo.py | 430 | 3.8125 | 4 | ''' print the ten most common words in the text '''
import string
handle=open('romeo-full.txt')
counts=dict()
for line in handle:
line=line.translate(None,string.punctuation)
line=line.lower()
words=line.split()
for word in words:
if not word in counts:
counts[word]=1
else:
counts[word]=counts[word]+1
res... |
cf8efc269f8d53acd9b41e2bc876a32f3b11c620 | juraj80/Python-Data-Stuctures | /09/bigcountA.py | 596 | 3.53125 | 4 | name = raw_input("Enter file:")
if len(name) < 1 : name = "mbox-short.txt"
handle = open(name)
emails=list()
for line in handle:
line=line.rstrip()
if line=="":continue
if not line.startswith("From:"):continue
words=line.split()
emails.append(words[1])
counts=dict()
for email in emails:
if not e... |
4bd83144bd8246dd40fd063efb8ccb6808ab4abf | juraj80/Python-Data-Stuctures | /07/enterfile.py | 171 | 3.59375 | 4 | inp=raw_input("Enter a file:")
try:
file=open(inp)
except:
print "Error. Please Enter a File."
exit()
for line in file:
line=line.rstrip()
print line
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.