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 |
|---|---|---|---|---|---|---|
f7ecdbdab77b31336e1cfffd3f132896e6a7a104 | Akshata1801/Motion_Planning_Algorithms | /DFS_maze.py | 4,831 | 3.84375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Mar 1 01:33:12 2020
@author: akpo2
"""
import numpy as np
import matplotlib.pyplot as plt
# Defining the maze wherein 1's represent the free path and 0's represent the obstacles
def GetMaze():
return np.array([[ 1, 0, 1, 1, 1, 1, 0, 1, 1, 1 ],
[ 1, 0, 1... |
9404f00b0b6febab69e510c6e0796a2564217e87 | Davies-Career-and-Technical-High-School/2-1-activity-basic-calculations-Alex-Rodrigues22 | /question1.py | 96 | 3.890625 | 4 | num = int(input("Enter a number: "))
print(int(num + 1))
print(int(num + 2))
print(int(num + 3)) |
846ba86bb7a3468ad1ff09035f74e8c992cd093c | lewiss9581/CTI110 | /M3LAB_Lewis.py | 978 | 4.1875 | 4 | # The purpose of this program is to calculate user input of their number grades and then output the letter grade
# Lewis.
# The def main or code being excuted later sets the following variables: A_score = 90, B_score = 80, C_score = 70, D_score = 60, F_score = 50,
A_score = 90
B_score = 80
C_score = 70
D_score ... |
0584b0091ac0d93bcb9d6d05efb4b1389dfe5a9e | tknmk/get_primefactors_by_range | /get_allcombinations_by_primenumbers.py | 1,095 | 3.921875 | 4 | # -*- coding: utf-8 -*-
import sys
import pprint
import itertools
# input a base number from console.
argvs = sys.argv
mini_num = int(argvs[1])
max_num = int(argvs[2])
# Set a range and
# get prime numbers by for loops
def get_prime_numbers(mini_num,max_num):
result = []
print ('The range is between %d to ... |
175fa7681657a9c1f71eef5997e4fcaf299fa042 | Manchangdx/pc | /00_练习题参考答案/06_面向对象编程/按要求实现类/classtest.py | 311 | 3.53125 | 4 | class UserData:
def __init__(self, id, name):
self.id = id
self.name = name
def __repr__(self):
return 'ID:{} Name:{}'.format(self.id, self.name)
if __name__ == '__main__':
user1 = UserData(101, 'Jack')
user2 = UserData(102, 'Louplus')
print(user1)
print(user2)
|
2eafc5ecaacc118b8811f44eb9de9cc895d24511 | jgomezfr/battleship | /battleship.py | 3,723 | 3.6875 | 4 | #!/usr/bin/env python3
import keyboardInput
import display
import time
import random
# emptyBoard = [ [0] * 10 for _ in range(10)]
playerOneTopBoard = [ [0] * 10 for _ in range(10)]
playerOneBottomBoard = [ [0] * 10 for _ in range(10)]
playerTwoTopBoard = [ [0] * 10 for _ in range(10)]
playerTwoBottomBoard = [ [0] *... |
0b48fb108dc57086bb5021fc398cea73abebec75 | Adonisbruno/algoritmos_de_ordenacao | /auxiliar.py | 927 | 3.53125 | 4 | from random import randint
import matplotlib.pyplot as plt
def vector_random(size, start, stop):
v = []
for a in range(1, size, 1):
v.append(randint(start,stop))
return v
def ler_entrada(filename):
arquivo = open(filename,"r")
linhas = arquivo.read()
arquivo.close()
vetor = map(int... |
d4e8ca2fb1e02bbc0c118c17af5b2eb365ed5bcb | lance6716/algs4-python | /1.3-bags-queues-and-stacks/GeneralizedQueue-1.3.38.py | 7,812 | 3.953125 | 4 | #!/usr/bin/env python3
class RBTree:
"""Left leaning RBTree based to achieve logarithmic insert/delete"""
class Node:
def __init__(self, key, value, N=1, red=True):
"""N is the number of nodes(include itself) in this subtree
red indicate the edge to this node is color red, in ot... |
50b31aff9848d141fcf1ca8b916958743b7603b0 | Phillyfan625/Text-Adventure-Game | /adventure.py | 2,925 | 3.84375 | 4 | import random
import sys
import time
def script():
restart = input("Would you like to restart this program?")
if restart == "yes" or restart == "y" or restart == "Yes":
playGame()
if restart == "n" or restart == "no" or restart == "No":
exit()
def playGame():
... |
938e7ec894153df47319fd6d88581ee7c30e6dc8 | cx1802/hello_world | /assignments/XiePeidi_assign5_part3c.py | 2,558 | 4.125 | 4 | """
Peidi Xie
March 30th, 2019
Introduction to Programming, Section 03
Part 3c: Custom Number Range
"""
'''
# iterate from 1 to 1000 to test whether the iterator number is a prime number
for i in range(1, 1001):
# 1 is technically not a prime number
if i == 1:
print("1 is technically not a prime number.... |
51402fed292fc202588a3531f613438fa0879985 | cx1802/hello_world | /assignments/XiePeidi_assign5_part3b.py | 2,319 | 4.09375 | 4 | """
Peidi Xie
March 30th, 2019
Introduction to Programming, Section 03
Part 3b: Find all prime numbers between 1 and 1000
"""
'''
# prompt the user to enter a positive number
number = int(input("Enter a positive number to test: "))
# if the user doesn't enter a positive number, ask the user to enter again until
# the u... |
5a0ff242f87b21940fae0f3c9aa908cb5a9d3365 | cx1802/hello_world | /assignments/XiePeidi_assign6_part1_challenge2.py | 556 | 3.96875 | 4 | """
Peidi Xie
April 1st, 2019
Introduction to Programming, Section 03
Challenge 2
"""
# function: maximum
# input: two integers/floats
# processing: compares the two supplied values
# output: returns the larger value (integer/float)
def maximum(a, b):
if a > b:
return a
else:
return ... |
b6dd19aa0ca31e4fe5561adaab8edcd0fe052002 | cx1802/hello_world | /assignments/XiePeidi_assign5_part3a.py | 1,436 | 4.0625 | 4 | """
Peidi Xie
March 30th, 2019
Introduction to Programming, Section 03
Part 3a: Prime Number Finder
"""
# prompt the user to enter a positive number
number = int(input("Enter a positive number to test: "))
# if the user doesn't enter a positive number, ask the user to enter again until
# the user supplies a positive n... |
8ba9e854eef2d5bb9bd9b605873edd0852eae79a | cx1802/hello_world | /assignments/XiePeidi_assign6_part1_challenge5.py | 743 | 3.953125 | 4 | """
Peidi Xie
April 1st, 2019
Introduction to Programming, Section 03
Challenge 5
"""
def maximum(a, b):
if a > b:
return a
else:
return b
def minimum(a, b):
if a > b:
return b
else:
return a
# function: simple_sort_version2
# input: three integers/floats/string... |
51e724b2d5adb799cf48cec2521e1a3957926cd5 | jchamish/python3-algorithms | /LinkedList.py | 1,359 | 3.890625 | 4 | import random
class Node(object):
def __init__(self, data=None):
self.data = data
self.next_node = None
class LinkedList(object):
def __init__(self):
self.size = 0
self.head = None
self.tail = None
def insert(self, data):
tmp = Node(data)
tmp.nex... |
b34666961323cde95af364a14fed5caa8e97db99 | jsuvanto/15-puzzle | /board.py | 4,031 | 4.15625 | 4 | # random is required for the shuffle method.
import random
# String used to represent the empty tile.
EMPTYSTRING = "*"
# Moves are stored in a dictionary to access them easily.
# Consider self.__empty and MOVES[direction] as vectors. The sum of
# these two vectors is the new position of the empty tile.
MOVES = {
... |
9995d9b032dbc886a61523b84891cf10ac8235fc | kevincuax/Smartcar_coding_challenge | /Smartcar.py | 5,665 | 3.578125 | 4 | import requests
import json
"""
This file contains functions to implement Smartcar API.
Uses data obtained from GM API and returns data in suggested format
"""
#use GM API to get vehicle info
def get_vehicle_info(id):
"""
Get vehicle info based on ID
params: id(int) used to identify car
returns: res, a jso... |
4f78e4a3b0f5f7433e5e6fc983e1735747e8535a | royforlinux/DataMining-Football-Match-Prediction | /src/gui/CountryGui.py | 1,078 | 3.6875 | 4 | import src.util.GuiUtil as GuiUtil
import src.application.Domain.Country as Country
def run():
GuiUtil.print_head("Countries")
menu = {1:"Name"}
GuiUtil.print_menu("Country menu:", menu, add_go_back = True)
while True:
try:
user_input = input("\nSelect an item: ")
user... |
6ff1c445956e49805509269998cbc63cfacd0c96 | pkseniya/programming_practice | /HW_week_4/n5.py | 167 | 3.84375 | 4 | list1 = [1, 2, 3, 4, 5, 6, 7, 8, 9]
list2 = [10, 8, 6, 4, 2]
set1 = set(list1)
set2 = set(list2)
intersection_list = sorted(list(set1 & set2))
print(intersection_list) |
6d7b95883d94db5e47ab5a764eee756a00a78ff8 | AlexBGoode/instabot | /instabot/bot/delay.py | 1,777 | 3.515625 | 4 | """
Function to calculate delays for like/follow/unfollow etc.
"""
from time import time
from time import sleep
import random
def add_dispersion(delay_value):
v = delay_value * (1 + random.random() / 5)
# print v
return v
def like_delay(bot):
t = time()
d = t - bot.like_delay_moment
if... |
a5f10c74f6a140ad75604c9defd3a44e3e0bd4f8 | GunjanPande/tutions-python3 | /REVISION CONTENT/3. Output/3 end in print function.py | 637 | 4.4375 | 4 | def main():
# below three print statements will print in three separate lines
# because default end character/string is "\n" i.e. new line
print("Hello")
print("hi")
print("Namaste")
# we can change default end character/string to any thing we want
# Hello, hi, Namaste\n
print... |
5da93262d82abcbaba4c15c7026b84d1e0a3bbe0 | GunjanPande/tutions-python3 | /Challenges/Random module Challenges/058.py | 300 | 3.65625 | 4 | """
58
Make a maths quiz that asks five questions by randomly
generating two whole numbers to make the question
(e.g. [num1] + [num2]). Ask the user to enter the
answer. If they get it right add a point to their score. At
the end of the quiz, tell them how many they got correct
out of five""" |
1da87e75e533b3dd33251cc8a75c2fdd699eb236 | GunjanPande/tutions-python3 | /Challenges/While Loop Challenges/050.py | 824 | 4.15625 | 4 | """
50
Ask the user to enter a number between
10 and 20.
If they enter a value under 10,
display the message “Too low” and ask
them to try again.
If they enter a value
above 20, display the message “Too high”
and ask them to try again.
Keep repeating
this until they enter a value that is
between 10 and ... |
d1ef303f7eed55f771c695665ef95dd295ba1a77 | GunjanPande/tutions-python3 | /15. Turtle in python/2. Basic example.py | 170 | 3.921875 | 4 | import turtle
def main():
# turtle.shape("turtle")
for i in range(5):
turtle.forward(100)
turtle.right(72)
turtle.exitonclick()
main() |
032151fc2846316feeeabdda96fd724783d7b18e | GunjanPande/tutions-python3 | /Challenges/Basics/005.py | 404 | 4.28125 | 4 | # 005
# Ask the user to enter three
# numbers. Add together the first
# two numbers and then multiply
# this total by the third. Display the
# answer as The answer is
# [answer]. .
def main():
num1 = int( input("Enter number 1: ") )
num2 = int( input("Enter number 2: ") )
num3 = int( input("Enter number 3: "... |
fa45e0bf675adaffdecdf35f3c20c315431b9104 | GunjanPande/tutions-python3 | /10-12. Loops/oddNo2.py | 303 | 4.15625 | 4 | """
Q - Print first n odd number
Take value of n from user
ex. if n = 3
print -> 1, 3, 5
Hint: Use odd no. formula
"""
def main():
n = int(input("Please enter how many odd no.s to print:"))
i = 1
while( i <= n ):
oddNo = 2 * i - 1
print(oddNo)
i = i + 1
main() |
048fa2b8bddcea58578490c440cc0902c4c026fc | GunjanPande/tutions-python3 | /10-12. Loops/FOR LOOPS/forloop1.py | 247 | 4.25 | 4 |
names = [] # names list
n = int(input("How many names? : "))
for i in range(n): # loop will repeat n times
name = input()
names.append(name)
# advanced for loop (for loop in combination with list)
for name in names:
print(name) |
21b8fd17e21b59b8042717fc3286319c914da980 | GunjanPande/tutions-python3 | /17. File Handling basics/Table Example/main.py | 910 | 3.9375 | 4 | def main():
numbers = []
# we will take input from a text file named input.txt which is already present in the same folder as our main.py file
# file.read() # gives whole content of the file as a string
# file.readlines() gives a list of each line in the file, where each line is in the form of a st... |
f2efb3214c73b2438bca6c9f431ce7395b1acf9f | GunjanPande/tutions-python3 | /Challenges/For Loop Challenges/044.py | 340 | 3.828125 | 4 | """44
Ask how many people the user wants to invite to a party.
If they enter a number below 10, (if)
ask for the names and after each name display “[name] has been invited”. (loop ex. for i in range(count))
If they enter a number which is 10 or higher, (else)
display the message “Too many people”.
... |
fd14e438d7cded648828192a171e18f8a38f1a95 | GunjanPande/tutions-python3 | /REVISION CONTENT/4. Input/1. Input.py | 1,173 | 4.125 | 4 | def main():
name = input("Please enter name - ")
print("Name - '{}'".format(name))
# ValueError comes during when we the input provided is not of required
age = int( input("Please enter age - ") )
print("Age - {}".format(age))
height = float( input("Please enter height - ") )
print("Height... |
b2fe7b891e4f40d446d2cb784df8d5f0c5b6b342 | GunjanPande/tutions-python3 | /22. List Methods/main2.py | 700 | 4.25 | 4 | def main():
# 5. Combining items of two different lists in one single list using the + operator
rishavList = ["GTA", "Notebooks", "Bicycle"]
harshitList = ["Pens", "Hard disk", "Cover"]
shoppingList = rishavList + harshitList
print( str(shoppingList) )
# Note - when we use + operator -> ... |
f9a8a7021c76d91edb5ff3d0903a9d9ebb41e1dd | GunjanPande/tutions-python3 | /10-12. Loops/wholeNos.py | 275 | 4.21875 | 4 | """
Print WHOLE numbers upto n. Ask value of n from user.
"""
def main():
print("program to print whole numbers upto n")
n = int(input("Enter value of n: "))
i = 0 # whole number starts from 0
while( i <= n ):
print( i )
i = i + 1
main() |
92582e199045c37d0bf11ffc564deb37ca2f4c3e | GunjanPande/tutions-python3 | /14. String Methods/StringFunctions-2.py | 882 | 4.28125 | 4 | def main():
name = input("enter a string: ")
print(name) # harshit jaiswal
# always remember, in coding, couting starts from 0 and it is called
# variable_name[start_index: end_index + 1] will give a part of the complete string stored in the variable_name
first_name = name[0: 7]
print(fi... |
2a107f0eaadb3a0e84bf96c62f4620bd4aaff554 | GunjanPande/tutions-python3 | /REVISION CONTENT/7. range function/1. use in for loop.py | 503 | 3.9375 | 4 | def main():
# range function with only one argument
# start = 0 (default)
# end = argument
# jump = 1 (default)
# range(10) -> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 END
# below loop runs 10 times
for i in range(10):
print(i)
print()
for i in range(0, 10):
print(i)
p... |
ab85fc139d49fcc5bee8afe3967ae0dfc502329b | Jason-Hlavac/Sorting-Algorithms | /Odd-Even_sort.py | 544 | 3.71875 | 4 | import random
numbers = []
for i in range(random.randint(75,150)):
numbers.append(random.randint(-10000, 10000))
def odd_even(arr):
done = 0
while(done == 0):
done = 1
for i in range(0, len(arr)-1, 2):
if (arr[i] > arr[i+1]):
arr[i],arr[i+1] = arr[i+1], arr[i]
... |
879ad48f1e17e268ee742520ea2313e4059d5fb8 | naresh2504/python | /squareroot.py | 73 | 3.78125 | 4 | import math
num = int(input('enter the value'))
print(math.sqrt(num))
|
64348625f50aa368da546dece41911c151e9a2f4 | Cc-bugwriter/CV | /assignment1/main.py | 3,509 | 3.5625 | 4 | import numpy as np
import matplotlib.pyplot as plt
def load_image(path):
return plt.imread(path)
#
# Problem 1: Getting to know Python
#
from problem1 import *
def problem1():
"""Example code implementing the steps in Problem 1"""
img = load_image("data/a1p1.png")
display_image(img)
save_as_np... |
0f270802dc58873ece1a841f875fad70f1dc5132 | SOUROVSARKERTEC12/Learning-Python | /Simple Factorial.py | 97 | 3.546875 | 4 | num = int(input())
n = 1
if num >= 1:
for i in range(1, num + 1):
n = n * i
print(n)
|
ba2e790350a3aba34937a9688f7324bcef302360 | sp-yduck/AtCoder-ABC | /ABC201-225/202/b.py | 155 | 3.921875 | 4 | S = str(input())
rS = reversed(S)
ans = ""
for s in rS:
if s == "6":
ans += "9"
elif s == "9":
ans += "6"
else:
ans += s
print(ans) |
06f6b84ffbb1534cc1253a5a718ab60c1f27f541 | sp-yduck/AtCoder-ABC | /ABC151-175/169/d.py | 398 | 3.625 | 4 | from math import sqrt
N = int(input())
def sieve(N):
data = []
for d in range(2, int(sqrt(N))+1):
e = 0
while N%d == 0:
N //= d
e += 1
if e:
data.append((d,e))
if N>1:
data.append((N,1))
return data
ans = 0
for p, e in sieve(N):
a... |
fcb3368547a788d2c545d81e28341337b3f93165 | gustavohvgarcia/LearningPython | /Exemplos-Basicos/Relembrando.py | 339 | 3.78125 | 4 | a = int(input("Entre com o primeiro valor: "))
b = int(input("Entre com o segundo valor: "))
soma = a+b
sub = a-b
div = a/b
mult = a*b
resto = a%b
resultado = (f'Soma: {soma}, diferença = {sub}, divisao = {div}, produto = {mult}, resto = {resto}'.format(soma=soma, sub = sub, div =div, produto = mult, resto = resto))
... |
d5e67654ccf34d7b953a87ee29c731d7c7c7e9fd | vanshika-2008/Project-97 | /NumberGuess.py | 616 | 4.25 | 4 | import random
number = random.randint(1 , 9)
chances = 0
print("Number Guessing Game")
print("Guess a number (between 1 to 9)")
while chances<5 :
guess = int(input("Enter your guess :"))
if(guess == number) :
print("Congratulations!! You won the game")
if(guess> number) :
print("Your gue... |
a5b7ebe0ee0a4519159c2d6ab4692d296accc423 | DahlitzFlorian/introduction-to-pythons-operator-module-article-snippets | /student_class.py | 845 | 3.59375 | 4 | # student_class.py
import operator
class Student:
def __init__(self, first_name: str, last_name: str, student_id: int) -> None:
self.first_name: str = first_name
self.last_name: str = last_name
self.student_id: str = student_id
def __repr__(self) -> str:
return f"Student(f... |
450c6af2d2286f30df9dd5e59eb249d041179aef | bainco/bainco.github.io | /course-files/lectures/lecture15 -old/event_demos/demo8_just_move_one_keyboard.py | 2,741 | 4.03125 | 4 | '''
This demo shows you how you can create a new image by clicking the screen.
Documentation:
* tkinter events: https://www.python-course.eu/tkinter_events_binds.php
* Canvas: https://anzeljg.github.io/rin2/book2/2405/docs/tkinter/canvas.html
* Other Canvas methods: https://anzeljg.github.io/rin2/book2/2405/docs/... |
a13d7dae6ff86b927330398d4dc4be159578ece5 | bainco/bainco.github.io | /course-files/lectures/lecture24-old/answers/04_members_of_congress.py | 720 | 3.53125 | 4 | # How many representatives does each state have in the House?
import sys
import os
from csv import reader
dir_path = os.path.dirname(sys.argv[0])
file_path = os.path.join(dir_path, 'legislators-current.csv')
# End VS Code Hack:
f = open(file_path, 'r', encoding='utf8', errors='ignore')
congress_representatives_by_sta... |
9029fa1e713ee2fca0d5f5f1cedb8f2df84cd6a9 | bainco/bainco.github.io | /course-files/lectures/lecture15 -old/event_demos/animate_using_images.py | 1,092 | 4 | 4 | '''
This demo shows you how you can create a new image by clicking the screen.
Important: In order for this to work, you'll need to install pillow using PIP:
From your command line, type: pip3 install pillow
If you're not comfortable with the command line, you can run the file in this folder
named install_python_pack... |
94a6e3a07fef9fc20c6b1fef569f39040c40e80a | bainco/bainco.github.io | /course-files/lectures/lecture24-old/answers/07_trees_by_condition_evanston.py | 1,235 | 3.84375 | 4 | from csv import reader
# write a program that reads the contents of the Trees_data.csv file
# to find out the number of trees in each health category...
# Next week: we're going to make a map of them!
# VS Code Hack:
import sys
import os
dir_path = os.path.dirname(sys.argv[0])
file_path = os.path.join(dir_path, 'Tree... |
94f8024d239a711ec3c171bf7d03ab456bad0888 | bainco/bainco.github.io | /course-files/lectures/lecture15/answers/00_find_largest_number.py | 319 | 4.09375 | 4 | numbers = [65, 1800, 12, 20, 19163, 5000, 260, 0, 40, 953, 775, 67, 33]
# Challenge: write a program that finds the biggest number
# in the numbers list above
largest_yet = numbers[0]
for num in numbers:
if num > largest_yet:
largest_yet = num
print('The largest number in the list is:', largest_yet) |
c1792383d703ea4bfe2d8f0666fb959e2f1699d7 | bainco/bainco.github.io | /course-files/lectures/lecture24/answers/02_restaurant_violations.py | 1,137 | 3.84375 | 4 | # write a program that reads the contents of the Food_Establishment_Violations
# for the City of Evanston and counts the number of violations that have occurred
# for each restaurant code. The, print out the restaurant code and the number of violations
import csv
# 1. start by creating a lookup table where
# the key i... |
9c2bd129ab10ce8ded46862f029582b9dfc4c5f1 | bainco/bainco.github.io | /course-files/lectures/lecture12-old/02_while_animate.py | 1,003 | 4.03125 | 4 | from tkinter import Canvas, Tk
import time
import shapes
gui = Tk()
gui.title('Animation')
canvas = Canvas(gui, width=500, height=500, background='white')
canvas.pack()
########################## YOUR CODE BELOW THIS LINE ##############################
# Using a while loop, please complete the following:
# 1. Make ... |
93e03f599d5396729fdb9fc81d186e2e6c47b8cf | bainco/bainco.github.io | /course-files/lectures/lecture21/01_files/answers/02_counting_lines_a_file.py | 186 | 3.625 | 4 | import utilities
f = open(utilities.get_file_path('moby_dick.txt'), 'r', encoding='utf8')
counter = 0
for line in f:
counter += 1
print('there are ', counter, 'lines in the file.') |
e701409d084960ec4fd8df4bf05d75cd81d8c80a | bainco/bainco.github.io | /course-files/lectures/lecture11-old/answers/sonic_pi/03_answers_while_play_notes.py | 555 | 3.625 | 4 | import psonic
MARIO_NOTES = [
76, 76, 76, 72, 76, 79, 67, 72, 67, 64, 69, 71,
70, 69, 67, 76, 79, 81, 77, 79, 76, 72, 74, 71
]
note_number = 0
psonic.use_synth(psonic.PIANO)
while note_number < len(MARIO_NOTES):
print(note_number, '/', len(MARIO_NOTES), 'MIDI NOTE:', MARIO_NOTES[note_number])
... |
7519300e7167e2add6b75380d49ca5a6adcadd19 | bainco/bainco.github.io | /course-files/lectures/lecture09/scope/03_function_scope.py | 284 | 3.609375 | 4 | ################################################################
# Scope 3: Global variables can be accessed inside of a function
################################################################
name1 = 'Lindsay'
def demo_3(name):
print(name)
print(name1)
demo_3('Walter')
|
ca6b343f53789135348360f416abbf31a2c5ccfa | bainco/bainco.github.io | /course-files/lectures/lecture11-old/old/diamond_challenge.py | 649 | 3.53125 | 4 | from tkinter import Canvas, Tk
# initialize window
gui = Tk()
canvas = Canvas(gui, width=700, height=450, background='white')
canvas.pack()
########################## YOUR CODE BELOW THIS LINE ##############################
canvas.create_polygon(
[
(300, 100), # top-most coordinate
(400, 200), #... |
640c540cda422daed64649da63fdf0e50c784131 | bainco/bainco.github.io | /course-files/homework/hw01/turtle_programs.py | 1,456 | 4.53125 | 5 | from MyTurtle import *
### TURTLE CHEATSHEET ###############################################
# Pretend we have a turtle named: turtle_0
# If we want turtle_0 to go forward 100 steps we just say:
# turtle_0.forward(100)
# If we want turtle_0 to turn left or right 90 degrees, we just say:
# turtle_0.left(90)
# turtle_0... |
b04bf14ed35f8042e222ed3a1901d14fdc69ce63 | bainco/bainco.github.io | /course-files/lectures/lecture11/conditionals/03_even_or_odd_challenge.py | 266 | 3.921875 | 4 | '''
Practice:
Write a function called even_or_odd that takes 1
positional parameter — an int called num — and
returns a string that says either 'even' or 'odd'
Prove that your function works by printing the results
of several function calls to the screen
''' |
c4aa895e47df53ab6f7297d03d2e892e3b11df59 | bainco/bainco.github.io | /course-files/lectures/lecture13/while_loops/05_continue.py | 245 | 3.703125 | 4 | numbers = [
76, 76, 76, 72, 76, 79, 67, 72, 67, 64, 69, 71,
70, 69, 67, 76, 79, 81, 77, 79, 76, 72, 74, 71
]
# Challenge: skip over all of the numbers that equal 67
for num in numbers:
if num == 67:
continue
print(num)
|
88d381a5806bd1d18f616b4bbb096282382f41ec | bainco/bainco.github.io | /course-files/lectures/lecture17/demo7a_layout.py | 1,870 | 3.890625 | 4 | # If you want to have text-based user input:
'''
Documentation:
* tkinter events: https://www.python-course.eu/tkinter_events_binds.php
* Canvas: https://anzeljg.github.io/rin2/book2/2405/docs/tkinter/canvas.html
* Other Canvas methods: https://anzeljg.github.io/rin2/book2/2405/docs/tkinter/canvas-methods.html
''... |
58cfb075dbcaa11e511c92a6a5d42b336498096f | bainco/bainco.github.io | /course-files/tutorials/tutorial05/warmup/a_while_always_true.py | 803 | 4.125 | 4 | import time
'''
A few things to note here:
1. The while loop never terminates. It will print this greeting until
you cancel out of the program (Ctl+C or go the Shell menu at the top of
the screen and select Interrupt Execution), and "Program terminated"
will never print.
2. This is known as... |
6b4d95e6959977d670d0d986d08ae3ed6980a682 | bainco/bainco.github.io | /course-files/lectures/lecture18-old/10_bubbles.py | 855 | 3.921875 | 4 | import utilities
canvas = utilities.create_canvas_window()
##################################################################################
# Your code below this line...
# Your job: Modify the code below so that as
# you loop through each line of the file, you:
# 1. create a variable called "center" that
# st... |
f582865c44a63c43ab303d41c6267bbcef03407b | bainco/bainco.github.io | /course-files/lectures/lecture13/while_loops/02_while_print_elements_of_list.py | 133 | 3.6875 | 4 | names = ['Shameik Moore', 'Kimiko Glenn', 'Tom Holland', 'Andrew Garfield', 'Tobey Maguire', 'Hailee Steinfeld']
# write a while loop that prints every item in the names list:
|
182f595098f71ce6cea9f8a536c8bff1557765e1 | bainco/bainco.github.io | /course-files/lectures/lecture11-old/old/07_color_mixer.py | 620 | 3.53125 | 4 | '''
INSTRUCTIONS: Update this function as follows:
If red is turned on, make the background red.
If yellow is turned on, make the background yellow.
If blue is turned on, make the background blue.
If red and yellow are both turned on, make the background orange.
If red and blue are turned on, make the background purple... |
f66f20710ace1b793b5385eb6abb66161ff23f28 | bainco/bainco.github.io | /course-files/tutorials/tutorial06/01_mouse_events.py | 1,168 | 3.609375 | 4 | from tkinter import Canvas, Tk
import random
import time
import mario_module
import utilities
gui = Tk()
gui.title('Mouse Events')
canvas = Canvas(gui, width=500, height=500)
canvas.pack()
########################## YOUR CODE BELOW THIS LINE ##############################
MOUSE_CLICK = '<Button-1>'
MOUSE_DRAG = '<B1-M... |
dc67ecd32fc7e602e97675510c2d97d2cb2e184b | bainco/bainco.github.io | /course-files/homework/hw01/calculator_programs.py | 329 | 4.21875 | 4 | # Exercise 1:
# Exercise 2:
# Exercise 3:
# Exercise 4:
# Hint: to find the length in number of letters of a string, we can use the len function
# like so: len("hello"). If we wanted to find the number of characters in a string
# that's stored in a variable, we'd instead use the variable's name: len(v... |
c0495efbf0679a33a48221795187928f6927c1f5 | bainco/bainco.github.io | /course-files/lectures/lecture19/01_error_handling/01_try_except_syntax.py | 287 | 3.875 | 4 | try:
# wrap the "try" block around the thing that may potentially error:
val = 'adasdasdasdasdas'
result = int(val)
except:
# write some code that will gracefully handle the error in the event
# that the error happens:
print(val, 'cannot be converted to an int!') |
32ce4bc7ed6d3c02f8c2f9a1f1fe74d56c4eb724 | bainco/bainco.github.io | /course-files/lectures/lecture04/turtle_programs.py | 837 | 4.5625 | 5 | from MyTurtle import *
### TURTLE CHEATSHEET ###############################################
# Pretend we have a turtle named: turtle_0
# If we want turtle_0 to go forward 100 steps we just say:
# turtle_0.forward(100)
# If we want turtle_0 to turn left or right 90 degrees, we just say:
# turtle_0.left(90)
# turtle_0... |
8f4230226c46ca9ff049e2289b97df9be0604840 | fmacias64/CourseraPython | /miniProject1/miniProject1.py | 2,328 | 4.125 | 4 | import random
# Rock-paper-scissors-lizard-Spock template
# The key idea of this program is to equate the strings
# "rock", "paper", "scissors", "lizard", "Spock" to numbers
# as follows:
#
# 0 - rock
# 1 - Spock
# 2 - paper
# 3 - lizard
# 4 - scissors
# helper functions
def name_to_number(name):
# convert name ... |
645b579108d94f26defc4e89817aae5e8db4aefe | narisada014/ABC | /begginer_contests/172/A.py | 81 | 3.859375 | 4 | a = int(input())
sum = 0
for i in range(3):
sum += a ** (i+1)
print(int(sum)) |
e75a296103746529c97d26383e932f766cc9c314 | bkmz1840/FiMPlusPlus | /FiM++/tests/test_program.py | 2,670 | 3.53125 | 4 | import unittest
from program import Program
class TestProgram(unittest.TestCase):
def test_find_main_method(self):
p1 = Program("../test_pr_1.fpp")
self.assertRaises(SyntaxError, p1.find_main_method)
p2 = Program("../test_pr_2.fpp")
self.assertRaises(SyntaxError, p2.find_main_metho... |
9499eb017ab1052f331ee3e9bef2e98b0926b5e9 | MeghaSah/python_internship1 | /day_4.py | 681 | 4.28125 | 4 | # write a prrogram to create a list of n integer values and add an tem to the list
numbers = [1,2,3,4,5,6]
numbers.append(7)
print(numbers)
#delete the item from the list
numbers.remove(5)
print(numbers)
# storing largest number to the list
largest = max(numbers)
print(largest)
# storing smallest number... |
40eb7c2ebb5a8305e789df10d9c81deb2ec759b3 | winterbeef/algos | /ctci-2.3.py | 458 | 3.796875 | 4 | #!/usr/bin/env python
import listlib
def delmid(head):
p1 = None
p2 = head
while p2:
p2 = p2.next
if p2:
p1 = p1.next if p1 else head
p2 = p2.next
if p1 and p1.next and p1.next.next:
p1.next = p1.next.next
if __name__ == '__main__':
for sz in ran... |
a2b523898544fbb90d89797d8d9876d8127edb94 | winterbeef/algos | /ctci-2.2.py | 1,150 | 3.75 | 4 | #!/usr/bin/env python
import random
from pprint import pprint
from collections import deque
class Node(object):
def __init__(self, val):
self.val = val
self.next = None
def __repr__(self):
return "<{:02d}>".format(self.val)
def add_last(self, new):
cur = self
while... |
ec1edd4ade834ad02023b032db68acbb27cbe7e4 | Yining1/dailyprogrammer | /[Difficult] Challenge #3/[Difficult] Challenge #3.py | 975 | 4 | 4 | # https://www.reddit.com/r/dailyprogrammer/comments/pkwgf/2112012_challenge_3_difficult/
# Welcome to cipher day!
# For this challenge, you need to write a program that will take the scrambled words from this post
# (https://pastebin.com/jSD873gL), and compare them against THIS WORD LIST to unscramble them.
# For bonus... |
a4e20eda0af308132291b6c6646b9e6118437e42 | Guilherme-Bodart/uVA-TPA | /src/uva01062/uva01062.py | 1,194 | 3.6875 | 4 | # uva01062.py
# UVa 01062 - Containers
# @authors Jadson Pereira.
# Get-Content entrada.txt | python uva01062.py > saida.txt >>>>Rodando o programa com entrada por .txt
#Leitura dos dados do arquivo.
def entrada():
return input()
#inicio da solução
indexCase: int = 1
data = entrada()
while(data != 'end'):
... |
3b361f14bc195be0d5003e142ad8eb4dc24da6e2 | danlaratta/calculator | /Caculator_App/Calculator.py | 4,943 | 4.15625 | 4 |
import tkinter as tk
# creates window and window size
window = tk.Tk()
window.geometry("225x425")
# titles the window
window.title("Calculator App")
# entry field to display numbers
entry1 = tk.Entry(width=17)
entry1.grid(row=0, column=0, columnspan=3, pady=5)
# function to do addition
def on_click(number):
#... |
1f5548f1e7d7eb845eabf8e3c9c422ba67991732 | Ziiv-git/DATAQUEST | /data_visualisation.py | 3,621 | 4.125 | 4 | When we read the dataset into a DataFrame, pandas will set the data type of the DATE column as a text column.
Because of how pandas reads in strings internally, this column is given a data type of object.
We need to convert this column to the datetime type using the pandas.to_datetime() function, which returns a Series... |
96c4a7eb46dfdd7ab1bc2f4b1511d254bb4221ab | Ziiv-git/DATAQUEST | /API.py | 5,083 | 3.796875 | 4 | # An API is a set of methods and tools that allows different applications to interact with each other. Programmers use APIs to query and retrieve data
# dynamically (which they can then integrate into their own apps). A client can retrieve information quickly and easily with an API.
#
# Reddit, Spotify, Twitter, Facebo... |
a0e35ce61d9ac58cb839c16d5117f69db1db2334 | ps863/Stock-Data-GUI-Application | /Stock Data GUI App.py | 3,351 | 3.890625 | 4 | from tkinter import *
from tkinter.font import Font
import requests
import locale
class App:
"""GUI app that retrieve stock price for a company listed on the NYSE"""
def __init__(self,window_name):
"""Initializes the main window of GUI application"""
#Setting name of main window title
... |
1012b7dc04426d3a59614805b19c141662a76399 | GDGVIT/quicktext | /quicktext/utils/configuration.py | 783 | 3.828125 | 4 | from quicktext.imports import *
def read_yaml(path):
"""
This function reads a YAML file
Args:
path (str): Path to YAML file
Returns:
dict: Parsed YAML file
"""
yaml_file = open(path)
parsed_file = yaml.load(yaml_file, Loader=yaml.FullLoader)
yaml_file.close()
edic... |
af7a8c41370cdd904413ae4616dc37cead04e5b3 | shaydamoezzi/Roboteam-training | /RRT_Simulation_final.py | 5,856 | 3.71875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 26 23:29:07 2020
@author: shaydamoezzi
Roboteam training: RRT simulation
"""
#importing modules
import random, pygame, sys, math
from math import *
from pygame import *
#variable initializations
XDIM = 720
YDIM = 500
windowSize = [XDIM, YDIM]
de... |
d40d0b4806b8081914dbb97ee7e77efa42393967 | Jigenkumar/PyGame | /main.py | 810 | 3.59375 | 4 | import pygame
#Window Creation
x = pygame.init()
gamewindow = pygame.display.set_mode((900, 500))
pygame.display.set_caption("My Game")
#Game Specific Veriables
exit_game = False
game_over = False
#Creating Game Loop
while not exit_game:
for event in pygame.event.get():
if event.type == pygame.QUIT:
... |
a537a13ca20b398dca436acedff7c64293a033ca | xiejian1/yunwei | /CleanData/pandas_demo/apply_test.py | 593 | 3.765625 | 4 | import pandas as pd
grades_df = pd.DataFrame(
data={'exam1': [43, 81, 78, 75, 89, 70, 91, 65, 98, 87],
'exam2': [24, 63, 56, 56, 67, 51, 79, 46, 72, 60]},
index=['Andre', 'Barry', 'Chris', 'Dan', 'Emilio',
'Fred', 'Greta', 'Humbert', 'Ivan', 'James']
)
def convert_grades_curve(exam_grades... |
bda340062aed8861e6fb566b06c034619b3ae70f | Jonnee69/Lucky-Unicorn | /05_Lu_statement_generator.py | 1,032 | 4.21875 | 4 | token = input("choose a token: ")
COST = 1
UNICORN = 5
ZEB_HOR = 0.5
balance = 10
# Adjust balance based on the chosen and generate feedback
if token == "unicorn":
# prints unicorn statement
print()
print("*******************************************")
print("***** Congratulations! It's ${:.2f} {} **... |
d2d3339f9d3d988f58f34c3ca047980d53d0d640 | perfettiful/pypd | /pd_object_classes/number.py | 596 | 3.859375 | 4 |
##########################################################
##########################################################
# description: abstract class that represents a Number
#
# autor: jeraman
# date: 04/04/2009
##########################################################
#################################################... |
8d750428cd3e9dfba4f502e479a11e7574247647 | SPandeyCodes/Python-Basics | /quadratic.py | 266 | 3.765625 | 4 | #SAILESH PANDEY
# Python Program to Solve Quadratic Equation
import cmath #importing maths
a = 2
b = 3
c = 4
det = (b**2) - (4*a*c)
first = (-b-cmath.sqrt(det))/(2*a)
second = (-b+cmath.sqrt(det))/(2*a)
print(' Solutions : {0} and {1}'.format(first,second)) |
0d1292a713b41add2aaff410b99f72c747df5c7d | pigetnet/core | /string/python/getConfigFormat.py | 2,276 | 3.578125 | 4 | #!/usr/bin/python
# source : http://stackoverflow.com/questions/11294535/verify-if-a-string-is-json-in-python
# source : http://stackoverflow.com/questions/82831/how-to-check-whether-a-file-exists-using-python
import ConfigParser
import sys
import json
import os.path
global file
global file_contents
#Check if file ex... |
673ccf4f4da2b09a28adeb66fb721b53c5e7997e | gabrieleliasdev/python-cev | /ex104.py | 1,050 | 3.640625 | 4 | """
Exercício Python #104 - Validando entrada de dados em Python
Crie um programa que tenha a função leiaInt(), que vai funcionar de forma semelhante 'a função input()
do Python, só que fazendo a validação para aceitar apenas um valor numérico.
Ex: n = leiaInt('Digite um n: ')
"""
from pattern import ti... |
2403815f758c6f4148d9e57d7dd23ce2d507451d | gabrieleliasdev/python-cev | /ex055.py | 1,185 | 4.21875 | 4 | """
055 - Faça um programa que leia o peso de cinco pessoas. No final, mostre qual foi o maior
e o menor peso lidos.
"""
"""
w1 = float(input(f"Type the weight of 1ª person: Kg "))
w2 = float(input(f"Type the weight of 2ª person: Kg "))
w3 = float(input(f"Type the weight of 3ª person: Kg "))
w4 = float(input(f"Type... |
6c32c1db6890ba4a22f5e933d749212658b0584d | gabrieleliasdev/python-cev | /ex046A13.py | 878 | 4.09375 | 4 | print("{:=^20}".format(" 'Exempla 01' "))
for c in range(1, 6):
print("Hello")
print("End")
print("{:=^20}".format(" 'Exempla 02' "))
for c in range(0, 6):
print(c)
print("End")
print("{:=^20}".format(" 'Exempla 03' "))
for c in range(6, 0, -1):
print(c)
print("End")
print("{:=^20}".format(" 'Exempla 04' "))
for ... |
d7743ed7e4c58c36c1da69cc55c018277e7bab13 | gabrieleliasdev/python-cev | /ex072.py | 638 | 3.96875 | 4 | """ 072
Crie um programa que tenha uma tupla totalmente preenchida com uma contagem por extenso, de zero até vinte.
Seu programa deverá ler um número pelo teclado (entre 0 e 20) e mostrá-lo por extenso.
"""
print("\n{:=^50}\n".format("Exercise 72"))
lst = ("zero", "one", "two", "three", "four", "five", "six", ... |
d4e8435c99d55b5537d5e3a9b328a89d54c39adc | gabrieleliasdev/python-cev | /ex005.py | 221 | 3.9375 | 4 | # Faça um programa que leia um número inteiro e mostre na tela o seu sucessor e seu antecessor.
number = int(input('>>> '))
print('The successor to {} is {} and its predecessor is {}'.format(number,number+1,number-1 ))
|
3aa8ae23ee066c33fe146ac11b891abb58f36204 | gabrieleliasdev/python-cev | /ex113.py | 423 | 3.78125 | 4 | """
Exercício Python #113 - Funções aprofundadas em Python
Crie um código em Python que teste se o site pudim está acessível pelo computador usado.
"""
from pattern import title, end
from lesson22 import validate
title("In-depth Python Functions")
i = validate.integer("Type a integer number » ")
r = validate.re... |
2956cf3e1f649a9da29bc20220e26e324a404373 | gabrieleliasdev/python-cev | /ex023.py | 346 | 3.671875 | 4 | # Faça um programa que leia um número de 0 a 9999 e mostre na tela cada um dos digitos separados.
# Ex; Digite um número: 1834 unidade: 4 dezena: 3 centena: 8 milhar: 1
n1 = int(input('\nType a number of 04-digit, ex.: 1834:\n>>> '))
n = str(n1)
print('\nUnity: {} | Ten: {} | Hundred: {} | Thousands: {}\n'.format(n[... |
72a1c6cee1535bd01a68fae1dc905c774fc5fd26 | gabrieleliasdev/python-cev | /ex037.py | 752 | 4.125 | 4 | """037 - Escreva um programa que leia um número inteiro qualquer e pela para o usuário escolher qual será a
base de conversão: 1) para binário 2) octal 3) hexadecimal"""
n = int(input("\nType the number you want to convert:\n>>> "))
print("""\nChoose the option for conversion:
[a] Convert to Binary
[b] Convert to O... |
fe7bf50c9a7fbde5bce12f2a10d114d978a78526 | gabrieleliasdev/python-cev | /ex042.py | 784 | 4.25 | 4 | """042 - Refaça o Desafio 035 dos triângulos, acrescentando o recurso de mostrar que tipo de triângulo será formado:
- Equilátero: todos os lados iguais.
- Isóceles: dois lados iguais.
- Escaleno: todos os lados diferentes."""
s = '-=-'*20
print(s)
print('Analisador de Triângulos')
print(s)
r1 = float(input('Fir... |
7f4e3e72f69435664c03881c46d60d4dcabbd825 | gabrieleliasdev/python-cev | /ex051.py | 352 | 3.828125 | 4 | """051 - Desenvolva um programa que leia o primeiro termo e a razão de uma PA. No final, mostre os 10 primeiros
termos dessa progressão."""
fn = int(input("Type the first number: "))
r = int(input("Ratio: "))
t = fn + (10-1) * r #décimo termo de uma progressão aritmética
for c in range(fn, t + r, r):
print(f"{c}",... |
567adb23810d80454e4a6d20115695123cc7a42e | gabrieleliasdev/python-cev | /ex066.py | 476 | 3.9375 | 4 | """
Crie um programa que leia números inteiros pelo teclado.
O programa só vai parar quando o usuário digitar o valor 999, que é a condição de parada.
No final, mostre quantos números foram digitados e qual foi a soma entre elas (desconsiderando o flag).
"""
cont = sm = n = 0
while True:
n = int(input... |
5f090982d7b20f1f53368b387bf90c4121e01ad3 | gabrieleliasdev/python-cev | /ex019.py | 297 | 3.9375 | 4 | from random import choice
a1 = str(input('\nName of student 1:\n '))
a2 = str(input('Name of student 2:\n '))
a3 = str(input('Name of student 3:\n '))
a4 = str(input('Name of student 4:\n '))
lista = [a1, a2, a3, a4]
choosing = choice(lista)
print('The chosen student is {}'.format(choosing))
|
681fba3f6d5b0595e604367258c96e98a7ac2e83 | gabrieleliasdev/python-cev | /ex044.py | 1,250 | 4.125 | 4 | """044 - Elabore um programa que calcule o valor a ser pago por um produto, considerando o seu preço normal e
condição de pagamento:
- à vista dinheiro/cheque: 10% de desconto.
- à vista no cartão: 5% de desconto.
- em até 2x no cartão: preço normal
- 3x ou mais no cartão: 20% de juros"""
v = float(input("\n... |
ae985260b4dd43f768b61630a2b751f06342309c | gabrieleliasdev/python-cev | /ex034.py | 669 | 4 | 4 | # Escreva um programa que pergunte o salário de um funcionário e calcule o valor do seu aumento.
# Para salários superiores a R$ 1.250,00, calcule o valor do seu aumento de 10%.
# Para os inferiores ou iguais, o aumento é de 15%
s = '-=-'*20
m = int(input(f'\n{s}\nReports your salary and the increase will be based o... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.