首页 > 其他分享 >CDS523 Principle of Data Analytics

CDS523 Principle of Data Analytics

时间:2024-11-18 18:18:19浏览次数:1  
标签:plaintext text Analytics program Principle file output input Data

CDS523 Principle of Data Analytics and Programming

Programming Assignment 3

(Due: 20 th November 2024, 23:59)

  1. (5 marks) In the past, the frequency analysis of letters was an important step in breaking cipher. Write aPython program that prompt the user to input the path of a text file and output the occurrence count of

all 26 English alphabet (ignoring case) in the text file specified by the user.Sample input and output:TerminalPlease enter the path of the text file: asg3_q1_sample.txtThe frequency of English alphabet:a: 1b: 1c: 1…z: 1You should output the count of every English alphabet one byone in alphabetical order. Each line shouldcontain an Englishalphabet followed by its count. The input and output are omitted to save space in this assignment specification but your program shouldoutput the count of all English alphabets.

15 marks in total) In cryptography, a Caesar cipher is one of the simplest forms of substitution cipher.The encryption is performed through shifting each letter in the plaintext forward by a number of positions defined by the user along the alphabetical order. For example, if the user has defined the numberof forward position shift to be 4, every letter E in the plaintext will be replaced by A in the ciphertextbecause character A is 4 positions in front of letter E in alphabetical order.Consider the following mapping between each alphabet in plaintext and its corresponding alphabet in

ciphertext where the encryption is performed by shifting 4 alphabets forward.PlainA B C D E F G H IJ K L M N O P Q R S T U V W X Y ZCipher W X Y Z A B C D E F G H IJ K L M N O P Q R S T U VProcess of Encryption:Input plaintext:The quick brown fox jumps over the lazy dog.

Encryption ProcessPlain T h e q u i c k b r o w n f o x j u m p s o v e r t h e l a z y d o g .↓↓↓ ↓↓↓↓↓ ↓↓↓↓↓ ↓↓↓ ↓↓↓↓↓ ↓↓↓↓ ↓↓↓ ↓↓↓↓ ↓↓↓Cipher P d a m q e y g x n k s j b k t f q i l ok r a n p d a h w v u z k c .Output ciphertext:Pda mqeyg xnksj bkt fqilo kran pda hwvu zkc.Process of Decryption:The decryption of a ciphertext encrypted with Caesar cipher can be achieved by reversing the encryptionprocess (i.e. shifting the letters backward).Input ciphertext:Pdamqeyg xnksj bkt fqilo kran pda hwvu zkc.Decryption ProcessCipher P d a m q e y g x n k s j b k t f q i l o k r a n p d a h w v u z k c .↓↓↓ ↓↓↓↓↓↓↓↓↓↓ ↓↓↓ ↓↓↓↓↓ ↓↓↓↓ ↓↓↓ ↓↓↓↓ ↓↓↓Plain T h e q u i c k b r o w n f o x j u m p s o v e r t h e l a z y d o g .Output plaintext:The quick brown fox jumps over the lazy dog.a) (6 marks) Write a program that prompt the user to input (1) the number of forward position shift an(2) the plaintext message that they代写CDS523 Principle of Data Analytics  want to encrypt into the console. The program then output the encrypted message to the console.Sample input andoutput:TerminalPlease enter the number of position shift: 4Please enter the plaintext message: The quick brown foxjumps over thelazy dog.The encrypted message is: Pda mqeyg xnksjbkt fqilo kran pda hwvu zkc.

) (5 marks) Modify the program in (a) such that it will prompt the user to input (1) the number of forward position shift, (2) the path of the plaintext text file and (3) the path of the ciphertext text file.The program then encrypts the content of the plaintext text file and output the result ciphertext to the ciphertext text file.Sample input and output:

encrypted.txt

  1. c) (2 marks) Modify the program in (a) such that it will prompt the user to input (1) the number of forward position shift and (2) the encrypted message that they want to decrypt into the console. Theprogram then output the decrypted plaintext message to the console.Sample input and output:TerminalPlease enter the number of position shift: 4

 enter the encrypted message: Pda mqeyg xnksj bkt fqilo kran pdahwvu zkc.The decrypted message is: The quick brown fox jumps over the lazy dog.

  1. d) (2 marks) Modify the program in (c) such that it will prompt the user to input (1) the number of forward position for shifting, (2) the path of the ciphertext text file and (3) the path of the decrypted plaintext text file. The program then decrypts the content of thciphertext text file and output the result plaintext to the plaintext text file.Sample input and output:Terminal enter the number of position shift: 4Please enter the path of the input encrypted file: encrypted.txtPlease enter the path of the output decrypted file: decrypted.txtAssumption:
  • Only English alphabet (upper case or lower case) characters have to be encrypted and decrypted.
  • Characters other than English alphabet are preserve during the encryption and decryption.
  • Case of every English alphabet is preserved during the encryption and decryption process.

Assumptions You may assume that every input of the program is valid in format.

Submission Students should submit their source code as (1) a single Jupiter Notebook file (i.e. .ipynb file) OR (2) a zip filethat contains standalone Python script files (i.e. .py files) for answering the programing questions to thesubmission box on the Moodle elearning platform on or before 20 th November 2024, 23:59. Students areexpected to name their file submission in the name of <your_student_ID>_asg3.ipynb OR <your_student_ID>_asg3.zip and their source code should follow the following format:

标签:plaintext,text,Analytics,program,Principle,file,output,input,Data
From: https://www.cnblogs.com/comp9021T2/p/18552296

相关文章

  • 东胜物流软件 GetDataListCA SQL注入漏洞复现
    0x01产品简介东胜物流软件是青岛东胜伟业软件有限公司一款集订单管理、仓库管理、运输管理等多种功能于一体的物流管理软件。该公司初创于2004年11月(前身为青岛景宏物流信息技术有限公司),专注于航运物流相关环节的产品和服务。东胜物流信息管理系统货代版采用MS-SQLserver大型......
  • 联邦学习开山之作Communication-Efficient Learning of Deep Networks from Decentral
    1介绍1.1背景越来越多的手机和平板电脑成为许多人的主要计算设备。这些设备上强大的传感器(包括摄像头、麦克风和GPS),加上它们经常被携带的事实,意味着它们可以访问前所未有的大量数据,其中大部分本质上是私人的。根据这些数据学习的模型持有承诺通过支持更智能的应用程序来大大提......
  • 【汇编语言】更灵活的定位内存地址的方法(二)—— 从 [bx+idata] 到 [bx+si+idata]:让你
    文章目录前言1.[bx+idata]1.1更加灵活的访问内存1.2示例1.3问题一1.4问题一的分析与求解2.用[bx+idata]的方式进行数组的处理2.1问题引入2.2原来的解决方案2.3新的解决方案2.3.1改进后的程序2.3.2还可以写成这样2.3.3用C语言来描述看看2.4比较与总结3.......
  • SCB-Dataset3:首个涵盖从幼儿园到大学的多行为类别学生课堂行为检测数据集
    2023-10-04,由成都东软学院创建首个涵盖从幼儿园到大学的多行为类别学生课堂行为检测数据集(SCB-dataset3),这个数据集通过提供丰富的学生行为图像和标签,为自动检测学生课堂行为提供了重要的资源,有助于分析学生课堂表现和提高教学效果。数据集地址:学生课堂行为数据集(SCB-dataset......
  • SciTech-BigDataAIML-Statistical Model-Bayes Inference-数据/事实 ∩ 假设: 政治经
    SciTech-BigDataAIML-StatisticalModelBayesInference-数据/事实∩假设\(\large\begin{array}{rl}\\P(H|D)&=\dfrac{P(H)×P(D|H)}{P(D)}\\H:&HypothesisorBeliefandJudgement\\D:&Data/Reality\\P(D\bigcapH):&am......
  • Encoder Data compression
    Lab3:EncoderIntroductionDatacompressionistheprocessofencodinginformationusingfewerbitsthantheoriginalrepresentation.Run-lengthencoding(RLE)isasimpleyeteffectivecompressionalgorithm:repeateddataarestoredasasingledataandth......
  • GoFurther - Chapter 5: Database Setup and Configuration
     zzh@ZZHPC:/zdata/Github/greenlight$dockerpullpostgreszzh@ZZHPC:/zdata/Github/greenlight$dockerrun--namepostgres17-p5432:5432-ePOSTGRES_USER=root-ePOSTGRES_PASSWORD=root-dpostgres:latest zzh@ZZHPC:~$dockerexec-itpostgres17psql......
  • 哋它亢技术(DataCon) WiKi专题——0.目录大纲
    哋它亢技术-WiKi专题哋它亢WiKi专栏文章列表目录大纲1.哋它亢的历史与起源2.哋它亢的技术原理3.哋它亢的应用领域4.哋它亢的技术挑战5.哋它亢的市场与产业影响6.哋它亢的未来展望结语哋它亢WiKi随着新技术层出不穷,一些充满潜力的创新开始崭露头角,并迅速引起了全......
  • 惊爆!72.1K star 的 Netdata:实时监控与可视化的超炫神器!
    在当今复杂的IT环境中,实时监控与可视化对于保障系统的稳定运行和性能优化至关重要。无论是服务器、应用程序,还是网络设备,及时获取性能数据能够帮助我们快速定位问题、优化资源配置。Netdata,作为一个开源的实时监控工具,正是为此而生。Netdata不仅是一个轻量级的监控与可视化平......
  • WWDC 23 ,SwiftUI 5 和 SwiftData 的初印象
    WWDC23,SwiftUI5和SwiftData的初印象东坡肘子​ ​关注他 17人赞同了该文章WWDC2023正在如火如荼地进行。苹果不仅带来了全新形态的硬件产品,还推出了几个相当震撼的新框架。本文将聊聊我对本届WWDC中SwiftUI5.0和SwiftData的初步印象。......