C31RF Empirical Financial Modelling 2024 - 2025 Course Work: Panel Data Analysis 1. Overview This mid-term assignment is based on 30% of total marks in C31RF on an individual project. Submission format: each student submits the assignment in Canvas. Deadline for submission: Week 8 Monday 3rd March 2025 4pm. 2. Background Banks play a crucial role in an economy by efficiently allocating scarce resources to potential borrowers with the most promising prospects. However, under conditions of uncertainty, where relative prices can no longer be predicted with precision, the efficient allocation of funds may fail to materialize. Research has demonstrated that reductions in loanable funds can significantly impact bank- dependent borrowers, such as small businesses. These borrowers may face substantial reductions in their fixed investment expenditures or, in extreme cases, bankruptcy (e.g., Ivashina and Scharfstein, 2010; Ferri et al., 2014). This underscores the importance of understanding of the factors that influence banks’ lending behavior, a topic that has garnered renewed attention from researchers in the aftermath of the 2008 financial crisis. The crisis had far-reaching repercussions for both developed and emerging economies throughout the globe. In this coursework, you are tasked with empirically examining the relationship between uncertainty and banks’ lending behavior. The literature suggests that this relationship is influenced by a combination of bank-specific characteristics (e.g., size, profitability, liquidity, non-performing loans) and macroeconomic variables (e.g., GDP growth rate, long-term interest rates). Therefore, these factors should be incorporated into the analysis to provide a comprehensive understanding of the topic. 3. Data You can download the data file (Excel) from Canvas that contains a large panel of commercial banks collected from the Fitch for UK banks. Note that the total loans and total net loans data are currently in logarithmic format, please take the first difference. The analysis covers the period between 1999 – 2014. 4. Reports Requirement 1) Establish your hypothesis. You need to give prediction in a hypothesis based on literature (You should find more related literature to support your hypothesis). For example, H1: There is a positive (or negative) relation between XXX and XXX. 2) Briefly describe the research method you intend to employ. This should include: what is the model (formula)? what is the dependent variable? And what are independent variables and control variables? 3) Demonstrate empirical results. You are required to employ proper model(s) you learn from this course. Results should be demonstrated in well-organized table(s). Do not copy the original format of tables from E-views or Stata! Look at papers on how they present tables! 4) Briefly discuss your results and give the conclusion(s). 5) Briefly discuss the limits and potential problems of this research. 6) Optional Opportunity for Individual Initiative: In this part of your Report, you have the opportunity (if you wish to use it - not compulsory) to discuss other potential additional variables maybe useful in explaining the banks’ lending behaviour. 7) The length for the assignment should be ~1,500 words (excluding tables and references). 8) Do not COPY contents directly from sources. Potential References (please search for further references) • Baum, C.F., Caglayan, M. and Xu, B., 2021. The impact of uncertainty on financial institutions: A cross‐country study. International Journal of Finance & Economics, 26(3), pp.3719-3739. • Caglayan, M., and Xu, B. (2016). Sentiment volatility and bank lending behavior. International Review of Financial Analysis, 45:107-120. • Ferri, G., Kalmi, P., and Kerola, E. (2014). Does bank ownership affect lending behavior? evidence from the Euro area. Journal of Banking & Finance, 48:194–209. • Ivashina, V., and Scharfstein, D. (2010). Bank lending during the financial crisis of 2008. Journal of Financial Economics, 97(3):319–338. Table 1. Variable definitions. BankID Bank ID number. Year Year. In_GL Logarithmic of total loans, please take the difference to get the return. ln_NL Logarithmic of total net loans, please take the difference to get the return. ROAA This ratio measures the returns generated from the assets financed by the bank to compare banks' relative efficiency and their operational performance. Equity_TA The equity to asset ratio measures a company's financial leverage calculated by dividing its equity by its total assets. It indicates the percentage of total assets that is financed by shareholders' equity. Lossres_GL This ratio measures the loan loss provision to total loans. The provision is used to cover for different types of loan losses. Liq_Tdb This ratio looks at what percentage of total customer deposits and other short-term funds could be met if they were withdrawn suddenly, the higher this percentage the more liquid the bank is and less vulnerable to a classic run on the banks. size Natural logarithm of the bank's total assets (millions of dollars). IR Long-term interest rates (percent). GDPGrowth Logarithmic first difference of GDP (percent). dumFC Dummy variable to capture the effect of 2008 financial crisis. Composite Leading Indicator (dCLI) CLI is an aggregate time series displaying a reasonably consistent leading relationship with the reference series for the macroeconomic cycle in a country. CLI is designed to provide early signals of turning points (peaks and troughs) between expansions and slowdowns of economic activity. dCLI is the changes in CLI. Business Sentiment Indicator (dBSI) BSI is a composite sentiment indicator that summarizes managers' assessments and expectations of the general economic situation. dBSI is the changes of BSI Consumer Sentiment Indicator (dCSI) CSI include indicators on consumer confidence, expected economic situation and price expectations. dCSI is the changes of CSI.
Economics 4160 Urban and Regional Economics Winter 2025 COURSE DESCRIPTION This seminar-style. course introduces students to urban and regional economics topics, including urbanization, local labour and housing market, transportation, pollution, urban poverty, crime, and fiscal matters. Throughout the semester, we will learn canonical urban and regional economics models and concepts and read and discuss contemporary empirical research in urban and regional economics. Through a series of lectures, presentations, and class discussions, the course aims to develop the skills to apply economics to urban policy problems, communicate economic ideas and research findings, and conduct independent research. LEARNING OUTCOMES Upon successful completion of the course, the student will be able to • understand how to work with and apply foundational models in urban economics • understand empirical tools in urban economics • work with spatial data and maps • understand, synthesize, and criticize academic literature on urban policy issues • communicate economic ideas and research findings • understand the components and process of independent research PREREQUISITES The minimum requirement is ECON-1100. However, more advanced level microeconomics courses (e.g., ECON-2210), a basic understanding of calculus, and knowledge about statistics or econometrics will be great assets in this course. TEXTBOOK AND COURSE MATERIALS Required textbook: Urban Economics (9th ed.), by Arthur O’Sullivan, International Student Edition, McGraw Hill Education. Additional suggested textbooks: • Brueckner, Jan K. Lectures on urban economics. MIT Press, 2011 (Can be purchased on Amazon for $60) • Scott Cunningham, Causal Inference: The Mixtape. Yale University Press, 2021. (Can be purchased on Amazon for $50.26 and be freely accessed online at https://mixtape.scunning.com/) • Angrist, Joshua D., and Jörn-Steffen Pischke. Mostly Harmless Econometrics: An Empiricist's Companion. Princeton University Press, 2009. (Can be purchased on Amazon for $74.55) Additional readings (articles, reports, etc., that can be freely accessed via Leddy Library or other websites) will be provided on Brightspace. EMAILS Please always be courteous and respectful in your email correspondence. I reply to emails on weekdays within 48 hours if they require a response. (For example, an email informing me that a student will miss a class does not require a response.) Emails received over the weekend generally will not be replied to until Sunday evening or Monday morning. Before emailing me, please check the syllabus, recent emails from me, and announcements posted on Brightspace to see if the information you are looking for is provided there—it often is! Email is not a substitute for office hours. If you have a question about the material, it is best to come to my office hours or ask me during or after class. Please do not wait to email a question about the exam, an assignment, or a class just before these things occur. If you do, chances are your question will go unanswered. REQUIREMENTS AND GRADING Grading Your final grade (letter) will be based on the following scale: This will be determined using the following scheme: ProblemSet 2 due Feb14 ProblemSet 4 due Mar2120% (5% per assignment)Lab AssignmentDue April310%Paper presentationMarch 25 – April 325%Term paperPreliminary report due Feb7 March14 2135%
CIS 481: Parallel & Distributed Software Systems Homework #2 Problem Set 2 Due: 11:59PM, Tuesday, February 25, 2025 Note: There are 5 problems with 10 points maximum. All homework must be edited using a word processor, and submitted via myCourses. Please include a cover page with your full name (or group info), course title, problem set number, and your submission date. You will automatically lose 1 point if the cover page is missing. Problem 2-1. Await Statement (1.5 points) Andrews, Exercise 2.19, page 86. Note: For simplicity, the while-loop is read as while (x != y) { x = x – 1; y = y + 1; } Problem 2-2. Scheduling Policy (1.5 points) Andrews, Exercise 2.32 (b) only, page 89. Note: Give detailed explanations to justify your answers. Problem 2-3. Scheduling Policy (3 points) Andrews, Exercise 2.33 (a), (b) and (c), page 90. Note: Give detailed explanations to justify your answers. Problem 2-4. Critical Section Problem (2 points) Andrews, Exercise 3.3 (a) and (b) only, page 142. Hint: Define a shared variable sem with initial value of 1. In each process, define a local variable x with initial value of 0. Invoke Swap with parameters (x, sem). Problem 2-5. Critical Section Problem (2 points) Andrews, Exercise 3.8 (a) and (b), page 144. General Remarks: 1. Always provide your reasoning/explanations, and not only your final answers. 2. You may discuss assigned problems with your classmates, but you must individually write your own solutions/code for all assignments. 3. Assignments are to be submitted via myCourses by the due date.
Create a function that accepts four double values as parameters. These four double values should NOT modify the related values in main. The function should return the minimum of the four values, maximum of the four values, and average of the four values. Hint: Remember pass-by-reference to return multiple values – your function should have seven parameters and a return type of void. Pass-byreference should be used only with variables that it is necessary for. Test Cases: Test Case 1: Please enter four numbers: Number 1: Number 2: Number 3: Number 4: Minimum is -7.8 Maximum is 4.6 Average is -0.3 Test Case 2: Please enter four numbers: Number 1: Number 2: Number 3: Number 4: Minimum is -7.8 Maximum is 4.6 Average is -0.3 Test Case 3: Please enter four numbers: Number 1: Number 2: Number 3: Number 4: Minimum is 5.3 Maximum is 5.3 Average is 5.3
Write a function called treeTop that prints the top of a tree. It should take no parameters and return void. Write a second function called treeTrunk that prints the trunk of a tree. It should take one integer as a parameter for height (how many lines tall the trunk is), and also have a return type of void. Finally, create a function called drawTrees that takes two integer parameters, one for height and one for the number of trees to draw. drawTrees should use treeTop and treeTrunk. Have the user enter the height of the trees (same for all) and number of trees to draw. Note: The backslash symbol is used for certain special characters in strings in C++, such as (new line) and (tab), as such, to actually draw a single backslash you need two consecutive backslashes in your string. Test cases: Test case 1: Enter tree height: Enter number of trees: ^ / / /____ | | | | ^ / / /____ | | | | ^ / / /____ | | | | Test case 2: Enter tree height: Enter number of trees: ^ / / /____ | | | | | | | | | |
Write a function called dist that takes two double values as parameters and returns the absolute value of the difference of the two numbers (i.e. how far apart the numbers would be on a number line). Do NOT use cmath/math.h for this lab. In main ask the user to enter the two values, then print out the numbers and result in a sentence. The function dist should NOT print anything or receive any input from the user (no cin or cout in the dist function, only within main). Test cases (Slight rounding errors are OK): Test case 1: Input a number: Input another number: The distance between 5.3 and 1.7 is 3.6 Test case 2: Input a number: Input another number: The distance between 1.7 and 5.3 is 3.6 Test case 3: Input a number: Input another number: The distance between 2.5 and -3.4 is 5.9 Test case 4: Input a number: Input another number: The distance between -4.7 and 4.7 is 9.4 Test case 5: Input a number: Input another number: The distance between 4.7 and 4.7 is 0
Have the user input a filename to read in ints from. Print each to the screen, one per line and keep a running total. Print the total at the end. If the file does not exist say so and do not print the total. Test Case 1: File contents (ask user to enter filename, the file they enter contains this): 2 4 6 8 10 Sample output: Read 2 from file. Read 4 from file. Read 6 from file. Read 8 from file. Read 10 from file. Total is 30. Test Case 2: File contents (ask user to enter filename, the file they enter contains this): 1 3 5 7 Sample Output: Read 1 from file. Read 3 from file. Read 5 from file. Read 7 from file. Total is 16. Test Case 3: (nonexistent file – user enters nonexistent filename) Sample output: Failed to open file.
Overview: This week, you have studied Web application vulnerabilities, password complexity, logs and cryptographic algorithms. The Lab for this week demonstrates your knowledge of this additional knowledge applied using Python functionality.Submission requirements for this project include 2 files. (Zipping them into one file is acceptable and encouraged): Python Web Application Code (Python code for all routes, templates, static files and other files) Word or PDF file containing your test, pylint results and Cryptographic results.1. (50 points) In this exercise you will update your web site to include a password update form and provide additional validation on the password check. Specifically you should create: a. Password update Form – This Python form allows a previously registered user to reset their password after they have successfully logged in.b. Authentication functions – These Python functions will check the following NIST SP 800-63B criteria are met upon password update: Use the previous criteria for password length and complexity. (This work should already be done.) Compare the prospective secrets against a list that contains values known to be commonlyused, expected, or compromised (Provided as CommonPasswords.txt). If the chosen secret is found in the list, the application SHALL advise the subscriber that they need to select a different secret.c. Logger – Create a log to log all failed login attempts. The Log should include date, time and IP address.Hints: 1. Start early. This will take you longer than you think. 2. Leverage the File I/O, Flask and Data structures work previously performed in the class. 3. Use functions to enhance code reuse and modularity. 4. Use Python Lists or other data structures to store the Common Passwords and then appropriate search functions to expedite comparisons. 5. Use comments to document your code 6. Test with many combinations. 7. Use pylint to verify the code style – the goal is a 10!2. (30 points) Using the Decrypting Secret Messages sites found in this week’s readings, decrypt the following messages. a. – …. .. … / … -.. . …- / …– —– —– / -.-. .-.. .- … … / …. .- … / … — — . / … – .-. .- -. –. . / .-. . –.- ..- . … – … .-.-.- 2 b. U28gdGhpcyBpcyBiYXNlNjQuIE5vdyBJIGtub3cu c. — Psuwb Ysm —- W oa gc qzsjsf. Bc cbs qcizr dcggwpzm twuifs hvwg cih. — Sbr Ysm — Provide the decoded message along with the Cipher and any other parameters you used to solve each puzzle.Hints: 1. Use the rumkin site 2. You will need to experiment some to narrow down the possible algorithms used. Some are more obvious than others. 3. You will know when you have selected the correct Cipher3. (20 points) Document your results of the application running from your programming environment. You should also include and discuss your pylint results for the application. Provide your test results for each requirement in the Web application, associated functions and provide your resulting log files.Discuss the log file and how it could be used to possibly detect patterns of abuse. Describe the results of your NIST password complexity functions and how you tested each requirement. Include the Cipher tool results and write up in this document as well.Any submissions that do not represent work originating from the student will be submitted to the Dean’s office and evaluated for possible academic integrity violations and sanctions.
Overview: This week, you studied additional Flask functionality for creating a secure login form and associated files for a web site. The Lab for this week demonstrates your knowledge of this additional Python functionality. Be sure to use the examples in the textbook reading along with the associate libraries, functions and processes when completing the assignments for this week.Submission requirements for this project includes multiple files. (Zipping them into one file is acceptable and encouraged): Python Web Page Code (Python code, Templates, CSS and other associated files) Word or PDF file containing your test and pylint resultsThis exercise uses your programming environment to enhance the Web site you created last week with additional functionality to include images, tables and a Form using Python flask. Specifically, you will add two (2) additional routes allowing a user to register and login to a web site.Additional security considerations include other routes (beyond the register route) will not be accessible until a successful login has occurred. In addition to the requirements list above the following functionality should be found within your web site on one or more web pages. Add at least 4 different images. The images should be local in your environment. For example, they should be saved in your environment and referenced similar to this syntax: A Table with at least 4 rows and 3 columns. A user registration form A user login form A password complexity should be enforced to include at least 12 characters in length, and include at least 1 uppercase character, 1 lowercase character, 1 number and 1 special character. The content and topic of the new images, and tables are up to you. How much is required for the user registration is up to you as well. However, the registration and associated login should contain at least a login name and password.Hints: 1. Start early. This will take you longer than you think. 2. Test all aspects of the forms from input to output on your environment. 3. Use comments to document your code 4. Test with many combinations. 5. Use pylint to verify the code style – the goal is a 10!2. (20 points) Document your testing results using your programming environment. You should also include and discuss your pylint results for the application. The test document should include a test table 2 that includes the input values, the expected results and the actual results. A screen capture should be included that shows the actual test results of running each test case found in the test table. Be sure to include multiple test cases to provide full coverage for all code and for each function you develop and test. Any submissions that do not represent work originating from the student will be submitted to the Dean’s office and evaluated for possible academic integrity violations and sanctions.
Overview: In this week, you have studied additional Python language syntax including File I/O, Exceptions and Object-Oriented Programming. The Lab for this week demonstrates your knowledge of this additional Python functionality. Be sure to use the examples in the textbook reading along with the associate libraries, functions and processes when completing the assignments for this week.Submission requirements for this project include 4 files. (Zipping them into one file is acceptable and encouraged): Python Data Analysis Code 2 Input Files (Same files supplied to you) Word, Excel or PDF file containing your test resultsThis exercise (80 points) allows a user to load one of two CSV files and then perform histogram analysis and plots for select variables on the datasets. The first dataset represents the population change for specific dates for U.S. regions. The second dataset represents Housing data over an extended period of time describing home age, number of bedrooms and other variables. The first row provides a column name for each dataset.The following columns should be used to perform analysis: PopChange.csv: Pop Apr 1 Pop Jul 1 Change Pop Housing.csv: AGE BEDRMS BUILT ROOMS UTILITYNotice for the Housing CSV file, there are more columns in the file than are required to be analyzed. You can and should still load each column. Specific statistics should include: Count Mean Standard Deviation Min Max Histogram A user interface might look similar to this: ***************** Welcome to the Python Data Analysis App********** Select the file you want to analyze: 1. Population Data 2. Housing Data 3. Exit the Program 1 You have entered Population Data. Select the Column you want to analyze: a. Pop Apr 1 b. Pop Jul 1 c. Change Pop d. Exit Column a You selected Pop Apr 1 The statistics for this column are: Count = 10000 Mean = 32.5 Standard Deviation = 4.5 Min = 53.2 Max = 12.5The Histogram of this column is now displayed. Select the Column you want to analyze: a. Pop Apr 1 b. Pop Jul 1 c. Change Pop d. Exit Column d You selected to exit the column menu Select the file you want to analyze: 1. Population Data 2. Housing Data 3. Exit the Program 3 *************** Thanks for using the Data Analysis App********** If an inappropriate entry is detected, the program should prompt for a correct value and continue to do so until a correct value is entered.Hints: 1. Use the Pandas, Numpy, MatplotLib and other Python modules when appropriate. 2. Be sure to install the required Python modules in your environment before you import or try to use them in your code. For example, pip install each of the required modules that are external Python libraries that you need.3. If an inappropriate entry is detected, the program should prompt for a correct value and continue to do so until a correct value is entered. 4. Use comments to document your code 5. Test with many combinations. 6. Use pylint to verify the code style – the goal is a 10!7. The user Interface should continue to run until the user indicates they are ready to exit. 8. Be sure to review the previous readings and modules as you may need to use statistics and other modules to complete this lab.2. (20 points) Document your testing results using your programming environment. You should also include and discuss your pylint results for the application. The test document should include a test table that includes the input values, the expected results and the actual results. A screen capture should be included that shows the actual test results of running each test case found in the test table. Be sure to include multiple test cases to provide full coverage for all code and for each function you develop and test.Any submissions that do not represent work originating from the student will be submitted to the Dean’s office and evaluated for possible academic integrity violations and sanctions.
Overview: In this week, you have studied additional Python language syntax for rendering HTML templates using the Python Flask module. The Lab for this week demonstrates your knowledge of this additional Python functionality. Be sure to use the examples in the textbook and readings along with the associate libraries, functions and processes when completing the assignments for this week.Submission requirements for this project includes multiple 2 files. (Zipping them into one file is acceptable and encouraged): Python Web Page Code (Python code, Templates, CSS and other associated files) Word or PDF file containing your test and pylint resultsThis lab consists of two parts. 1. (80 points) This exercise (80 points) uses your programming environment to generate a simple Web site using Python flask. The site should be unique, include at least 3 routes (e.g. 3 pages one can navigate), each route should render the HTML pages by using the render_template() functionality. A style sheet should be included that is used by all Web pages. Proper organization should take place of the web site including the location of templates and static pages. Keep in the basic HTML form for a function web page includes the following components: Page Title …your page content… In addition to the requirements list above the following functionality should be found within your web site on one or more web pages. Use at least 3 different heading styles (e.g. , , ) Paragraph () Comments ) Ordered list Unordered list At least 3 Links to other External Web Sites Display the Date and Time on a Web page (Hint: Just use the Python datetime functions)The content and topic of the Web site is up to you. Consider an information web site about a topic you are interested. It should be unique and something you want to create. Hints: 1. Be sure to end tags that are started (e.g. ) 2. Start early. This will take you longer than you think. 3. Use comments to document your code 4. Test with many combinations. 5. Use pylint to verify the code style – the goal is a 10!2. (20 points) Document your testing results using your programming environment. You should also include and discuss your pylint results for the application. The test document should include a test table that includes the input values, the expected results and the actual results. A screen capture should be included that shows the actual test results of running each test case found in the test table. Be sure to include multiple test cases to provide full coverage for all code and for each function you develop and test.Any submissions that do not represent work originating from the student will be submitted to the Dean’s office and evaluated for possible academic integrity violations and sanctions.
Overview: In this week, you have studied additional Python language syntax including Arrays and Strings. In particular, you used the numpy, regular expressions, and Panda libraries to help manipulate and store data. The Lab for this week demonstrates your knowledge of this additional Python functionality. Be sure to use the examples in the textbook reading along with the associate libraries, functions and processes when completing the assignments for this week.Submission requirements for this project include 2 files. (Zipping them into one file is acceptable and encouraged): • Python Numpy and Pandas Application Code • Word or PDF file containing your test and pylint results along with the Password cracking activity resultsThis lab consists of three parts. 1. (60 points) allows a user to enter and validate their phone number and zipcode+4. Then the user will enter values of two, 3×3 matrices and then select from options including, addition, subtraction, matrix multiplication, and element by element multiplication. You should use numpy.matmul() for matrix multiplication (e.g. np.matmul(a, b) ). The program should compute the appropriate results and return the results, the transpose of the results, the mean of the rows for the results, and the mean of the columns for the results.When entering data, the application should use regular expressions and/or Pandas functionality to check the format of the phone number and zipcode. You should check that each value is numeric for the matrices. The user interface should continue to run until the user indicates they are ready to exit. A user interface might look similar to this: ***************** Welcome to the Python Matrix Application***********Do you want to play the Matrix Game? Enter Y for Yes or N for No: Y Enter your phone number (XXX-XXX-XXXX: 555-555-55 Your phone number is not in correct format. Please renter: 555-555-5555 Enter your zip code+4 (XXXXX-XXXX): 21022-3213 2 Enter your first 3×3 matrix: 1 2 4 4 2 1 3 8 9 Your first 3×3 matrix is: 1 2 4 4 2 1 3 8 9 Enter your second 3×3 matrix: 3 2 1 7 2 5 5 2 1 Your first 3×3 matrix is: 3 2 1 7 2 5 5 2 1 Select a Matrix Operation from the list below: a. Addition b. Subtraction c. Matrix Multiplication d. Element by element multiplication a You selected Addition. The results are: 4 4 5 11 4 6 8 10 10 The Transpose is: 4 11 8 4 4 10 5 6 10 The row and column mean values of the results are: Row: 4.33, 7, 9.33 Column: 7.66, 6, 7 3 Do you want to play the Matrix Game? Enter Y for Yes or N for No: N *********** Thanks for playing Python Numpy *************** If an inappropriate entry is detected, the program should prompt for a correct value and continue to do so until a correct value is entered.Hints: 1. Use numpy, pandas and regular expressions as appropriate. 2. Create and use functions as often as possible 3. Both integers and float values are acceptable 4. Use comments to document your code 5. Test with many combinations. 6. Use pylint to verify the code style – the goal is a 10!2. (15 points) Document your testing results using your programming environment. You should also include and discuss your pylint results for the application. The test document should include a test table that includes the input values, the expected results and the actual results. A screen capture should be included that shows the actual test results of running each test case found in the test table. Be sure to include multiple test cases to provide full coverage for all code and for each function you develop and test.3. (25 points) Password crackers can easily be written using Python code. You can also generate a hashed password using Python with a variety of hash algorithms. For this exercise, you will create use Python code to generate ten (10) passwords with different hashing algorithms and then use a popular online password cracking website to see if the passwords can be cracked.For example, the following Python code can be used to hash a password input using MD-5, SHA-256 and SHA-512 algorithms. import hashlib # input a message to encode print(‘Enter a message to encode:’) message = input() # encode it to bytes using UTF-8 encoding message = message.encode() # hash with MD5 (very weak) print(hashlib.md5(message).hexdigest())# Lets try a stronger SHA-2 family print(hashlib.sha256(message).hexdigest()) print(hashlib.sha512(message).hexdigest()) When you run this at the command prompt, you enter a password and then you will receive the hashed values for the MD-5, SHA-256 and SHA-512 algorithms, respectively. In this case, hello05 was entered and resulted in the 3 outputs. Notice, the SHA-512 is quite long and extends over two lines. If we take those 3 output hashes and input them into the Crackstation.net URL, the passwords are hacked in each case:Notice in each case, the original password of hello05 was cracked. You can salt a password by adding some random text of a phrase to the beginning of your actual password. This will add some strength to preventing a quick decryption. For this simple Python code, you can simulate a salt by adding a string to the front of password and then run the output into the Crackstation. For example, consider this salted password: wellwhatdoyouknowaboutthathello05In this case the phase “wellwhatdoyouknowaboutthat” is placed in front of hello05. The resulting output hashes are: 9aa8390dd622412e6a5ec75f35a661d9 94e0cb79b0dbbe82ea06c37af830f21bf926593618c6859141e553e61c759800 05f1d3eaaf9fc6b72410d16f78df7db42599367160c60f46888d6a888e68beef0b696ddb9c57debaaba2869 d45f23cdf0538b31449c9191d0254645b5b16ff61 When use those hash values as input into the Crackstation, the decoder fails:For your activity, experiment with the Python script using MD-5, SHA-256 and SHA-512 hash algorithms for at least 20 different passwords. Be sure to experiment with “easy” passwords, salted passwords as well as randomly generated passwords (e.g. from sites such as Norton password generator (https://my.norton.com/extspa/passwordmanager?path=pwd-gen). For your report, prepare a table that shows the input password, the resulting hashes and if the Crackstation.net site was able to crack the password. An example table is shown below: Table 1. Password Cracking Activity Results Password Hash output Did Crackstation work?password01 af88a0ae641589b908fa8b31f0fcf6e1 4b8f353889d9a05d17946e26d014efe99407cba8bd9d 0102d4aab10ce6229043 746a5a2664633cb15829e80cc8d5dd7368b1d939756e 7b069df9df482e2afc3c44029ec71ffbf7cc9916719d861 b60fc34b5 bd6a4f2cb0fe7747d99d5b219162 Yes …Be sure to describe what you learned from this password cracking activity and what would you recommend as possible strong passwords after completing this activity in your report? Any submissions that do not represent work originating from the student will be submitted to the Dean’s office and evaluated for possible academic integrity violations and sanctions.
Overview: This week, you have studied additional Python language syntax including functions The Lab for this week demonstrates your knowledge of this additional Python functionality.Submission requirements for this project include 2 files. (Zipping them into one file is acceptable and encouraged): Python Command Line Math and Security Related Application Code Word or PDF file containing your test and pylint resultsThe first exercise produces a command line menu-driven python application providing users with the ability to perform several math and security related functions. The second part documents your testing and pylint analysis results.1. (80 points) Create a menu-driven python application with following menu options for users to run at the command line: a. Generate Secure Password b. Calculate and Format a Percentage c. How many days from today until July 4, 2025? d. Use the Law of Cosines to calculate the leg of a triangle. e. Calculate the volume of a Right Circular Cylinder f. Exit programAs you put this menu together be sure to adhere to the following guidance and hints: 1. Create functions to be called sending in the parameters the user enters. 2. Validate input data to ensure each entry from the user is correct before proceeding. 3. Prompt the user to reenter information as needed.4. The following Python sites are excellent resources for learning more about the string, datetime, secrets, math, and random number libraries mentioned in the readings that you should use as part of this exercise. i. https://docs.python.org/3/library/random.html ii. https://docs.python.org/3/library/secrets.html iii. https://docs.python.org/3/library/string.html iv. https://docs.python.org/3/library/datetime.html v. https://docs.python.org/3/library/math.html 5. Use comments to document your code 6. Test with many combinations. 7. Use pylint to verify the code style – the goal is a 10!Some additional guidance related to your functions created:1. For the secure Password, you should prompt the user for the length of the password to be created, as well as the complexity (i.e. Use of Upper Case, Use of Lower Case, Use of Numbers, Use of special characters). Check out options from commercial password generators such as Norton. (https://my.norton.com/extspa/passwordmanager?path=pwd-gen). Note in a command line interface, the input and prompts are just text, so you won’t be creating a GUI, just the functionality that allows the user to enter the information needed.2. For the percentage, consider a simple example, where the user has to enter the numerator and denominator and the number of decimal points for formatting. For example, 22, 57, 3 would yield 38.596 percent. 3. For days until July 4, 2025 the output should just be the number of days. There would be no input other than the selection from the menu4. The formula for the law of cosines can be found at sites such as https://www.mathsisfun.com/algebra/trig-cosine-law.html. You want to solve for c (lower case c) in the following diagram. 5. The formula for a right cylinder can be found here: https://www.mathsisfun.com/geometry/prism-vs-cylinder.html. Be sure to select right circular cylinder. 6. When exiting the program be sure to thank the user for visiting your application.2. (20 points) Document your testing results using your programming environment. You should also include and discuss your pylint results for the application. The test document should include a test table that includes the input values, the expected results and the actual results. A screen capture should be included that shows the actual test results of running each test case found in the test table. Be sure to include multiple test cases to provide full coverage for all code and for each function you develop and test.Any submissions that do not represent work originating from the student will be submitted to the Dean’s office and evaluated for possible academic integrity violations and sanctions.
Overview: In this week, you have set-up your Python Environment. The Lab for this week demonstrates your first use of this environment with a fairly simple Python application. You will also use pylint to verify your code is using professional coding style and standards.Submission requirements include 2 files. (Zipping them into one file is acceptable): • Python Voter Registration Application Code (python code) • Word or PDF file containing your test and pylint resultsThis lab consists of two parts. The first exercise produces a voter registration application asking the user a few simple questions followed by a confirmation of registration, provided the user is eligible. The second part documents your testing and pylint analysis results.1. Using your Python programming environment, write a Python application that supports voter registration. The application will launch and run from the command line prompt. The application will prompt the user for their first name, last name, age, country of citizenship, state of residence and zipcode. To be a valid registration all fields must be entered. If they are at least 18 years old and a U.S citizen, they can move forward and be prompted for the remaining questions and register to vote. If not, they should not be presented with the additional questions.There should be some error checking logic on the input statements to make sure the age numbers entered seem reasonable (e.g. a person is probably not > 120 years) and states should be 2 letters representing only valid U.S. States. The application should prompt the user for the needed questions to complete the registration and reprompt when data is invalid giving the user the opportunity to retry. The output should summarize the input data and congratulate the user if they are eligible to vote and entered all of the data. The user should be given options to exit the program at any time to cancel the registration process.The following is a possible application interface. Other application interfaces are possible as well. (80 points) **************************************************************** Welcome to the Python Voter Registration Application. Do you want to continue with Voter Registration? Yes. What is your first name? Sally Do you want to continue with the voter Registration? What is your last name? Smith Do you want to continue with the voter Registration? Yes What is your age? 49 Do you want to continue with the voter Registration? 2 Yes Are you a U.S. Citizen? Yes Do you want to continue with the voter Registration? Yes What state do you live? MD Do you want to continue with the voter Registration? Yes What is your zipcode? 21012 Thanks for registering to vote. Here is the information we received: Name (first last): Sally Smith Age: 49 U.S. Citizen: Yes State: MD Zipcode: 21012 Thanks for trying the Voter Registration Application. Your voter registration card should be shipped within 3 weeks. ****************************************************************Hints: 1. Be sure to add logic to test for continuing the registration process. 2. Validate data is valid on entry (e.g. all fields have input data, age seems correct, states seem correct.) 3. Test with many combinations. For example, what happens if you enter invalid data? Exit the application at any point, or aren’t 18 years old? 4. Use comments to document your code 5. Use pylint to verify the code style – the goal is a 10!2. Document your test results for each application within your programming environment. You should also include and discuss your pylint results for each application. The test document should include a test table that includes the input values, the expected results and the actual results. A screen capture should be included that shows the actual test results of running each test case found in the test table. Be sure to include multiple test cases to provide full coverage for all code.For example, you should demonstrate each set of logic in the code works as expected and every statement in the code is reached through the test cases. (20 points) A possible test table may look like this: Test Case Input Expected Output Actual Output Pass? 1a 1,2,3,4,5,6,7,8,9,10 Sum= 54, Range =9 Sum= 54, Range =9 Yes 1b 2,10,1,11,11,32,42,21,32,23 Sum= 183, Range =41 Sum= 183, Range =41 Yes 3 1c 3,g,e,s,7,12,e,s,x,! Error Error No input validation issue … Include the screen captures support each of the test cases. These are the screen captures validating the actual output for each test case.Any submissions that do not represent work originating from the student will be submitted to the Dean’s office and evaluated for possible academic integrity violations and sanctions.
CMSC 430 Project 4 The fourth project involves modifying the semantic analyzer for the attached compiler by adding checks for semantic errors. The static semantic rules of this language are the following: Variable and parameter names have local scope. The scope rules require that all names be declared and prohibit duplicate names within the same scope. The type correspondence rules are as follows: Both expressions in the when statement must be the same type The type of the switch expression must be Integer. All the case statements in a switch statement must match in type. No coercion is performed. Arithmetic operators can only be used with numeric types. All list elements must be of the same type. In a list variable declaration, the type of the list must match the type of the elements. List subscripts must be integer expressions. Character literals can be compared to one another but they cannot be compared to numeric expressions. Only integer operands can be used with the remainder operator. All the statements in an if statement must match in type. No coercion is performed. In a fold statement, the list must be a numeric type. A narrowing variable initialization or function return error occurs when a real value is being forced into integer. Widening is permitted. In all other cases, the type must match. Type coercion from an integer to a real type is performed within arithmetic expressions. You must make the following semantic checks. Those highlighted in yellow are already performed by the code that you have been provided, although you are must make minor modifications to account for the addition of real types and the need to perform type coercion and to handle the additional arithmetic, relational and logical operators. Type Mismatch on Variable Initialization When Types Mismatch Switch Expression Not Integer Case Types Mismatch Arithmetic Operator Requires Numeric Types Undeclared Scalar Undeclared List List Element Types Do Not Match List Type Does Not Match Element Types List Subscript Must Be Integer Character Literals Cannot be Compared to Numeric Expressions Remainder Operator Requires Integer Operands If-Elsif-Else Type Mismatch Fold Requires A Numeric List Illegal Narrowing Variable Initialization Illegal Narrowing Function Return Type Mismatch on Function Return Duplicate Scalar Duplicate ListThis project requires modification to the bison input file, so that it defines the additional semantic checks necessary to produce these errors and addition of functions to the library of type checking functions already provided in types.cc. You must also make some modifications to the functions provided. You need to add a check to the checkAssignment function for mismatched types in the case that nonnumeric and numeric types are mixed. You need to also add code to the checkArithmetic function to coerce integers to reals when the types are mixed.The provided code includes a template class Symbols that defines the symbol table. It already includes a check for undeclared identifiers. You need to add a check for duplicate identifiers. Like the lexical and syntax errors, the compiler should display the semantic errors in the compilation listing, after the line in which they occur. An example of a compilation listing output containing semantic errors is shown below: 1 // Multiple Semantic Errors 2 3 function main returns integer; 4 value: integer is 4.5; Semantic Error, Illegal Narrowing Variable Initialization 5 numbers: list of real is (1, 2, 3); Semantic Error, List Type Does Not Match Element Types 6 one: integer is ‘1’; Semantic Error, Type Mismatch on Variable Initialization 7 begin 8 if value > 0 then 9 fold left + (‘a’, ‘b’) endfold; Semantic Error, Fold Requires A Numeric List 10 elsif name = ‘N’ then Semantic Error, Undeclared Scalar name 11 fold right * (1, 2.5) endfold; Semantic Error, List Element Types Do Not Match 12 else 13 when value < 10, 1 : 1.5; Semantic Error, When Types Mismatch 14 endif; 15 end; Lexical Errors 0 Syntax Errors 0 Semantic Errors 7You are to submit two files. 1. The first is a .zip file that contains all the source code for the project. The .zip file should contain the flex input file, which should be a .l file, the bison file, which should be a .y file, all .cc and .h files and a makefile that builds the project.2. The second is a Word document (PDF or RTF is also acceptable) that contains the documentation for the project, which should include the following: a. A discussion of how you approached the project b. A test plan that includes test cases that you have created indicating what aspects of the program each one is testing and a screen shot of your compiler run on that test case c. A discussion of lessons learned from the project and any improvements that could be made
CMSC 430 Project 3 The third project involves modifying the attached interpreter so that it interprets programs for the complete language. When the program is run on the command line, the parameters to the function should be supplied as command line arguments. For example, for the following function header of a program in the file text.txt: function main x: integer, y: integer returns character; One would execute the program as follows: $ ./compile < test.txt 10 -10 In this case, the parameter x would be initialized to 10 and the parameter y to -10. An example of a program execution is shown below: $ ./compile < test.txt 10 -10 1 // Determines the quadrant of a point on the x-y plane 2 3 function main x: integer, y: integer returns character; 4 begin 5 if x > 0 then 6 if y > 0 then 7 ‘1’; 8 elsif y < 0 then 9 ‘4’; 10 else 11 ‘Y’; 12 endif; 13 elsif x < 0 then 14 if y > 0 then 15 ‘3’; 16 elsif y < 0 then 17 ‘2’; 18 else 19 ‘Y’; 20 endif; 21 else 22 if y 0 then 23 ‘X’; 24 else 25 ‘O’; 26 endif; 27 endif; 28 end; Compiled Successfully Result = 52 After the compilation listing is output, the value of the expression which comprises the body of the function should be displayed as shown above. The existing code evaluates some of the arithmetic, relational and logical operators together with the case statement and decimal integer and real literals only. You are to add the necessary code to include all of the following: Hexadecimal integer and character literals that include escape characters All additional arithmetic operators All additional relational and logical operators Both if and fold statements Functions with multiple variables Functions with parameters The fold statement repeatedly applies the specified operation to the list of values, producing one final value. A left fold associates the operator left to right and a right fold right to left. For example, the following left fold: fold left – (3, 2, 1) endfold; would be evaluated as ((3 – 2) – 1) = 0, but using a right fold: fold right – (3, 2, 1) endfold; It would be evaluated as (3 – (2 – 1)) = 2. For operations that are associative, the result would be the same whether it is as folded to the left or right. This project requires modification to the bison input file, so that it defines the additional the necessary computations for the above added features. You will need to add functions to the library of evaluation functions already provided in values.cc. You must also make some modifications to the functions already provided. You are to submit two files. 1. The first is a .zip file that contains all the source code for the project. The .zip file should contain the flex input file, which should be a .l file, the bison file, which should be a .y file, all .cc and .h files and a makefile that builds the project. 2. The second is a Word document (PDF or RTF is also acceptable) that contains the documentation for the project, which should include the following: a. A discussion of how you approached the project b. A test plan that includes test cases that you have created indicating what aspects of the program each one is testing and a screen shot of your compiler run on that test case c. A discussion of lessons learned from the project and any improvements that could be made
CMSC 430 Project 2 The second project involves modifying the syntactic analyzer for the attached compiler by adding to the existing grammar. The full grammar of the language is shown below. The highlighted portions of the grammar show what you must either modify or add to the existing grammar. function: function_header {variable} body function_header: FUNCTION IDENTIFIER [parameters] RETURNS type ; variable: IDENTIFIER : type IS statement ; | IDENTIFIER : LIST OF type IS list ; list: ( expression {, expression} ) parameters: parameter {, parameter} parameter: IDENTIFIER : type type: INTEGER | REAL | CHARACTER body: BEGIN statement END ; statement: expression ; | WHEN condition , expression : expression ; | SWITCH expression IS {case} OTHERS ARROW statement ENDSWITCH ; | IF condition THEN statement {ELSIF condition THEN statement} ELSE statement ENDIF ; | FOLD direction operator list_choice ENDFOLD ; case: CASE INT_LITERAL ARROW statement direction: LEFT | RIGHT operator: ADDOP | MULOP list_choice: list | IDENTIFIER condition: expression RELOP expression | condition logical_operator condition | ( condition ) | NOTOP condition logical_operator: ANDOP | OROP expression: ( expression ) | expression arithmetic_operator expression | NEGOP expression | INT_LITERAL | REAL_LITERAL | CHAR_LITERAL | IDENTIFIER ( expression ) | IDENTIFIERarithmetic_operator: ADDOP | MULOP | MODOP | EXPOP In the above grammar, the red symbols are nonterminals, the blue symbols are terminals and the black punctuation are EBNF metasymbols. The braces denote repetition 0 or more times and the brackets denote optional.You must rewrite the grammar to eliminate the EBNF brace and bracket metasymbols and to incorporate the significance of parentheses, operator precedence and associativity for all operators. The precedence and associativity rules are as follows: Among binary arithmetic operators the exponentiation operator has highest precedence followed by the multiplying operators and then the adding operators. But the unary negation operator ~ has higher precedence that all of the binary operators. All relational operators have the same precedence. Among the binary logical operators, & has higher precedence than |. But the unary logical operator ! has higher precedence than either of the binary logical operators. All binary operators except the exponentiation operator are left associative. The directives to specify precedence and associativity, such as %prec and %left, may not be used.Your parser should be able to correctly parse any syntactically correct program without any problem. You must modify the syntactic analyzer to detect and recover from additional syntax errors using the semicolon as the synchronization token. To accomplish detecting additional errors an error production must be added to the function body, to the variable declaration and to the when clause.Your bison input file should not produce any shift/reduce or reduce/reduce errors. Eliminating them can be difficult so the best strategy is not introduce any. That is best achieved by making small incremental additions to the grammar and ensuring that no addition introduces any such errors. An example of compilation listing output containing syntax errors is shown below: 1 — Multiple errors 2 3 function main a integer returns real; Syntax Error, Unexpected INTEGER, expecting ‘:’ 4 b: integer is * 2; Syntax Error, Unexpected MULOP 5 c: real is 6.0; 6 begin 7 if a > c then 8 b + / .4; Syntax Error, Unexpected MULOP 9 else 10 case b is 11 when => 2; Syntax Error, Unexpected ARROW, expecting INT_LITERAL 12 when 2 => c; 13 endcase; Syntax Error, Unexpected ENDCASE, expecting OTHERS or WHEN 14 endif; 15 end; Lexical Errors 0 Syntax Errors 5 Semantic Errors 0You are to submit two files. The first is a .zip file that contains all the source code for the project. The .zip file should contain the flex input file, which should be a .l file, the bison file, which should be a .y file, all .cc and .h files and a makefile that builds the project. The second is a Word document (PDF or RTF is also acceptable) that contains the documentation for the project, which should include the following: a. A discussion of how you approached the project b. A test plan that includes test cases that you have created indicating what aspects of the program each one is testing and a screen shot of your compiler run on that test case c. A discussion of lessons learned from the project and any improvements that could be made
CMSC 430 Project 1 The first project involves modifying the attached lexical analyzer and the compilation listing generator code. You need to make the following modifications to the lexical analyzer, scanner.l: 1. The following reserved words should be added: else, elsif, endfold, endif, fold, if, left, real, right, then Each reserved words should be a separate token. The token name should be the same as the lexeme, but in all upper case. 2. Two additional logical operators should be added. The lexeme for the first should be | and its token should be OROP. The second logical operator added should be ! and its token should be NOTOP. 3. Five relational operators should be added. They are =, , >, >= and