blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
979435e090e41bff2066755c1c0d65a4c33298cf | aryajayan/python-training | /day3/q2.py | 262 | 4.375 | 4 | # Given a dictionary {"name": "python", "ext": "py", "creator": "guido"}, print both keys and values.
d={"name": "python", "ext": "py", "creator": "guido"}
for key, value in d.items():
print(key, value)
# --Output--
# name python
# ext py
# creator guido | true |
cd8a38d26c03dd73fde61e337aecd5c02b7761b5 | aryajayan/python-training | /day3/q4.py | 485 | 4.25 | 4 | # Guessing Game. Accept a guess number and tell us if it's higher or less than the hardcoded number
num=10
guess_num=int(input("Guess the number : "))
if guess_num>num:
print("higher than the given number")
elif guess_num<num:
print("lower than the given number")
else:
print("You got the number")
# --O... | true |
69110ed6b4e2943ca3cb7ca4e56d5ce884b3bf60 | sumedhkhodke/waiver_assignment | /eas503_test.py | 2,239 | 4.53125 | 5 | """
------------
INSTRUCTIONS
------------
The file 'Students.csv' contains a dump of a non-normalized database. Your assignment is to first normalize the database
and then write some SQL queries.
To normalize the database, create the following four tables in sqlite3 and populate them with data from 'Students.csv'.
... | true |
022d70630593eeccb4082c9378465f0551f39f9c | bhavesh-20/Genetic-Algorithm | /Sudoku/random_generation.py | 2,493 | 4.1875 | 4 | import numpy as np
"""Function which generates random strings for genetic algorithm, each string
is a representation of genetic string used in the algorithm. Randomness is used in a smart way to remove
the chance of each row having duplicates in sudoku and also trying to minimise conflicts with columns,
hence the ge... | true |
8c3267e725eb737b3335f0ff4d94977e1a90be59 | ViMitre/sparta-python | /1/classes/car.py | 797 | 4.15625 | 4 | # Max speed
# Current speed
# Getter - return current speed
# Accelerate and decelerate methods
# Accelerate past max speed
# What if it keeps braking?
class Car:
def __init__(self, current_speed, max_speed):
self.current_speed = current_speed
self.max_speed = max_speed
def get_speed(self):
... | true |
e3156589342632ac3996d4787be30275f7b9b062 | standrewscollege2018/2021-year-11-classwork-ethanbonis | /Zoo.py | 245 | 4.28125 | 4 | #This code will ask for your age and based on this info, will ask -
#you to pay the child price or to pay the adult price.
CHILD_AGE = 13
age = int(input("What is your age?"))
if age <= CHILD_AGE:
print("child")
else:
print("adult")
| true |
10dbdc70ade2b6ba83a7b1233d70e636d8747626 | ERAN1202/python_digital_net4u | /lesson_1/Final_Pro.Func.py | 2,213 | 4.15625 | 4 | '''create a menu:
a. IP system?
b. DNS system?
a
====
1. search for IP address from a list
2. add IP address to a list
3. delete IP address to a list
4. print all the IPs to the screen
b
===
1. serach for URL from a dictionary
2. add URL + IP address to a dictionary
3. delete URL from a dictio... | true |
cdd3dbd0d964d9d914893f60a95ed0a79129a626 | AvivSham/LeetCodeQ | /Easy/DistanceBetweenBusStops.py | 413 | 4.125 | 4 | from typing import List
def distance_between_bus_stops(distance: List[int], start: int, destination: int) -> int:
clockwise = sum(distance[min(start, destination):max(start, destination)])
counter_clockwise = sum(distance) - clockwise
return min(clockwise, counter_clockwise)
if __name__ == '__m... | true |
99fc98fe21ae10439644ff02e044d377e5a346c1 | rafawelsh/CodeGuildLabs | /python/Python labs/9.unit_converter.py | 254 | 4.1875 | 4 | #9.unit_converter.py
# ft = int(input("What is the distance in feet?: "))
# m = round((ft * 0.3048),5)
#
# print(ft,"ft is", m, "m")
def conversion(disntance, meter):
disntance = int(input("What is the distance? "))
unit = input("What are the units? ")
| true |
e4692682f070ad1e3ed787efbd8811d68d74d253 | a62mds/exercism | /python/linked-list/linked_list.py | 1,841 | 4.125 | 4 | # Skeleton file for the Python "linked-list" exercise.
# Implement the LinkedList class
class Node(object):
def __init__(self, value, next=None, prev=None):
self.value = value
self.next = next
self.prev = prev
def __str__(self):
return '{}'.format(self.value)
class LinkedList... | true |
69c9988c1a00e304da3a71ba9e589142db2c17d9 | RCTom168/Intro-to-Python-1 | /Intro-Python-I-master/src/09_dictionaries.py | 2,180 | 4.53125 | 5 | """
Dictionaries are Python's implementation of associative arrays.
There's not much different with Python's version compared to what
you'll find in other languages (though you can also initialize and
populate dictionaries using comprehensions just like you can with
lists!).
The docs can be found here:
https://docs.py... | true |
1b09af7656619a1281f588e050f722e326edca1b | krishnanandk/kkprojects | /functions/demo.py | 645 | 4.21875 | 4 | #inbuild function
#print()
#input()
#type
#normal syntax to create a function
#def functionname(arguments):
#function definition
#function call: #using fn name
#3methods
#1. Functions without an argument and no return type
#2. Function with arguments and no return type
#3. Function with arguments and return ty... | true |
a61f578bb01b0c574a3ba130db048990c2712189 | excaliware/python | /lcm.py | 1,328 | 4.28125 | 4 | """
Find the lowest common multiple (LCM) of the given numbers.
"""
import math
"""
Find the prime factors of the given number.
"""
def find_factors(n):
factors = []
# First, find the factor 2, if any.
while n % 2 == 0:
n = n // 2
factors.append(2)
# From now on, check odd numbers only.
d = 3
while d <=... | true |
5d83d1235d048388394af8a6e56bf55c289c7957 | johnyijaq/Pyhton-For-Everybody | /Course 3. Using Python to Access Web Data/Week 2. Regular Expressions.py | 2,782 | 4.5625 | 5 | Chapter 11 Assignment: Extracting Data With Regular Expressions
# Finding Numbers in a Haystack
# In this assignment you will read through and parse a file with text and
# numbers. You will extract all the numbers in the file and compute the sum of
# the numbers.
# Data Files
# We provide two files for this... | true |
491bee39b76c5252187bc734dddd247aa017ed7d | thomasyu929/Leetcode | /Tree/symmetricTree.py | 1,436 | 4.21875 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
# 1 Recursive
# def isSymmetric(self, root: TreeNode) -> bool:
# if not root:
# return True
# ... | true |
e7c2a3d268ff5f03cb453656cf931a91a9e7a529 | ccmaf/Python-Stuff | /listfun.py | 265 | 4.28125 | 4 | #goal: make a list from user input and print out any
#number from the list that is < 5
print("please enter 3 numbers.")
n1 = input("n1: ")
n2 = input("n2: ")
n3 = input("n3: ")
list = [int(n1),int(n2),int(n3)]
for element in list:
if element < 5:
print(element) | true |
34cd3453ff8de1f95b60e93bd24e575870bcc669 | Thiksha/Pylab | /prog7.py | 439 | 4.21875 | 4 | # Python program using NumPy
# for some basic mathematical
# operations
import numpy as np
# Creating two arrays of rank 2
x = np.array([[1, 2], [3, 4]])
y = np.array([[5, 6], [7, 8]])
# Creating two arrays of rank 1
v = np.array([9, 10])
w = np.array([11, 12])
# Inner product of vectors
print(np.dot(v, ... | true |
1359d33adaa10e2ba9022cc703ef855ccf7c9355 | distracted-coder/Exercism-Python | /yacht/yacht.py | 2,602 | 4.125 | 4 | """
This exercise stub and the test suite contain several enumerated constants.
Since Python 2 does not have the enum module, the idiomatic way to write
enumerated constants has traditionally been a NAME assigned to an arbitrary,
but unique value. An integer is traditionally used because it’s memory
efficient.
It is a... | true |
669ed897002906ec966e9e6c7d06a97230402f0a | noalez/Assignment1 | /Q3.py | 1,371 | 4.21875 | 4 | def compare_subjects_within_student(subj1_all_students,
subj2_all_students):
"""
Compare the two subjects with their students and print out the "preferred"
subject for each student. Single-subject students shouldn't be printed.
Choice for the data structure of ... | true |
48dba6ea3eab7303ec08688d1964730d12a64a51 | affandhia/ifml-pwa | /main/utils/naming_management.py | 1,875 | 4.125 | 4 | import re
def dasherize(word):
"""Replace underscores with dashes in the string.
Example::
>>> dasherize("FooBar")
"foo-bar"
Args:
word (str): input word
Returns:
input word with underscores replaced by dashes
"""
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1-\2', word)
... | true |
0c781cdc145f18c892b5eb8a6cfc5548451f1b85 | abhishekk3/Practice_python | /monotonic_array.py | 758 | 4.25 | 4 | #Problem Statement: Given an array of integers, we would like to determine whether the array is monotonic (non-decreasing/non-increasing) or not.
#Examples:
#1 2 5 5 8->true
#9 4 4 2 2->true
#1 4 6 3->false
#1 1 1 1 1 1->true
def monotonic_arr(arr):
num = arr[1]
if arr [0] < arr [1]:
... | true |
43a6ed3e8d2afe9b208f4d790d2c784593bb16ce | djangoearnhardt/Exercism | /acronym.py | 254 | 4.15625 | 4 | # Convert a long phrase to its acronym
print("Enter your long phrase, and I'll convert it to an acronym.")
str = input()
# str = str.split()
str_len = len(str)
output = ''
for i in str.upper().split():
output += i[0]
print(f"Your acronym is", output)
| true |
2ad6f815dbd3d0bdc29d9902486701b6790dbfa5 | Emaasit/think-python | /card.py | 1,757 | 4.5625 | 5 | """This is Chapter 18: Inheritance
Learning Python programming using the book titled
Think Python, 2nd Edition
by Allen Downey
http://thinkpython2.com
Copyright 2017 Daniel Emaasit
License: http://creativecommons.org/licenses/by/4.0/
"""
from random import shuffle
class Card:
"""Represents the cards in deck
... | true |
166a849b4c82c1f0486cce56a0dcf17cf9e0ca9f | foureyes/csci-ua.0479-spring2021-001 | /resources/code/class11/fraction.py | 1,429 | 4.125 | 4 | class Fraction:
def __init__(self, n, d):
self.n = n
self.d = d
# this means that this method can be called without instance
# and consequently, no self is needed
# instead, you call it on the actual class itself
# Fraction.gcf()
@staticmethod
def gcf(a, b):
# go t... | true |
5ce4d0d839d165438d3149d00e6ceea0bd48d2fa | foureyes/csci-ua.0479-spring2021-001 | /assignments/hw03/counting.py | 593 | 4.46875 | 4 | """
counting.py
=====
use *while* loops to do the following:
* print out "while loops"
* use a while loop to count from 2 up-to and including 10 by 2's.
* use another while loop to count down from 5 down to 1
use *for* loops to do the following:
* print out "for loops"
* use a for loop to count from 2 up-to and in... | true |
c9f5850173477fdec74a2cf3eeaea216a5d221b7 | foureyes/csci-ua.0479-spring2021-001 | /_includes/classes/17/count.py | 315 | 4.1875 | 4 | def count_letters(letter, word):
"""returns the number of times a letter occurs in a word"""
count = 0
for c in word:
if c == letter:
count += 1
return count
assert 3 == count_letters("a", "aardvark"), "should count letters in word"
assert 0 == count_letters("x", "aardvark"), "zero if no letters in word"
| true |
33827cee45fdaf7aa3210750392d51b51c4a58f9 | foureyes/csci-ua.0479-spring2021-001 | /resources/code/class04_return.py | 766 | 4.375 | 4 | """
return is a statement
a value has to be on the right hand side
that value can be an expression (that will be evaluated before the return)
and it does 2 things:
* immediately stops the function
* gives back the value / expression to the right of it
return statements have to be in a function
they can be in a ... | true |
3df9bf90f72f82039043e5db9b15d36424e2a5b6 | foureyes/csci-ua.0479-spring2021-001 | /_includes/classes/15/factorial_iterative_version_user_input.py | 214 | 4.21875 | 4 | def factorial(n):
product = 1
for i in range(n, 0, -1):
product = product * i
return product
user_input = input("Give me a number, I'll give you the factorial\n>")
num = int(user_input)
print(factorial(num))
| true |
244f4199d414d124c61646de18df4e6cfa1f30b8 | foureyes/csci-ua.0479-spring2021-001 | /resources/code/class05.py | 2,109 | 4.46875 | 4 | # go over some of the "old" slides
# try a sample "quiz" question(s) ... practice for the upcoming
# field some homework questions
# go over strings
# or go over more intermediate level stuff w/ lists
"""
>>> def foo(bar):
...
"""
"""foo will print out the argument passed in"""
"""
... print(bar)
...
>>> ... | true |
0497b83fab0d8c6f4eb21717c2ffdb9f4717f926 | foureyes/csci-ua.0479-spring2021-001 | /resources/code/class07_redact_dna.py | 1,561 | 4.21875 | 4 | """
redact(words, illegal_words)
word is a list of strings
illegal_words also a list of strings
if one of the strings in words exists in illegal words
then "replace" the first three letters with dashes
otherwise, word stays the same
if less than 3, then all chars
returns an entirely new list composed of censored word... | true |
58a7b172b7f719eca24e0f98780dc5056daa0a3e | foureyes/csci-ua.0479-spring2021-001 | /assignments/hw03/grade.py | 1,073 | 4.5 | 4 | """
grade.py
=====
Translate a numeric grade to a letter grade.
1. Ask the user for a numeric grade.
2. Use the table below to calculate the corresponding letter:
90-100 - A
80-89 - B
70-79 - C
60-69 - D
0-59 - F
3. Print out both the number and letter grade.
4. If the value is not numeric, all... | true |
64153c77965ffd4fc5ecab9c382e17c496b9ed6b | foureyes/csci-ua.0479-spring2021-001 | /assignments/hw06/translate_passage.py | 2,885 | 4.25 | 4 | """
translate_passage.py
=====
Use your to_pig_latin function to translate an entire passage of text. Do this
by importing your pig_latin module, and calling your to_pig_latin function.
You can use any source text that you want!
For example: Mary Shelley's Frankenstein from Project Gutenberg:
http://www.gutenberg.... | true |
1fb70af92655eb5feeefcdb9b69a6eac5bab9db7 | julienawilson/data-structures | /src/shortest_path.py | 1,492 | 4.15625 | 4 | """Shortest path between two nodes in a graph."""
import math
def dijkstra_path(graph, start, end):
"""Shortest path using Dijkstra's algorithm."""
path_table = {}
node_dict = {}
# try:
# infinity = math.inf
# except:
infinity = float("inf")
for node in graph.nodes():
path... | true |
4713b6f84dd3413a20d71fe230fdcf2b499a2621 | fermolanoc/sw-capstone | /lab2/student_dataclass.py | 676 | 4.3125 | 4 | from dataclasses import dataclass
@dataclass # dataclass decorator to simplify class definition
class Student:
# define attributes with data types -> this usually goes on __init__ method along with self
name: str
college_id: int
gpa: float
# override how info will be printed
def __str__(self... | true |
9697410fe37ce6a23ed05209a1f203ffd532cbc1 | codingram/courses | /python-for-everybody/08_file_count.py | 712 | 4.28125 | 4 | # Exercise 5:
#
# Open the file mbox-short.txt and read it line by line. When you find a line
# that starts with 'From ' like the following line:
#
# From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008
#
# You will parse the From line using split() and print out the second word in
# the line (i.e. the entire add... | true |
ead7827cba391e26589a66717709406c0a27001b | codingram/courses | /python-for-everybody/08_list_max_min.py | 586 | 4.46875 | 4 | # Exercise 6:
#
# Rewrite the program that prompts the user for a list of numbers and prints out
# the maximum and minimum of the numbers at the end when the user enters “done”.
# Write the program to store the numbers the user enters in a list and use the
# max() and min() functions to compute the maximum and minimum ... | true |
d847f9cc90b307d3f6aeb41d3841b26fe94fdf66 | codingram/courses | /MITx6001x/edx/ps1/ps1_3.py | 815 | 4.34375 | 4 | """ Assume s is a string of lower case characters.
Write a program that prints the longest substring of s in which the letters occur
in alphabetical order. For example, if s = 'azcbobobegghakl', then your program
should print:
Longest substring in alphabetical order is: beggh
In the case of ties, print the first... | true |
8f8c494b841104a69bea119b5a278f74479070a3 | bestyoucanbe/joypython0826-b | /dictionaryOfWords.py | 1,599 | 4.8125 | 5 | # You are going to build a Python Dictionary to represent an actual dictionary. Each key/value pair within the Dictionary will contain a single word as the key, and a definition as the value. Below is some starter code. You need to add a few more words and definitions to the dictionary.
# After you have added them, us... | true |
0b7e61fb66ee63523dd111eec1e8b4184d373191 | Ayush05m/coding-pattern | /Python Codes/longestSubString.py | 682 | 4.125 | 4 | def longest_unique_subString(str1):
windowstart = 0
max_length = 0
index_map = {}
for windowend in range(len(str1)):
right = str1[windowend]
if right in index_map:
windowstart = max(windowstart, index_map[right] + 1)
index_map[right] = windowend
max_length = m... | true |
68f7c4431ce6d5e6ba0cff983ed6f23603434d22 | zahraishah/zahraishah.github.io | /ErdosRenyi_graphs.py | 1,217 | 4.3125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 13 11:43:46 2020
@author: malaikakironde
"""
#This document goes over implementing a random graph using
#the Erdos-Renyi Model
import sys
import matplotlib.pyplot as plt
import networkx as nx
import random
def erdos_renyi(G,p):
#finding a... | true |
c085dc3d74bbb82b00b1de60f434a9a0dd53be3e | milenacudak96/python_fundamentals | /labs/04_conditionals_loops/04_07_search.py | 365 | 4.15625 | 4 | '''
Receive a number between 0 and 1,000,000,000 from the user.
Use while loop to find the number - when the number is found exit the loop and print the number to the console.
'''
number = int(input('enter the number between 0 and 1000000000: '))
while number in range(1, 1000000000):
print(number)
break
els... | true |
ec8885cb263e5d23fc69f837f83882bab1d48d23 | milenacudak96/python_fundamentals | /labs/04_conditionals_loops/04_01_divisible.py | 333 | 4.40625 | 4 | '''
Write a program that takes a number between 1 and 1,000,000,000
from the user and determines whether it is divisible by 3 using an if statement.
Print the result.
'''
number = int(input('enter the number between 1 and 1000000000: '))
if number % 3 == 0:
print('its divisible by 3')
else:
print('its not div... | true |
d12615c7de5b1a340a8469fb265b15aa3c5fc7b3 | milenacudak96/python_fundamentals | /labs/07_classes_objects_methods/07_02_shapes.py | 797 | 4.5 | 4 | '''
Create two classes that model a rectangle and a circle. The rectangle class should
be constructed by length and width while the circle class should be constructed by
radius.
Write methods in the appropriate class so that you can calculate the area (of the rectangle and circle),
perimeter (of the rectangle) and cir... | true |
35968dce2d4f437986f46c8762d798a869a32eec | ashutoshnarayan/Coursera | /guess_the_number.py | 2,461 | 4.34375 | 4 | # "Guess the number" mini-project
# input will come from buttons and an input field
# all output for the game will be printed in the console
import simplegui
import math
import random
# initialize global variables used in your code
count_of_guesses = 7
game_range = 100
secret_number = random.randrange(0, 1... | true |
654adb4d0cfffff4f410b5408e631eeeb9d4856e | mannhuynh/Python-Codes | /OOP/APP_1/water.py | 1,271 | 4.5625 | 5 | class Water:
"""
How do you access a class variable (e.g., boiling_temperature ) from within a method (e.g., from state)?
The answer is: You can access class variables by using self. So, in our example,
you would write self.boiling_temperature. See the state method below for an illustration.
The key... | true |
051dc584bef186573140404b6de74f8ba9fc1fdf | Mariobouzakhm/Hangman | /hangman.py | 2,574 | 4.1875 | 4 | import filemanager, random
def createWordList(word):
lst = list()
for i in range(len(word)):
lst.append('-')
return lst
def modifyWordList(lst, word, letter):
for i in range(len(word)):
if word[i] == letter:
lst[i] = letter
return lst
#Open a File Handle with the file ... | true |
7ccc450c398e40e9e8c97b927d20dbf0d4f83b7b | sergiosanchezbarradas/Udemy_Masterclass_Python | /sequences/automate boring.py | 551 | 4.1875 | 4 | # This program says hello and asks for my name.
print('Hello, world!')
print('Whats your name')
your_name = input()
print('nice to meet you ' + your_name)
length_name = (len(your_name))
print('your name is {} characters long'.format(length_name))
print("What's your age")
age = input()
print("You will be " + str(int(a... | true |
2ed3de8d74a1df5c2a32776675614f670af9b7bc | eraldomuha/software_development_projects | /rock_paper_scissors.py | 2,995 | 4.21875 | 4 | #!/usr/bin/env python3
from random import choice
"""This program plays a game of Rock, Paper, Scissors between two Players,
and reports both Player's scores each round."""
moves = ['rock', 'paper', 'scissors']
"""The Player class is the parent class for all of the Players
in this game"""
class Player... | true |
2a53202790f416952f3e0eeaf46eeffda1b2440f | lachilles/oo-melons | /melons2.py | 2,009 | 4.25 | 4 | """This file should have our order classes in it."""
class AbstractMelonOrder(object):
"""Default melon order """
def __init__(self, species, qty):
self.species = species
self.qty = qty
self.shipped = False
self.flat_rate = 0
def get_total(self):
"""Calc... | true |
56fe479ffd914e40a60ecdd381d7dbfe37163c32 | Tonyynot14/Textbook | /chapter5.10.py | 339 | 4.15625 | 4 | students = int(input("How many students do you have?"))
highest = 0
secondhighest = 0
for i in range(students):
score = int(input("What are the scores for the test?"))
if score > highest:
secondhighest=highest
highest = score
print("The highest test score was", highest, "\nThe second highest wa... | true |
7eb418fe5e33623b74ee446a4d515e32afa5c82c | Tonyynot14/Textbook | /nsidepolygonclass.py | 1,229 | 4.1875 | 4 | #Tony Wade
# Class for regular polygons
# Class that defines a polygon based on n(number of sides), side(length of side)
# x(x coordinate) y(y coordinate)
import math
class RegularPolygon:
# initalizer and default constructor of regular polygon
def __init__(self, n=3, side = 1, x = 0, y = 0 ):
self.__... | true |
c5634614d01183874ccc6c7e0a0f651e9cd345ca | coldmanck/leetcode-python | /0426_Convert_Binary_Search_Tree_to_Sorted_Doubly_Linked_List.py | 1,445 | 4.28125 | 4 | # Runtime: 36 ms, faster than 55.87% of Python3 online submissions for Convert Binary Search Tree to Sorted Doubly Linked List.
# Memory Usage: 14.8 MB, less than 100.00% of Python3 online submissions for Convert Binary Search Tree to Sorted Doubly Linked List.
# Definition for a Node.
class Node:
def __init__(sel... | true |
e0453bfe71a01326909b1105ad8333463af4d7a4 | coldmanck/leetcode-python | /0077_Combinations.py | 1,190 | 4.15625 | 4 | class Solution:
'''Backtrack. Time: O(k*C^n_k) Space (C^n_k)'''
def combine(self, n: int, k: int) -> List[List[int]]:
def backtrack(i, cur_arr, ans, arr):
if len(cur_arr) == k:
ans.append(cur_arr)
return
for j in range(i, n):
backtr... | true |
4bdb539d304920611d832ccf249baa155666b01b | JelenaKiblik/School-python | /kt1/exam.py | 1,672 | 4.125 | 4 | """Kontrolltoo."""
def capitalize_string(s: str) -> str:
"""
Return capitalized string. The first char is capitalized, the rest remain as they are.
capitalize_string("abc") => "Abc"
capitalize_string("ABc") => "ABc"
capitalize_string("") => ""
"""
if len(s) >= 1:
return s[0].upper... | true |
6c0e0a844f7b4a863884ece04c4560c09167bb17 | lkrauss15/Old-School-Stuff | /CarCalc.py | 660 | 4.1875 | 4 | # Programmer: Luke Krauss
# Date: 9/15/14
# File: Wordproblems.py
# This program allows a user to input specific numbers for a word problem. In this case, the user is saing up to purchase a car.
def main():
print ("So you're saving up to buy a car?")
carCost = input("How much is the car? ")
currentCash =... | true |
3d9b540022732b42d3cb58317f9ac9c0fd2193cb | lcarbonaro/python | /session20161129/guess.v1.py | 336 | 4.15625 | 4 | from random import randint
rand = randint(1,20)
print('I have picked a random integer between 1 and 20.')
guess = input('Enter your guess: ')
if guess<rand:
print('That is too low.')
if guess>rand:
print('That is too high.')
if guess==rand:
print('That is correct.')
print('The random integer was:... | true |
5f241775792987d41cda409b63a38a36cf5981b7 | KevinMFinch/Python-Samples | /productCommercial.py | 591 | 4.125 | 4 | print("Hello! I am going to ask you questions about your device to create a commercial.")
yourObject = input("What is your object? ")
yourData = input("What data does it take? ")
how = input("How will you record the "+yourData+" from your "+yourObject+"?")
where = input("Where will the "+how+" be located? ")
cost = inp... | true |
a69bfc55246f403b8b5711818e6591e150739c09 | jaysonmassey/CMIS102 | /Assignment_2_CMIS_102_Jayson_Massey.py | 2,585 | 4.53125 | 5 | # Assignment 2 CMIS 102 Jayson Massey
# The second assignment involves writing a Python program to compute the price of a theater ticket.
# Your program should prompt the user for the patron's age and whether the movie is 3D.
# Children and seniors should receive a discounted price. x
# There should be a surcharg... | true |
9fa7ba142e1959040911fd07092dabf96e018ecf | gasgit-cs/pforcs-problem-sheet | /es.py | 2,040 | 4.3125 | 4 | # program to read in a file and count ocurrence of a char
# author glen gardiner
# run program calling es.py and passing the name of a file to read
# example: python es.py Lorem-ipsum.txt
# for this task its es.py md.txt
import sys
# fn - filename
# i - input from user
# uc - uppercase i
# lc - lowercase i
fn = sys... | true |
df03082be153b1535a15ba6a35f9fbfd8c6480e5 | robertggovias/robertgovia.github.io | /python/cs241/w04/assignment04/customer.py | 2,220 | 4.1875 | 4 | from order import Order
from product import Product
class Customer:
'''id=0
price
quantity'''
def __init__(self):
'''
Construction of an empty object to receive the id from the customer, and his name. Then will receive the list of orders
'''
self.id = ""
self.nam... | true |
b0972ddcba708ccaf388c5f53d596f2bccebfb99 | NishantGhanate/PythonScripts | /Scripts/alien.py | 927 | 4.21875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Jan 11 13:39:32 2019
@author: Nishant Ghanate
"""
# your code goes here
import pandas as pd
#Take User input for alphabetical order and string
#a= input('Enter the order of alphabet : \n')
#b= input('Enter the string you want to sort according to the Alphabet provided : \n'... | true |
bd446e6a1cd0e8bcb5fe6745d2ebe9b78c40639e | pavanpandya/Python | /Python Basic/27_Sets.py | 589 | 4.5 | 4 | # Set-Unordered Collection of unique objects
my_set = {1, 2, 3, 4, 5, 6}
print(my_set)
# Now let say we have an another set name my_set2
my_set2 = {1, 2, 3, 4, 5, 5}
print(my_set2)
# Here this will only print the unique objects.
my_set.add(100)
my_set.add(2)
# Here 2 is not added in the set because it is already pre... | true |
adff70a67790e99f15a4effcddf6d69269395bf9 | pavanpandya/Python | /Python Basic/38_Range().py | 965 | 4.46875 | 4 | # Range - It returns an object that produces a sequence of integers from start(inclusive) to stop(exclusive) by step.
# Syntax:
# range(stop)
# range(start, stop[, step])
print(range(100))
# will give output:
# range(0, 100)
print(range(0, 100))
# will give output:
# range(0, 100)
for number in range(0, 100):
pr... | true |
4bf1675599ba2c0097469ead8eccccc889334057 | pavanpandya/Python | /Other Python Section/06_Error_Handling.py | 718 | 4.21875 | 4 | # Error Handling:
while True:
try:
age = int(input('What is your age: '))
print(age)
except:
print('Please enter a number')
# The above code means try the code and if there is any error run except.
else:
print('Thank You')
break
# If there is any error then inst... | true |
59ca9c162a99aabaa5affebfe41f32241e655379 | pavanpandya/Python | /Python Basic/11_Formatted_Strings.py | 768 | 4.34375 | 4 | # Formatted Strings
name = 'Pavan'
age = 19
# print('Hi' + name + '. You are ' + age + ' year old.') --> This will throw an error as age is int
# and string Concatenation only works with strings
print('Hi ' + name + '. You are ' + str(age) + ' year old.')
# Better Way of doing This
print(f'Hi {name}. You are {age} ye... | true |
be072451108e2ad01b0c6f2638d13f3352104d16 | pavanpandya/Python | /OOP by Telusko/10_Constructor_in_Inheritance.py | 1,292 | 4.59375 | 5 | # SUB CLASS CAN ACCESS ALL THE FEATURES OF SUPER CLASS
# BUT
# SUPER CLASS CANNOT ACCESS ANY FEATURES OF SUB CLASS
'''
IMPORTANT RULE:
When you create object of sub class it will call init of sub class first.
If you have call super then it will first call init of super class and then call the init of sub class.
'''... | true |
266c658edeabb5217f3cd1b8cf61a2ad2de4fea2 | pavanpandya/Python | /Python Basic/07_Augmented_Assignment_Operator.py | 471 | 4.71875 | 5 | # Augmented Assignment Operator
Some_value = 5
# Some_value = Some_value + 5
# instead of doing this we will use Augmented Assignment Operator,
Some_value += 5 # --> which is equal to Some_value = Some_value + 5
# NOTE : In order to work this "Some_value += 5", the variable "Some_value" should be defined before or ... | true |
3f1dce9f42dbd335fa08610df5732a308fb7f744 | pavanpandya/Python | /Python Basic/56_Exercise_Functions.py | 332 | 4.125 | 4 | def Highest_Even_Number(li):
evens = []
for item in li:
if(item % 2 == 0):
evens.append(item)
max = 0
for i in evens:
if(i > max):
max = i
return max
# By using Max Function.
# return max(evens)
my_List = [10, 2, 3, 4, 8, 11]
print(Highest_Even_Numbe... | true |
14039762193d12d2ab24057aa383a327bc254eb5 | pavanpandya/Python | /Other Python Section/08_Exercise_error_handling.py | 551 | 4.15625 | 4 | while True:
try:
age = int(input('What is your age: '))
print(age)
except ValueError:
print('Please Enter a number')
except ZeroDivisionError:
print("You can't Enter Zero")
else:
print('Thank You')
break
finally:
print("Okay, I'am Finally Done"... | true |
ff82750488e0dd6ee02cdda39ebad5fc36df5fe4 | cameron-teed/ICS3U-5-04-PY | /cyliinder.py | 922 | 4.3125 | 4 | #!/usr/bin/env python3
# Created by: Cameron Teed
# Created on: Nov 2019
# This program calculates volume of a cylinder
import math
def volume_calculator(radius, height):
# calculates the volume
# process
volume = math.pi * radius * radius * height
return round(volume, 2)
def main():
# This i... | true |
0fd7593dc7b0faafc04fa0664278eb7ed1859e80 | Zgonz19/Towers-of-Hanoi | /TowersofHanoi.py | 2,875 | 4.125 | 4 | # COSC 3320, Towers of Hanoi, Assignment 1
# Gonzalo Zepeda, ID: 1561524
# when called, printMove function prints the current move as long as the parameters
# entered correspond to the solution.
# notable parameters: which disk is moving, disk location, disk destination, number of moves so far
def printMove(disk, sour... | true |
985035622d0ea945f08a311f4b075820771d1652 | mswift42/project-euler | /euler38.py | 954 | 4.28125 | 4 | #!/usr/bin/env
# -*- coding: utf-8 -*-
"""Pandigital mutiples
Problem 38
28 February 2003
Take the number 192 and multiply it by each of 1, 2, and 3:
192 1 = 192
192 2 = 384
192 3 = 576
By concatenating each product we get the 1 to 9 pandigital, 192384576. We will call 192384576 the concatenated product of 192 an... | true |
46811fc30524954812699c4ecc59ea0ce77735fb | Igor-Zhelezniak-1/ICS3U-Unit4-02-Python-Math_Program | /math_program.py | 766 | 4.21875 | 4 | #!/usr/bin/env python3
# Created by: Igor
# Created on: Sept 2021
# This is math_program
def main():
loop_counter = 1
answer = 1
# input
integer = input("Enter any positive number: ")
print("")
# process & output
try:
number = int(integer)
if number < 0:
prin... | true |
aedda9665a6e79cc9c6fb033d1b04aa9c4ba3565 | ecornelldev/ctech400s | /ctech402/module_6/M6_Codio_PROJECT/exercise_files/startercode3.py | 498 | 4.34375 | 4 |
####
# Player and Computer each have 3 dice
# They each roll all 3 dice until one player rolls 3 matching dice.
#######
# import random package
import random
# player and computers total score
player_score = 0
computer_score = 0
# define a function that is checks for three matching dice
# function returns True or ... | true |
688528928849a3a923618670d60ad349799e16a2 | satvikag2001/codechef | /func_game_south.py | 1,541 | 4.1875 | 4 | from sys import exit
import func_extra
prompt = ">>>>"
def south():
print("You have entered the castle of DOOM ,from its rear end")
print("It is dark and faint sounds of screaming can be heard.")
print("you are absoulutely defenceless so like every sane peron you walk down the dusty corridor taking in")
pr... | true |
943d825de16d00b7e445aaa34666b1cad7ec2844 | ishantk/GW2021PY1 | /Session18C.py | 2,084 | 4.125 | 4 | # Why Inheritance
# Code Redundancy -> Development Time
class FlightBooking:
def __init__(self, from_location, to_location, departure_date, travellers, travel_class):
self.from_location = from_location
self.to_location = to_location
self.departure_date = departure_date
self.travell... | true |
7ad70114f889d526874f3bda353179532676a51c | rantsandruse/pytorch_lstm_01intro | /main_example.py | 2,312 | 4.25 | 4 | '''
This is the "quick example", based on:
https://pytorch.org/tutorials/beginner/nlp/sequence_models_tutorial.html
'''
import numpy as np
import torch
import torch.nn as nn
# This is the beginning of the original tutorial
torch.manual_seed(1)
# The first implementation
# Initialize inputs as a list of tensors
# pass... | true |
3c04e2019071ccdf771f3fd7c2bfb0189235ac59 | hirenpatel1207/IPEM_Smart_Coffee | /WorkingDirectory/Raspberry_Pi_Code/calculateParticularFeature.py | 1,037 | 4.15625 | 4 | """
Brief:
this file calculates particular features passed in the argument.
Calculate various features to generate the feature vector which can be used for prediction
"""
import numpy as np
# Note: pass the feature name correctly to avoid error
def calculateParticularFeatureFunc(x, featureName):
# calcu... | true |
150583f46366913093372af43576e892f3d7b3e5 | aysegulkrms/SummerPythonCourse | /Week3/10_Loops_4.py | 345 | 4.1875 | 4 | max_temp = 102.5
temperature = float(input("Enter the substance's temperature "))
while temperature > max_temp:
print("Turn down the thermostat. Wait 5 minutes. Check the temperature again")
temperature = float(input("Enter the new Celsius temperature "))
print("The temperature is acceptable")
print("Check ... | true |
ee1cc4de9e1fefc268d34dfc27d1ef6cd73573ea | nbrahman/LeetCode | /ReverseInteger.py | 929 | 4.15625 | 4 | '''
Reverse digits of an integer.
Example1: x = 123, return 321
Example2: x = -123, return -321
click to show spoilers.
Note:
The input is assumed to be a 32-bit signed integer. Your function should return 0 when the reversed integer overflows.
'''
class Solution(object):
def reverse(self, x):
"""
... | true |
3c7f4279f3901b455a9a8320029206845a06afc4 | atriekak/LeetCode | /solutions/341. Flatten Nested List Iterator.py | 2,459 | 4.1875 | 4 | # """
# This is the interface that allows for creating nested lists.
# You should not implement it, or speculate about its implementation
# """
#class NestedInteger:
# def isInteger(self) -> bool:
# """
# @return True if this NestedInteger holds a single integer, rather than a nested list.
# """... | true |
a3a462573a5d9069a7736bd4036dd1f2012e079f | Novandev/chapt2 | /convert3.py | 483 | 4.25 | 4 | # convert3.py
# A program that convert Celsius temps to Fahrenheit and prints a table
# redone by donovan Adams
def main():
print "This is a program that converts Celcius to Fahrenheit."
print "Here are the temperatures every 10 degrees"
print " ____________________"
for i in [10,20,30,40,50,60,70,80,9... | true |
9d0a204ea2f2a8311b09b1c3cc7e278e9535364a | danieled01/python | /myapps/test_scripts/reverse.py | 355 | 4.5625 | 5 | #have to write a function that will return the value of a string backwards:
def solution(string):
return string[::-1]
#string[::1] works by specifying which elements you want as [begin:end:step]. So by specifying -1 for the step you are telling Python to use -1 as a step which in turn starts
#from the end. This... | true |
db892f7ee026d9356d5ffce80899ffb20bc3e698 | DevanKula/CP5632_Workshops | /Workshop 7/do from scratch.py | 364 | 4.15625 | 4 |
word_string = str(input("Enter the a phrase: ")).split()
counter = 0
words_dicts = {}
for word in word_string:
counter = word_string.count(word)
words_dicts = {word:counter}
print(words_dicts)
#print(word_count)
# print(words_lists)
#
# word_count = word_string.count(words)
#for word in words_lists:
# ... | true |
b86a00994c09f0ecf9cd87ef82f50d66b69f9dc7 | abhisheklomsh/MyTutorials | /#100daysOfCode/day1.py | 2,781 | 4.34375 | 4 | """
Two Number Sum:
Write a function that takes in a non-empty array of distinct integers and an integer representing a target sum.
If any two numbers in the input array sum upto the target sum, the function should return them in an array, in any order.
If no two numbers sum up to the target sum,... | true |
ee53bf76298753fd95975aefde030d4ae3baf56a | prathimaautomation/python_oop | /python_functions.py | 1,422 | 4.59375 | 5 | # Let's create a function
# Syntax def is used to declare followed by name of the function():
# First Iteration
# def greeting():
# print("Welcome on Board! enjoy your trip.")
# # pass # pass keyword that allows the interpretor to skip this without errors
#
#
# greeting() # if we didn't call the function it ... | true |
b77dc0558251c9f7e86390143e4d708a48249f15 | 2kaiser/raspberry_pi_cnn | /mp1/pt2.py | 2,403 | 4.15625 | 4 | import numpy as np
#Step 1: Generate a 2-dim all-zero array A, with the size of 9 x 6 (row x column).
A = np.zeros((9,6))
print("A is: ")
print(A)
#Step 2: Create a block-I shape by replacing certain elements from 0 to 1 in array A
A[0][1:5] = 1 #top of I
A[1][1:5] = 1 #top of I
A[2][2:4] = 1 #middle of I
A[3][2:4] = ... | true |
9b7535587b9e92bcd7cf5bb1577863b01b1f3792 | lacoperon/CTCI_Implementations | /1_ArraysAndStrings/1.3.py | 1,672 | 4.1875 | 4 | '''
Elliot Williams
08/02/18
Q: `URLify`: Write a method to replace all spaces in a string with '%20'. You
may assume that the string has sufficient space at the end to hold the
additional characters, and that you are given the "true" length of the string
'''
def URLify(char_array, true_length):
j = len(cha... | true |
5a481d5050fe713ca17e5b63747f03488e0f6540 | jknight1725/pizza_compare | /pizza.py | 948 | 4.125 | 4 | #!/usr/bin/env python3
from math import pi
from sys import argv
p1_size = int(argv[1])
p1_price = int(argv[2])
p2_size = int(argv[3])
p2_price = int(argv[4])
def pizza(size, price):
stats = {}
radius = size / 2
radius_squared = radius*radius
area = radius_squared * pi
stats['size'] = size
st... | true |
4ea6c3c11397c35e0acadf6e69de7c2489d6ddbf | RLewis11769/holbertonschool-higher_level_programming | /0x0B-python-input_output/100-append_after.py | 773 | 4.125 | 4 | #!/usr/bin/python3
"""
append_after - inserts text to file if line contains string
@filename: file to search and append to
@search_string: if in line, insert text after given line
@new_string: text to insert after found text
"""
def append_after(filename="", search_string="", new_string=""):
""" Appends new_stri... | true |
182e81555a1d0d5f4d9312d73ba8dfed7bc50841 | Andy931/AssignmentsForICS4U | /BinarySearchInPython.py | 2,318 | 4.15625 | 4 | # Created by: Andy Liu
# Created on: Oct 17 2016
# Created for: ICS4U
# Assignment #3b
# This program searches a number exists in an random array using binary search
from random import randint
array_size = 250 # define the size of the array
def binary_search(search_value, num):
# these variables defi... | true |
697b324ffae85c598109b5ac5986f2c3af5dddc3 | DenisLo-master/python_basic_11.06.2020 | /homeworks/less3/task3.py | 839 | 4.5625 | 5 | """
3. Реализовать функцию my_func(), которая принимает три позиционных аргумента, и возвращает сумму наибольших двух аргументов.
"""
def my_func(num1: int, num2: int, num3: int) -> int:
"""
search for two of the smallest arguments out of three
:param num1: any number
:param num2: any number
:par... | true |
d621e1e36862636796eb36c99ecbdc070b4a2328 | skawad/pythonpractice | /datastructures/ex_08_05.py | 1,003 | 4.1875 | 4 | # Open the file mbox-short.txt and read it line by line. When you find a line
# that starts with 'From ' like the following line:
# From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008
# You will parse the From line using split() and print out the second word in the line (i.e. the entire address of the person who ... | true |
cc6567dbbf51778cc3aa8ca439727d1b6b80ea07 | janelstewart/myshoppinglistproject.py | /shopping_list_project.py | 2,044 | 4.25 | 4 | my_shopping_lists_by_list_name = {}
def add_list(list_name):
#check if list name exists in dictionary
#if doesnt exist add list to dictionary
if list_name not in my_shopping_lists_by_list_name:
my_shopping_lists_by_list_name[list_name] = []
def add_item_to_list(list_name,item):
#use list name to retrieve lis... | true |
e4b882493feb4792ecd3b72b781edb0856b5ffb5 | Suhyun-2012/Suhyun-2012.github.io | /Works/CYO.py | 893 | 4.28125 | 4 | answer1 = input("Should I go walk on the beach or go inside or go to the city?")
if answer1 == "beach":
if input("Should I go swimming or make a sandcastle?") == "sandcastle":
print("Wow, my sandcastle is very tall!")
#elif input(print("Should I go swimming or make a sandcastle?")) == "jiooswimming":
... | true |
19c38fbcff05936e5b981613229378b6569c890f | williamdarkocode/AlgortithmsAndDataStructures | /threeway_set_disjoint.py | 1,243 | 4.125 | 4 | # given 3 sequences of numbers, A, B, C, determine if their intersection is empty. Namely, there does not exist an element x such that
# x is in A, B, and C
# Assume no individual sequence contains duplicates
import numpy as np
def return_smallest_to_largest(A,B,C):
list_of_lists = [A,B,C]
len_list = [len(A),... | true |
11a37184c06031fb300cc01555acc86b5fc7620e | milesmackenzie/dataquest | /step_1/python_intro_beginner/intro_functions/movie_metadata_exercise3.py | 785 | 4.375 | 4 | # Write a function index_equals_str() that takes in three arguments: a list, an index and a string, and checks whether that index of the list is equal to that string.
# Call the function with a different order of the inputs, using named arguments.
# Call the function on wonder_woman to check whether or not it is a movi... | true |
144387536b64e9518bb04d72279f8bcd28cd4e77 | sivabuddi/Python_Assign | /python_deep_learning_icp1/stringreplacement.py | 1,355 | 4.21875 | 4 | # Replace Class in Python
class Replace:
def replace(self,input_string,original_word, replacement_word):
output_string = ""
temp_string = ""
temp_counter = -1
init = 0
for char in input_string:
# check if its starting with Original word for replacing
... | true |
624fece2eb26804725675757255cafe640ad30a5 | islamuzkg/tip-calculator-start | /main.py | 1,332 | 4.15625 | 4 | #If the bill was $150.00, split between 5 people, with 12% tip.
#Each person should pay (150.00 / 5) * 1.12 = 33.6
#Format the result to 2 decimal places = 33.60
#Tip: There are 2 ways to round a number. You might have to do some Googling to solve this.💪
#HINT 1: https://www.google.com/search?q=how+to+round+number+to... | true |
ab4dc1572c3040ffb05287f4779bb16b41b0fa65 | Magical-Man/Python | /Learning Python/allcmd.py | 990 | 4.34375 | 4 | assert 2 + 2 == 4, "Huston, we have a probelm"
#If the above was == 5, there would be an error.
for n in range(2, 10):
for x in range(2, n):
if n % x == 0:
print(n, 'equals', x, '*', n//x)
break
else:
#loop fell through without finding a factor
print(n, 'is a p... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.