blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
c06217c63dd9a7d955ae6f2545773486d84158b0 | Iliya-Yeriskin/Learning-Path | /Python/Exercise/Mid Exercise/4.py | 266 | 4.40625 | 4 | '''
4. Write a Python program to accept a filename from the user and print the extension of that.
Sample filename : abc.java
Output : java
'''
file=input("Please enter a file full name: ")
type=file.split(".")
print("Your file type is: " + repr(type[-1]))
| true |
0d19a4381c7c94180999bc78613aecdf65cf04a0 | Iliya-Yeriskin/Learning-Path | /Python/Projects/Rolling Cubes.py | 2,517 | 4.1875 | 4 | '''
Cube project:
receive an input of player money
every game costs 3₪
every round we will roll 2 cubes,
1.if cubes are the same player wins 100₪
2.if the cubes are the same and both are "6" player wins 1000₪
3.if the cubes different but cube 2 = 2 player wins 40₪
4.if the cubes different but cube 1 = 1 player ... | true |
5736199cbc797c8ae7d2cc6d8fc09da59023d5e2 | Iliya-Yeriskin/Learning-Path | /Python/Exercise/Mid Exercise/10.py | 306 | 4.3125 | 4 | '''
10. Write a Python program to create a dictionary from a string. Note: Track the count of the letters from the string.
Sample string : 'Net4U'
Expected output: {'N': 1, 'e': 1, 't': 2, '4': 1, 'U': 1}
'''
word=input("Please enter a word: ")
dict={i:word.count(i) for i in word}
print(dict)
| true |
8146be5d85020e6b965d2c4caf1991678677e410 | Balgeum-Cha/vscode | /class.py | 796 | 4.3125 | 4 | #%%
a = [1,2,3,4,]
a.append(5)
print(a)
# %%
def test():
pass
class Person:
pass
bob = Person()
cathy = Person()
a = list()
b = list()
# %%
# 생성자
class Person:
def __init__(self):
print(self,'is generated')
self.name = 'Kate'
self.age = 10
p1 = Person()
p2 = Person()
p1.name = '... | false |
03a72365c3d05751de58a9e973736dd925ea6bb2 | Stefan1502/Practice-Python | /exercise 13.py | 684 | 4.5 | 4 | #Write a program that asks the user how many Fibonnaci numbers to generate and then generates them.
#Take this opportunity to think about how you can use functions.
#Make sure to ask the user to enter the number of numbers in the sequence to generate.
#(Hint: The Fibonnaci seqence is a sequence of numbers where the n... | true |
252901028a8feadeb4070b57ff330d2c2751757c | Stefan1502/Practice-Python | /exercise 9.py | 894 | 4.21875 | 4 | #Generate a random number between 1 and 9 (including 1 and 9). Ask the user to guess the number, then tell them whether they guessed too low, too high, or exactly right.
#(Hint: remember to use the user input lessons from the very first exercise)
#Extras: Keep the game going until the user types “exit” Keep track of h... | true |
b831314d05f1b2a996e687d3f43f046ef46eab0d | Stefan1502/Practice-Python | /exercise 28.py | 421 | 4.375 | 4 | # Implement a function that takes as input three variables, and returns the largest of the three.
# Do this without using the Python max() function!
# The goal of this exercise is to think about some internals that Python normally takes care of for us.
# All you need is some variables and if statements!
... | true |
d0fdd8537fc6e96de145f6c409cc166699a51ee1 | ericrommel/codenation_python_web | /Week01/Chapter04/Exercises/ex_4-10.py | 1,171 | 4.34375 | 4 | # Extend your program above. Draw five stars, but between each, pick up the pen, move forward by 350 units, turn right
# by 144, put the pen down, and draw the next star. You’ll get something like this:
#
# _images/five_stars.png
#
# What would it look like if you didn’t pick up the pen?
import turtle
def make_wind... | true |
7fcd55b167623ad4139ebe7d9eab75f958c78fb2 | ericrommel/codenation_python_web | /Week01/Chapter04/Exercises/ex_4-09.py | 694 | 4.53125 | 5 | # Write a void function to draw a star, where the length of each side is 100 units. (Hint: You should turn the turtle
# by 144 degrees at each point.)
#
# _images/star.png
import turtle
def make_window(color="lightgreen", title="Exercise"):
win = turtle.Screen()
win.bgcolor(color)
win.title(title)
... | true |
f4aeba34d229b94abb230c2d9607b8f39570fede | ericrommel/codenation_python_web | /Week01/Chapter03/Exercises/ex_3-06.py | 871 | 4.3125 | 4 | # Use for loops to make a turtle draw these regular polygons (regular means all sides the same lengths, all angles the same):
# An equilateral triangle
# A square
# A hexagon (six sides)
# An octagon (eight sides)
import turtle
wn = turtle.Screen()
wn.bgcolor("lightgreen")
wn.title("Exercise 6")
tria... | true |
35da7c155a1d54f1e941e58340e43121a898e006 | Elton86/ExerciciosPython | /EstruturaDeDecisao/Exe16.py | 1,294 | 4.40625 | 4 | """Faça um programa que calcule as raízes de uma equação do segundo grau, na forma ax2 + bx + c. O programa deverá
pedir os valores de a, b e c e fazer as consistências, informando ao usuário nas seguintes situações:
- Se o usuário informar o valor de A igual a zero, a equação não é do segundo grau e o programa não dev... | false |
5760b3a9d3a22ff5c9fd0065db155cf87d873abf | Elton86/ExerciciosPython | /ExerciciosListas/Exe13.py | 618 | 4.1875 | 4 | """Faça um programa que receba a temperatura média de cada mês do ano e armazene-as em uma lista. Após isto, calcule
a média anual das temperaturas e mostre todas as temperaturas acima da média anual, e em que mês elas ocorreram
(mostrar o mês por extenso: 1 – Janeiro, 2 – Fevereiro, . . . )."""
mes = []
media = 0
fo... | false |
bc7321cb0a9bb06e00df001975f0772fcfeb13be | Elton86/ExerciciosPython | /ExerciciosListas/Exe15.py | 1,511 | 4.125 | 4 | """Faça um programa que leia um número indeterminado de valores, correspondentes a notas, encerrando a entrada de
dados quando for informado um valor igual a -1 (que não deve ser armazenado). Após esta entrada de dados, faça:
Mostre a quantidade de valores que foram lidos;
Exiba todos os valores na ordem em que foram i... | false |
5de87c8f9022f227208214470e78d6cb200dff8a | Elton86/ExerciciosPython | /ExerciciosComStrings/Exe04.py | 281 | 4.25 | 4 | """Nome na vertical em escada. Modifique o programa anterior de forma a mostrar o nome em formato de escada.
F
FU
FUL
FULA
FULAN
FULANO"""
nome = input("Digite o nome: ")
for i in range(1, len(nome) + 1):
for j in range(0, i):
print(nome[j], end=" ")
print(" ")
| false |
5f8d04547f72564b308b9645c73f192b12a4c2b1 | Elton86/ExerciciosPython | /ExerciciosFuncoes/Exe09.py | 236 | 4.3125 | 4 | """Reverso do número. Faça uma função que retorne o reverso de um número inteiro informado. Por exemplo: 127 -> 721.
"""
def inverte_num(num):
return num[::-1]
numero = input("Digite o numero: ")
print(inverte_num(numero))
| false |
bd0d86565d9a8380c8ede6fc6a36249d4b134ffb | arabindamahato/personal_python_program | /risagrud/function/actual_argument/default_argument.py | 690 | 4.5625 | 5 | ''' In default argument the function contain already a arguments. if we give any veriable
at the time of function calling then it takes explicitely . If we dont give any arguments then
the function receives the default arguments'''
'''Sometimes we can provide default values for our positional arguments. '''
def wish(... | true |
90aba704a0cf75e1359c3585d1986dbb7a5b826d | arabindamahato/personal_python_program | /programming_class_akshaysir/find_last_digit.py | 353 | 4.28125 | 4 | print('To find the last digit of any number')
n=int(input('Enter your no : '))
o=n%10
print('The last digit of {} is {}'.format(n,o))
#To find last digit of a given no without using modulas and arithmatic operator
print('To find last digit of a given no')
n=(input('Enter your no : '))
o=n[-1]
p=int(o)
print('The las... | true |
e4bc895b6c639fda81703d162b07034888231d50 | Laurensvaldez/PythonCrashCourse | /CH8: Functions/try_it_yourself_ch8_8_8.py | 986 | 4.375 | 4 | # Start with your program from exercise 8-7. Write a while loop that allows users to enter an album's artist and title.
# Once you have that information, call make_album() with the user's input and print the dictionary that's created.
# Be sure to include a quit value in the while loop.
def make_album(artist, title, t... | true |
9cb4ce71d22344f24e1d3cc338bb9e83ed1ad3ad | Laurensvaldez/PythonCrashCourse | /CH8: Functions/making_pizzas.py | 1,837 | 4.3125 | 4 | # In this file we will import the function of pizza_import.py
import pizza_import
print("Importing all the functions in the module")
pizza_import.make_pizza(16, 'pepperoni')
pizza_import.make_pizza(12, 'mushrooms', 'green peppers', 'extra cheese')
print("-------------------------------------------")
# To use the import... | true |
146541bd8096d3dada3b6b651f7d74caf3d8fe68 | Laurensvaldez/PythonCrashCourse | /CH9: Classes/9-6_ice_cream_stand.py | 2,095 | 4.5625 | 5 | # Write a class called IceCreamStand that inherits from the Restaurant class you wrote in Exercise 9-1 or Exercise 9-4
# Either version of the class will work; just pick the one you like better
class Restaurant:
"""A simple restaurant class"""
def __init__(self, restaurant_name, cuisine_type):
"""Initi... | true |
f14e51cff185f2277385b1a0d580fd0a077e7195 | Laurensvaldez/PythonCrashCourse | /Ch6: Dictionaries/try_it_yourself_ch6_6_1.py | 514 | 4.3125 | 4 | # Try it yourself challenge 6-1
# Person
# Use a dictionary to store information about a person you know.
# Store their first name, last name, age, and the city in which they live. You should have keys such as
# first_name, last_name, age, and city. Print each piece of information stored in your dictionary.
person = ... | true |
755616213684796cb48d924e5bf927e994e030d1 | Laurensvaldez/PythonCrashCourse | /CH4: working with lists/try_it_yourself_ch4_4_11.py | 500 | 4.21875 | 4 | print ("More Loops")
# all versions of foods.py in this section have avoided using for loops when printing to save space
# Choose a version of foods.py, and write two for loops to print each list of foods
my_foods = ['pizza', 'falafel', 'carrot cake']
print ("My favorite foods are: ")
for food in my_foods:
print... | true |
2593aeaf239015183c48861a96af3d1feb21d6d3 | Laurensvaldez/PythonCrashCourse | /CH9: Classes/9-5_login_attempts.py | 2,622 | 4.46875 | 4 | # Add an attribute called login_attempts to your User class from Exercise 9-3
class User:
"""A class to describe a user"""
# Create two attributes called first_name and last_name
# and then create several other attributes that are typically stored in a user profile
def __init__(self, first_name, last_n... | true |
a4ca9323e0c5bbd2cd4f81cb49151482d2a3d802 | phu-mai/calculate | /calculate.py | 777 | 4.125 | 4 | from datetime import datetime
def string_to_date(input):
return datetime.strptime(input, "%d/%m/%Y")
def check_date(input):
if string_to_date(input) < datetime.strptime("01/01/1900", "%d/%m/%Y") or string_to_date(input) > datetime.strptime("31/12/2999", "%d/%m/%Y"):
return False
else:
retu... | true |
56490d658082b16ec7ec9140147f0e3e0544c630 | subhendu17620/RUAS-sem-04 | /PP/Java/lab03/a.py | 1,391 | 4.1875 | 4 | # Python3 program to print all Duplicates in array
# A class to represent array of bits using
# array of integers
class BitArray:
# Constructor
def __init__(self, n):
# Divide by 32. To store n bits, we need
# n/32 + 1 integers (Assuming int is stored
# using 32 bits)
self.arr = [0] * ((n >> 5) + ... | true |
f600b3970b3c556a9aa03af8d6ef7b1f1dd124f7 | MirjaLagerwaard/MountRUSHmore | /main.py | 1,500 | 4.28125 | 4 | import sys
from algorithm import *
if __name__ == "__main__":
# Error when the user did not give the right amount of arguments
if len(sys.argv) <= 1 or len(sys.argv) > 3:
print "Usage: python main.py <6_1/6_2/6_3/9_1/9_2/9_3/12> <breadth/depth/random>"
exit()
# update fp to the CSV file t... | true |
90bda58a280724875f5ba10d8171e81e093338ac | prince-singh98/python-codes | /ConditionalStatements/DigitAlphabateOrSpecialCharecter.py | 229 | 4.28125 | 4 | char = input("enter a alphabet")
if((char>='a' and char<='z') or (char>='A' and char<='Z')):
print(char,"is alphabet")
elif(char>='0' and char<='9'):
print(char, "is digit")
else:
print(char, "is special character")
| true |
4c19578d82cdd55affaef69cd74f214a1664b1ff | prince-singh98/python-codes | /Relation/RelationList.py | 1,049 | 4.1875 | 4 | A = {"A", "B", "C"}
def is_symmetric(relation):
for a, b in relation:
if (a,b) in relation and (b,a) in relation and a != b:
return "Symmetric"
return "Asymmetric"
print(is_symmetric([("A","A"), ("A","C"), ("C","A"), ("C","C")])) # True
print(is_symmetric([("A","A"), ("A","C"), ("A","B"),... | false |
68e536bf4e5f3b3a7f8a853223e83f6f03511a98 | Chrisgo-75/intro_python | /conditionals/switch_or_case.py | 696 | 4.15625 | 4 | #!/usr/bin/env python3
# Index
# Python does not have a "switch" or "case" control structure which
# allows you to select from multiple choices of a single variable.
# But there are strategies that can simulate it.
#
# 1.
def main():
# 1.
choices = dict(
one = 'first',
two = 'second',
... | true |
85145d7b919824030bb2ce9a1f2132cfadcac9df | Chrisgo-75/intro_python | /general_syntax/strings.py | 1,433 | 4.9375 | 5 | #!/usr/bin/env python3
# Index
# 1. Strings can be created with single or double quotes.
# 2. Can introduce new line into a string.
# 3. Display escape characters (literally). Use "r" per example below.
# - r == "raw string" which is primarily used in regular expressions.
# 4. Format or replace characte... | true |
7a16498f5039f500dbb9b916d5f6a87ba3215c4b | datarocksAmy/APL_Python | /ICE/ICE02/ICE2.py | 2,515 | 4.125 | 4 | '''
* Python Programming for Data Scientists and Engineers
* ICE #2
* Q1 : Frequencies of characters in the string.
* Q2 : Max word length in the string.
* Q3 : Count numbers of digits and characters in the string.
* #11 Chia-Hui Amy Lin
'''
# Prompt user for a sentence
user_input_sentence = input("Please ... | true |
9094b07c5ef5da96a89870a898db9b9c010dbc45 | datarocksAmy/APL_Python | /Lab Assignment/Lab04/Lab04_b_MashDictionaries.py | 1,293 | 4.125 | 4 | # ------------------------------------------------------------
# * Python Programming for Data Scientists and Engineers
# * LAB #4-b Mash Dictionaries
# * #11 Chia-Hui Amy Lin
# ------------------------------------------------------------
# Dictionary
from statistics import mean
# Function
def mash(input_dict):
... | true |
5db43d9103f910dfeb21e7196142c38fc112af38 | datarocksAmy/APL_Python | /ICE/ICE03/ICE3-2 New List.py | 1,845 | 4.1875 | 4 | '''
* Python Programming for Data Scientists and Engineers
* ICE #3-2 Make new list
* Take in a list of numbers.
* Make a new list for only the first and last elements.
* #11 Chia-Hui Amy Lin
'''
# Function for prompting user for numbers, append and return the list
def user_enter_num(count_prompt, user_num_... | true |
dbc3dfae249a74877e71007e05cd933c92d13459 | lelong03/python_algorithm | /array/median_sorted_arrays.py | 2,041 | 4.125 | 4 | # Find median of two sorted arrays of same size
# Objective: Given two sorted arrays of size n.
# Write an algorithm to find the median of combined array (merger of both the given arrays, size = 2n).
# What is Median?
# If n is odd then Median (M) = value of ((n + 1)/2)th item term.
# If n is even then Median (M) = ... | true |
0847e2a138d297ceb53d34e5c15004424227907e | lelong03/python_algorithm | /array/next_permutation.py | 1,358 | 4.125 | 4 | # Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.
# If such arrangement is not possible, it must rearrange it as the lowest possible order (ie, sorted in ascending order).
# The replacement must be in-place, do not allocate extra memory.
# Here are so... | true |
90cc3867cb7a055bfea83ee921836bbb94ff915d | lelong03/python_algorithm | /recursion/list_sub_sets.py | 1,117 | 4.28125 | 4 | # Question: List all sub sets of one set
# Solutions:
# - with base case n = 0, there is one sub set {}
# - with n = 1, there are: {}, {a}
# - with n = 2, there are: {}, {a}, {b}, {a,b}
# - with n = 3, there are: {}, {a}, {b}, {c}, {a,b}, {a,c}, {b,c}, {a,b,c}
# P(3) = P(2) + {c}
# Using Recursion
def list_sub_set(a_... | false |
429a91d928bbf33f9ddf0c5daea25a8777d65084 | anutha13/Python | /demo.py | 1,058 | 4.21875 | 4 | from time import sleep
from threading import Thread
class Hello(Thread):
def run(self):
for i in range(5):
print("hello")
sleep(1)
class Hi(Thread):
def run(self):
for i in range(5):
print("Hi")
t1=Hello()
t2=Hi()
t1.start() ... | true |
5a0140339b66c37c3d1f7056f8a2b8520630d39c | JasleenUT/Encryption | /ElGamal/ElGamal_Alice.py | 1,669 | 4.1875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Nov 23 20:07:58 2018
@author: jasleenarora
"""
# Read the values from intermediate file
with open('intermediate.txt','r') as f:
content = f.readlines()
p = int(content[0])
g = int(content[1])
a = int(content[2])
c1 = int(content[3])
c2 = ... | true |
2a0c0bb0c9f718791d2742a1e43bfd097c8c5196 | maiconarantes/Atividade2 | /questao2.py | 805 | 4.28125 | 4 | #_*_coding:latin1_*_
#Elaborar um programa que lê 3 valores a,b,c e verifica se eles formam
#ou não um triângulo. Supor que os valores lidos são inteiros e positivos. Caso
#os valores formem um triângulo, calcular e escrever a área deste triângulo. Se
#não formam triângulo escrever os valores lidos. (Se a > b + ... | false |
d96e0003f97a041987cb123654bbd02b12c62220 | ChristianChang97/Computational-Thinking | /ex1.py | 283 | 4.15625 | 4 | print("1TDS - FIAP - Primeiro Programa Python")
numero = int (input("Digite um número: "))
#campo para digitação do número
quadrado = numero*numero
#cálculo do quadrado do número
print("O quadrado do número {} é {}".format(numero, quadrado))
#impressão do resultado | false |
31437cfb86cb0bdd9ce378ba6aacd44a48c1a3dd | opember44/Engineering_4_Notebook | /Python/calculator.py | 1,426 | 4.34375 | 4 | # Python Program 1 - Calculator
# Written by Olivia Pemberton
def doMath (num1, num2, operation):
# defines do math function
# program will need yo to enter 2 numbers to do operation
if operation == 1:
x = round((num1 + num2), 2)
return str(x)
if operation == 2:
x = round((num1 - num2), 2)
return str(x)
if... | true |
1916dfb9e0fe6e071f41364a68eade456d4310aa | walterkwon/CWK-Memento-Python | /ep018.py | 2,397 | 4.40625 | 4 | #!/usr/bin/env python3
# Wankyu Choi - Creative Works of Knowledge 2019
# https://www.youtube.com/wankyuchoi
#
#
# Episode 018 - Data Types: Tuple & Set Types
def main():
"""Entry Point"""
print("=" * 10, "Tuple", "=" * 10)
a_list = ['wankyu', 'james', 'fred', 'tom', 'harry']
a_tuple = ('wankyu', 'j... | false |
d95b1bfa19fa52013079f7d63f7794d1c6736d84 | hectorzaragoza/python | /functions.py | 1,985 | 4.1875 | 4 | #functions allow us to put something into it, does something to it, and gives a different output.
#We start with def to define the function, then we name it, VarName()
#def function(input1, input2, input3,...):
# code
# more code
# return value
#result = functionName(In1, In2, In3,...)
#result = value
def addO... | true |
ef58048b8b05de8a3239b61c320f601d02da1daa | manjushachava1/PythonEndeavors | /ListLessThanTen.py | 498 | 4.21875 | 4 | # Program 3
# Take a list and print out the numbers less than 5
# Extras:
# 1. Write program in one line of code
# 2. Ask the user for a number and return a list that contains elements that are smaller than that user number.
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
b = []
c = []
# Extra 1
for element in a:
if... | true |
7f66d0d287df330aaad8d58a3d74308a85171942 | JavaScriptBach/Project-Euler | /004.py | 518 | 4.125 | 4 | #coding=utf-8
"""
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
Find the largest palindrome made from the product of two 3-digit numbers.
"""
def is_palindrome(num):
string = str(num)
for i in range(0, len(string) / 2):
if stri... | true |
592e65372e0cbbbbaaaa50e61b16a4546e6301a5 | pgiardiniere/notes-WhirlwindTourOfPython | /06-scalarTypes.py | 2,782 | 4.53125 | 5 | ### Simple Types in Python ::
# --- Python Scalar Types ---
# ----------------------------------------------
# Type Example Description
# ``````````````````````````````````````````````
# int x = 1 integers
# float x = 1.0 floating point nums
# complex x = 1 + 2j complex n... | true |
6b43604d2d995874639262c7995a22dde3bd5b41 | eshulok/2.-Variables | /main.py | 604 | 4.53125 | 5 | #Variables are like nicknames for values
#You can assign a value to a variable
temperature = 75
#And then use the variable name in your code
print(temperature)
#You can change the value of the variable
temperature = 100
print(temperature)
#You can use variables for operations
temp_today = 85
temp_yesterday = 79
#How... | true |
37499520285d5a5b5b8746d02a4fc06854627f13 | riyaasenthilkumar/riya19 | /factorial.py | 270 | 4.125 | 4 | num=7
num=int(input("Enter a number:"))
factorial=1
if num<0:
print("factorial does not exist for negative number")
elif num==0:
print("the factorial of0 is 1")
else:
for i in range (1,num+1):
factorial=factorial*i
print("the factorial of",num,"is",factorial)
| true |
ccf67c2b2625e3ae6d1acc1e7cca475f8b3e5f67 | Xtreme-89/Python-projects | /main.py | 1,424 | 4.1875 | 4 | <<<<<<< HEAD
is_male = True
is_tall = False
if is_male and is_tall:
print("You are a tall male")
elif is_male and not is_tall:
print("You are a short male")
elif not is_male and is_tall:
print("You are a tall female")
else:
print("You are a short female")
#comparisons
def max_num(num1, num2, num3):
... | true |
3b6c35f55899dbc8819e048fdbdebb065cd01db1 | brunomatt/ProjectEulerNum4 | /ProjectEulerNum4.py | 734 | 4.28125 | 4 | #A palindromic number reads the same both ways.
#The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
#Find the largest palindrome made from the product of two 3-digit numbers.
products = []
palindromes = []
three_digit_nums = range(100,1000)
for k in three_digit_nums:
for j in t... | true |
18187aef39ed5cdb6edad56d8599bc80586d93f8 | TokarAndrii/PythonStuff | /pythonTasks/data_structures/moreOnList.py | 1,760 | 4.71875 | 5 | # https: // docs.python.org/3.0/tutorial/datastructures.html
# list.append(x)
# Add an item to the end of the list
# equivalent to a[len(a):] = [x].
# list.extend(L)
# Extend the list by appending all the items in the given list
# equivalent to a[len(a):] = L.
# list.insert(i, x)
# Insert an item at a given positio... | true |
1f3aaa0e48d787f2b1ec361d800cbc8d4606c7af | wicarte/492 | /a3.py | 845 | 4.125 | 4 | #Assignment 3 (W3D4) - William Carter
#What I think will happen before running the code:
#I think the code prompts the user to enter a number, casts
#the number as an int, counts up by 1 on the interval (2, user
#provided number), and prints whenever the outer loop iterator (i)
#is not cleanly divisible by the inner l... | true |
06e3854ec42cb507701909da375a8e2f6dc62ab7 | Pissuu/6thsempython | /simplecalc.py | 480 | 4.15625 | 4 | print("simple calculator")
print(" enter 1 for *")
print(" enter 2 for /")
print(" enter 3 for +")
print(" enter 4 for -")
choice=int(input())
ans=int
a1=int(input("enter first argument"))
a2=int(input("enter second argument"))
if choice==1:
ans=a1*a2
print("answer is:",ans)
if choice==2:
ans... | false |
1a948637866f58b51f76d1b69c070d67a6a615c8 | nbenkler/CS110_Intro_CS | /HW #5/untitled folder/convertFunctions.py | 955 | 4.15625 | 4 | # Program to read file HW5_Input.txt and convert characters in the file to their unicode, hexadecimal, and binary representations.
#Noam Benkler
#2/12/18
def fileIngest(fileName):
inFile = open(fileName, "r")
return inFile
inFile.close()
def conversionOutput(file):
for line in file:
full = (line)
characte... | true |
590d5ad63a0fcf7f0f27a6352051093acfc9923c | nbenkler/CS110_Intro_CS | /Lab 3/functions.py | 1,026 | 4.4375 | 4 | '''function.py
Blake Howald 9/19/17, modified for Python 3 from original by Jeff Ondich, 25 September 2009
A very brief example of how functions interact with
their callers via parameters and return values.
Before you run this program, try to predict exactly
what output will appear, and in what order.... | true |
78ef5fc28e3f4ae7efc5ed523eeffe246496c403 | alexmkubiak/MIT_IntroCS | /week1/pset1_2.py | 413 | 4.125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu May 24 18:00:03 2018
This code determines how many times the string 'bob' occurs in a string s.
@author: Alex
"""
s = 'azcbobobegghakl'
count = 0
index = 0
for index in s:
if s[index] == 'b':
if s[index + 1] == 'o':
if s[index... | true |
9ecd69b1dc1bd808055cea00eabc82428dc12056 | TheChuey/DevCamp | /range_slices_in_pythonList.py | 982 | 4.3125 | 4 | tags = [
'python',
'development',
'tutorials',
'code',
'programing',
'computer science'
]
#tags_range = tags[:-1:2]
tags_range = tags[::-1] # reverses the oder of the list
# slicing function
print(tags_range)
"""
# Advanced Techniques for Implementing Ranges and Slices in Pyth... | true |
fddd74d8a7cbb7641c3d0bfbfb2ee7901639d7f3 | DyadushkaArchi/python_hw | /Python_hw_20.py | 987 | 4.125 | 4 | import random
#==========================================================================
#task 19
#==========================================================================
#Написать функцию для поиска разницы сумм всех четных и всех нечетных чисел среди
#100 случайно сгенерированных чисел в произвольном числовом ди... | false |
09a4ae07c0b9e3c8d1604bfaea0ce58078d52936 | asim09/Algorithm | /data-types/List/sort-list-of-string.py | 256 | 4.1875 | 4 | # Python Program to sort a list according to the length of the elements
a = ['Apple', 'Ball', 'Cat', 'Ox']
for i in range(len(a)):
for j in range(len(a) - i - 1):
if len(a[j]) > len(a[j+1]):
a[j], a[j+1] = a[j+1], a[j]
print(a[-1])
| true |
234a8bc6f168afac7ab18c566b0a783e5e9080fd | prabalbhandari04/python_ | /labexercise2.py | 312 | 4.28125 | 4 | #Write a program that reads the length of the base and the height of a right-angled triangle and prints the area. Every number is given on a separate line.#
length_of_base = int(input("Enter the lenght of base:"))
height = int(input("Enter the height:"))
area = (1/2)*(length_of_base*height)
print(area) | true |
06fe1661b93a940e28adb9c5fab488df85e19eb8 | ankush-phulia/Lift-MDP-Model | /simulator/Elevator.py | 2,956 | 4.25 | 4 | class Elevator(object):
"""
- state representation of the elevator
"""
def __init__(self, N, K):
self.N = N # number of floors
self.K = K # number of elevators
# initial positions of all elevators
self.pos = [0]*... | true |
608c925a7bb0d43f25cbb24431020093dd0617c4 | FefAzvdo/Python-Training | /Aulas/013.py | 431 | 4.21875 | 4 | # Estruturas de Repetição
# Output: 1, 2, 3, 4, 5
for count in range(1, 6):
print(count)
# Executa 3x
# Output: * * *
for count in range(0, 3):
print("*")
for count in range(0, 11):
if(count % 2 == 0):
print(f"{count} é PAR")
else:
print(f"{count} é ÍMPAR")
for count in range(6, 0, ... | false |
1218eb2a6ac77aecfdef4846500dc1623c58c418 | FefAzvdo/Python-Training | /Exercicios/Aula 10/033.py | 738 | 4.25 | 4 | # Condição de existência de um triângulo
# Para construir um triângulo não podemos utilizar qualquer medida, tem que seguir a condição de existência:
# Para construir um triângulo é necessário que a medida de qualquer um dos lados seja menor que a soma das medidas dos outros dois e maior que o valor absoluto da difere... | false |
1d8df8f0fd6996602088725eaef8fb63429cdf99 | mileshill/HackerRank | /AI/Bot_Building/Bot_Saves_Princess/princess.py | 2,127 | 4.125 | 4 | #!/usr/bin/env python2
"""
Bot Saves Princess:
Mario is located at the center of the grid. Princess Peach is located at one of the four corners. Peach is denoted by 'p' and Mario by 'm'. The goal is to make the proper moves to reach the princess
Input:
First line contains an ODD integer (3<=N<=99) ... | true |
f1d0eed5c88aff33508a9b32e9aaec1a3f962de3 | rahulkumar1m/exercism-python-track | /isogram/isogram.py | 528 | 4.3125 | 4 | def is_isogram(string) -> bool:
# Tokenizing the characters in the string
string = [char for char in string.lower()]
# initializing an empty list of characters present in the string
characters = []
# if a character from string is already present in our list of characters, we return False
for c... | true |
7912b115e12d200e6981cdbe55ca8c3175eba085 | fangbz1986/python_study | /函数式编程/03filter.py | 1,222 | 4.125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
Python内建的filter()函数用于过滤序列。
和map()类似,filter()也接收一个函数和一个序列。和map()不同的是,filter()把传入的函数依次作用于每个元素,然后根据返回值是True还是False决定保留还是丢弃该元素。
filter()的作用是从一个序列中筛出符合条件的元素。由于filter()使用了惰性计算,所以只有在取filter()结果的时候,才会真正筛选并每次返回下一个筛出的元素。
'''
# 例如,在一个list中,删掉偶数,只保留奇数,可以这么写:
def is_odd(n):... | false |
122a3f71dd406d2cea9d838e3fe1260cd0e3adcf | hardlyHacking/cs1 | /static/solutions/labs/gravity/solution/system.py | 2,283 | 4.21875 | 4 | # system.py
# Solution for CS 1 Lab Assignment 3.
# Definition of the System class for gravity simulation.
# A System represents several Body objects.
# Based on code written by Aaron Watanabe and Devin Balkcom.
UNIVERSAL_GRAVITATIONAL_CONSTANT = 6.67384e-11
from math import sqrt
from body import Body
class System:... | true |
490389021ee556bb98c72ae687389445ebb6dcb7 | Andras00P/Python_Exercise_solutions | /31 - Guess_Game.py | 855 | 4.46875 | 4 | ''' Build a simple guessing game where it will continuously ask the user to enter a number between 1 and 10.
If the user's guesses matched, the user will score 10 points, and display the score.
If the user's guess doesn't match, display the generated number.
Also, if the user enters "q" stop the game. ''... | true |
1312a36aee5ceebbb32beedfef010210a5bb19bb | Andras00P/Python_Exercise_solutions | /18 - Calculate_Grades.py | 871 | 4.21875 | 4 | ''' Calculate final grade from five subjects '''
def grades(a, b, c, d, e):
avg_grade = int((a + b + c + d + e) / 5)
f_grade = ""
if avg_grade >= 90:
f_grade = "Grade A"
elif avg_grade >= 80:
f_grade = "Grade B"
elif avg_grade >= 70:
f_grade = "Grade C"
elif... | false |
3607e93c5431e03789f3f980fd2220c4a8dc9b10 | Andras00P/Python_Exercise_solutions | /24 - Reverse_String.py | 443 | 4.375 | 4 | """ Reverse a string.
If the input is: Hello World.
The output should be: .dlroW olleH """
def reverse_string(text):
result = ""
for char in text:
result = char + result
return result
# Shortcut
def reverse_string2(text):
return text[::-1]
usr_text = input("Wri... | true |
a5fd62036f3dd8a6ec226ffae14b48c6c5ab06ca | Andras00P/Python_Exercise_solutions | /21 - Check_Prime.py | 357 | 4.21875 | 4 | ''' For a given number, check whether the number is a prime number or not '''
def is_prime(num):
for i in range(2, num):
if (num % i) == 0:
return False
return True
usr_num = int(input("Enter number: \n"))
if is_prime(usr_num):
print("The number is a Prime")
else:
... | true |
06afe217a85fc98b1689ac6e6119a118fe91f9b5 | garciacastano09/pycourse | /intermediate/exercises/mod_05_iterators_generators_coroutines/exercise.py | 2,627 | 4.125 | 4 | #-*- coding: utf-8 -*-
u'''
MOD 05: Iterators, generators and coroutines
'''
def repeat_items(sequence, num_times=2):
'''Iterate the sequence returning each element repeated several times
>>> list(repeat_items([1, 2, 3]))
[1, 1, 2, 2, 3, 3]
>>> list(repeat_items([1, 2, 3], 3))
[1, 1, 1, 2, 2, 2,... | true |
014e36604daf04ec73c663fe223cd445fcd01ca5 | garciacastano09/pycourse | /advanced/exercises/mod_05_functools/exercise_mod_05.py | 585 | 4.25 | 4 | #!/usr/bin/env python
#-*- coding: utf-8 -*-
u"""
Created on Oct 5, 2013
@author: pablito56
@license: MIT
@contact: pablito56@gmail.com
Module 05 functools exercise
>>> it = power_of(2)
>>> it.next()
1
>>> it.next()
2
>>> it.next()
4
>>> it.next()
8
>>> it.next()
16
>>> it = power_of(3)
>>> it.next()
1
>>>... | true |
c3d462c1e5cd9bb28a67ee54f8f80c03ec14f06a | ACEinfinity7/Determinant2x2 | /deter_lib.py | 792 | 4.125 | 4 | def deter2x2(matrix):
"""
function to calculate the determinant of
the 2x2 matrix.
The determinant of a matrix is defined as
the upper-left element times the lower right element
minus
the upper-right element times the lower left element
"""
result = (matrix[0][0]*matrix[1][1])-(matri... | true |
e354f576673621e8dc851bda02d495a5196f9f7d | mitchellflax/lpsr-samples | /3-6ATkinterExample/remoteControl.py | 464 | 4.28125 | 4 | import turtle
from Tkinter import *
# create the root Tkinter window and a Frame to go in it
root = Tk()
frame = Frame(root, height=100, width=100)
# create our turtle
shawn = turtle.Turtle()
# make some simple buttons
fwd = Button(frame, text='fwd', fg='red', command=lambda: shawn.forward(50))
left = Button(frame, ... | true |
ed15cbf4fd067d8b9c8194d22b795cb55005797f | mitchellflax/lpsr-samples | /ProblemSets/PS5/teamManager.py | 1,525 | 4.3125 | 4 | # a Player on a team has a name, an age, and a number of goals so far this season
class Player(object):
def __init__(self, name, age, goals):
self.name = name
self.age = age
self.goals = goals
def printStats(self):
print("Name: " + self.name)
print("Age: " + str(self.age))
print("Goals: " + str(self.goa... | true |
505b7944e773905bd8b1c5c8be4ce6d9a3b58730 | mitchellflax/lpsr-samples | /4-2WritingFiles/haikuGenerator2.py | 1,548 | 4.3125 | 4 | # haikuGenerator.py
import random
# Ask the user for the lines of the haiku
print('Welcome to the Haiku generator!')
print('Would you like to write your haiku from scratch or get a randomized first line?')
print('(1) I\'ll write it from scratch')
print('(2) Start me with a random line')
user_choice = int(raw_input()... | true |
7e13745a73f6d77bbebcc267c0d4481ba6a86d3a | mitchellflax/lpsr-samples | /3-4FunctionsInTurtle/samplePatternTemplate.py | 495 | 4.25 | 4 | # samplePattern.py
import turtle
# myTurtle is a Turtle object
# side is the length of a side in points
def makeTriangle(myTurtle, side):
pass
# make our turtle
kipp = turtle.Turtle()
kipp.forward(150)
kipp.right(180)
# kipp makes triangles centered at a point that shifts
# and decreases in size with each loop
len... | true |
f9f2cbd0408139865c1cb412a80c1d60b5cc038c | Brian-Musembi/ICS3U-Unit6-04-Python | /array_average.py | 1,839 | 4.1875 | 4 | #!/usr/bin/env python3
# Created by Brian Musembi
# Created on June 2021
# This program prints a 2D array and finds the average of all the numbers
import random
def average_2D(list_2D):
# This function finds the average
total = 0
rows = len(list_2D)
columns = len(list_2D[0])
for row_value in l... | true |
c054b2383fd5b7d7a042d69673d2708aef9be0b1 | coreman14/Python-From-java | /CPRG251/Assignment 6/Movie.py | 2,090 | 4.40625 | 4 | class Movie():
def __init__(self, mins:int, name:str, year:int):
"""Creates an object and assign the respective args
Args:
mins (int): Length of the movie
name (str): Name of the movie
year (int): Year the movie was released
"""
self.mins... | true |
34d705727c44475ce5c1411558760a01969ef75b | Syvacus/python_programming_project | /Session number 2.py | 2,246 | 4.1875 | 4 | # Question 1
# Problem: '15151515' is printed because the chairs variable is text instead of a number
# Solution: Convert the chairs variable from text to number
chairs = '15' # <- this is a string (text) rather than an int (number)
nails = 4
total_nails = int(chairs) * nails # <- convert string to int by wrapping... | true |
acab7dba850041e5b5283d1a661a00a76b17a8c1 | NapsterZ4/python_basic_course | /tuplas.py | 492 | 4.1875 | 4 | # listas que no pueden modificarse
a = (1, 4, 5.6, "Juan", 6, "Maria")
b = ["Jorge", 5, "Peru", 90]
tup2 = 34, "Javier", 9.6, "Murillo"
c = tuple(b) # Convirtiendo la lista en tupla
d = list(a) # Conviertiendo la tupla en una lista
print(tup2)
print(a)
print(c) # Resultado de la lista convertida en tupla
print(d)... | false |
95d7dd2afe45d705d1bbb3884245e1258651f0c0 | DHANI4/NUMBER-GUESSING-GAME | /NumberGuessing.py | 443 | 4.28125 | 4 | import random
print("Number Guessing Game")
rand=random.randint(1,20)
print("Guess a Number between 1-20")
chances=0
while(chances<5):
chances=chances+1
guess=int(input("Enter Your Guess"))
if(guess==rand):
print("Congratulations You Won!!")
break
elif(guess<rand):
p... | true |
949b939ef934fb793119900d36b377d7069c1916 | vivianlorenaortiz/holbertonschool-higher_level_programming | /0x07-python-test_driven_development/4-print_square.py | 345 | 4.3125 | 4 | #!/usr/bin/python3
"""
Funtion that prints a square with the character #.
"""
def print_square(size):
"""
Function print square.
"""
if type(size) is not int:
raise TypeError("size must be an integer")
elif size < 0:
raise ValueError("size must be >= 0")
for i in range(size):
... | true |
809e7e3a4be9be995241c67909ae61fc5796d98d | drummerevans/Vector_Multiply | /cross_input.py | 564 | 4.125 | 4 | import numpy as np
items = []
max = 3
while len(items) < max:
item = input("Add an element to the list: ")
items.append(int(item))
print("The length of the list is now increased to {:d}." .format(len(items)))
print(items)
things = []
values = 3
for i in range(0, values):
thing = input("Add an eleme... | true |
44a4dda12809ebd8ba6e3c6c52c96e130a0fa7e1 | PrateekMinhas/Python | /assignment14.py | 1,555 | 4.4375 | 4 | Q.1- Write a python program to print the cube of each value of a list using list comprehension.
lst=[1,2,3,4,5]
lstc=[i**3 for i in lst]
print(lstc)
#Q.2- Write a python program to get all the prime numbers in a specific range using list comprehension.
lst_pr= [ i for i in range(2,int(input("Enter the end input of th... | true |
cc1aa3c2ec38ffc869b942af0491d3c44baf9ba1 | PrateekMinhas/Python | /assignment3.py | 2,048 | 4.25 | 4 |
#Q.1- Create a list with user defined inputs.
ls=[]
x=int(input("enter the number of elements"))
for i in range (x):
m=input()
ls.append(m)
print (ls)
#Q.2- Add the following list to above created list:
#[‘google’,’apple’,’facebook’,’microsoft’,’tesla’]
ls1=['google','apple','facebook','micr... | true |
cef5dd3e9ca6fe8f9ce33b6e4f8aca9e35f368f4 | 0xch25/Data-Structures | /2.Arrays/Problems/Running sum of 1D Array.py | 497 | 4.21875 | 4 | '''Given an array nums. We define a running sum of an array as runningSum[i] = sum(nums[0]…nums[i]).
Return the running sum of nums.
Example 1:
Input: nums = [1,2,3,4]
Output: [1,3,6,10]
Explanation: Running sum is obtained as follows: [1, 1+2, 1+2+3, 1+2+3+4]'''
def runningSum(nums):
sum =0
for i in range(len(... | true |
7816262c0cda16be8c7d255780fba2c1203905a8 | 0xch25/Data-Structures | /3.Stacks/Palindrome using Stacks.py | 544 | 4.15625 | 4 | '''Program to check weather the given string is palindrome or not'''
class Stack:
def __init__(self):
self.items = []
def push(self, data):
self.items.append(data)
def pop(self):
return self.items.pop()
def is_empty(self):
return self.items == []
s = Stack()
str= inp... | true |
e70a83469f49d7f0dcb0ce94f8621e1b8b032836 | 0xch25/Data-Structures | /10.Strings/Problems/Shuffle String.py | 776 | 4.1875 | 4 | '''
Given a string s and an integer array indices of the same length.
The string s will be shuffled such that the character at the ith position moves to indices[i] in the shuffled string.
Return the shuffled string.
Example 1:
Input: s = "codeleet", indices = [4,5,6,7,0,2,1,3]
Output: "leetcode"
Explanation: As shown, ... | true |
4f45c92ee32651269b186c7ac51ce7897ed1ab1c | memuller/bunnyscript | /Python/14-lists-index.py | 473 | 4.125 | 4 | # -*- coding: utf-8 -*-
'''
Faça um programa exatamente como o anterior,
mas que possua um for no qual a variável de controle represente o índice
de cada elemento, ao invés de o elemento em si.
for i blabla:
#aqui i deve ser o índice de cada elemento
'''
# len(lista)
# retorna a quantidade de elementos de uma li... | false |
e30453364c48bdf2673d717cbd4ec9e06eca6581 | memuller/bunnyscript | /Python/17-list-duplicates.py | 892 | 4.125 | 4 | # -*- coding: utf-8 -*-
'''
Escreva um programa que leia palavras fornecidas pelo usuário.
Caso a palavra não tenha sido fornecida anteriormente, a adicionamos em uma lista.
Paramos de ler palavras quando o usuário não inserir nenhuma.
Ao final do programa, imprimimos a lista das palavras não-repetidas inseridas.
'''... | false |
355a3568f845a02c8c3af90bf627ea2a207d7b84 | ndri/challenges | /old/33.py | 1,139 | 4.125 | 4 | #!/usr/bin/env python
# 33 - Area Calculator
import sys
try:
shape, args = sys.argv[1], ' '.join(sys.argv[2:])
except:
sys.exit('Error. Use -h for help.')
if shape == '-h':
print 'Challenge 33 - Area Calculator'
print '-h\t\t\tDisplay this help'
print '-r width height\t\tArea for a rectangle'
... | true |
e416d465ae64dad5353d431d099ff1fab5e801cf | CodingPirates/taarnby-python | /uge1/5_lister.py | 2,203 | 4.125 | 4 | #coding=utf8
# Når vores programmer bliver lidt mere komplicerede får vi rigtig mange variable
# Det gør at de bliver mere og mere besværlige at læse
# Nogle gange så hænger flere af de variable sammen
# Så kan vi prøve at lave dem om til en enkelt variabel som gemmer på mere end én ting ad gangen
# Den mest simple he... | false |
42096d931802f6a0edcfa5702f2a91d0bbba2cd5 | LaloGarcia91/CrackingTheCodingInterview | /Chapter_1/CheckPermutation.py | 775 | 4.125 | 4 | class CheckPermutation:
def __init__(self, str1, str2):
self.checkIfIsPermutation(str1, str2)
def checkIfIsPermutation(self, str1, str2):
str1_len = len(str1)
str2_len = len(str2)
if str1_len == str2_len:
counterIfEqualLetters = 0
for str1_letter in str... | true |
cfaef8bea20c252652c22f58e5c0b569b46312e4 | miawich/repository_mia | /Notes/NotesB/05_sorting_miawich.py | 2,149 | 4.21875 | 4 | # sorting
import random
import time
# swapping values
a = 1
b = 2
temp = a
a = b
b = temp
print(a, b)
# pythonic way
a, b = b, a # works only in python
# selection sort
my_list = [random.randrange(1, 100) for x in range(100)]
my_list_2 = my_list[:]
my_list_3 = my_list[:]
print(my_list)
print()
for cur_pos in ra... | false |
13550a3bd2b683327b96a2676f5d006b69353b73 | AndreiBratkovski/CodeFights-Solutions | /Arcade/Intro/Smooth Sailing/isLucky.py | 614 | 4.21875 | 4 | """
Ticket numbers usually consist of an even number of digits. A ticket number is considered lucky if the sum of the first half of the digits is equal to the sum of the second half.
Given a ticket number n, determine if it's lucky or not.
Example
For n = 1230, the output should be
isLucky(n) = true;
For n = 239017,... | true |
27f090cb703d12372205b7308efe17f5e0a73980 | AndreiBratkovski/CodeFights-Solutions | /Arcade/Intro/Smooth Sailing/commonCharacterCount.py | 718 | 4.34375 | 4 | """
Given two strings, find the number of common characters between them.
Example
For s1 = "aabcc" and s2 = "adcaa", the output should be
commonCharacterCount(s1, s2) = 3.
Strings have 3 common characters - 2 "a"s and 1 "c".
"""
def commonCharacterCount(s1, s2):
global_count = 0
char_count1 = 0
... | true |
b7315bf9114c641c1b3493ffef65109da2dc9046 | Surenu1248/Python3 | /eighth.py | 434 | 4.15625 | 4 | # Repeat program 7 with Tuples (Take example from Tutorial)
tpl1 = (10,20,30,40,50,60,70,80,90,100,110)
tpl2 = (11,22,33,44,55,66,77,88,99)
# Printing all Elements.....
print("List Elements are: ", tpl1)
# Slicing Operations.....
print("Slicing Operation: ", tpl1[3:6])
# Repetition.....
print("Repetition of list f... | true |
54d2387d255062fe1e739f7defeb0cff1f9cf634 | Surenu1248/Python3 | /third.py | 233 | 4.375 | 4 | # Write a program to find given number is odd or Even
def even_or_odd(a):
if a % 2 == 0:
print(a, " is Even Number.....")
else:
print(a, " is Odd Number.....")
print(even_or_odd(10))
print(even_or_odd(5))
| false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.