text stringlengths 37 1.41M |
|---|
#!/usr/bin/env python3
#Script to create a while loop to calculate the factorail of 1000
count = 1
total = 1
while count < 10001:
count+=1
total = total*count
print(total)
print('done')
|
#!/usr/bin/env python3
#Script to interate through a list
nums = [101,2,15,22,95,33,2,27,72,15,52]
odd = 0
even = 0
for num in nums:
if num%2 == 0:
even+=num
else:
odd+=num
print(odd)
print(even)
|
from collections import namedtuple
from bs4 import BeautifulSoup
import requests
PACKT = "https://bites-data.s3.us-east-2.amazonaws.com/packt.html"
CONTENT = requests.get(PACKT).text
Book = namedtuple("Book", "title description image link")
def get_book():
"""make a Soup object, parse the relevant html section... |
from itertools import combinations
def find_number_pairs(numbers, N=10):
return [pair for pair in combinations(numbers, 2) if sum(pair) == N]
|
from functools import reduce
from typing import List, Union
def join_lists(lst_of_lst: List[List[str]], sep: str) -> Union[List[str], None]:
if not lst_of_lst:
return None
return reduce(lambda x, y: x + [sep] + y, lst_of_lst) |
class MungeManager(object):
def __init__(self, obj):
self.obj = obj
self.operations = []
def add_op(self, op):
self.operations.append(op)
def exit(self):
print(self.operations)
class MungeOp(object):
def __init__(self, manager, op_name, top_level=True):
self.ma... |
"""
Utility functions for parsing URLSs.
"""
import re
def domain_name(absolute_url):
"""
takes an absolute url, such as https://youtube.com/hithere
and returns https://youtube.com
"""
protocol = https_or_http(absolute_url)
if protocol is None:
return None
else:
end = absol... |
#Red Black Tree
#A large chunk of this code was stolen because the goal wasn't to reinvent
#Red Black trees but to get a better understanding of it. So its still a
#Work in progress.
class Node():
def __init__(self, arg0, parent=None, left=None, right=None):
self.red=True
self.value=arg0
self.parent=pa... |
#Problem 34
#145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.
#
#Find the sum of all numbers which are equal to the sum of the factorial of their digits.
#
#Note: as 1! = 1 and 2! = 2 are not sums they are not included.
#
import sys
sys.path.append("../SupportFunctions/")
import EulerSupport
import math
... |
#If we take 47, reverse and add, 47 + 74 = 121, which is palindromic.
#
#Not all numbers produce palindromes so quickly. For example,
#
#349 + 943 = 1292,
#1292 + 2921 = 4213
#4213 + 3124 = 7337
#
#That is, 349 took three iterations to arrive at a palindrome.
#
#Although no one has proved it yet, it is thought that som... |
import numpy
import matplotlib
from matplotlib import pyplot
def linear_convection():
# density
# dt - czas
# u - prędkość w kierunku x
x = 2
nodes = 101
dx = x / (nodes - 1)
timesteps = 700
dt = 0.001
c = 4 # wave speed
u = numpy.ones(nodes)
u[int(0.5/dx):int(1/dx+1)] = 2... |
def check_if_nice(line):
if sum(1 for c in line if c in 'aeiou') < 3:
return 0
if all(line[x] != line[x - 1] for x in range(1, len(line))):
return 0
if any(x in line for x in ['ab', 'cd', 'pq', 'xy']):
return 0
return 1
with open("aoc5.txt") as f:
print((sum(check_if_nice(li... |
def converter(tipe_weight, value_coin):
weight=float(input(f"enter to {tipe_weight} to convert "))
tipe_weight+=str(round(weight/value_coin))
print(f"you have $ { tipe_weight } ")
def converter1(type_coin, value_coin1):
weight=float(input(f"enter type coint {type_coin} to convert "))
type_coin ... |
'''Cinco miembros de un club contra la obesidad desean saber cuanto han
bajado o subido de peso desde la última vez que se reunieron. Para esto se
debe realizar un ritual de pesaje en donde cada uno se pesa en diez
básculas distintas para así tener el pormedio mas exacto de su peso. Si
existe diferencia positiva en... |
from ann import ANN
from utils import plot_curve
import time
import numpy as np
import pandas as pd
# Scikit-Learning only used for datasets and data preparation
from sklearn import datasets
from sklearn.utils import shuffle
from sklearn.model_selection import train_test_split
def iris_gradient_test():
# Gradi... |
def main():
my_list = ['a', [1, 2, 3], 'z']
print(my_list[0])
print(my_list[1])
print(my_list[1][1])
print()
print([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18][15])
print()
myList = list('xyzabc')
print(myList)
myList.sort()
print(myList)
print()
fr... |
# Aligning columns:
numbers = [1, 19, 1234, 4560, -25]
for number in numbers:
print("Number is {:<5,.1f}".format(number)) |
# Program 1
name = input("Please enter your name: " )
out_file = open("name.txt", "w")
out_file.write(name)
out_file.close()
# Program 2
in_file = open("name.txt", "r")
name = in_file.read()
print("Your name is", name)
in_file.close()
# Program 3
in_file = open("numbers.txt", "r")
first_num = int(in_file.readline... |
"""
This program takes a picture and encodes a message in the blue channel of the RGB color space. Blue was chosen specifically because studies have shown that the human eye is least sensitive to blue light, which allows slight changes to the blue channel to go completely undetected.
Works with jpg, png that don't hav... |
number = input("Bir sayı giriniz: ")
total= 0
for i in number :
x = int(i)
total += x*x*x
if total == int(number) :
print("It is an armstrong number")
else :
print("It is not an armstrong number")
|
#Input two number and calculate their remainder
x=int(input("Enter the first number"))
y=int(input("Enter the second number"))
z=x%y
print(z)
|
#calculate simple intrest
P=int(input("Enter the principal"))
R=int(input("Enter the rate"))
T=int(input("Enter the Time"))
SI=(P*R*T/100)
print("Simple Intrest=",SI)
|
#Average of four numbers
w=int(input("Enter the first number"))
x=int(input("Enter the second number"))
y=int(input("Enter the third number"))
z=int(input("Enter the fourth number"))
a=((w+x+y+z)/4)
print(a)
|
puan=0
bir = input("Türkiye'nin başkenti nedir? ")
if bir == "Ankara":
puan+=10
print("Doğru cevap!")
else:
print("Yanlış cevap!")
iki = input("En büyük uydusu olan gezegen nedir? ")
if iki == "Jüpiter":
puan+=10
print("Doğru cevap!")
else:
print("Yanlış cevap!")
üç = input("Hava sıcaklığını ölçen cihaz ... |
print("Taschenrechner")
zahl1 = input("Bitte geben Sie die erste Zahl ein: ")
zahl2 = input("Bitte geben Sie die zweite Zahl ein: ")
operation = input("+ oder - oder * oder / rechnen? ")
if (operation == "/" and zahl2 == "0"):
print("Rechnen mit 0 ist nicht möglich",)
exit()
if (operation... |
'''
From a given list of numbers, only the first and last numbers can be chosen
at a given point in time. There are two players 'A' & 'B'. They get to pick
up the numbers in turn. Player 'A' starts first. Pick a winning sequence of
numbers for 'A' and 'B' so that 'A' wins always, no matter how well 'B' plays.
... |
#hello world function returning string
def hello_world():
return ('Hello, World!')
name ="Pati"
#hello name
def hello(name):
return('Hello ' + name +"!")
if len(name)>0:
hello(name)
else:
hello_world()
#print hello
def print_hello(name):
print(hello(name))
print_hello(name)
#t... |
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
res = ""
def tree2str(self, root: Optional[TreeNode]) -> str:
def pre_traverse(root):
... |
# Definition for singly-linked list.
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
class Solution(object):
def partition(self, head: ListNode, x):
"""
:type head: ListNode
:type x: int
:rtype: ListNode
"""
less_head... |
from collections import deque
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def maxLevelSum(self, root: Optional[TreeNode]) -> int:
q = deque([r... |
"""
# Definition for a Node.
class Node:
def __init__(self, val = 0, neighbors = None):
self.val = val
self.neighbors = neighbors if neighbors is not None else []
"""
class Node:
def __init__(self, val = 0, neighbors = None):
self.val = val
self.neighbors = neighbors if neighbo... |
# The key idea is to align the length of two Linked node list.
# Then traverse the list to find the intersection.
# Definition for singly-linked list.
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
def LenListNode(head: ListNode) -> int:
n = 0
while head:
... |
from collections import Counter
from typing import List
class Solution:
def canBeEqual(self, target: List[int], arr: List[int]) -> bool:
s_t, s_a = Counter(target), Counter(arr)
if s_t != s_a:
return False
return True
if __name__ == "__main__":
sol = Solution()
targe... |
class Solution:
def isValid(self, s: str) -> bool:
if len(s) % 2 == 1:
return False
stack = []
pairs = {')': '(', ']': '[', '}': '{'}
for i in range(len(s)):
if s[i] in '([{':
stack.append(s[i])
else:
if len(stack) ... |
# shouldn't be i+1, actually, i and i+n also can count 1
# class Solution:
# def winnerOfGame(self, colors: str) -> bool:
# l = len(colors)
# i = 1
# num_A, num_B = 0, 0
# while i < l-1:
# if colors[i] == 'A' and colors[i+1] == 'A' and i+1 != l-1:
# num_A ... |
# class Solution:
# def largestMerge(self, word1: str, word2: str) -> str:
# res = ""
# i, j, l_i, l_j = 0, 0, 0, 0
# while i + l_i < len(word1) and j + l_j < len(word2):
# if word1[i+l_i] < word2[j+l_j]:
# res += word2[j:j+l_j+1]
# j += l_j + 1
# ... |
import pygame
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
BLUE = (0, 0, 255)
GREEN = (0, 255, 0)
RED = (255, 0, 0)
PURPLE = (255, 0, 255)
class Wall(pygame.sprite.Sprite):
"""This class represents the bar at the bottom that the player controls """
def __init__(self, x, y, width, height, color):
... |
import sys
import json
"""
Usage: ipython frequency.py <tweet_file>
"""
def read_tweets(tweet_file):
tweets = []
for line in open(tweet_file):
try:
tweets.append(json.loads(line).get('text',''))
except:
pass
return tweets
def getwords(tweets):
words = []
for tw... |
letter='''Dear, <|NAME|>
you have been selected!
date<|DATE|>
'''
name=input("enter your name")
date=input("enter date")
letter=letter.replace("<|NAME|>",name)
letter=letter.replace("<|DATE>",date)
print(letter)
|
"""
REFERENCE
Hospital::equipmentLevel information
0 = Transport arranged for people
1 = Transport arranged for people
2 = Transport arranged for people
3 = Transport arranged for people
4 = Transport arranged for people
5 = Transport arranged for people
"""
"""
class Solution(object):
def __init__(self, location,... |
class LinkedList:
def __init__(self,content):
self.content = content
self.next = None
def __str__(self):
current = self
result = []
while current != None:
result.append(str(current.content))
current = current.next
return "=>".join(result)
|
s = input("Please enter a sentence: ")
cap = []
out = []
for word in s.split():
if word.islower():
out.append(word)
else:
cap.append(word)
onelist = withcap + without
for word in onelist:
print (word)
uin = input("Enter your text: ")
## hold lower case/upper case words
up_words = []
no_u... |
n=input( )
m=input( )
a=len( n)+len( m)
#print( a)
for i in range( 0,a):
print( m[i],end="")
print( n[i])
|
# sound = 'blee'
# if sound != 'blee':
# print("What sound are you making?")
# else:
# print("What a weird sound!")
# number = 7
# if number == 7:
# print("This is your lucky number.")
# else:
# print("Wrong number.")
# number1 = 3
# number2 = 7
# print(number1 >= 4 or number2 > 7)
guitars = ['acoustic', 'elec... |
class Restaurant:
"""A simple attempt to model a restaurant."""
def __init__(self, restaurant_name, cuisine_type):
self.restaurant_name = restaurant_name
self.cuisine_type = cuisine_type
self.number_served = 0
def describe_restaurant(self):
print(f"{self.restaurant_name} is a {self.cuisine_type} restaurant... |
def show_contents(filename):
"""Show the contents of a file."""
try:
with open(filename) as f:
contents = f.read()
except FileNotFoundError:
# print(f"Sorry, the file {filename} does not exist.")
pass
else:
# Show the contents of the file.
print(contents)
filenames = ['cats.txt', 'dogs.txt']
for filen... |
cubes = []
for value in range(1, 11):
cubes.append(value**3)
print(cubes)
# list comprehension
cubes = [value**3 for value in range(1, 11)]
print(cubes)
print("The first three items in the list are:")
print(cubes[:3])
print("Three items from the middle of the list are:")
print(cubes[4:7])
print("The last three i... |
age = 12
if age < 4:
print("Your admission cost is $0.")
#previous test failed so it evaluates another "if" test here
elif age < 18:
print("Your admission cost is $25.")
else:
print("Your admission cost is $40.")
age = 12
if age < 4:
price = 0
elif age < 18:
price = 25
elif age < 65:
price = 40
elif age >= 65:... |
import pizza
pizza.make_pizza(16, 'pepperoni') #syntax = module_name.function_name()
pizza.make_pizza(12, 'mushrooms', 'green peppers', 'extra cheese')
# This syntax will import a specific function from a module:
# from module_name import function_name
from pizza import make_pizza
# Since the function was explicity... |
for value in range(1, 6):
print(value)
for value in range(6):
print(value)
numbers = list(range(1, 6))
print(numbers)
even_numbers = list(range(2, 11, 2))
print(even_numbers)
for value in range(1, 21):
print(value)
|
# Enter your code here. Read input from STDIN. Print output to STDOUT
for _ in range (int (input())) :
w = input();
print(w[::2], w[1::2])
|
ip=input("Enter your seqence (Mod/Dividee):")
op=['%','/']
for x in ip:
if x in op:
if(x=='%'):
k1=int(ip.split(x)[0])
k2=int(ip.split(x)[1])
ans=k1%k2
elif(x=='/'):
k1=int(ip.split(x)[0])
k2=int(ip.split(x)[1])
ans=k1//k2
print(ans)
|
st=input("Enter the string")
st2=input("Enter the character:")
i=0
for x in st:
i+=1
if x==st2:
break
print(i)
|
str=raw_input('Enter your string \n')
str1=list(str)
if (str1[0].isdigit()):
print '\n The string start with digit '
else:
print '\n The string is not start with digit'
|
ip=input("Enter any String:")
a=[]
flag=0
for x in ip:
if x not in a:
a.append(x)
else:
flag=1
if(flag==1):
print("No")
else:
print("Yes")
|
n=int(input("Enter Any value:"))
flag=0
for x in range(2,n):
if n%x==0:
flag=1
break
if flag==1:
print("Yes")
else:
print("No")
|
n=int(input("Enter N value:"))
k=int(input("Enter K value:"))
print("Enter your array:")
a=[]
for x in range(n):
m=int(input())
a.append(m)
if k in a:
print("Yes")
else:
print("No")
|
str=raw_input('Enter your line: \n')
c=0
for x in str:
if (x.isalpha()) or (x.isdigit()):
c=c+1
print 'The total numeric character in the string is:',c
|
st=list(input().strip())
ans=""
for x in range(len(st)-1):
if st[x]==" " and st[x+1]==" ":
st[x]=""
for x in st:
ans+=x
print(ans)
|
st=raw_input('Enter any string \n')
str=list(st.split())
str.reverse()
print 'Reverse word is',' '.join(str)
|
st=input("Enter the string")
k=int(input("Enter k value"))
ans=''
for x in range(0,k):
ans=ans+st[x]
print(ans)
|
n=int(input())
a=input().strip().split(" ")
ans=1
for x in a:
ans*=int(x)
if ans%2==0:
print("even")
else:
print("odd")
|
n=int(input('how many elemnts?\n'))
print 'Enter the elements:\n'
s=[]
for x in range(0,n):
num=int(input())
s.append(num)
k=int(input('Enter k value:\n'))
for x in range(0,k):
t=s[n-1]
for y in range(n-1,0,-1):
s[y]=s[y-1]
s[0]=t
print s
|
n=int(input("How many elements??"))
a=[]
b=[]
for x in range(n):
a.append(int(input()))
for x in range(0,n):
if x+1 not in a:
b.append(x+1)
for y in b:
for x in range(0,n):
if a[x]!=x+1:
a[x]=y
break
print(a)
|
n=int(input("Enter the N value:"))
q=int(input("Enter the Q value:"))
a=[]
b=[]
print("Enter the Elelments:")
for x in range(n):
p=int(input())
a.append(p)
for y in range(q):
l=int(input("L value:"))
r=int(input("R value:"))
b=sorted(a)
for x in b:
if l%x==0 and r%x==0:
... |
st=input("Enter the your line")
c=0
for x in st:
if x==" ":
c=c+1
print("space is:",c)
|
n=int(input('Enter the number'))
sum=0
for x in range(1,n+1):
sum=sum+x
print 'The sum from 1 to',n,'is:',sum
|
str=raw_input('Enter your line: \n')
c=0
d=1
sym=",./<>?;':[]{}+_=-)(*&^%$#@!~`)"
for x in str:
if (x.isalpha()) or (x.isdigit()) or (x in sym):
c=c+1
else:
d=d+1
print 'The total word in the string is:',d
|
x=int(input("Enter your 1st number"))
y=int(input("Enter ur 2nd number"))
if x > y:
greater = x
else:
greater = y
c=0
while (c==0):
if (greater%x==0) and (greater%y==0):
lcm=greater
break
greater=greater+1
print "The LCM of",x,"and",y,"is:",lcm
|
n1=input("Enter Your 1st Number:")
n2=input("Enter your 2nd Number:")
print(n1+n2)
|
str=raw_input('Enter any string:\n')
s=[]
st=list(str)
st.sort()
for x in st:
if x not in s:
s.append(x)
for x in s:
print x,
|
num1=int(input('Enter the binary:\n'))
num=[int(i) for i in str(num1)]
s=len(num)
st=[]
sum=0
for x in num:
a=1
for y in range(0,s-1):
if(x==1):
a=a*2
if(x==1):
st.append(a)
s=s-1
for x in st:
sum=sum+x
print 'Decimal equlant is',sum
|
num1=int(input('Enter your 1st number'))
num2=int(input('Enter your 2nd number'))
print 'Befor swapping: \n',num1,num2
print 'After swapping:\n'
num1=num1^num2
num2=num1^num2
num1=num1^num2
print num1,num2
|
class Soldier:
def __init__(self, name, lastname):
self.name = name
self.lastname = lastname
def __str__(self):
return f'Солдат {self.name} {self.lastname}'
class Guns:
def __init__(self):
self.bullets = 40
def bullets_left(self):
print(f'осталось патр... |
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
# Copyright (C) 2020 dvolkov
class Stack:
"""
Stack Data Structure. Last In First Out (LIFO)
"""
def __init__(self):
self.items = []
def push(self, item):
self.items.append(item)
def pop(self):
return self.items.pop() if... |
#CTI 110
#P3LAB - DEBUGGING
#Smith
#June 22, 2018
#
def main():
# This program takes a number grade and outputs a letter grade.
# system uses 10-point grading scale
# TO DO: define the rest of the scores
score = float(input('Enter grade: ')) #define variables
Asc = 90
Bsc = ... |
#CTI-110
#P2HW2 - Tip Tax Total
#Stephon Smith
#June 13, 2018
#
fct = float(input("How much was your food? ")) #Food cost
tat = fct * .18 #Tip ammount
stx = fct * .07 #Sales tax
print("Tip ammount is ", tat)
#print("Tip ammount is ",format( tat,... |
#CTI-110
#P5T1 - Kilometer converter
#Stephon Smith
#July 3, 2018
#
conversion_factor = 0.6214
def main ():
#get the distance in Kilometers.
kilometers = float(input("Enter a distance in Kilometers: "))
#Display the distance converted to Miles.
show_miles (kilometers)
#convert k... |
"""
Provides utility functions to query prometheus API to get metric data
"""
__author__ = 'Vasudev Bongale"
import requests
import json
QUERY_URL = 'http://localhost:9090/api/v1/query'
QUERY_RANGE_URL = 'http://localhost:9090/api/v1/query_range'
def run_query(prom_query):
"""
Get the response of a simple... |
# printMatrix(m) takes a 2D matrix or nested list as parameter and prints out
# the elements in the matrix by its row and columns
# printMatrix([[1,2,3],[4,5,6],[7,8,9]])
# 1 2 3
# 4 5 6
# 7 8 9
def printMatrix(m):
for r in range(len(m)):
for c in range(len(m)):
print(m[r][c], end=' ')
... |
# returns the first name in list
# firstNames(['Christian, Salas']
# returns (['Salas'])
def firstNames(lst):
l = []
for name in lst:
l.append(name.split(',')[1])
return l |
# guess(n) that simulates a number guesing game. It first generates a random numer
# between 1 and (n), then repeatedly prompts the user to enter the number guessed by the
# user, until the user enters the correct number.
# If the number entered by the user is larger than the randomly generated number
# It displays 'Th... |
# safeOpen() that opens a file and handles the exception when the file doesn't exists
# It returns the file object returned from opening the file or nothing when
# such exception occurs.
def safeOpen(fname):
try:
return open(fname, 'r')
except FileNotFoundError:
pass
|
# Implement a function product(l) that takes a list l as parameter and multiplies all the numbers
# in l, and returns the product of the multiplication
def product(l):
result = 1
for num in l:
result = result * num
print(result)
# Write a function that concatenates all #s in a string to 1 string
d... |
def average_of_three(num1, num2, num3):
sum = num1 + num2 + num3
average = sum / 3.0
return average
print(average_of_three(3, 7, 8)) # => 6.0
print(average_of_three(2, 5, 17)) # => 8.0
print(average_of_three(2, 8, 1)) # => 3.666666 |
#encoding:UTF-8
#Autor: Carlos E. Carbajal Nogus
#Descripcion: programa que calcula los pagos de un trabajador
#Inicio
def calcularPago_normal(horasNormales,pagoHora): #Función que calcula los pagos por horas de trabajo normales
res1= horasNormales*pagoHora
return res1
def calcularPago_extra(horasExtra,pagoHor... |
#!/usr/bin/env python3
print("Welcome to the Voter Registration App")
# Get user input
name = input("\nPlease enter your name: ").title().strip()
age = int(input("Please enter your age: "))
# List of parties
parties = ['Democratic', 'Republican', 'Independent', 'Libertarian', 'Green']
# Verify user age
if age > ... |
# This program will convert miles per hour to meters per second and kilometer per hour
# Welcome message
print("Welcome to the mileage converter App")
# Get user input
miles_per_hour = float(input("What is your speed in miles per hour: "))
# Meters Conversion calculation
miles_per_second = miles_per_hour * 0.4474
mi... |
# This program will convert given temperatures to different measuring units
print("\nWelcome to the Temperature Conversion App")
temp_f = float(input("What is the temperature in Fahrenheit: "))
# Temperature Conversions
temp_c = (5/9) * (temp_f - 32)
temp_k = temp_c + 273.15
# Round Temperatures to 2 decimal places... |
fibonacci = lambda x : 0 if x == 0 else 1 if 0 < x <= 2 else fibonacci(x - 1) + fibonacci(x - 2)
print(fibonacci(20))
|
#list-3
L=[0,2,10,40,50]
a=L[3]
print(a)
x=L[0:4]
print(x)
L1=[1,2,3]
L2=[4,5,6]
l=L1+L2
print(l)
|
'''
This file:
provide basic functions for other files
'''
import pandas as pd
import jieba
from collections import Counter
import numpy as np
import math
import config
PUNCTUATION = config.PUNCTUATION
VERBAL = config.VERBAL # token for [语音]
EMPTY = config.EMPTY # token for nan
PIC = config.PIC #token for [图片]
S... |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Jul 1 16:06:33 2017
@author: amit
"""
class Solution(object):
def lengthOfLongestSubstring(self, s):
"""
:type s: str
:rtype: int
"""
def map(s):
op = ''
for word in s:
... |
# great_directors = ["Martin Scorsese", "Steven Spielberg", "Francis Ford Coppola"]
# great_directors[1]="Michael Bay"
# print(great_directors)
# # Given the transformers list below, overwrite “Bumblebee” with “Grimlock”.
# transformers = ["Optimus Prime", "Megatron", "Bumblebee", "Starscream"]
# transformers[2]="Griml... |
# def greeting():
# return "HI Python"
#
# print(greeting())
#####
#leap year\
# month_days=[0,31,28,31,30,31,30,31,31,30,31,30,31]
# def is_leap(year):
# return year%4==0 and (year%100!=0 & year%400==0 )
#
# def days_in_month(year,month):
# if not 1<= month <=12:
# return "invalid month"
# if... |
# import logging
# logging.basicConfig(filename="Mylog.log",level="DEBUG")
# try:
# logging.info("The code might have exception")
# sum=10/0
#
# except ZeroDivisionError as ze:
# print("exception caught",ze)
# logging.warning("Code came across exception")
# except ArithmeticError as ar:
# print("if ... |
user_uttr = input("ユーザー発話> ")
if user_uttr == "何時":
print("条件は成り立ちます。")
else:
print("条件は成り立ちません。")
|
# while.py - 繰り返しのプログラム
utterance = input("ユーザ発話> ")
while utterance == "はい":
print("条件が成り立ちました。")
utterance = input("ユーザ発話> ")
print("条件が成り立ちませんでした。")
|
class Students:
count=0
def __init__(self,id,fname,lname,course,year,gpa,university,mobile):
self.StudentID=id
self.StudentFirstName=fname
self.StudentLastName=lname
self.Course=course
self.Year=year
self.Gpa=gpa
self.University=university
self.Ema... |
#!/usr/bin/env python3
#Import same moduls
import os
import sys
import turtle
#Create a Window
wn = turtle.getscreen()
wn.bgcolor("black")
wn.setup(700,700)
wn.title("That Good Game")
#Create a Help Window
#Create a Border
border_pen = turtle.Turtle()
border_pen.setposition(-300,-300)
border_pen.p... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.