Module 1: Hello Python!

Spread the love

INTRODUCTION – Hello Python!

In this module, the primary goal is to introduce you to the Coursera platform and familiarize you with the course structure. Once you’re comfortable with the setup, you’ll begin exploring the basics of programming languages and syntax, particularly focusing on automation through scripting. The highlight of this module is an introduction to Python, where we will cover fundamental functions, keywords, and basic arithmetic operations within the language.

As we move through Python’s core features, you’ll build a strong foundation in the language. We’ll start by covering essential functions and keywords, which serve as the fundamental components of Python programming. Moreover, this module will provide you with an understanding of basic arithmetic operations, setting the stage for more advanced topics.

By the end of this module, you’ll also be introduced to various code editors and Integrated Development Environments (IDEs). These tools are crucial for writing Python code effectively and will help you select the best environment for your programming tasks.


Learning Objectives:

  • Define the terms computer program, programming language, script, and automation.
  • Use the print() function to output data to the screen.
  • Explain the difference between the syntax and semantics of a programming language.
  • List some of the key characteristics of the Python language.
  • Use basic Python arithmetic operators to evaluate mathematical expressions.

PRACTICE QUIZ: INTRODUCTION TO PROGRAMMING

1. What’s a computer program?

  • A set of languages available in the computer
  • A process for getting duplicate values removed from a list
  • A list of instructions that the computer has to follow to reach a goal (CORRECT)
  • A file that gets copied to all machines in the network

You nailed it! At its core, a computer program is a set of instructions that directs your computer on how to perform specific tasks.

2. What’s the syntax of a language?

  • The rules of how to express things in that language (CORRECT)
  • The subject of a sentence
  • The difference between one language and another
  • The meaning of the words

Right on! In human language syntax refers to the rules for constructing sentences while in programming languages syntax dictates the rules for writing each instruction correctly.

3. What’s the difference between a program and a script?

  • There’s not much difference, but scripts are usually simpler and shorter. (CORRECT)
  • Scripts are only written in Python.
  • Scripts can only be used for simple tasks.
  • Programs are written by software engineers; scripts are written by system administrators.

You got it! The distinction between a program and a script is often unclear; however scripts typically have a shorter development cycle. this way they run to work shorter simpler and get work print further quick compared to good programs

4. Which of these scenarios are good candidates for automation? Select all that apply.

  • Generating a sales report, split by region and product type (CORRECT)
  • Creating your own startup company
  • Helping a user who’s having network troubles
  • Copying a file to all computers in a company (CORRECT)
  • Interviewing a candidate for a job
  • Investigating the root cause of a machine failing to boot

Thank you! Automating tasks like creating reports that present stored data in specific formats can save a lot of time and effort, making the process more efficient. Similarly, automating tasks like copying files to other computers helps eliminate redundant manual work, streamlining workflows and boosting productivity. Great job recognizing how automation can simplify these tasks!

5. What are semantics when applied to programming code?

  • The rules for how a programming instruction is written
  • The difference in number values in one instance of a script compared to another
  • The intended meaning or logic of coded statements (CORRECT)
  • The end result of a programming instruction

Nice job! The intended meaning or effect of coded statements are referred to as semantics. 

6. Why do we need to learn the syntax and semantics of a programming language?

  • To be able to easily switch to a different programming language
  • So that we know which part is the subject and which one is the predicate
  • To allow us to clearly express what we want the computer to do (CORRECT)
  • To understand why our computer crashes

You nailed it! Knowing the syntax and understanding the semantics of a programming language enable us to correctly instruct the Calculater on what actions we want it to perform. sentence structure ensures the book of instructions are print inch amp right arrange spell semantics ensures those book of instructions are tacit and dead arsenic conscious

7. What’s automation?

  • The process of telling a computer what to do
  • The process of installing traffic lights
  • The process of getting a haircut
  • The process of replacing a manual step with one that happens automatically (CORRECT)

Right on! By replacing a manual step with an Simplifyd one we Make Productivity through Mechanization which helps minimize unnecessary manual tasks and saves time.

8. Which of the following tasks do you think are good candidates for automation? Check all that apply.

  • Investigating reports that customers are having difficulty accessing your company’s external website
  • Installing software on laptops given to new employees when they are hired (CORRECT)
  • Designing a configuration management system for deploying software patches
  • Periodically scanning the disk usage of a group of fileservers (CORRECT)

extremely! Automating the installation and configuration of software ensures that everyone receives the same setup while also reducing the manual effort required for each new employee.

Exactly! Automating disk usage scans takes the burden off your shoulders ensuring the task is consistently performed without the risk of forgetting it when needed.

PRACTICE QUIZ: INTRODUCTION TO PROGRAMMING

1. Python is an example of what type of programming language?

  • General purpose scripting language (CORRECT)
  • Machine language
  • Client-side scripting language
  • Platform-specific scripting language

You got it! Python is one of the general purpose scripting languages that are widely used for scripting and automation.

2. Why is Python relevant to IT? Select all that apply.

  • Python is used in fast-growing areas of IT, like machine learning and data analytics. (CORRECT)
  • Python works well as a scripting language for IT automation. (CORRECT)
  • Python scripts run on IT servers only.
  • Python can be used to calculate statistics, run e-commerce sites, process images, interact with web services, and more. (CORRECT)
 

Exactly! Python is a widely used tool in IT fields like machine learning and data analytics due to its simplicity and effectiveness.

Absolutely! Python allows you to automate repetitive IT tasks through easy-to-write and maintain scripts, saving time and reducing errors.

Spot on! Python’s versatility makes it suitable for a wide range of IT-related tasks, from web development to system administration and beyond.

3. Let’s check whether you soaked all that in with a quick question! Select all options that explain why Python is relevant to today’s IT industry.

  • Python scripts are easy to write, understand, and maintain. (CORRECT)
  • There are many system administration tools built with Python. (CORRECT)
  • Python was written by Guido van Rossum in 1991.
  • Python is available on a wide variety of platforms. (CORRECT)
  • There have been multiple major version releases over the years which incorporate significant changes to the language.

Exactly! Python is designed to be intuitive, closely resembling natural language, which makes writing, understanding, and maintaining scripts much easier.

You’re absolutely right! The Python community has built a rich ecosystem of tools, libraries, and frameworks that greatly assist system administrators in streamlining their tasks.

Great job! Python’s cross-platform availability—on Windows, Linux, macOS, and even mobile devices—makes it an ideal choice for IT specialists who need to create scripts that work seamlessly across different environments.

PRACTICE QUIZ: HELLO WORLD

1. What are functions in Python?

  • Functions let us use Python as a calculator.
  • Functions are pieces of code that perform a unit of work. (CORRECT)
  • Functions are only used to print messages to the screen.
  • Functions are how we tell if our program is functioning or not.

Right on! Python functions encapsulate a certain action, like outputting a message to the screen in the case of print().

2. What are keywords in Python?

  • Keywords are reserved words that are used to construct instructions. (CORRECT)
  • Keywords are used to calculate mathematical operations.
  • Keywords are used to print messages like “Hello World!” to the screen.
  • Keywords are the words that we need to memorize to program in Python.

You got it! Using the reserved words provided by the language we can construct complex instructions that will make our scripts.

3. What does the print function do in Python?

  • The print function generates PDFs and sends it to the nearest printer.
  • The print function stores values provided by the user.
  • The print function outputs messages to the screen (CORRECT)
  • The print function calculates mathematical operations.

You nailed it! Using the print() we can generate output for the user of our programs.

MODULE 1 GRADED ASSESSMENT

1. What is a computer program?

  • The overview of what the computer will have to do to solve an automation problem.
  • Step-by-step instructions on how to complete a set of tasks, to be executed by a computer. (CORRECT)
  • The syntax and semantics of a programming language.
  • A file that gets printed by the Python interpreter.

2. What is a function?

  • A document describing a software project
  • A reusable block of code that performs a specific task (CORRECT)
  • The beginning of a program defining who wrote it and why
  • The task a program is written to accomplish

3. What are some of the benefits of automation? Select all that apply.

  • More cost-effective for complex, seldom-done tasks
  • Consistency (CORRECT)
  • Can accomplish creative tasks
  • Doesn’t get tired (CORRECT)

4. What is the term for the intended meaning or effect of statements in a programming language?

  • Semantics (CORRECT)
  • Format
  • Grammar
  • Syntax

5. What is a property of Python that makes it easier to understand than some other programming languages?

  • You can use Python code in any other language.
  • Python doesn’t have a defined syntax.
  • Code is similar to the English language. (CORRECT)
  • Basic guidelines can be given and it will write the code.

6. What should be the output of the expression below?

1	1 print((9-3)/(2*(1+2)))
  • 1.0 (CORRECT)
  • 19.36
  • 49.0
  • 0.28

7. What is automation?

  • The inputs and outputs of a program
  • The process of replacing a manual step with an automated step (CORRECT)
  • The rules of a programming language
  • The process of designing a solution to a problem

8. What is the difference between syntax and semantics in a programming language?

  • Syntax is a set of rules for how statements are constructed. Semantics refers to the intended meaning or effect of statements. (CORRECT)
  • Syntax is the effect the instructions have on the system and semantics are how to write the instructions.
  • Syntax is the tool that executes a computer program and semantics is the development environment.
  • Syntax refers to computer programs and semantics is another word for scripts.

9. What is the program that reads and executes Python code by translating it to computer instructions called?

  • Interpreter (CORRECT)
  • Compiler
  • Translator
  • Linker

10. Which Python function will output text, or other value, to the screen?

  • echo
  • print() (CORRECT)
  • output()
  • console.out

11. Once you have learned the basics of a programming language, how does this affect your ability to learn and use a second programming language?”

  • It’s difficult to learn and use a second language.
  • It’s easier to learn and use a second language. (CORRECT)
  • The syntax and semantics will be the same.
  • You should only code in one language.

12. What are some tasks that might be a good fit for full automation? Select all that apply.

  • Detecting and removing duplicate data (CORRECT)
  • Interviewing and hiring employees
  • Updating specific files on multiple computers (CORRECT)
  • Haircuts and styling

13. What should be the output of the expression below?

1	print(12/(1+2)+2**2)
  • 8.0 (CORRECT)
  • 6.0
  • 15.0
  • 81.0

14. Which of the following are true about programming languages? Select all that apply.

  • Similar to human language, programming languages use syntax and semantics. (CORRECT)
  • Programming languages are used to write computer programs and scripts. (CORRECT)
  • Programming languages is a synonym for pseudocode.
  • Some common programming languages include Python, Java, C, C++, C#, and R. (CORRECT)

15. Which of the following are characteristics of the Python language? Select all that apply.

  • Python is cross-platform compatible (CORRECT)
  • Python is used in a wide variety of applications (CORRECT)
  • Python has many platform-specific tools, like Bash or Powershell
  • Python is an object-oriented language not fit for general purpose scripting

16. Which Python function will output text, or other value, to the screen?

  • echo
  • print() (CORRECT)
  • output()
  • console.out

17. What should be the output of the expression below?

1	print(2+2/((2+2)+(2**2)))
  • 5.0
  • 50.0
  • 2.25 (CORRECT)
  • 12.0

18. Use the Python print function to calculate how many number-based passcodes can be formed with 10 numerals (0 through 9).  Here’s a hint to help you: When each digit of a passcode is independent of the others, the total number of combinations is simply the number of possibilities for each digit raised to the power of the length of the passcode. So, for a 1-numeral passcode, there would be 10 possibilities; one for every numeral from 0 to 9.  For a 2-numeral passcode, each numeral is independent of the other, so there would be 10 times 10 possibilities. Using this information, print the amount of possible passwords that can be formed with 3 numerals.

Note: Your result should be in the number format, not a sentence.

Use the Python print function to calculate - Question
1	# Should print 1000
2	print(10**3)

Correct!

19. Keeping in mind there are 60 seconds per minute, write a program that calculates how many seconds there are in an hour. Print the result to the screen. Note: Your result should be in the format of just a number, not a sentence.

60 seconds per minute - Question

1 # Enter code here: 2 print(60*60) 3 # Should print 3600

20. Fill in the blank to calculate how many sectors a given 16 GB (gigabyte) hard disk drive has. The given hard drive is divided into sectors of 512 bytes each. Divide the total bytes on the drive by the number of bytes in a sector to calculate how many sectors this drive has.  Your result should be a number. Note: To calculate the total bytes on the disk drive, multiply by multiples of 1024. In the code below,  you can calculate the “disk_size” of 16 GB by multiplying 16 by 1024 three times to go from bytes, to kilobytes, to megabytes, and finally to gigabytes.

calculate how many sectors a given 16 GB (gigabyte) - Question

1 disk_size = 16*1024*1024*1024 2 sector_size = 512 3 sector_amount = float(disk_size/sector_size) 4 5 print(sector_amount) # Should print 33554432.0

21. The computer will find any loopholes it can.

  • If a program is not clear, it’s called a script.
  • Computers do exactly what they are told. (CORRECT)
  • A program won’t work if there are any logic errors.

22. Which of the following are characteristics of the Python language? Select all that apply.

  • Python is cross-platform compatible (CORRECT)
  • Python is used in a wide variety of applications (CORRECT)
  • Python has many platform-specific tools, like Bash or Powershell
  • Python is an object-oriented language not fit for general purpose scripting

23. Write a Python script that outputs “Automating with Python is fun!” to the screen. Remember that syntax precision is important in programming languages. A missing capital letter, spelling error, or punctuation mark can produce errors.

1 print(“Automating with Python is fun!”)

24. In one year, if there are 365 days, with 24 hours in a day, , write a program to calculate the number of hours in a year. Print the result on the screen. Note: Your result should be in the format of just a number, not a sentence.

In one year, if there are 365 days, with 24 hours in a day - Question

1 # Enter code here: 2 print(24*365) 3 4 # Should print 8760

25. Use Python to calculate how many different passwords can be formed with 6 lower case English letters (excludes any character not found in the English alphabet).  For a 1 letter password, there would be 26 possibilities; one for every letter of the English alphabet.  For a 2 letter password, each letter is independent of the other, so there would be 26 times 26 possibilities. Using this information, print the amount of possible passwords that can be formed with 3 letters.

Use Python to calculate how many different passwords can be formed - Question

1 # Enter code here: 2 print(26**3) 3 4 # Should print 17576

26. Assuming there are 60 minutes in an hour, write a program that calculates the number of minutes in a 24 hour day. Print the result on the screen. Note: Your result should be in the format of just a number, not a sentence.

Assuming there are 60 minutes in an hour - Question

1 # Enter code here: 2 print(24*60) 3 # Should print 1440

28. Consider this scenario about using Python to make calculations:

In a managed computing environment, there are 200 remote computers that must download 200 MB (megabytes) of updates each month. There are 1024 KB (kilobytes) in each MB.

Fill in the blank in the code below to compute the number of total kilobytes downloaded by all computers from the remote update server each month. Multiply the total number of computers by the download size in KB to calculate.

there are 200 remote computers that must download 200 MB (megabytes) of updates each month - Question

1 download_size_kb = 200*1024 2 total_computers = 200 3 total_kbs = float(download_size_kb*total_computers) 4 5 print(total_kbs) # Should print 40960000.0

CONCLUSION – Hello Python!

 

In conclusion, this introductory module has set the stage for your journey on the Coursera platform and within the course structure. We’ve covered the fundamentals of programming languages and syntax, with a focus on the key role of automation through scripting. The core of our exploration was an introduction to the Python programming language, where we discussed essential functions, keywords, and arithmetic operations.

As you move forward, you’ve built a strong foundation in Python, a versatile language used across various fields. Your understanding of basic functions, keywords, and arithmetic operations will serve as a solid base for the upcoming modules, where we will explore more advanced programming and automation concepts. Moreover, your familiarity with code editors and IDEs empowers you to select the tools that best fit your coding style.

Prepare to apply this newfound knowledge as we dive deeper into the world of programming and automation in the next modules. The journey is just beginning, and we’re excited to watch your skills grow and thrive in the dynamic world of Python programming.

Leave a Comment