python代写 python作业代写 python程序代写 代写python程序

Python Quiz代做,Python Exam代写

                                                                                                

1. (5 marks)
With any entered email address in the “username@companyname.domainname” format (e.g., tom@microsoft.com or peter@chess.co.th), write a Python code to print the username, company name and domain name of the entered email address. Note that the company name must be capitalized.

                                                                                                                                                                                                                                

Sample Run 1

                                                                                                                            

Enter your email: tom@microsoft.com Your username is tom.
Your company is Microsoft.
Your domain name is ".com".

                                                                                                                                                                                               

Sample Run 2

                                                                                                                                                                                               

Enter your email: peter@bmw.co.th Your username is peter.
Your company is Bmw.
Your domain name is ".co.th".

                                               

Notes:

                                                                                                                                                                                               
  • 1 mark if you can print the username
  • 2 marks if you can print the company name                                                        
  • 2 marks if you can print the domain name
                                                                                                                                                                                              

2. (5 marks) Write a Python code that computes and prints the net balance of a bank account based on transaction logs entered by a user until “q” or “Q” is entered. The format of the transaction log is “code amount”, where code is D, W and T for deposit, withdrawal, and transfer. Amount is an amount of money (integer value). For any other codes entered, the code print “{code amount} is an invalid transaction!!! Try again.” The initial balance is set to 1000.

                                                                                                                                                                                                       

Sample Run 1

                                                                                                                                                                                               

Your initial balance is 1000. Enter a transaction: D 200

                                                                                                                                                                                               

Enter a transaction: W 500
Enter a transaction: C 300
C 300 is an invalid transaction!! Try Again. Enter a transaction: M 300
M 300 is an invalid transaction!! Try Again. Enter a transaction: T 500
Enter a transaction: q
Your total balance is 200.

                                                                       

CSX3001/ITX3001 Fundamental of Computer Programming, CS1201 Computer Programming I

                                       

3. (5 marks) Write a function, namely RepalceDupandSum(numlist), that takes a list of integers as an input parameter. The function replaces all duplicated integers except its first appearance with ‘dE’ or ‘dO’ if the duplicated integer is an even or an odd number, respectively. The function returns the list and the sum of all unique integers.

                                                                                                                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                       

Sample Run 1

                                                               

numlist = [1,2,3,2,4,1,5,5,6,6,6]
outlist, total = ReplaceDupandSum(numlist)

                                                               

print(outlist)
print(f'The total sum of uniqued integers is {total}.')

                                                               

#output is

                                                                                                                                               
                                                                                                                                                                       

[1, 2, 3, 'dE', 4, 'dO', 5, 'dO', 6, 'dE', 'dE'] The total sum of unique integers is 21.

                                                                                                                                               
                                       
                                                                                               

4. (5 marks) Write a Python code that takes a sequence of binary digits such as 01101001.... with a minimum length of sequence equal to 4. If the length is less than 4, the code prints “Too short sequence!!!” and ends the program. Otherwise, the code creates a matrix with a size m by n, where m is set to 4 (a number of row is fixed to 4) and n is equal to the integer quotient of the length of the sequence divided by m. In other words, it is a floor division. The remainder is ignored.

                                                                                                                                                                                                       

Sample run#1

                                                                                                                                                                                               

Enter a sequence: 1010101011111 <- length is 13, ignore last digit [1, 0, 1] n = 13 // 4 = 3
[0, 1, 0] so a matrix of 4 x 3 is printed [1, 0, 1]

                                               

[1, 1, 1]

                                                                                                                                                                                               

Sample run#2

                                                                                                                                                                                               

Enter a sequence: 1101101101 <- length is 10, ignore last 2 digits [1, 1] n = 10 // 4 = 2
[0, 1] so a matrix of 4 x 2 is printed [1, 0]

                                               

[1, 1]

                                                                                                                                                                                               

Sample run#3

                                                                                                                                                                                               
Enter a sequence: 101 Too short sequence!!!
                                                                                                               

       

京ICP备2025144562号-1
微信
程序代写,编程代写
使用微信扫一扫关注
在线客服
欢迎在线资讯
联系时间: 全天