目前分類:Python練習題 (18)

瀏覽方式: 標題列表 簡短摘要

Write a roll the dice program as following. User can input if roll again or not(y/n)

截圖 2021-05-10 上午2.42.17.jpg


文章標籤

Terror-P 發表在 痞客邦 留言(0) 人氣()

Write a Python program that takes a text file as input and returns the number of words in words.txt

截圖 2021-05-08 下午8.17.28.jpg

Write a Python program to count the number of lines in a text file.

截圖 2021-05-08 下午8.17.57.jpg

文章標籤

Terror-P 發表在 痞客邦 留言(0) 人氣()

Create a Time class and initialize it with hours and minutes.

截圖 2021-05-08 下午7.35.02.jpg


文章標籤

Terror-P 發表在 痞客邦 留言(0) 人氣()

Please define a Shape class as following and define Circle Class and Rectangle Class to inherit from Shape. In Circle and Rectange Class, please add function cal_area to calculate area and add function cal_perimeter to calculate perimeter.

截圖 2021-05-08 下午7.31.08.jpg

截圖 2021-05-08 下午7.31.42.jpg

文章標籤

Terror-P 發表在 痞客邦 留言(0) 人氣()

BLACKJACK: Given three integers between 1 and 11, if their sum is less than or equal to 21, return their sum. If their sum exceeds 21 and there's an eleven, reduce the total sum by 10. Finally, if the sum (even after adjustment) exceeds 21, return 'BUST'

截圖 2021-05-08 下午4.23.43.jpg


文章標籤

Terror-P 發表在 痞客邦 留言(0) 人氣()

Given an array of distinct positive numbers, the task is to calculate the number of subsets (or subsequences) from the array such that each subset contains consecutive numbers

截圖 2021-05-08 下午4.19.42.jpg

Take two lists and write a program that returns a list that contains only the elements that are common between these two lists (without duplicates). Make sure your program works on two lists of different sizes

截圖 2021-05-08 下午4.19.58.jpg

文章標籤

Terror-P 發表在 痞客邦 留言(0) 人氣()

Ask the user for a string and print out whether this string is a palindrome or not. (A palindrome is a string that reads the same forwards and backwards.)

截圖 2021-05-07 下午6.54.32.jpg


文章標籤

Terror-P 發表在 痞客邦 留言(0) 人氣()

Given two vector, calculate distance between them

截圖 2021-05-07 下午6.54.06.jpg


文章標籤

Terror-P 發表在 痞客邦 留言(0) 人氣()

Given a test string, please switch this string to lower and calculate frequency of each character

截圖 2021-05-06 上午3.43.53.jpg

Write a Python function that accepts a string and calculate the number of upper case letters and lower case letters.

截圖 2021-05-08 下午4.11.47.jpg

文章標籤

Terror-P 發表在 痞客邦 留言(0) 人氣()

input a number greater than 1, detect if this number is prime number or not

if it is prime number, print "this is a prime number"

if it is not prime number ,print "this is not a prime number"

截圖 2021-05-06 上午3.43.22.jpg


文章標籤

Terror-P 發表在 痞客邦 留言(0) 人氣()

write 9*9 multiplication table

截圖 2021-05-06 上午2.33.58.jpg

截圖 2021-05-12 上午1.34.30.jpg

文章標籤

Terror-P 發表在 痞客邦 留言(0) 人氣()

input a integer, calculate factorial of the number.

5! = 5*4*3*2*1
4! = 4*3*2*1

文章標籤

Terror-P 發表在 痞客邦 留言(0) 人氣()

截圖 2021-05-05 下午9.11.23.jpg


文章標籤

Terror-P 發表在 痞客邦 留言(0) 人氣()

截圖 2021-05-05 下午8.05.18.jpg

截圖 2021-05-05 下午7.57.23.jpg

文章標籤

Terror-P 發表在 痞客邦 留言(0) 人氣()

Lucky number

input a integer number, detect if the number is considered lucky. If the number is lucky, print "lucky number". If not, print "regular number"

Definition of lucky number: the sum of the first three digits equals the sum of the last three digits in a number.

截圖 2021-05-05 下午8.00.28.jpg

 

文章標籤

Terror-P 發表在 痞客邦 留言(0) 人氣()

Please do temperature conversion. Given a Celsius temperature, please change it to Fahrenheit

F=9/5*C+32

C=5/9(F-32)

文章標籤

Terror-P 發表在 痞客邦 留言(0) 人氣()

Write a Python program which accepts the radius of a circle from the user and compute the area.

截圖 2021-05-03 下午9.50.48.jpg


文章標籤

Terror-P 發表在 痞客邦 留言(0) 人氣()

Given weight and height of a person, calculate BMI

 

BMI=w/(h*h)

文章標籤

Terror-P 發表在 痞客邦 留言(0) 人氣()