blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
b6ee3ae1c6ffa6db1546c8dd7bd12d5e0cfaf4eb | jonmckay/Python-Automate | /Section-6-Lists/lists-and-strings.py | 945 | 4.40625 | 4 | list('Hello')
name = 'Zophie'
name = [0]
print(name)
# Taking a section of a string
name[1:3]
print(name)
# Create a new string using slices
name = 'Zophie a cat'
newName = name[0:7] + 'the' + name[8:12]
print(newName)
# References
spam = 42
cheese = spam
spam = 100
print(spam)
# When you assign a list to a variab... | true |
51aac9ce3556555f4292613680e1658480079c57 | venkateshmorishetty/CSPP1 | /m22/assignment2/clean_input.py | 433 | 4.1875 | 4 | '''
Write a function to clean up a given string by removing the special characters and retain
alphabets in both upper and lower case and numbers.
'''
import re
def clean_string(string):
'''filters the string'''
result = re.sub('[^a-zA-Z0-9]', '', string)
return result
def main():
'''read input and pass ... | true |
12fe78e6920e54715d4ca8c9b12520a1419de7ba | venkateshmorishetty/CSPP1 | /m22/assignment3/tokenize.py | 644 | 4.21875 | 4 | '''
Write a function to tokenize a given string and return a dictionary with the frequency of
each word
'''
import re
dictionary = {}
def tokenize(string):
'''tokenize'''
# string1 = re.sub('[^a-zA-Z0-9]','',string)
list1 = string.split(' ')
for index_ in list1:
index1 = re.sub('[^a-zA-Z0-9]', '... | true |
c5ce313a4133c2fa03e8d33b14f0bbae1cdc726d | donyewuc/Personal-Projects | /TicTacToe.py | 1,606 | 4.15625 | 4 | #! python3
#This program lets you play a simple 2-player game of Tic-Tac-Toe
import sys
board = {'tl':' ','tm':' ','tr':' ','ml':' '
,'mm':' ','mr':' ','bl':' ','bm':' ','br':' ',}
count = 0
turn = 'X'
plays = []
def win(check):
'''This function checks to see if you have won the game'''
chec... | true |
f52d78d9aec18519119d29e9ba2abdef0746ff5e | rhwb/python | /numbers3.py | 286 | 4.125 | 4 | num1 = input("Please enter a number here: \n")
print("The number you have entered is: %s \n" %num1)
num2 = input("Enter another number: \n")
print("The second number you have entered is: %s \n" %num2)
num3 = int(num1) + int(num2)
print("%s + %s + %d" %num1 %num2 %num3)
| true |
27efacb6f3c118d46510ebf05b0cfa49c96e6428 | luiscavazos/testrepo | /firstfile.py | 1,644 | 4.21875 | 4 | #name= "Luis"
#Country= "Mexico"
#Age= 37
#hourly_wage = 1000
#Satisfied = True
#daily_wage = hourly_wage * 8
#print ("Your name is " + name)
#print("you live in " + Country )
#print("You are " + str(Age) + " years old")
#print("You make " + str(daily_wage) + " per day")
#print("Are you satisfied with your current wag... | false |
0cc1d3b2b39b518d6eae67a7b1f06349d2d6b443 | ArchieMuddy/PythonExercises | /List/Exercise1/Approach4.py | 315 | 4.125 | 4 | # Swap the first and last elements of a list
# Approach 4: Use the * operand
inputList =[12, 35, 9, 56, 24]
first, *remaining, last = inputList #stores first element in first, last element in last and remaining element in *remaining
newList = last, *remaining, first #swap first and last
print(newList) | true |
688ffa9841e756a65d959b7fe1773fd87429bfea | ArchieMuddy/PythonExercises | /List/Exercise1/Approach2.py | 382 | 4.1875 | 4 | # Swap the first and last elements of the list
# Approach 2: Don;t use the len function. Instead use list[-1] to access the last element of the list
#swap function
def swapList(newList):
newList[0], newList[-1] = newList[-1], newList[0] #swapping logic without temp variable
return newList
#calling cod... | true |
6d10a456493f1a50482ff74626f4c327e104228d | shitalajagekar/Python-Practice | /main.py | 2,811 | 4.34375 | 4 | # print("Hello world\n")
# this is comment
a=18
b="shital"
c=2.2
# print(a+3)
# converting int into float and string
a1=float(a)
a2=str(a)
# print(a1,a2)
# converting string into int and float
# b1=int(b) # can not convert sting into int and float
# b2= float(b)
# print(b1,"\n", b2)
# converting float... | false |
eb380d10f572e10320923a650768d38d730b086f | crash-bandic00t/python_dev | /1_fourth/algorithm_python/lesson1/task3.py | 441 | 4.15625 | 4 | # По введенным пользователем координатам двух точек вывести уравнение прямой вида y=kx+b, проходящей через эти точки.
x1 = int(input("x1 = "))
y1 = int(input("y1 = "))
x2 = int(input("x2 = "))
y2 = int(input("y2 = "))
k = (y1 - y2) / (x1 - x2)
b = y2 - k*x2
print(f'Уравнение прямой для этих точек: y = {k}x + {b}')... | false |
83b8c613b59572c31964330fde92946fe5fafd20 | crash-bandic00t/python_dev | /1_fourth/algorithm_python/lesson1/task5.py | 1,190 | 4.1875 | 4 | # Пользователь вводит две буквы. Определить, на каких местах алфавита они стоят и сколько между ними находится букв.
import string
firstLetter = input('Введите букву английского алфавита для левой границы: ')
secondLetter = input('Введите букву английского алфавита для правой границы: ')
firstLetter = firstLetter.lo... | false |
f51bbb6a8590dd857d55f366d76238761a0a3f06 | sodomojo/Week3 | /hw3.py | 2,476 | 4.375 | 4 | #!/usr/bin/env python
"""
This script will do the following
- Ask the user to enter a starting and ending number
- Check that the starting number is not less than 1
- Check that the ending number is at least 5 times greater than the starting number
- Create a list of integers in the range of the user's starting and e... | true |
1186f93b2e38957a25e78ee8b9d779e0f9677b5c | Thorarinng/prog_01_kaflaverkefni | /Midterm_2/longest_gamla.py | 1,015 | 4.25 | 4 | import string
# Function definitions start here
def open_file(fname):
"""Tekur inn texta skrá or opnar hana"""
try:
word_file = ''
input_file = open(fname, 'r')
# for line in input_file:
# word_file += line
except FileNotFoundError:
print("File {}.txt no... | true |
7edf6cc78129f9429b46630d61ad5526fff2a0a3 | Thorarinng/prog_01_kaflaverkefni | /timaverkefni/7-5.py | 635 | 4.34375 | 4 | # palindrome function definition goes here
def is_palindrome(strengur):
nyr_strengur = strip(strengur)
if nyr_strengur and (nyr_strengur[::-1] == nyr_strengur):
return print('"{}"'.format(strengur), "is a palindrome.")
else:
return print('"{}"'.format(strengur), "is not a palindrome.")
def ... | false |
547302f7fe8bd3ef6a5c35997b5520053af1d85f | Thorarinng/prog_01_kaflaverkefni | /Skilaverkefni/hw2/2-2_characterCounts.py | 734 | 4.15625 | 4 | # Hlynur Magnus Magnusson
# Hlynurm18@ru.is
import string
my_string = input("Enter a sentence: ")
count_digit = 0
count_lower = 0
count_upper = 0
count_punktur = 0
# for every character in the string it checks for digits, lower, upper and punctuations
# on each encounter we add one to the counter
for char in my_str... | true |
8335d1830f941ba3fcc6dc7f08a4e0a8430ec8c8 | Thorarinng/prog_01_kaflaverkefni | /timaverkefni/7-6.py | 308 | 4.125 | 4 | # Your function definition goes here
def fibo(tala):
n1, n2 = 0, 1
print(1, end=' ')
for i in range(tala-1):
fib = n1 + n2
n1 = n2
n2 = fib
print(fib, end=' ')
n = int(input("Input the length of Fibonacci sequence (n>=1): "))
# Call your function here
fibo(n) | false |
633e22f59f95aa72896543ce0cc13b2e1d16c725 | ajialala/python_work_study | /study_class_2.py | 909 | 4.21875 | 4 | class A():
def __init__(self):
self.__name='python' #私有变量,翻译成 self._A__name='python'
def __say(self): #私有方法,翻译成 def _A__say(self)
print(self.__name) #翻译成 self._A__name
a=A()
#print a.__name #访问私有属性,报错!AttributeError: A instance has no attribute '__name'
print(a.__dict__) #查询出实例a的属性的集合
print... | false |
30cdfee01e33cbe30f08337a89371974b08debbf | monergeim/python | /fibonacci/func_l.py | 375 | 4.46875 | 4 | #!/usr/bin/python3.8
#calculates the nth Fibonacci number in O(n) time == without using any "for" or "while" loops
import numpy as np
num = input("Enter fibonacci num:")
def fib_matrix(n):
Matrix = np.matrix([[0,1],[1,1]])
vec = np.array([[0],[1]])
F=np.matmul(Matrix**n,vec)
return F[0,0]
print("Fi... | true |
c51c5a55278b99d693a35a448a8240936a97e67c | wesley-998/Python-Exercicies | /33_Maio-numero.py | 656 | 4.1875 | 4 | print('Digite 3 números: ')
n1 = int(input())
n2 = int(input())
n3 = int(input())
if n1>n2>n3 or n1>n3>n2:
print('{} é maior que {} e {}'.format(n1,n2,n3))
elif n2>n1>n3 or n2>n3>n2:
print('{} é maior que {} e {}'.format(n2,n1,n3))
elif n3>n1>n2 or n3>n2>n1:
print('{} é maior que {} e {}'.for... | false |
0d23856e20f128756fa1e29a5120a2de3b015060 | wesley-998/Python-Exercicies | /096_Funcoes-area.py | 460 | 4.1875 | 4 | '''
Programa com a função área(), que recebe as dimenções de um terreno retangular e
mostre a área do terreno.
'''
def area(largura,comprimento):
m3 = a * l
print(f'A área do terreno com {a}m de largura e {l}m de largura é {m3}m². ')
def linha():
print('__' * 50)
linha()
print('Controle ... | false |
da6493892c17f517ea3d53b1feacbf053d5faf30 | wesley-998/Python-Exercicies | /021_MP3.py | 351 | 4.1875 | 4 | """Programa que lê um número qualquer inteiro e converte para Binário, Hexadecimal ou Octadecimal"""
n1 = int(input('Digite o número que você deseja converter: '))
opcao = int(input('''Digite a opção desejada.
[ 1 ] Binário
[ 2 ] Octal
[ 3 ] Hexadecimal
'''))
if opcao == 1:
print('{} em binário é {}'... | false |
de3a1f6d4905d4ae4b3049bb6fecbc121513a12b | veselotome4e/Programming0 | /Week 2/Saturday_Tasks/is_prime.py | 263 | 4.125 | 4 | import math
n = int(input("Enter n: "))
prime = True
start = 2
while start <= math.sqrt(n):
if n % start == 0:
prime = False
break
start +=1
if prime:
print("The number is prime!")
else:
print("The number is not prime!")
| true |
ecdfd79a0db5fa78a123fcf9f20ecc6f08cc8982 | veselotome4e/Programming0 | /Week 2/AndOrNotProblems/simple_answers.py | 363 | 4.15625 | 4 | userInput = input("Enter some text: ")
if "hello" in userInput or "Hello" in userInput:
print("Hello there, good stranger!")
elif "how are you?" in userInput:
print("I am fine, thanks. How are you?")
elif "feelings" in userInput:
print("I am a machine. I have no feelings")
elif "age" in userInput:
prin... | true |
28f7be01317bfe5f3caf7639d6fe99535c898856 | veselotome4e/Programming0 | /Week 7/is_string_palindrom.py | 520 | 4.1875 | 4 | def is_string_palindrom(string):
string = string.lower()
delimiters = [',','.','!','?',':','-',"'",'"', ' ']
modified = [x for x in string if x not in delimiters]
modified = from_list_to_string(modified)
return modified == modified[::-1]
def from_list_to_string(l):
s = ""
for each in l:
... | false |
06bb7485d5b94dff9b03b6ff15a06bdad535e024 | raotarun/assignment3 | /ass2.py | 1,492 | 4.1875 | 4 | #Create a list with user defined inputs.
a=[]
b=int(input("Enter First Element"))
a.append(b)
print(a)
#Add the following list to above created list: [‘google’,’apple’,’facebook’,’microsoft’,’tesla’]
c=["google","apple","facebook","microsoft","tesla"]
c.append(a)
print(c)
#Count the number of time an object occurs in... | true |
a5f490adc76c885d3f41e1f2990baf2e14305eb6 | ericnnn123/Practice_Python | /Exercise6.py | 367 | 4.28125 | 4 | def CheckPalindrome(word):
reverse = word[::-1]
if word == reverse:
print("'{}' is a palindrome".format(word))
else:
print("'{}' is not a palindrome".format(word))
try:
print("Enter a word to check if it's a palindrome")
word = str(input()).lower()
CheckPalindrome(wo... | true |
23e31ffbe33b07da776bcf58aecbd78b6f5c0e3d | JenishSolomon/Assignments | /assignment_1.py | 233 | 4.21875 | 4 |
#Area of the Circle
A = 3.14
B = float(input("Enter the Radius of the circle: "))
C = "is:"
print ("Input the Radius of the circle : ",B);
print ("The area of the circle with radius",B,C)
print (float(A*B**2))
| true |
238496ecca652af5fdefa421a9d0db146e78f7d3 | pteerawatt/Elevator | /elevator1.3.py | 1,348 | 4.4375 | 4 | # In this exercise we demonstrait a program that simulates riding an elevator.
#simple version
# this is 2nd draft
# refractored
import time
import sys
def print_pause(message): #add print_pause() to refractor
print(message)
sys.stdout.flush()
time.sleep(2)
print_pause("You have just arrived at your new... | true |
c2052a8082181a75fe993a36aff6a19cfe23ac8c | melgreg/sals-shipping | /shipping.py | 1,323 | 4.15625 | 4 | class ShippingMethod:
"""A method of shipping with associated costs."""
def __init__(self, name, flat_fee=0.00, max_per_pound=0.00, cutoffs=[]):
self.name = name
self.flat_fee = flat_fee
self.max_per_pound = max_per_pound
self.cutoffs = cutoffs
def get_cost(self, w):
... | true |
a3ca0d1f54d4a9e301fbe78c23a8bd3ebbff2194 | dmayo0317/python-challenge | /PyBank/main.py | 2,210 | 4.1875 | 4 | #Note most of code was provided by the UTSA instructor(Jeff Anderson) just modify to fit the assignment.
#Impot os module and reading CSV modules
import os
import csv
# Creating Variable to hold the data
profit = []
rowcount = 0
TotalProfit = 0
AverageProfit = 0
AverageChange = 0
LostProfit = 0
GainProfit = 0
#locat... | true |
08df24bcafbb22a66ebead8d4fcdb81494347f52 | ankit-kejriwal/Python | /calculator.py | 314 | 4.34375 | 4 | num1 = float(input("ENter first number"))
num2 = (input("ENter oprtator"))
num3 = float(input("ENter second number"))
if num2 == "+":
print(num1+num3)
elif num2 == '-':
print(num1 - num3)
elif num2 == '*':
print(num1 * num3)
elif num2 == '/':
print(num1 / num3)
else:
print("wrong operator")
| false |
233e89bf08eaaa7765e33f26e6b94adce4b66474 | alok8899/colab_python | /python057.py | 1,032 | 4.15625 | 4 | #! python3
import os
os.system("cls")
"""
def factorials(innumber):
#Factorial=1
while innumber>=1:
Factorial=Factorial*(innumber)
innumber-=1
return Factorial
print("the factorial of no ")
invalue=int(input("enter the value to find the factorial : "))
factorials(invalue)
print("the factorial of",factorial... | false |
bd56bc9c8f411d9cb58862397e9fa779055a59c0 | vtainio/PythonInBrowser | /public/examples/print.py | 933 | 4.40625 | 4 | # print.py
# Now we know how to print!
print "Welcome to study with Python"
# 1. Write on line 6 code that prints your name to the console
# 2. If you want to print scandic letters you have to add u in front of the text, like this.
# Take the '#' away and click run
# print u"äö"
# 3. We can also print other things... | true |
76708d7104e7cf43dbfef33cdfe3712de9905a31 | hglennwade/hglennrock.github.io | /gdi-intro-python/examples/chained.py | 253 | 4.34375 | 4 | raw_input = input('Please enter a number: ')
#For Python 2.7 use
#raw_input = raw_input('Please enter a number: ')
x = int(raw_input)
if x > 5:
print('x is greater than 5')
elif x < 5:
print('x is less than 5')
else:
print('x is equal to 5') | true |
a4458a5f224971b83dd334bb0c1dbec49495809e | professionalPeter/adventofcode | /2019/day01.py | 885 | 4.125 | 4 |
def calc_simple_fuel_requirement(mass):
"""Return the fuel required for a given mass"""
return int(mass/3) - 2
def calc_total_fuel_requirement(mass):
"""Return the total fuel requirement for the mass including
the recursive fuel requirements"""
fuel_for_this_mass = calc_simple_fuel_requirement... | true |
6f7ad11ac3dbce19b9e8d17e82df4fb74440b6b1 | Bhoomika-KB/Python-Programming | /even_odd_bitwise.py | 236 | 4.40625 | 4 | # -*- coding: utf-8 -*-
num = int(input("Enter a number: "))
# checking the number using bitwise operator
if num&1:
print(num,"is an odd number.")
else:
print(num,"is an even number.") | true |
970de860d7934e94625f86272a8147684d6152e1 | JoamirS/Fundamentos-python | /12class.py | 872 | 4.1875 | 4 | """ Criando uma lista composta """
#People = [['Bruce Wayne', 45], ['Steve Rodgers', 70], ['Peter Parker', 20], ['Superman', 40]]
#print(People[0][0])
""" Criando uma estrutura em que faço o cadastro de 3 pessoas e no final apago os dados de Data, mas os dados de People continuam """
People = list()
Data = list()
AllA... | false |
3e9ed0848c34588af83cf79f29e854e6d1c9d510 | Puthiaraj1/PythonBasicPrograms | /ListRangesTuples/listsExamples.py | 379 | 4.125 | 4 | ipAddress = '1.2.3.4' #input("Please enter an IP address :")
print(ipAddress.count(".")) # Here I am using sequence inbuilt method count
even = [2,4,6,8]
odd = [1,3,5,7,9]
numbers = even + odd # adding two list
numbers.sort() # This is another method to sort the list value in ascending
# You can use sorted(numbers).... | true |
2b587eb5292af3261309413e7cd9436add8b72ef | dilesh111/Python | /20thApril2018.py | 904 | 4.625 | 5 | ''' Python program to find the
multiplication table (from 1 to 10)'''
num = 12
# To take input from the user
# num = int(input("Display multiplication table of? "))
# use for loop to iterate 10 times
for i in range(1, 11):
print(num,'x',i,'=',num*i)
# Python program to find the largest number among the three ... | true |
dfcf5d72d3ccedb10309dfacb5117364d8e7060c | anajera10/mis3640 | /Assignment 1/nim.py | 975 | 4.15625 | 4 | from random import randrange
def nim():
"""
Plays the game of Nim with the user - the pile size, AI intelligence and starting user are randomly determined
Returns True if the user wins, and False if the computer wins
"""
# randomly pick pile size
pile_size = randrange(10,100)
# random - dec... | true |
264f1813ea8c0463f4b6d87be10a167f33e30d5b | wheezardth/6hours | /Strings.py | 1,222 | 4.25 | 4 | # triple quotes allow to use single & double quotes in strings
# No Need For Escape characters! (Yet...)
course = '''***Monty-Python's Course for "smart" people***'''
print(course)
wisdom = '''
Triple quotes also allow to write
string with line breaks in them.
This is super convenient.
Serial.print(vomit)
'... | true |
1c0125fd19de4485bd49b72f0995f57583dd31c7 | wheezardth/6hours | /classes.py | 890 | 4.1875 | 4 | # classes define custom data types that represent more complex structures
# Default python naming convention: email_client_handler
# Pascal naming convention: EmailClientHandler
# classes in python are named using the Pascal naming convention
# classes are defined using the class keyword
# classes are blueprints of co... | true |
881ae7a58bdc18dac968b135294022aec4f641c9 | wheezardth/6hours | /StringTricks.py | 754 | 4.125 | 4 | course = 'Python for Beginners'
# len() gives string length (and other things!)
print(len(course)) # len() is a FUNCTION
course.upper() # .something() is a METHOD because it belong to a class
print(course) # the original variabe is not affected
capString = course.upper()
print(capString) # the new one is tho
print(cou... | true |
34ba84a353937822b8f9329effc073185459a380 | C-Joseph/formation_python_06_2020 | /mes_scripts/volubile.py | 324 | 4.3125 | 4 | #!/usr/bin/env python3
#Tells user if length of string entered is <10, <10 and >20 or >20
phrase = input("Write something here: ")
if len(phrase) < 10:
print("Phrase of less than 10 characters")
elif len(phrase) <= 20:
print("Phrase of 10 to 20 characters")
else:
print("Phrase of more than 20 character... | true |
426dbdf9f784ee6b3c1333b0fda1a9a2eacc2676 | antonborisov87/python-homework | /задание по строкам/test2.py | 903 | 4.5 | 4 | """Задание по строкам:
1.1. Create file with file name test.py
1.2. Create variable x and assign "London has a diverse range of people and cultures, and more than 300 languages are
spoken in the region." string to it.
1.3. Print this string with all letters uppercase.
1.4. Print this string the index of first "c" lette... | true |
7c99435541a487308dba15237bf4c57867e205f3 | neugene/lifelonglearner | /Weight_Goal_Tracker.py | 1,975 | 4.21875 | 4 | #This program tracks weightloss goals based on a few parameters.
# The entries of initial weight and current weight establish the daily weight loss change/rate
# which is used to extrapolate the target weight loss date
from datetime import datetime, timedelta
initial_weight = float(input("Enter initial weight... | true |
d09b15df7682cf7a027b8e70300274a98a5be5df | matham/vsync_rpi_data | /animate.py | 1,557 | 4.375 | 4 | '''
Widget animation
================
This example demonstrates creating and applying a multi-part animation to
a button widget. You should see a button labelled 'plop' that will move with
an animation when clicked.
'''
from os import environ
#environ['KIVY_CLOCK'] = 'interrupt'
import kivy
kivy.require('1.0.7')
from... | true |
ee0c3ca2ae21b7dc7b0c0894210277392cbe3456 | ebonnecab/CS-1.3-Core-Data-Structures | /Code/search.py | 2,869 | 4.28125 | 4 | #!python
def linear_search(array, item):
"""return the first index of item in array or None if item is not found
Worst case time complexity is O(n) where n is every item in array
"""
# implement linear_search_iterative and linear_search_recursive below, then
# change this to call your implementatio... | true |
4dacde6d91cc83d58f4bc06c19bba5fe436493af | Harshan-Sarkar/important_concepts | /WHJR_PYTHON/Other_programms/Pallindrome_Detector.py | 227 | 4.28125 | 4 | a = input("Enter to check if a word is a pallindrome or not: ")
a = a.replace(" ", "")
b = a.upper()
c = b[::-1]
if b == c :
print(f"Yes, '{a}' is a pallindrome.")
else :
print(f"No, '{a}' is not a pallindrome.") | false |
2ffe0b58632675457a7f159c5da87cda4c8ca5ea | lew18/practicepython.org-mysolutions | /ex16-password_generator.py | 2,119 | 4.15625 | 4 | """
https://www.practicepython.org
Exercise 16: Reverse Word OrderPassword Generator
4 chilis
Write a password generator in Python. Be creative with how you generate
passwords - strong passwords have a mix of lowercase letters, uppercase
letters, numbers, and symbols. The passwords should be random, generating
a new ... | true |
a782134e78b9059206f0068a4896d51898c2d42f | lew18/practicepython.org-mysolutions | /ex18-cose_and_bulls.py | 2,236 | 4.375 | 4 | """
https://www.practicepython.org
Exercise 18: Cows and Bulls
3 chilis
Create a program that will play the “cows and bulls” game with the user.
The game works like this:
Randomly generate a 4-digit number. Ask the user to guess a 4-digit number.
For every digit that the user guessed correctly in the correct place, ... | true |
64fdc533942c6079155317077310ca6a2cf052fc | lew18/practicepython.org-mysolutions | /ex24-draw_game_board.py | 1,891 | 4.8125 | 5 | """
https://www.practicepython.org
Exercise 24: Draw a Game Board
2 chilis
This exercise is Part 1 of 4 of the Tic Tac Toe exercise series.
The other exercises are: Part 2, Part 3, and Part 4.
Time for some fake graphics! Let’s say we want to draw game boards that look like this:
--- --- ---
| | | |
--- -... | true |
56280fb746e3ecab8bd857bfb66615ed32819dbd | lew18/practicepython.org-mysolutions | /ex02-odd_or_even.py | 975 | 4.40625 | 4 | """
https://www.practicepython.org
Exercise 2: Odd or Even
1 chile
Ask the user for a number. Depending on whether the number is even or odd,
print out an appropriate message to the user.
Hint: how does an even / odd number react differently when divided by 2?
Extras:
1. If the number is a multiple of 4, print out a ... | true |
7cd4741918ca8944686e2aa3905aa0e59fe022ee | OtchereDev/python-mini-project | /age_check.py | 383 | 4.40625 | 4 | print('Hello user, Welcome to the age grouping app \n')
age= int(input('\n Please what is your age in numbers? '))
if age == 0 or age <= 12:
print('Kid')
elif age<=30 or age <= 19:
print('Teenager')
elif age<=20 or age<=30:
print('Young Adult')
elif age<=31 or age<=64:
print('Adult')
elif age>=65:
... | false |
d51ea53c283dcd6fc2af776a8e0600f72a26efa9 | iaryankashyap/ReadX | /Code/ReadX.py | 1,069 | 4.34375 | 4 | # This program calculates the difficulty of a body of text by assigning it a grade
# gets user input about the text
text = input("Text: ")
letters = 0
words = 0
sentences = 0
counter = 0
for i in text:
counter += 1
for i in range(counter):
# counts the letters using ascii code
if (ord(text[i]) >= 65 and... | true |
468f10c5d3c13113a73f4fc36c454a082cd2d3a0 | Sunsmailer/PythonByMediasoft | /PythonByMediasoft/lesson2duplicates.py | 449 | 4.21875 | 4 | #первый вариант
duplicates = ['1', '2', '3', '3', '6', '4', '5', '6']
new_duplicates = []
[new_duplicates.append(item) for item in duplicates if item not in new_duplicates]
new_duplicates.sort()
print(new_duplicates)
#второй вариант
dup1 = {'1', '2', '3', '3', '6', '4', '5', '6'}
dup2 = {'1', '2', '3', '4... | false |
6d38db8cf36b30a5d45a44aa94592a57b4212251 | ashwithaDevireddy/PythonPrograms | /conditional.py | 280 | 4.125 | 4 | var=float(input("Enter the number :"))
if var > 50:
print("greater")
elif var == 50:
print("equal") // used if multiple conditions are implemented
else:
print("smaller")
output:
Enter the number :2
smaller
Enter the number :50
equal
Enter the number :51
greater
| true |
b9fdb656f713c1ac6f5a408d006ca9823f46b773 | rishabhgupta/HackerRank-Python | /datatypes.py | 2,430 | 4.1875 | 4 | # 1. LISTS
"""
You have to initialize your list L = [] and follow the N commands given in N lines.
"""
arr = []
n = input()
for i in range(int(n)):
input_str = input()
split_str = input_str.split(' ')
if split_str[0] == 'insert':
arr.insert(int(split_str[1]),int(split_str[2]))
elif split_str[... | true |
8ba19ee0a4811e3f73a66d95e82614ac2b553973 | weifengli001/pythondev | /vendingmachine/test.py | 2,787 | 4.28125 | 4 | """
CPSC-442X Python Programming
Assignment 1: Vending Machine
Author: Weifeng Li
UBID: 984558
"""
#Global varable
paid_amount = 0.0#The total amount of insert coins
total = 0 #The total costs
change = 0 # change
drinks = {"Water" : 1, "Soda" : 1.5, "Juice" : 3} # The drinks dictionary stores drinks and their price
sn... | true |
0055ee064f2ecc83380d31b3de93f6fa181d2aa5 | kriyazhao/Python-DataStructure-Algorithms | /7.1_BinaryTree.py | 2,786 | 4.15625 | 4 |
#--------------------------------------------------------------------------
# Define a binary tree using List
def BinaryTree(root):
return [root, [], []]
def insertLeft(root, branch):
leftChild = root.pop(1)
if len(leftChild) < 1:
root.insert(1, [branch, [], []])
else:
root.insert(1, [... | true |
35d14bfa9ce714b65bf4f014cecab4b9be4d5901 | linnienaryshkin/python_playground | /src/basics_tkinter.py | 1,596 | 4.28125 | 4 | from tkinter import *
# Create an empty Tkinter window
window = Tk()
def from_kg():
# Get user value from input box and multiply by 1000 to get kilograms
gram = float(e2_value.get())*1000
# Get user value from input box and multiply by 2.20462 to get pounds
pound = float(e2_value.get())*2.20462
... | true |
9c64dee86c030a1784532286137edefaa9a33543 | NtateLephadi/csc1015f_assignment_4 | /bukiyip.py | 761 | 4.1875 | 4 | # convert a decimal number to bukiyip.
def decimal_to_bukiyip(a):
bukiyip = ''
quotient = 2000000
while quotient > 0:
quotient = a // 3
remainder = a % 3
bukiyip += str(remainder)
a = quotient
return bukiyip[::-1]
# convert a bukiyip number to decimal
def bukiyip_to_d... | false |
8e526b0f26f52a9b3f606d9ca4e65b85e8ceba4d | pevifol/Lista_de_exercicios | /Lista 1 e 2/Primeiros multiplos de 5 ou 7.py | 810 | 4.3125 | 4 | '''
Este programa define uma função chamada primul, que utiliza o parametro x
e retorna os primeiros X multiplos de 7, e os primeiros X multiplos de 5,
no formato de lista.
Em seguida, o programa pergunta educadamente, e executa o primul(x) até o valor digitado.
'''
def primul(x):
z=x+1
list5=[]
list7=... | false |
7580ac5ec609dc67bcd19be51e92dfd3b0c053e2 | sajalkuikel/100-Python-Exercises | /Solutions/3.Exercise50-75/68.py | 723 | 4.125 | 4 | # user friendly translator
# both earth and EaRtH should display the translation correctly
#
# d = dict(weather="clima", earth="terra", rain="chuva", sajal= "सजल", kuikel="कुइकेल")
#
#
# def vocabulary(word):
# try:
# return d[word]
# except KeyError:
# return "The word doesn't exist in this dic... | true |
3a76f1bbcf4aab994b7fa62a7be456cf5be16957 | nazam9519/lists_and_structures | /dlinkedlist/dlinkedlist.py | 929 | 4.125 | 4 | #doubly linked list
from linkedlist import double_linkedlist
from linkedlist import linkedlist
from IData_Structure import stack_i
from IData_Structure import queue
def main():
stacky = stack_i()
stacky.push(1)
stacky.push(2)
print(stacky.peek())
stacky.pop()
print(stacky.peek())
nqueu... | false |
112071c49cbf91b77f12e542f3252a3533b750bb | cadenjohnsen/quickSelectandBinarySearch | /binarySearch.py | 2,074 | 4.375 | 4 | #!/usr/bin/env python3
from random import randint
# function to execute the binary search algorithm
def binarysearch(num, array):
row = 0 # start at the top
col = int(len(array[0])) - 1 # start at the far right
while((row < int(len(array))) and (col >= 0)): # search from top right t... | true |
dccd11a977c0cffa7796fd48c9ac7b91f4f392c6 | theOGcat/lab4Python | /lab9.py | 774 | 4.3125 | 4 | #LorryWei
#104952078
#lab9
#Example program that calculate the factorial n! , n! is the product of all positive
#integers less than or equal to n
#for example, 5! = 5*4*3*2*1 = 120
#The value of 0! is 1
#
#PsuedoCode Begin:
#
#using for loops
#for i = 1; i <=n ++1
#factorial *= i
#print out the lis... | true |
c5192b712f8bc5d41532ff4cbdc11407297740ed | theOGcat/lab4Python | /q1.py | 1,598 | 4.34375 | 4 | #LorryWei
#104952078
#Assignment3 Question1
#Example of using function randrange(). Simulates roll of two dices.
#The random module function are given below. The random module contains some very useful functions
#one of them is randrange()
#randrange(start,stop)
#PsuedoCode Begin:
#
#import randrange f... | true |
ea6e3ceef83f99f3a5f5c8c985a07198e7113d6e | Dev-Castro/ALP_FATEC-FRV | /expressoes_aritmeticas/ex002.py | 274 | 4.1875 | 4 | # Expressões Aritméticas
'''
2) Implemente um algoritmo (fluxograma) e o
programa em Python que recebe dois números
inteiros e mostre o resultado da multiplicação deles
'''
n1 = int(input("n1: "))
n2 = int(input("n2: "))
m = n1 * n2
print('Multiplicação: %i' % m) | false |
8946f235acdf5e0fa706a826264c799e8a8f6c4b | Rikharthu/Python-Masterclass | /Variables.py | 2,123 | 4.1875 | 4 | greeting = "Hello"
Greeting = "Greetings" # case-sensitive
name = "Bruce"
print(name)
name = 5 # not an error
print(name)
_myName = "Bob"
_myName2 = "Jack"
# TODO
# FIXME
age = 21
print(age) # OK
# print(greeting+age) #error, age is expected to be a string, since theres no implicit conversion
print(greeting + age... | true |
ba5801191299b1c6c21e2562aeeb081de04507cb | Alex-Iskar/learning_repository | /lesson_3/hw_3_4.py | 679 | 4.4375 | 4 | # Необходимо выполнить возведение числа x в степень y. Задание необходимо реализовать в виде функции my_func(x, y)
def my_func_1(arg_x, arg_y):
rez = arg_x**arg_y
return rez
def my_func_2(arg_x, arg_y):
rez = 1
for step in range(abs(arg_y)):
rez = rez * 1 / arg_x
return rez
x = int(input... | false |
8e8adfcf5c491b468107c9df4c447bf5109deb39 | EvaOEva/python1 | /03-可变类型和不可变类型.py | 1,426 | 4.34375 | 4 | # 可变类型:可以在原有数据的基础上对数据进行修改(添加或者删除或者修改数据),修改后内存地址不变
# 不可变类型: 不能在原有数据的基础上对数据进行修改,当然直接赋值一个新值,那么内存地址会发生改变
# 可变类型: 列表,集合,字典,对数据进行修改后内存地址不变
# 不可变类型: 字符串,数字,元组,不能再原有数据的基础上对数据进行修改
my_list = [1, 5, 6]
# 查看内存地址
print(my_list, id(my_list))
my_list[0] = 2
my_list.append(7)
del my_list[1]
print(my_list, id(my_list))
my_dict = {"n... | false |
88d33fb6f7c4026f0efdba747832d154f799220a | EvaOEva/python1 | /14-生成器.py | 1,055 | 4.40625 | 4 | # 生成器是一个特殊的迭代器,也就是说它可以通过next函数和for循环取值
# 迭代器和生成器的好处是: 根据需要每次生成一个值,不像列表把所有的数据都准备好,这样列表比较占用内存,而生成器和迭代器内存占用非常少
# 值只能往后面取不能往前面取值
# 1. 使用生成器的表达式
# result = [x for x in range(4)]
# print(result, type(result))
result = (x for x in range(4))
print(result)
# 测试: 使用next获取下一个值
# value = next(result)
# print(value)
# for value... | false |
e6fe97b2a4b264dcd8f52461ed0175c72f35a748 | EvaOEva/python1 | /16-单例.py | 569 | 4.1875 | 4 | # 单例: 在应用程序中不管创建多少次对象只有一个实例对象
class Person(object):
# 私有的类属性
__instance = None
# 创建对象
def __new__(cls, *args, **kwargs):
# if cls.__instance == None:
if not cls.__instance:
print("创建对象")
# 把创建的对象给类属性
cls.__instance = object.__new__(cls)
ret... | false |
c15e0bc88eb33491c412f24183dda888e9558c18 | realhardik18/minor-projects | /calculator.py | 1,663 | 4.34375 | 4 | print("this is a basic calculator, for help enter '!help'")
user_command=input(">")
while user_command!="!quit":
if user_command=="!help":
print("to use the below functions type !start")
print("for addition enter a ")
print("for multiplying enter m")
print("for dividing enter d")
... | true |
a193ed75e54ffb9fdd78a93a526f696e2467bae9 | deepdatanalytics/ASSIGNMENTS | /00_Ders/060820_OOP1.py | 2,953 | 4.15625 | 4 | # class Employee:
# raise_amnt = 1.04 #class attribute oldu. Objeleri de kapsıyor dolayısıyla.
# def __init__(self,firstname,lastname,email,pay):
# self.firstname = firstname
# self.lastname = lastname
# self.email = email
# self.pay = pay
# def fullname(self):
# ... | false |
2d7854170ec59e5368a1570547a74466e7fec9d3 | divu050704/Algo-Questions | /all_negative_elements.py | 661 | 4.28125 | 4 | def move_negative_elements(x):
print('Original list:\t',x)#We will first print the original list
size = int(len(x))#Length of the list
for i in range(0,size):
if x[i] < 0:#if x[i] is negative
main = x[i]#we will first save the element in variable because we are going to pop the element ... | true |
480682406029aacf02ab366cab99dbd00034b8e0 | sushgandhi/Analyze_Bay_Area_Bike_Share_Data | /dandp0-bikeshareanalysis/summarise_data.py | 2,980 | 4.15625 | 4 | def summarise_data(trip_in, station_data, trip_out):
"""
This function takes trip and station information and outputs a new
data file with a condensed summary of major trip information. The
trip_in and station_data arguments will be lists of data files for
the trip and station information, respectiv... | true |
b3a4a8f603b92c15e59fb7389c2b06ba96c11a7a | sweetpand/Algorithms | /Leetcode/Solutions/math/7. Reverse Integer.py | 576 | 4.1875 | 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 |
6eebb728c48a8b14b0875c97c733a1624542fd5d | sweetpand/Algorithms | /Leetcode/Solutions/Longest_Palindrome_Substring.py | 1,231 | 4.1875 | 4 | #Question: Given a string, find the longest palindrome in it
#Difficulty: Iterate through each element and determine if its a palindrome
#Difficulty: Easy
def longestPalindrome(s):
#Keep track of largest palindrome found so far
gmax = ""
#Helper function to find the longest palindrome given a l... | true |
13ada5c6d5e949bac39b65e40dded49cbd61e802 | dillon4287/CodeProjects | /Python/Coding Practice/linked_list/linked_list.py | 1,061 | 4.15625 | 4 | class Node:
def __init__(self, data) -> None:
self.value = data
self.Next = None
class linked_list:
def __init__(self) -> None:
self.head = None
def addLast(self, data):
if(self.head is None):
self.head = Node(data)
else:
root = self.head
... | true |
9b80e28d7892712937b7b010f9798f5a974a861b | hyeonukjeong/Algorithm | /kr/hs/dgsw/nyup/part01/design01/basic.py | 395 | 4.1875 | 4 | '''
1. 곱하기와 나누기
'''
print (3 * 2)
print (3 / 2)
print (3 ** 4)
'''
2. 할당문
'''
a = 1
b = 2
print (a + b)
'''
3. 문자
'''
c = "You need "
d = 'Python.'
print (c + d)
'''
4. 조건문
'''
e = 5
if e > 3:
print ("e는 3보다 크다.")
'''
5. 반복문
'''
for f in [1, 3, 7]:
print (f)
'''
6. 함수
'''
def add (g, h):
return (... | false |
51dda073f8280d086e89356b67ee4aa0779f30a7 | ator89/Python | /MITx_Python/week2/week2_exe3_guessMyNumber.py | 1,217 | 4.125 | 4 | import random
secret = int(input("Please think of a number between 0 and 100!"))
n = random.randint(0,100)
low = 0
high = 100
while n != secret:
print("Is your secret number " + str(n) + "?")
option = input("Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' ... | true |
1b1fe1a95570be4c2444f919cbf5b4eab9a1bd8b | harshithamagani/python_stack | /python/fundamentals/hello_world.py | 808 | 4.46875 | 4 |
print("Hello World!")
x = "Hello Python"
print(x)
y = 42
print(y)
name = "Zen"
print("My name is", name)
name = "Zen"
print("My name is " + name)
#F-Strings (Literal String Interpolation)
first_name="Zen"
last_name="Coder"
age=27
print(f"My name is {first_name} {last_name} and I am {age} years old.")
#string.for... | true |
1e7f9513f24543c2d3248a8c066300f033c6ba78 | harshithamagani/python_stack | /python/fundamentals/Function_Basic_II/valsGreatThanSecnd.py | 753 | 4.375 | 4 | #Write a function that accepts a list and creates a new list containing only the values from the original list that are greater than its 2nd value. Print how many values this is and then return the new list. If the list has less than 2 elements, have the function return False
#Example: values_greater_than_second([5,2,3... | true |
9444dff462f8659dd24b92f896d5e4726f72cd93 | Anju3245/Sample-example | /ex66.py | 393 | 4.1875 | 4 | print("enter number frist:")
frist = input()
print("enter second number:")
second = input()
print("enter third number:")
third = input()
if frist > second:
if frist > third:
print(f"{frist} is the largest")
else:
print(f"{third} is the largest ")
else:
if second > third:
print(f"{se... | true |
3c083f3459f90d53a318a1f3528a0349aa77b509 | thegr8kabeer/Current-Date-And-Time-Shower-Python | /current _date_and_time.py | 635 | 4.1875 | 4 | # A simple python project made by Thegr8kabeer to display the current date and time
# Easy to understand syntax for the person who knows the basics of Python by using the built-in Pyhton modules time and datetime
# Feel free to edit my code and do some experiments!!!
# Don't forget to follow me on instagram at https... | true |
f86d1082e54213ae28e0f7d67e235a45aa8bb441 | jatindergit/python-programs | /is-prime.py | 394 | 4.21875 | 4 | number = int(input('Enter any integer'))
def is_prime(n):
if n == 1:
prime = False
elif n == 2:
prime = True
else:
prime = True
for check_number in range(2, int(n/2) - 1):
if n % check_number == 0:
prime = False
return prime
if is_prime(numb... | false |
e30351f4fb9d2a579809bca75303940edd726416 | beenorgone-notebook/python-notebook | /py-book/py-book-dive_into_py3/examples/roman3.py | 2,328 | 4.125 | 4 | '''Convert to and from Roman numerals
This program is part of 'Dive Into Python 3', a free Python book for
experienced programmers. Visit http://diveintopython3.org/ for the
latest version.
'''
roman_numeral_map = (('M', 1000),
('CM', 900),
('D', 500),
... | true |
7e389217ee1a884961db1858d48fcd11f2ae42a6 | beenorgone-notebook/python-notebook | /py-recipes/use_translate_solve_alphametics.py | 2,039 | 4.15625 | 4 | def alphametics(puzzle):
'''
Solve alphametics puzzle:
HAWAII + IDAHO + IOWA + OHIO == STATES
510199 + 98153 + 9301 + 3593 == 621246
The letters spell out actual words, but if you replace each letter
with a digit from 0–9, it also “spells” an arithmetic equation.
The trick is to figure out w... | true |
c6f454afce86b20fd2be8c3fd955f810ef5a0d27 | DscAuca/into-to-python | /src/intro/string.py | 2,597 | 4.125 | 4 | print("hello world")
print('hello world')
print('"i think you\'re aweosme tho"')
print('this is "going to work" as i said')
name='salvi'
print('welcome '+ name +' you\'re awesome')
print(3*('i repeat you\'re awesome '))
print(len('aesome shit')/len(name))
print(name[0])
# Quiz: Fix the Quote
# The line of code in th... | true |
209e2d4a62767c2e446e9e53eaf1af476467d63d | DscAuca/into-to-python | /src/data structure/compound_datatype.py | 1,772 | 4.625 | 5 | elements = {"hydrogen": {"number": 1,
"weight": 1.00794,
"symbol": "H"},
"helium": {"number": 2,
"weight": 4.002602,
"symbol": "He"}}
helium = elements["helium"] # get the helium dictionary
hydrogen_weight... | true |
b9b9661b9bb7997c0121d7bc378ad1045abfcd99 | VMGranite/CTCI | /02 Chapter - Linked Lists in Python/2_4_Partition.py | 798 | 4.4375 | 4 | #!/usr/bin/env python3
# 1/--/2020
# Cracking the Coding Interview Question 2.4 (Linked Lists)
# Partition: Write code to partition a linked list around a value x,
# such that all nodes less than x come before all node greater than
# or equal to x. If x is contained within the list, the values
# of x only need to be af... | true |
6292be73038d38e901f1f978c2e64daadcd73922 | paramjeetsingh31/paramcmru | /programe 11.py | 507 | 4.46875 | 4 | # Python program to illustrate
# Iterating over a list
print("python")
l = ["param", "jeet", "singh"]
for i in l:
print(i)
# Iterating over a tuple (immutable)
print("\nTuple python")
t = ("param", "jeet", "singh")
for i in t:
print(i)
# Iterating over a String
print("\nString python")
s = "pa... | false |
4006054a3e31786ea7b93aa99cc2be4a305f5949 | candytale55/Copeland_Password_Username_Generators | /username_password_generators_slice_n_shift.py | 1,429 | 4.21875 | 4 | # username_generator take two inputs, first_name and last_name and returns a username. The username should be
# a slice of the first three letters of their first name and the first four letters of their last name.
# If their first name is less than three letters or their last name is less than four letters it should ... | true |
a9fe4064f0aa9a13bc6afcfec7b666f3977ff9e9 | mjdecker-teaching/mdecke-1300 | /notes/python/while.py | 1,958 | 4.28125 | 4 | ##
# @file while.py
#
# While-statement in Python based on: https://docs.python.org/3/tutorial
#
# @author Michael John Decker, Ph.D.
#
#while condition :
# (tabbed) statements
# condition: C style boolean operators
# tabbed: space is significant.
# * Avoid mixing tabs and spaces, Python relies on correct positi... | true |
b47f30bb8fcea15b3b08ec5cf0cd32412ec2b652 | sdesai8/pharmacy_counting | /src/helper_functions.py | 2,962 | 4.21875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Mar 24 00:17:08 2019
@author: savan
"""
from decimal import Decimal
def isPositiveDecimal(number):
"""
To validate if value is positive decimal number
Parameters:
arg1 (string): like example: prescriber_id/drug_cost
Return... | true |
883db011c2393aec6b1ee725ac2eeba0e356d8cb | xubonnie/ICS4U | /Modular Programming/scope.py | 468 | 4.125 | 4 | __author__ = 'eric'
import math
def distance(x1, y1, x2, y2):
d = math.sqrt((x2-x1)**2 + (y2-y1)**2)
return d
def main():
x_1 =input("Enter an x-value for the first point: ")
y_1 =input("Enter an y-value for the first point: ")
x_2 = input("Enter an x-value for the second point: ")
y_2 = inpu... | true |
2ad269ec438578eb8d482e862b0477df3ec346cf | alextrujillo4/EZ-PZ-language | /semantic_cube.py | 1,990 | 4.15625 | 4 | # Oscar Guevara A01825177
# Gerardo Ponce A00818934
# Listas de operadores.
operators = ['+', '-', '*', '/']
comparators = ['==', '>', '>=', '<', '<=', '<>']
# Verificar el tipo de resultado de una expresión.
def semantic(left, right, operator):
if(left == 'int'):
if(right == 'int'):
i... | false |
c2f444f85f06775591739985f9c60f745927dad7 | cynen/PythonStudy | /03-DataStructure/Queue.py | 1,339 | 4.125 | 4 | #coding=utf-8
class Queue(object):
def __init__(self):
self.__items=[]
def enqueue(self,item):
'''往队列中添加一个item元素'''
self.__items.insert(0,item)
#self.__items.append(item)
def dequeue(self):
'''从队列头部删除一个元素'''
if self.size():
return self.__items.... | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.