Week 1 – Hello Python!

1. What’s a computer program?

Answers

·        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

·        A file that gets copied to all machines in the network

Explanation: A computer program may be thought of as a collection of instructions that a computer follows in order to complete a task. It's a string of instructions written in code that tells the computer how to carry out a certain activity or set of operations. Imagine it as a recipe that you provide to your computer, informing it how to process and change data in order to get the result that you want.

2. What’s the syntax of a language?

Answers

·        The rules of how to express things in that language

·        The subject of a sentence

·        The difference between one language and another

·        The meaning of the words

Explanation: The term "syntax" is used to refer to the rules that are used in programming languages to determine how programs should be constructed. The syntax of a programming language may be compared to this. The syntax is what specifies the appropriate order of symbols, keywords, and other components that go into the construction of a good program.

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

Answers

·        There’s not much difference, but scripts are usually simpler and shorter.

·        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.

Explanation: There is a difference that should be made, despite the fact that the words "program" and "script" are often used interchangeably with one another.

A collection of instructions or code that is developed to do a particular job on a computer is referred to as a program. It is a more general phrase that refers to a wide variety of software, such as applications, system software, and utilities. It covers all of these categories. Before being run, programs are often converted into machine code or an intermediate code. Compilation occurs before execution.

On the other hand, a script is a kind of computer program that is interpreted rather than compiled. Scripts are often used in web-based applications. Scripts are often created in scripting languages such as Ruby, Python, or JavaScript. They are often used for the purposes of automating processes, carrying out duties related to system management, or extending functionality to other applications. Scripts are often understandable by humans and may be modified on the fly, eliminating the need for a separate process to compile the changes.

To reduce it all the way down to its most fundamental level, every program is a script, but not every script is a program. The difference is in the manner in which they are carried out, namely, either via compilation or interpretation.

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

Answers

·        Generating a sales report, split by region and product type

·        Creating your own startup company

·        Helping a user who’s having network troubles

·        Copying a file to all computers in a company

·        Interviewing a candidate for a job

·        Investigating the root cause of a machine failing to boot

5. What are semantics when applied to programming code?

Answers

·        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

·        The end result of a programming instruction

6. Fill in the correct Python command to put “My first Python program” onto the screen.

_____("My first Python program")

Answers

·        print(“My first Python program”)

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

Answers

·        General purpose scripting language

·        Machine Language

·        Platform-specific scripting language

·        Client-side scripting language

Explanation: Python is an example of a programming language that is high-level, interpreted, and designed for general-purpose use. It is meant to be understandable and has a clear syntax, which makes it approachable for novices while also having the capacity to satisfy specialists. In addition, Python is compatible with a number of other programming paradigms, such as procedural, object-oriented, and functional programming.

8. Convert this Bash command into Python:

echo Have a nice day

Answers

·        print(“Have a nice day”)

9. Fill in the correct Python commands to put “This is fun!” onto the screen 5 times.

for i in range(5):

_____("This is fun!")

Answers

·        for i in range(5):

print(“This is fun!”)

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

Answers

·        Python is used in fast-growing areas of IT, like machine learning and data analytics.

·        Python works well as a scripting language for IT automation.

·        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.

Explanation: Python is a flexible programming language that may be used for a wide range of tasks, including but not limited to web development, data analysis, artificial intelligence (AI), automation, scripting, and many more. Because of its adaptability, it may be used to do a broad variety of different IT jobs.

Because Python's syntax is straightforward and easy to comprehend, the programming language is well-suited for teaching novices. This is helpful in circumstances where people may come from a variety of different backgrounds and have varying degrees of expertise.

11. What are functions in Python?

Answers

·        Functions let us use Python as a calculator.

·        Functions are pieces of code that perform a unit of work.

·        unctions are only used to print messages to the screen.

·        Functions are how we tell if our program is functioning or not.

Explanation: In Python, a function is a section of code that may be reused and is designed to carry out a certain operation. The def keyword comes first, then the function name, then the arguments encased in parentheses, and finally a colon. This is how functions are defined. The code that will be run whenever the function is invoked may be found in the indented "body" of the function, which is formatted using tabs.

12. What are keywords in Python?

Answers

·        Keywords are reserved words that are used to construct instructions.

·        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.

Explanation: Because they are considered to be part of the syntax of the language, keywords in Python are words that cannot be used as identifiers (variable names, function names, etc.) even if they have specific meanings associated with them. The Python programming language's syntax and semantics are both specified by these terms.

13. What does the print function do in Python?

Answers

·        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

·        The print function calculates mathematical operations.

14. Output a message that says "Programming in Python is fun!" to the screen.

Answers

·        print(“Programming in Python is fun!”)

15. Replace the ___ placeholder and calculate the Golden ratio: 1+√5/2

Tip: to calculate the square root of a number x, you can use x**(1/2).

ratio = ___
print(ratio)

Answers

·        ratio = (1 + 5**(1/2)) / 2

print(ratio)


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

Answers

·        You should only code in one language.

·        It’s easier to learn and use a second language.

·        It’s difficult to learn and use a second language.

·        The syntax and semantics will be the same.


17. What is a shorter piece code, typically used to automate a specific task?

Answers

·        Variable

·        Syntax

·        Script

·        Markup

Explanation: A "script" is often used to refer to a more compact piece of code that is used to automate a certain job. Scripts are often short programs or sequences of instructions that are developed to carry out a certain purpose or automate a particular operation. Scripts may also be referred to as "batch files." Tasks such as file manipulation, data processing, system management, and operations that are repeated are examples of popular applications for these tools. Scripts, which may be created in a variety of scripting languages such as Python, JavaScript, or Bash, provide a fast and effective method for automating common tasks.

 

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

Answers

·        Updating specific files on multiple computers

·        Detecting and removing duplicate data

·        Interviewing and hiring employees

·        Haircuts and styling


19. What is the term for the set of rules for how statements are constructed in a programming language?

Answers

·        Format

·        Semantics

·        Syntax

·        Grammar

Explanation: The term "syntax" refers to the rules that govern the structure of statements inside a programming language and is derived from the word "syntax." The right structure and style of statements is defined by syntax, which also specifies how various aspects of a programming language, like as keywords, operators, and variables, should be joined to make valid and intelligible expressions or instructions. Syntax is the backbone of every programming language. When developing code for a computer, it is essential to follow the rules of the syntax so that the machine can properly comprehend and run the code.

 

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

Answers

·        Linker

·        Interpreter

·        Translator

·        Compiler

Explanation: The term "Python interpreter" refers to the piece of software that reads Python code and then puts that code into action by converting it into computer instructions. The Python code that is understandable by humans is first parsed by the interpreter, and then it is converted into instructions that are readable by computers. These instructions may then be carried out by the computer's processor. When you execute a Python script or input Python code in an interactive environment, the Python interpreter is the component that is responsible for understanding and carrying out the instructions in the current context.

 

21. 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.

# Enter code here:

_____

# Should print: Automating with Python is fun!

Answers

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

 

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

print((6-2)/(5*(1+4))+3)

Answers

·        3.16

·        50.0

·        12.0

·        5.0


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

# Enter code here:

_____

# Should print 525600

Answers

·        minutes_in_hour = 60

hours_in_day = 24

days_in_year = 365

 

minutes_in_year = minutes_in_hour * hours_in_day * days_in_year

 

print(minutes_in_year)

24. Use Python to calculate how many number-based passcodes can be formed with 10 numerals (0 through 9). For a 1 numeral passcode, there would be 10 possibilities. 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 8 numerals. Note: Your result should be in the format of just a number, not a sentence.

# Enter code here:

____

# Should print 100000000

Answers

·        numerals = 10

password_length = 8

 

possible_passwords = numerals ** password_length

print(possible_passwords)

25. 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 these computers from the remote update server each month.


download_size_kb = 200*1024

total_computers = 200

total_kbs = ____



print(total_kbs) # Should print 40960000.0

Answers

·        download_size_kb * total_computers

Shuffle Q/A 1


26. What is a function?

Answers

·        The beginning of a program defining who wrote it and why

·        A reusable block of code that performs a specific task

·        A document describing a software project

·        The task a program is written to accomplish

Explanation: A section of code that is well-organized and can be reused to carry out a particular job or a group of related activities is known as a function. In computer programming, functions are used to break up large portions of code into more manageable modules. This enables greater organization, as well as the reusability and abstraction of more difficult tasks.

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

Answers

·        Consistency

·        Can accomplish creative tasks

·        More cost-effective for complex, seldom-done tasks

·        Doesn’t get tired


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

Answers

·        Syntax

·        Grammar

·        Format

·        Semantics

Explanation: The intended meaning or impact of statements written in a programming language is referred to as their "semantics." The study of semantics focuses on the interpretation of the meaning of programming structures. This includes defining what the various statements and expressions in a program are intended to do in terms of their capabilities. It takes into account the operation of the program as a whole in addition to the connections that exist between the various components of the code. It is impossible to write proper and meaningful programs without first gaining an understanding of the semantics of the programming language being used.

 

29. Complete the code so that the string "I am writing Python code!" will print to the screen. Remember that syntax precision is important in programming languages. A missing capital letter, spelling error, or punctuation mark can produce errors.

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

print(6*2-5/(1+4)+3**2)

Answers

·        49.0

·        0.28

·        20.0

·        19.36

31. 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.

32. Mercury has a diameter of approximately 1,516 miles. Earth has a diameter of approximately 3,959 miles. Use Python to calculate how much larger Earth’s diameter is than Mercury's (in miles). Note: Your result should be in the format of a number, not a sentence.

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

On a college campus, there are 30 computers in each of the 20 computer labs that are spread across campus. The computers have a life cycle where they are replaced every 5 years, with an equal number (one-fifth) of the computers replaced each year.

Fill in the blank to compute the number of computers that are replaced each year. Note: Your result should be in the format of just a number, not a sentence.

34. What is a computer program?

Answers

·        A file that gets printed by the Python interpreter.

·        The syntax and semantics of a programming language.

·        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.

Explanation: A computer program, which is more often referred to as simply a "program," is a collection of instructions that a computer executes in order to carry out a certain activity or series of activities. These instructions are written in a programming language and may be as simple as a set of fundamental operations or as intricate as a complicated algorithm. They can also be expressed in any level of complexity in between.

Typically, the goal of developing a computer program is to provide a solution to a certain issue or to automate a particular procedure. It is made up of directives, or statements, as well as functions and algorithms, which lay out the steps that need to be carried out by the computer. The term "program" may refer to anything from a short script that executes a single command to a complex piece of software that consists of a number of interconnected modules.

A computer program's primary function is to mediate communication between the human user and the computer hardware, therefore empowering the latter to carry out the actions specified by the former (the programmer).

 

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

Answers

·        Python is cross-platform compatible

·        Python is used in a wide variety of applications

·        Python has many platform-specific tools, like Bash or Powershell

·        Python is an object-oriented language not fit for general purpose scripting


36. Keeping in mind there are 86400 seconds per day, write a program that calculates how many seconds there are in a week, if a week is 7 days. Print the result to the screen. Note: Your result should be in the format of just a number, not a sentence.

37. Use Python to calculate how many number-based passcodes can be formed with 10 numerals (0 through 9). For a 1 numeral passcode, there would be 10 possibilities. 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 8 numerals. Note: Your result should be in the format of just a number, not a sentence.


Shuffle Q/A 2


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

Answers

·        Syntax is a set of rules for how statements are constructed. Semantics refers to the intended meaning or effect of statements.

·        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.

Explanation: 
In a nutshell, syntax refers to the proper ordering of symbols and keywords inside a programming language. This ensures that the code is well-formed and follows the guidelines set out by the language. On the other hand, semantics is concerned with the meaning of the code, making sure that the code performs as it was meant to and generates the results that were expected. When it comes to developing efficient and error-free programs, having a solid understanding of both syntax and semantics is essential.

39. What is automation?

Answers

·        The inputs and outputs of a program

·        The process of replacing a manual step with an automated step

·        The rules of a programming language

·        The process of designing a solution to a problem

Explanation: The term "automation" refers to the use of machinery, computer systems, or specialized software to carry out activities or procedures that would otherwise need the participation of a human worker. The purpose of automation is to simplify and improve the performance of labor-intensive or repetitive tasks in order to achieve higher levels of productivity, accuracy, and efficiency. Automation is useful in many different spheres, such as the manufacturing industry, the information technology industry, corporate procedures, and even in daily life.

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

Answers

·        Basic guidelines can be given and it will write the code.

·        You can use Python code in any other language.

·        Python doesn’t have a defined syntax.

·        Code is similar to the English language.

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

Answers

·        echo

·        print()

·        output()

·        console.out

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

print(15+5+(3*2)/4**2+(3-7)*7)

Answers

·        15.0

·        81.0

·        -7.625

·        6.0

Post a Comment

Previous Post Next Post