赞
踩
- def is_prime(num):
- if num < 2:
- return False
- for i in range(2, int(num**0.5) + 1):
- if num % i == 0:
- return False
- return True
-
- def is_palindrome(num):
- return str(num) == str(num)[::-1]
-
- def generate_palindrome_primes(n):
- palindrome_primes = []
- num = 2
- while len(palindrome_primes) < n:
- if is_prime(num) and is_palindrome(num):
- palindrome_primes.append(num)
- num += 1
- return palindrome_primes
-
- if __name__ == "__main__":
- n = int(input())
- result = generate_palindrome_primes(n)
- print(" ".join(map(str, result)))
- def is_prime(num):
- if num < 2:
- return False
- for i in range(2, int(num**0.5) + 1):
- if num % i == 0:
- return False
- return True
-
- def is_palindrome(num):
- if str(num) == str(num)[::-1]:
- return False
- return True
-
- def generate_palindrome_primes(n):
- palindrome_primes = []
- num = 2
- while len(palindrome_primes) < n:
- num1 = int(str(num)[::-1])
- if is_prime(num) and is_palindrome(num)and is_prime(num1):
- palindrome_primes.append(num)
- num += 1
- return palindrome_primes
-
- if __name__ == "__main__":
- n = int(input())
- result = generate_palindrome_primes(n)
- print(" ".join(map(str, result)))
- def is_prime(n):
- """判断素数的函数,接收一个正整数为参数,参数是素数时返回True,否则返回False"""
- if n < 2:
- return False
- for i in range(2, int(n ** 0.5) + 1):
- if n % i == 0:
- return False
- return True
-
-
- def goldbach_conjecture(num):
- """ 哥德巴赫猜想, 接收一个不小于4的正整数为参数。
- 当参数为不小于4的偶数时,将其分解为两个素数的加和,按小数+数的格式输出。
- 有多种组合时全部输出,但不输出重复的组合,例如输出8=3+5,不输出8=5+3。
- 参数为奇数或小于4时,输出'Data error!'
- """
- if num % 2 != 0 or num < 4:
- print('Data error!')
- a = int(num/2)+1
- for i in range(1, a):
- if is_prime(i) and is_prime(num - i):
- print('{}={}+{}'.format(num, i, num - i))
-
-
- if __name__ == '__main__':
- positive_even = int(input()) # 输入一个正数
- goldbach_conjecture(positive_even)
- a = input()
- b = float(input())
- str1=''
- if a[- 1] != '¥' and a[- 1] != '$' or b < 0.0:
- print('Data error!')
- elif a[- 1] == '$':
- for i in a[:-1]:
- if i != ' ':
- str1 = str1 + i
- str1 = float(str1)
- money = float(b * str1)
- print('{:.2f}¥'.format(money))
- elif a[- 1] == '¥':
- for i in a[:-1]:
- if i != ' ':
- str1 = str1 + i
- str1 = float(str1)
- money = float(str1 / b)
- print('{:.2f}$'.format(money))
- n=input()
- t=n.split(" ")
- print('姓名:'+t[1])
- print('班级:'+t[2])
-
- j = 0
- for i in t[4]:
- if i=='年':
- break
- j = j+1
- print('出生:'+t[4][j-4:j+1])
- a = input()
-
- str1 = a[6:10]
- str2 = a[10:12]
- str3 = a[12:14]
-
- num = int(a[16])
-
- print('出生:'+str1+'年'+str2+'月'+str3+'日')
- if num%2==0:
- print('性别:女')
- else:
- print('性别:男')
- n = int(input())
-
- for i in range(0, n + 1):
- k = i
- a = k % 10 + int(k / 10) % 10 + int(k / 100) % 10
- if a == 5:
- print(i, end=" ")
-
print(len(input()))
- import string
-
- a = input()
-
- lower = string.ascii_lowercase
- upper = string.ascii_uppercase
-
- before = string.ascii_letters
- after = lower[3:] + lower[:3] + upper[5:] + upper[:5]
-
- table = "".maketrans(before, after)
- print(a.translate(table))
- a = input()
-
- t = a.split(" ")
-
- for i in t:
- print(i)
- n =input()
-
- str1 = n.swapcase()
-
- print(str1)
- a = input()
- b =input()
-
- index = b.find(a)
-
- if index == -1:
- print('Not Found')
- else:
- print('index = {}'.format(index))
- import random
- import string
-
-
- n,s = map(int,input().split(','))
-
- random.seed(s)
-
- all_chars = string.digits + string.ascii_letters + '!"#$%&\\()*+,-.'
-
- password = ''.join(random.choice(all_chars) for _ in range(n))
-
- print(password)
- import random
- import string
-
-
- n = int(input())
- s = int(input())
-
- random.seed(s)
-
- all_chars = r'BCEFGHJKMPQRTVWXY2346789'
-
- for i in range(n):
- password = ''.join(random.choice(all_chars) for _ in range(5)) + '-' + ''.join(
- random.choice(all_chars) for _ in range(5)) + '-' + ''.join(
- random.choice(all_chars) for _ in range(5)) + '-' + ''.join(
- random.choice(all_chars) for _ in range(5)) + '-' + ''.join(random.choice(all_chars) for _ in range(5))
- print(password)
- a = int(input())
- b = int(input())
-
- if a>=1 and a<=9 and b>=0:
- sum = 0
- k = a
- if b ==0:
- print('0')
- else:
- for i in range(1,b+1):
- sum = sum + k
- k=k*10+a
- print(sum)
-
- else:
- print('data error')
- a = input()
- num=0
- for i in a:
- if i==" ":
- num = num+1
-
- print(num+1)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。