blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
23a78d6732247649e4996df5839718f6987e7a4b | ShuLingLai/Firstproject | /5pdf.py | 2,133 | 4.34375 | 4 | #函式
def add_x_and_y(x, y):
pass #這個函式先不做事情
# --------------------------------------------------------------
def add_x_and_y1(x, y):
"""
add x and y1 and return sum
:param x: eg.10
:param y: eg.7
:return: x+y
"""
sum1 = x + y
return sum1
a = 10
b = 7
a_b = add_... | false |
446598af9a2c72219e915db9fe01437fc8fc9d7e | shantinavgurukul/loop_question | /odd_even.py | 383 | 4.125 | 4 | num=int(input("enter the number="))
while(num<=10):
if(num%2==0):
print("even num",num)
else:
print("odd num",num)
num=num+1
# num=1
# number=int(input("enter the number = "))
# while(num<=number):
# if(num%10==2):
# if(num%2==0):
# print(num,"even number")
# ... | false |
17094896a237ce2d5f4cc2e0a3b770058f187bcb | fatihtkale/Term-Todo | /script.py | 1,174 | 4.15625 | 4 | import sqlite3
conn = sqlite3.connect('db.db')
query = conn.cursor()
def run_program():
def get_info():
query = conn.cursor()
query.execute("SELECT * FROM Information")
rows = query.fetchall()
for row in rows:
print(row)
run_program()
def save_info(valu... | true |
8ff6e4d16550bff45f3c2e75d17f18cd1640adb1 | mvg2/astr-119-hw-2 | /variables_and_loops.py | 771 | 4.15625 | 4 | import numpy as np # imports the numpy module
def main():
i = 0 # assign integer value 0 to variable i
n = 10 # assign integer value 10 to variable n
x = 119.0 # assign float value 119.0 to variable x
# we can use numpy to declare arrays... | true |
cbaf511f13d0d0b892ea3a11a7b57f3bde24076e | maryjo6384/gitdemo | /dictreverse.py | 750 | 4.25 | 4 | #program to reverse the key and value in the dictionary
#pls review
dict ={"a":"!","b":"@","c":"#","d":"$","e":"5","f":"^","g":"&","h":"*","i":"(","j":"!)","k":"!@","l":"!#","m":"!$",
"n":"!%","o":"!^","p":"!&","q":"!*","r":"!(","s":"!)","t":"@@","u":"@#","v":"@%","w":"^y","x":"@^","y":"@&","z":"@("}
rev_dict= {}
... | false |
157c530a6a6f8d7bc729cbf6c1b945b3bdd83507 | Moosedemeanor/learn-python-3-the-hard-way | /ex03.py | 1,195 | 4.625 | 5 | # + plus
# - minus
# / slash
# * asterisk
# % percent
# < less-than
# > greater-than
# <= less-than-equal
# >= greater-than-equal
# print string text question
print("I will now count my chickens:")
# print Hens string then perform calculation
print("Hens", 25 + 30 / 6)
# print Roosters string then perform calculation
p... | true |
75888241e7d1af247414e9cdb72a2a2e9ebf70f3 | theodorp/CodeEval_Easy | /ageDistribution.py | 1,798 | 4.40625 | 4 | # AGE DISTRIBUTION
# CHALLENGE DESCRIPTION:
# You're responsible for providing a demographic report for your local school district based on age. To do this, you're going determine which 'category' each person fits into based on their age.
# The person's age will determine which category they should be in:
# If they'r... | true |
bb889189b4f6ed0e6e0119fa5f2612904fa95921 | theodorp/CodeEval_Easy | /swapCase.py | 645 | 4.25 | 4 | # SWAP CASE
# CHALLENGE DESCRIPTION:
# Write a program which swaps letters' case in a sentence. All non-letter characters should remain the same.
# INPUT SAMPLE:
# Your program should accept as its first argument a path to a filename. Input example is the following
# Hello world!
# JavaScript language 1.8
# A lett... | true |
e32d4c0ff6b060534d93f0d05d181de0bb6785d4 | theodorp/CodeEval_Easy | /happyNumbers.py | 1,204 | 4.25 | 4 | # HAPPY NUMBERS
# CHALLENGE DESCRIPTION:
# A happy number is defined by the following process. Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include ... | true |
fe8869fcc3952b4c795d5f4723d578c234e93b8d | theodorp/CodeEval_Easy | /majorElement.py | 1,138 | 4.15625 | 4 | # THE MAJOR ELEMENT
# CHALLENGE DESCRIPTION:
# The major element in a sequence with the length of L is the element which appears in a sequence more than L/2 times. The challenge is to find that element in a sequence.
# INPUT SAMPLE:
# Your program should accept as its first argument a path to a filename. Each line of... | true |
2c991f2a5e7da455ff2fcecc75ec4d7368e2af72 | theodorp/CodeEval_Easy | /lowerCase.py | 588 | 4.3125 | 4 | # LOWERCASE
# CHALLENGE DESCRIPTION:
# Given a string write a program to convert it into lowercase.
# INPUT SAMPLE:
# The first argument will be a path to a filename containing sentences, one per line. You can assume all characters are from the english language. E.g.
# HELLO CODEEVAL
# This is some text
# OUTPUT S... | true |
bc608d508ceb1236e5f6d020d216af56e751434c | theodorp/CodeEval_Easy | /mixedContent.py | 1,038 | 4.15625 | 4 | # MIXED CONTENT
# CHALLENGE DESCRIPTION:
# You have a string of words and digits divided by comma. Write a program
# which separates words with digits. You shouldn't change the order elements.
# INPUT SAMPLE:
# Your program should accept as its first argument a path to a filename. Input
# example is the following
# 8... | true |
05b9dbed2d6c37958599957c9a05b177f3b08b73 | jbhennes/CSCI-220-Programming-1 | /Chapter 7 Decisions/LetterGrade.py | 507 | 4.15625 | 4 | ## LetterGrade.py
def main():
print ("Given a numerical grade, returns the letter grade.")
# Get the numerical grade
grade = input("Enter your numerical grade: ")
if grade >= 90:
print ("Letter grade = A")
elif grade < 90 and grade >= 80:
print ("Letter grade = B")
elif g... | true |
28e47d7fd4572ff14512a9e86541cfeb8ee0e848 | jbhennes/CSCI-220-Programming-1 | /rectArea.py | 1,039 | 4.25 | 4 | #This function calculates the area of a rectangle.
def rectArea():
#Purpose of the program.
print("This program calculates the area of a rectangle.")
units = input("First, tell me the units that will be used: ")
#Define variables
length = eval(input("Please input the length of the rectangle: "))
... | true |
4c114ee054f6bca751ac665fb7fce7a63dcf6f1c | jbhennes/CSCI-220-Programming-1 | /Chapter 11 - lists/partialListFunctions.py | 1,967 | 4.375 | 4 | # listFunctions.py
# Author: Pharr
# Program to implement the list operations count and reverse.
from math import sqrt
def getElements():
list = [] # start with an empty list
# sentinel loop to get elements
item = raw_input("Enter an element (<Enter> to quit) >> ")
while item != "":
l... | true |
913c3d0fafc5017bc72172796e8b2c793d190c61 | jbhennes/CSCI-220-Programming-1 | /Chapter 7 Decisions/MaxOfThree3.py | 729 | 4.46875 | 4 | ## MaxOfThree3.py
## Finds largest of three user-specified numbers
def main():
x1 = eval(input("Enter a number: "))
x2 = eval(input("Enter a number: "))
if x1 > x2:
temp = x1
x1 = x2
x2 = temp
print ("here")
print ("The numbers in sorted order are: ")
... | true |
e97f890f65d8e44456af6118610c52f96d0e82ab | jbhennes/CSCI-220-Programming-1 | /Chapter 7 Decisions/MaxOfThree1.py | 508 | 4.53125 | 5 | ## MaxOfThree1.py
## Finds largest of three user-specified numbers
def main():
x1 = input("Enter a number: ")
x2 = input("Enter a number: ")
x3 = input("Enter a number: ")
# Determine which number is the largest
if x1 >= x2 and x1 >= x3: # x1 is largest
max = x1
elif x2 >=... | true |
2f6867f9b3569cfddafea7b46bf11ad254713d75 | jbhennes/CSCI-220-Programming-1 | /Chapter 8 While/GoodInput5.py | 493 | 4.28125 | 4 | ## GoodInput5.py
# This program asks the user to enter exactly 12 or 57.
# This version is WRONG!!!!!!
def main():
number = input("Enter the number 12 or 57: ")
# This version tries to move the negation in, but incorrectly,
# thus creating an infinite loop:
while number != 12 or number... | true |
835df901f9c9ababa430f2314a3a608503a51894 | Matt-McConway/Python-Crash-Course-Working | /Chapter 6 - Dictionaries/ex6-11_pp115_cities.py | 542 | 4.15625 | 4 | """
"""
cities = {"Auckland": {"Country": "New Zealand", "population": 1300000,
"fact": "Originally the capital"},
"Wellington": {"Country": "New Zealand", "population": 300000,
"fact": "Currently the capital"},
"Dunedin": {"Country": "New Zealand", "population": ... | false |
1ef289b88e2cf959f9e0f533df0ccfa180605154 | Matt-McConway/Python-Crash-Course-Working | /Chapter 7 - User Input and While Loops/ex7-2_pp121_restaurantSeating.py | 216 | 4.15625 | 4 | """
"""
toBeSeated = input("How many people are dining tonight? ")
if int(toBeSeated) > 8:
print("I'm sorry, you are going to have to wait for a table.")
else:
print("Right this way, your table is ready.")
| true |
72cdb814f466e26f8b799db19b4a06b69570076f | chetanpawar19/Python-Scripts | /PasswordGenerator.py | 1,103 | 4.25 | 4 | """
the script allows you to generate random password based on your choice of length, password combination.
requirements-
python 3 (any version)
random module of python in-built
author -chetan pawar
version- v1.0.1
"""
import random
digits_choice='0123456789'
alpha_uppercase_choice='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alph... | false |
45142c33c0203fe1bc2386bb7b53e0fb919f5b27 | Gutencode/python-programs | /conditionals/gradePercent.py | 829 | 4.3125 | 4 | ## Program to compute the grade from given percentage.
def grade(percent):
""" This function takes the percentage as input and returns the relevant grade. """
if (percent > 100):
print("Please enter the correct obtained percentage")
elif (percent >= 90):
return("A")
elif (perc... | true |
c6acf0c506bae2c792f8e9f647036776c335b506 | innovation-platform/Mad-Lib-generator | /mad.py | 1,203 | 4.125 | 4 | import tkinter
from tkinter import *
main=Tk()
main.geometry("500x500")
main.title("Mad Libs Generator")
Label(main,text="Mad Libs Generator",font="arial",bg="black",fg="white").pack()
Label(main,text="Click one:",font="italic",bg="white",fg="black").place(x=40,y=80)
def madlib1():
name=input("Enter a name ... | true |
a907255a5ecbd9c126c08cad5693e319344d6027 | Alekssin1/first_lab_OOP | /first_task.py | 649 | 4.15625 | 4 | import sys
# cut first element(name of the file)
expression = "".join(sys.argv[1:])
# We use join to make our expression a string with
# spaces and then using the function eval
# check whether the user input is empty
if expression:
try:
print(eval(expression))
except ZeroDivisionError:
print(... | true |
be9109066f9f34b4fa21aa46312871fb244c35ec | griadooss/HowTos | /Tkinter/05_buttons.py | 2,223 | 4.34375 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
"""
ZetCode Tkinter tutorial
In this script, we use pack manager
to position two buttons in the
bottom right corner of the window.
author: Jan Bodnar
last modified: December 2010
website: www.zetcode.com
"""
#We will have two frames.
#There is the base frame and an additio... | true |
f82da39fce4bb6efbffd817b4651cb1027e15410 | griadooss/HowTos | /Tkinter/01_basic_window.py | 2,700 | 4.34375 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
"""
ZetCode Tkinter tutorial
This script shows a simple window
on the screen.
author: Jan Bodnar
last modified: January 2011
website: www.zetcode.com
"""
#While this code is very small, the application window can do quite a lot.
#It can be resized, maximized, minimized.
#A... | true |
2a535a9f8cf2b45ffc9469195319a9a0df2df168 | griadooss/HowTos | /Tkinter/14_popup_menu.py | 1,706 | 4.40625 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
"""
ZetCode Tkinter tutorial
In this program, we create
a popup menu.
author: Jan Bodnar
last modified: December 2010
website: www.zetcode.com
"""
'''Popup menu'''
# In the next example, we create a popup menu.
# Popup menu is also called a context menu.
# It can be sho... | true |
cf108c19ac33a9286c8daba5bff0c3f9b7098711 | djcolantonio/PythonProjects | /homework_function_scor.py | 407 | 4.15625 | 4 | # This program evaluates the score and LOOPS
while True:
score = input('What is your score: ')
try:
if int(score) >= 90:
print('This is an excellent score')
elif int(score) >=80:
print('This is a good score')
else:
print('You need a better s... | true |
04a6d1f06fde2c1e1c1b886d0f92cf912a294a81 | djcolantonio/PythonProjects | /for and while loop.py | 226 | 4.125 | 4 | # for loop example
print('Today is')
for i in range(5):
print('Thursday Five Times ' + str(i))
# for while loop
print('Today is')
i=0
while i < 5:
print('Thursday Five Times ' + str(i))
i = i + 1
| false |
534456b717efe50a9709c45edeedf8579a945769 | CGayatri/Python-Practice1 | /control_3.py | 298 | 4.3125 | 4 | ## program 3 - to display a group of messages when the condition is true - to display suite
str = 'Yes'
if str == 'Yes':
print("Yes")
print("This is what you said")
print("Your response is good")
'''
F:\PY>py control_3.py
Yes
This is what you said
Your response is good
''' | true |
a3df363bd6c12796722d7c243b009bd04a213538 | CGayatri/Python-Practice1 | /control_13.py | 252 | 4.28125 | 4 | ## program 13 - to display each character from a string using sequence index
str = 'Hello'
n = len(str) # find no. of chars in str
print("Lenght :", n)
for i in range(n):
print(str[i])
'''
F:\PY>py control_13.py
Lenght : 5
H
e
l
l
o
''' | true |
6804a11ea2a813351e7b51112737afdddd3ab834 | CGayatri/Python-Practice1 | /inputs1.py | 225 | 4.21875 | 4 | ### program - 1 to accept a string from keyboard
# accepting a string from keyboard
str = input("Enter a string: ")
print("U entered: ", str)
#Output:
'''
F:\PY>py inputs1.py
Enter a string: Gayatri Chaudhari
U entered: Gayatri Chaudhari
'''
| false |
75dc369c4b309a387583cc7dc8d05d91c29cf318 | CGayatri/Python-Practice1 | /Module1/CaseStudy_1/demo5.py | 501 | 4.34375 | 4 | # 5.Please write a program which accepts a string from console and print the characters that have even indexes.
# Example: If the following string is given as input to the program:
# H1e2l3l4o5w6o7r8l9d
# Then, the output of the program should be:
# Helloworld
str = input("Enter input s... | true |
abbff9bfdf999a1e6e1026dca5edb78d3833974c | CGayatri/Python-Practice1 | /string_1.py | 799 | 4.1875 | 4 | ## program 1 - to access each element of a string in forward and reverse orders using while loop
# indexing on strings
str = 'Core Python'
# access each character using whie loop
i = 0 # i = 0, 1, 2, 3, ... (n-1)
n = len(str)
while i<n: # 0 to n-1
print(str[i], end=' ')
i+=1
... | false |
ffbc972b3eb83c04f21056e27e493a0ee9b1e4db | CGayatri/Python-Practice1 | /control_20.py | 343 | 4.375 | 4 | ## program 20 - to display stars in right angled triangular form using a single loop
# to display stars in right angled triangular form - v2.0
for i in range(1, 11):
print('* ' * (i)) # repeat star (*) for i times
## v1.0 :
'''
for i in range(1, 11):
for j in range(1, i+1):
print('* ', en... | false |
286c01b126996d05ee34b93bca9b3616a3199d69 | CGayatri/Python-Practice1 | /string_13_noOfWords.py | 668 | 4.125 | 4 | ## Program 13 - to find the number of words in a string
# as many number of spaces; +1 wuld be no of words
# to find no. of words in a string
str = input('Enter a string : ')
i=0
count=0
flag = True # this becomes False when no space is found
for s in str:
# Count only when there is no space pre... | true |
456bc270c408a04758347728e9bd02c1b3a96e52 | CGayatri/Python-Practice1 | /string_9_chars.py | 1,010 | 4.4375 | 4 | ## Working with Characters -- get a string --> get chars using indexing or slicing
## program 9 - to know the type of character entered by the user
str = input('Enter a character : ')
ch = str[0] # take only 0th character niito ch
# test ch
if (ch.isalnum()):
print("It is an alphabet or numeric charac... | true |
ea4b5b1bdd6bb54b8c439ee2ecfa37a0d0149748 | CGayatri/Python-Practice1 | /control_11.py | 707 | 4.15625 | 4 | ## program 11 - to display even numbers between m and n (minimum and maximum range)
m , n = [int(i) for i in input("Enter comma separated minimum and maximum range: ").split(',')]
# 1 to 10 ===>
x = m # start from m onwards
#x = 1 # start from ths number
# make start as even so that adding 2 to it would give nex... | true |
9d029614f80818e96a163348028788b3b4639937 | CGayatri/Python-Practice1 | /string_8.py | 416 | 4.28125 | 4 | ## Splitting and Joining Strings
## Program 8 - to accept and display a group of numbers
# string.split(seperator)
# separator.join(string)
str = input('Enter numbers separated by space : ')
# cut the string where a space is found
lst = str.split(' ')
# display the numbers from teh list
for i in lst :
print... | true |
bdde2a9d113f48aac14994980bad4e84caedd315 | CGayatri/Python-Practice1 | /prime.py | 558 | 4.15625 | 4 | # program to display prime numbers between range
#Take the input from the user:
lower = int(input("Enter lower range: "))
upper = int(input("Enter upper range: "))
for num in range(lower,upper + 1):
if num > 1:
for i in range(2,num):
if (num % i) == 0:
break
... | true |
457950d15654565ce70aa6b6c664eeb431ea25a2 | CGayatri/Python-Practice1 | /function_12_functionReturnsAnotherFun.py | 452 | 4.25 | 4 | ## Program 12 - to know how a function can return another function
# functions can return other functions
def display():
def message():
return 'How are you?'
return message
# call display() function and it returns message() function
# in following code, 'fun' refers to the name ... | true |
8e9e41a1adabea2eef1da2b4f66e6f1794105b1a | CGayatri/Python-Practice1 | /input22_argparse.py | 660 | 4.59375 | 5 | ## program - 22 : to find the power value of a number when it is rised to a particular power
import argparse
# call the ArgumentParser()
parser = argparse.ArgumentParser()
# add the arguments to teh parser
parser.add_argument('nums', nargs=2)
# retrieve arguments from parser
args = parser.parse_args()
#find the... | true |
d0ceb6917502b06bc741630afdf20a439299646b | lightTouchDev/lFpiepr | /flip.py | 1,240 | 4.21875 | 4 | #!/usr/bin/python3
# Write a program that reverses every other letter of a given string
# Ex. Hello -> eHllo | World -> oWlrd
from itertools import zip_longest
## With import
def flipper(word):
w = word[::2]
x = word[1::2]
r = ''
for i,a in zip_longest(x,w, fillvalue=''):
r += i
r +=... | false |
69d2b90af1c5dfa0145321e0d808576599d31ec7 | raiyanshadow/BasicPart1-py | /ex21.py | 272 | 4.40625 | 4 | # Write a Python program to find whether a given number (accept from the user) is even or odd, print out an appropriate message to the user.
n = int(input("ENTER NUMBER: "))
if n % 2 == 0:
print("That is an even number.")
else:
print("That is an odd number.")
| true |
493f3e7118bd295e73cd8e119f1af85f16415535 | novigit/learn_ete3 | /12_prune_tree.py | 771 | 4.15625 | 4 | #!/usr/bin/env python
from ete3 import Tree
# Let's create simple tree
t = Tree('((((H,K),(F,I)G),E),((L,(N,Q)O),(P,S)));', format=1)
print("Original tree looks like this:")
print(t)
# /-H
# /-|
# | \-K
# /-|
# | | /-F
# /-| \-|
# | | \-I
# | |
# | \-E... | false |
89d58cabd879fb0e9a0f3b01bf665c754f367653 | SharonOBoyle/python-lp3thw | /ex7.py | 1,028 | 4.25 | 4 | # print the sentence to the screen
print("Mary had a little lamb.")
# print the sentence to the screen, substituting 'snow' inside the {}
print("Its fleece was white as {}.".format('snow'))
# print the sentence to the screen
print("And everywhere that Mary went.")
# this printed 10 . characters in succession on the sam... | true |
e127418b2765a0cb6c76915003aafd5535aea7c1 | SharonOBoyle/python-lp3thw | /ex30.py | 1,007 | 4.25 | 4 | # create a variable named people with value 40
people = 40
cars = 4
trucks = 15
# if the boolean expression is true, execute the code in the block, otherwise skip it
if cars > people or trucks > people:
print(">>> if cars > people or trucks > people:", cars, people, trucks)
print("We should go somewhere")
# e... | true |
270bd98e879bcc4a2af763a7b6a399b812bce881 | SharonOBoyle/python-lp3thw | /ex15.py | 1,229 | 4.59375 | 5 | # import the argv module (argument variable/vector) from the sys package
# argv holds the arguments specified when running this script
# from the command line
from sys import argv
# unpack argv and assign it to the variables on the left, in that order
script, filename = argv
# open the file with the open() function wh... | true |
52c5e443a0c2dcd3f63995cdb92740bc6678e9e5 | sharkseba/taller-progra | /EjerciciosFunciones/ejercicio3.py | 842 | 4.3125 | 4 | """ Crear una funcion que calcule el promedio de los datos de una lista
La función debe recibir como parámetros una lista de datos
La funcion debe retornar el promedio """
# Dos formas de hacer este ejercicio
def promedio_forma_1(lista_datos):
suma_datos = 0 # Variable acumuladora de datos
contador_datos = 0... | false |
234a3e8927399a4f381b0c9b8b7e717abd33269e | sharkseba/taller-progra | /Ejercicios Control Flujo-condicionales/ejercicio21.py | 496 | 4.1875 | 4 | vocales = 'aeiou'
s = input('Ingrese una letra: ')
# Verificamos que el usuario haya ingresado solo 1 carácter
if len(s) == 1:
# Verificamos que la letra pertenezca al alfabeto
if s.isalpha():
if s in vocales or s in vocales.upper():
print('La letra ingresada es una vocal')
else:
... | false |
6113df963dc863bf01725cf9b01e68d99945b460 | walkeZ/Learning | /Python/1806/demo/练习05-摄氏度和华氏度转化.py | 952 | 4.21875 | 4 | '''
需求:# 用户输入摄氏温度s,输出华氏度h,h=(s*1.8)+32
# 接收用户输入
'''
# celsius = float(input('输入摄氏度:'))
# fahrenheit=(celsius*1.8)+32
# print('华氏温度:fahrenheit = ',fahrenheit)
print("-----------------方法&装饰器---------------------")
# 装饰器
def outer(func):
def inner():
print('装饰器')
func() # 这里要括号... | false |
de8ea9d23568b4d76643e70ccd4b0d8f4725e3a5 | 729416873/luqy | /test-workspace/testrun/class/C5类变量与实例变量.py | 649 | 4.125 | 4 | # self不是关键字,他其实是可以替换成其他的,但是关键字是不可变的
#类变量 与 实例变量
class Student():
# 类变量
name = 'qiyue'
age = 0
sum = 1
def __init__(self,name,age):
# self.实例变量的名字 ——实例变量 ,用来保存类的特征值
self.name = name # 特征值只和对象相关,与类无关
self.age = age
def do_homework(self):
print('hom... | false |
d616671e022050c16a9ab70912fd0d1ca6e1b97d | jmo24/Python | /EDX-6.00.1x/lect6-oddTuple.py | 547 | 4.3125 | 4 | '''
('I', 'am', 'a', 'test', 'tuple'), then evaluating oddTuples on this
input would return the tuple ('I', 'a', 'tuple')
'''
def oddTuples(aTup):
'''
aTup: a tuple
returns: tuple, every other element of aTup.
'''
# Your Code Here
#length = len(aTup)
#print length
#oddTuple = ()... | false |
81e0a9530720aef7190e88ce5fdabe5ab43b86d4 | ClearlightY/Python_learn | /top/clearlight/base/liaoxuefeng/base/Dict.py | 1,297 | 4.1875 | 4 | # dict: 使用键-值存储
d = {'Mike': 90, 'Bob': 70, 'Luck': 100}
print(d['Luck'])
# 最后放入key的value, 将会把前面的值冲掉
d['Mike'] = 98
print(d)
# 避免key不存在的错误
# 1. 通过in判断key是否存在
if 'Mike' in d:
print(d['Mike'])
# get(): 如果key不存在可以返回None或者返回指定的value, 若存在则返回key对应的value
print(d.get('Bob'))
print(d.get('Blue', -1))
print(d.get('Bob', 9... | false |
d0be707b6b95674e7a55339a7774568045b2a525 | stacykutyepov/python-cp-cheatsheet | /educative/slidingWindow/non_repeat_substring.py | 537 | 4.21875 | 4 | """
time: 13 min
errors: none!
"""
def non_repeat_substring(str):
maxLen, i = 0, 0
ht = {}
for i, c in enumerate(str):
if c in ht:
maxLen = max(maxLen, len(ht))
ht.clear()
ht[c] = True
maxLen = max(len(ht), maxLen)
return maxLen
def main():
print("Length of the longest substring... | true |
4b598ac15547bccf6febd027fc489c6d28657761 | rashi174/GeeksForGeeks | /reverse_array.py | 666 | 4.15625 | 4 | """
Given a string S as input. You have to reverse the given string.
Input: First line of input contains a single integer T which denotes the number of test cases. T test cases follows, first line of each test case contains a string S.
Output: Corresponding to each test case, print the string S in reverse order.... | true |
c28f332fc9cbc62aa584fb9cca14452e89904da7 | jieunjeon/daily-coding | /Leetcode/716-Max_Stack.py | 2,235 | 4.125 | 4 |
"""
https://leetcode.com/problems/max-stack/
716. Max Stack
Design a max stack that supports push, pop, top, peekMax and popMax.
push(x) -- Push element x onto stack.
pop() -- Remove the element on top of the stack and return it.
top() -- Get the element on the top.
peekMax() -- Retrieve the maximum element in the s... | true |
bb18fb0b36d359fcf7269535391e2d705a0cdf25 | RenataKukryakova/cs102 | /homework01/vigenere.py | 1,967 | 4.125 | 4 | def encrypt_vigenere(plaintext: str, keyword: str) -> str:
"""
Encrypts plaintext using a Vigenere cipher.
>>> encrypt_vigenere("PYTHON", "A")
'PYTHON'
>>> encrypt_vigenere("python", "a")
'python'
>>> encrypt_vigenere("ATTACKATDAWN", "LEMON")
'LXFOPVEFRNHR'
"""
ciphertext = ""
... | false |
21ea03e5095d04d74d6a5cae00df7cbb87a87bb7 | leonardosantos07/listas-exercicios-python | /estrutura_decisao/ex20.py | 741 | 4.21875 | 4 | #Faça um Programa para leitura de três notas parciais de um aluno.
#O programa deve calcular a média alcançada por aluno e presentar:
#A mensagem "Aprovado", se a média for maior ou igual a 7, com a respectiva média alcançada;
#A mensagem "Reprovado", se a média for menor do que 7, com a respectiva média alcançada;
#A ... | false |
6a5f82b4645e349246761c8b39829823fa7407a4 | Christopher14/Selection | /revision exercise 2.py | 240 | 4.15625 | 4 | #Christopher Pullen
#30-09-2014
#Revision exercise 2
age = int(input("please enter your age:"))
if age >= 17:
print ("you are legally able to drive a car with learner plates")
else:
print ("you are not legally able to drive a car")
| true |
7ed3bf159a9e29e856944f8fca2ad7c81bbb58cc | infx598g-s16/04-18-python3 | /interest.py | 1,118 | 4.40625 | 4 | # Prompt the user for an Initial Balance (and save to a variable)
# use the float() function to convert the input into a number.
balance = float(input("Initial balance: "))
# Prompt the user for an Annual Interest % (and save to a variable)
# use the float() function to convert the input into a number
interest = float... | true |
4fa6fd511e7dc72aaa4b372556c78a575a08b2ab | minh01082004m/C4T-BO5-Romace | /hey/session 4/session 5/test for/datati.py | 203 | 4.125 | 4 | #x= int(input(""))
#if x>0:
# print("x>0")
#else:
# print("x<0")
while True:
x= int(input("somethings"))
if x>0:
print("right")
break
else:
print("wrong")
| false |
a9bed29fb65836ee58d9de662e6ea4d1612ffdea | Mokarram-Mujtaba/Mini-Projects | /faulty calculator.py | 688 | 4.15625 | 4 | #Faulty calculator
#Design a calculator which gives wrong input whebn user enters the following calculation
# 45 * 3 = 555, 56+9 = 77, 56/6 = 4
x1=input("Enter the opertions you want.+,-,/,%,* \n")
x2=int(input("Enter the 1st number"))
x3=int(input("Enter the 2nd number"))
if x2==45 and x3==3 and x1=='*':
print(... | true |
b5778f7a056996cd63f63aa462d925ecfb0edd86 | khan-c/learning_python | /py3tutorial.py | 397 | 4.34375 | 4 | print("hello world")
# this is a tuple as opposed to a list
# syntax would be either written like this or with parantheses
programming_languages = "Python", "Java", "C++", "C#"
# an array would use brackets like this:
languages_list = ["Python", "Java", "C++", "C#"]
# for - in loop
for language in programming_langua... | true |
5b5c378c445b9de900f3a5a1a82970f784a4d2ca | spencercorwin/automate-the-boring-stuff-answers | /Chapter12MultiplicationTable.py | 952 | 4.15625 | 4 | #! usr/bin/env python3
#Chapter 12 Challenge - Multiplication Table Marker
#Takes the second argument of input, an integer, and makes a multiplication
#table of that size in Excel.
import os, sys, openpyxl
from openpyxl.styles import Font
wb = openpyxl.Workbook()
sheet = wb.active
#tableSize = sys.argv[1]
tableSize... | true |
43e0551fe36887ca2b140c7ab04352332c3b499f | DhruvGala/LearningPython_sample_codes | /TowerOfHanoi.py | 1,014 | 4.1875 | 4 | '''
Created on Oct 10, 2015
@author: DhruvGala
The following code is a general implementation of Tower of hanoi problem using python 3.
'''
from pip._vendor.distlib.compat import raw_input
'''
The following method carries out the recursive method calls to solve the
tower of hanoi problem.
'''
def towerOfHanoi(numbe... | true |
f916bcbca35a5b84111b9894f85bcc637628d1ff | arimont123/python-challenge | /PyBank/main.py | 2,137 | 4.125 | 4 | import os
import csv
#python file in same folder as budget_data.csv
csvpath = "budget_data.csv"
with open(csvpath) as csvfile:
csvreader = csv.reader(csvfile, delimiter = ",")
#start reading in data after first row of text
csvheader = next(csvreader)
#create empty lists to store data from each column
... | true |
27c5a897cd37bdb7a52017ea73996ace4d06380f | Arinze1020/List-of-my-script-project- | /ASK USER FOR A NUMBER AND ASK AND CHECK IF IT IS EVEN OR ODD/CHECK IF UNM IS EVEN OR ODD.PY.py | 213 | 4.21875 | 4 | prompt = "ENTER A NUMBER \n"
number = float(input(prompt))
if number%2 == 0:
print(number,"IS AN EVEN NUMBER")
elif number%2!= 0:
print(number,"IS AN ODD NUMBER")
else:
print("TRY INPUTING A NUMBER")
| false |
29c45bbdc3bf5ff5b822dbffc16ce7e1a91e7037 | kml1972/python-tutorials | /code/tutorial_27.py | 1,125 | 4.1875 | 4 |
shopping_list = [
'milk','eggs','bacon','beef',
'soup','bread','mustard','toothpaste'
]
# looping by index vs using an iterator
i = 0
while i < len(shopping_list):
curr_item = shopping_list[i]
print( curr_item )
i += 1
for curr_item in shopping_list:
print( curr_item )
#shopping_list.__i... | true |
3c99da6c123b0f76b02f11746f584acd92c00c48 | LKHUUU/SZU_Learning_Resource | /计算机与软件学院/Python程序设计/实验/实验1/problem1.py | 228 | 4.3125 | 4 | import math
radius = float(input("Enter the radius of a cylinder:"))
length = float(input("Enter the length of a cylinder:"))
area = radius*radius*math.pi
print("The area is", area)
print("The volume is", area*length)
| true |
502edac5b8c26c2ef81609d497f8084db91f0401 | zhaphod/ProjectEuler | /Python/proj_euler_problem_0001.py | 651 | 4.15625 | 4 | '''
Problem 1
Multiples of 3 and 5
If we list all the natural numbers below 10 that are multiples
of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
'''
sum = 0
def EulerProblem0001():
global sum
for i in range(1, 1000):
if i % 5 == 0 or i ... | true |
62cb1a8ac24e4382015eeb70a42a32e1087a7809 | Edwar2-2/PythonFullCoursexD | /07Ejercicios/Ejercicio1.py | 343 | 4.25 | 4 | """
Ejercicio 1.
- Crear variables una ""pais" y otra "continente"
- Mostrar su valor por pantalla (imprimir)
- Poner un comentario diciendo el tipo de dato
"""
pais = "Mexico" #String
continente = "America" #String
year = 2021 #Integer
print(pais)
print(continente)
print("{} - {} - {}".format(pais,co... | false |
c65e8e6d41ac120b28cf31d9f9dcf4f74d78c45e | leonguevara/DaysInAMonth_Python | /main.py | 930 | 4.625 | 5 | # main.py
# DaysInAMonth_Python
#
# This program will give you the number of days of any given month of any given year
#
# Python interpreter: 3.6
#
# Author: León Felipe Guevara Chávez
# email: leon.guevara@itesm.mx
# date: May 31, 2017
#
# We ask for and read the month's number
month = int(input("... | true |
e970e7280e098f8ba6d704bd1157320a55fa95a8 | jungjung917/Coderbyte_challenges | /easy/solutions/LetterChanges.py | 735 | 4.15625 | 4 | def LetterChanges(str):
letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
vowels = "aeiou"
str_replace = ""
for index, letter in enumerate(str):
print index
if letter in letters:
if letter.lower() == 'z':
str = str[:index] + chr(ord(letter)-25) + str[index+1... | false |
75972d8413cedaba4efe98bc5c28bbfed5c093ca | jungjung917/Coderbyte_challenges | /easy/solutions/ThirdGreatest.py | 1,142 | 4.5 | 4 | """
Using the Python language, have the function ThirdGreatest(strArr) take the array of strings stored in strArr and return the third largest word within in. So for example: if strArr is ["hello", "world", "before", "all"] your output should be world because "before" is 6 letters long, and "hello" and "world" are both... | true |
bd5801f9768c16fdf16d9992dd47f5506cbdedcc | jungjung917/Coderbyte_challenges | /medium/solutions/StringScramble.py | 572 | 4.375 | 4 | """
the function StringScramble(str1,str2) take both parameters being passed and return the string true if a portion of str1 characters can be rearranged to match str2, otherwise return the string false. For example: if str1 is "rkqodlw" and str2 is "world" the output should return true. Punctuation and symbols will no... | true |
26e0e5220c163bfc0631b25aabfb7395f986c941 | Endlex-net/practic_on_lintcode | /reverse-linked-list/code.py | 600 | 4.21875 | 4 | #-*-coding: utf-8 -*-
"""
Definition of ListNode
class ListNode(object):
def __init__(self, val, next=None):
self.val = val
self.next = next
"""
class Solution:
"""
@param head: The first node of the linked list.
@return: You should return the head of the reversed linked list.
... | true |
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 |
2aa9a4c79909747d5b6d9aafbbce8e2760e6331c | LinaSaidane/python_formation | /Boucles.py | 2,149 | 4.25 | 4 | """
les boucles: moyen de répéter un certain nbr de fois des instructions de notre
programme
"""
# Boucle :
# Programmer la table de multiplication par 7
nb = 10
print("1 *", nb , "=" , 1 * nb)
print("2 *", nb , "=" , 2 * nb)
print("3 *", nb , "=" , 3 * nb)
print("4 *", nb , "=" , 4 * nb)
print("5 *", nb ,... | false |
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 |
25bd3427740a8c0d28c86d307a6c7b8911159002 | pauldepalma/RA | /A:BasicPython/ex7.py | 459 | 4.1875 | 4 |
def evenOrOdd(num):
if num % 2 == 0: #modulus operator
return True
return False
def main():
while (True):
print("Enter an integer")
num = int(input())
if evenOrOdd(num):
print(str(num) + " is even")
else:
print(str(num) + " is o... | false |
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 |
abb2d0d74f582217f9a107b14ded58a7ed0719f1 | AvivSham/LeetCodeQ | /Easy/ReverseWordsInString.py | 373 | 4.21875 | 4 | def reverse_words(s: str) -> str:
s = s.split()
s.reverse()
return " ".join([i for i in s if i is not ""])
def reverse_words_v2(s: str) -> str:
return " ".join(reversed(s.split()))
def reverse_words_v3(s: str) -> str:
return " ".join(s.strip().split()[::-1])
if __name__ == '__mai... | false |
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 |
44131bea35c8b97c549b969a88593c770ad12418 | camillatoniatto/logica-da-programacao-python | /repeticao/while4.py | 392 | 4.1875 | 4 | #Ler um número N qualquer menor ou igual a 50 e apresentar o valor obtido da multiplicação
#sucessiva de N por 3 enquanto o produto for menor que 250 (N*3, N*3*3, N*3*3*3; etc)
numero=int(input("Insira um numero menor ou igual 50: "))
i=3
while numero<=50:
produto = numero * i
i = i * 3
if produto<=250:
p... | false |
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 |
97bc7c2bc0b4e66bffdc567d062078282cc4053a | MurielSpot/python_note | /py/網易云課程(瘋狂的python).py | 2,273 | 4.15625 | 4 | '''
網易雲課程:《瘋狂的python:快速入門精講》略略略😀
😋😑😆😘🙄
'''
print('''
《英雄无敌》之英雄降临
1. 开局玩家起名字。
2. 列表初始化为英雄属性、名字、血值、攻击力、防御力。
3. 判断名字是否为空,默认为“玩家一”。
4. 判断英雄行动方向。
''')
print('''
***
Hero is me! Welcome to visit my world!
You must obey my world\'s rules, or you will be expelled~~
***
''')
#name = input('input your... | false |
1ba1bd1ed3f48dc190b87e8225f4a0d51b907d62 | Raghavendrajoshi45/python | /faulty.py | 690 | 4.28125 | 4 | print("enter your number")
num1=int(input())
print("enter your number")
num2=int(input())
print('enter your choice '+' +,-,*,/,%')
num3=(input())
if (num1==45 and num2==3 and num3=='+'):
print("100")
elif (num1==45 and num2==3 and num3=='%'):
print("2")
elif (num1==45 and num2==3 and num3=='-'):
... | false |
8b0f1b43a3016813b55ba8850d1f40c78b46b0d1 | krishnanandk/kkprojects | /regular expression/demo3.py | 1,078 | 4.125 | 4 | #quantifiers
# quantifiers
# x='a+' a including group
# x='a*' count including zero number of a
# x='a?' count a as each including zero no of a
# x='a{2}' 2 no of a position
# x='a{2,3}' minimum 2 a and maximum 3 a
# x='^a' check starting with a
# x='a$' check ending with a
import re
# x = "a+" #group of a
# r="a... | false |
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.