Please do this in Python Programming and provide screenshots The output should be exact same like in the examples. If the output in the example is in 2 decimals, then it should be like that.    1g - Alphabet   Write a program that prints the alphabet on a single line. Do not write the alphabet as a literal string, instead use the ord() and chr() functions. Type help(ord) or help(chr) in IPython (called python console in PyCharm, button at the bottom of the screen by default) to get info on what these functions do.  You should get the following output: abcdefghijklmnopqrstuvwxyz   Put your program in alphabet.py   1h - Collatz   One of the most renowned unsolved problems in mathematics is the Collatz conjecture. The problem is stated as follows: Start out with some number n. Apply the following rule repeatedly to the number: if n is even, the next number is n/2 if n is odd, the next number is 3n + 1 This will give us a list of numbers. For example, when starting with 11 the list will be  11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 4 2 1 4 2 1 ... Once the sequence has reached 1, it will repeat 4, 2, 1 indefinitely. The conjecture is that no matter which starting number you pick, the sequence will reach 1 eventually.  This conjecture is probably correct. Using computers all numbers up to 268268 have been found to reach 1. Note that 268268 is quite a large number: it is about 40 times the number of grains of sands on earth, or 4 times the number of stars in the universe. If you can check 1 number per nanosecond, trying all 268268 numbers takes you about 10,000 (10 thousand) years.  This problem is very simple to state, but no one has proved the conjecture since Collatz stated it in 1937. There have even been mathematicians that have spent years of continued study on the conjecture, without success. Fortunately, writing a program that generates the Collatz sequence is a lot less challenging. Write a program that takes any positive integer and prints the corresponding Collatz sequence up to and including the first one. Example: Please enter a number: 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1   Put your program in collatz.py. Use the % (modulo) operator to determine if a number is odd or even.    Use print(n, end = " ") to print without a new line afterward, but with a space instead.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
  • Please do this in Python Programming and provide screenshots
  • The output should be exact same like in the examples.
  • If the output in the example is in 2 decimals, then it should be like that. 

 

1g - Alphabet

 

Write a program that prints the alphabet on a single line. Do not write the alphabet as a literal string, instead use the ord() and chr() functions. Type help(ord) or help(chr) in IPython (called python console in PyCharm, button at the bottom of the screen by default) to get info on what these functions do. 
You should get the following output:

abcdefghijklmnopqrstuvwxyz
 

Put your program in alphabet.py

 

1h - Collatz

 

One of the most renowned unsolved problems in mathematics is the Collatz conjecture. The problem is stated as follows:

Start out with some number n.

Apply the following rule repeatedly to the number:

  • if n is even, the next number is n/2
  • if n is odd, the next number is 3n + 1

This will give us a list of numbers. For example, when starting with 11 the list will be 

11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 4 2 1 4 2 1 ...

Once the sequence has reached 1, it will repeat 4, 2, 1 indefinitely. The conjecture is that no matter which starting number you pick, the sequence will reach 1 eventually.

 This conjecture is probably correct. Using computers all numbers up to 268268 have been found to reach 1. Note that 268268 is quite a large number: it is about 40 times the number of grains of sands on earth, or 4 times the number of stars in the universe. If you can check 1 number per nanosecond, trying all 268268 numbers takes you about 10,000 (10 thousand) years. 

This problem is very simple to state, but no one has proved the conjecture since Collatz stated it in 1937. There have even been mathematicians that have spent years of continued study on the conjecture, without success. Fortunately, writing a program that generates the Collatz sequence is a lot less challenging.

Write a program that takes any positive integer and prints the corresponding Collatz sequence up to and including the first one.

Example:

Please enter a number: 11
34 17 52 26 13 40 20 10 5 16 8 4 2 1
 

Put your program in collatz.py. Use the % (modulo) operator to determine if a number is odd or even.   

Use print(n, end = " ") to print without a new line afterward, but with a space instead.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

do by c++ Programming please 

Sample Testcase 0:
Input:

0

Output:

Invalid

Sample Testcase 1:
Input:

1

847

Output:

Invalid

Sample Testcase 2:

Input

1

77

Output:

63

Sample Testcase 3:

Input

2

(-54)

Output:

Negative

Sample Testcase 4:

Input

2

97

Output:

141

 

#include <iostream>
#include <cmath>
#include <cstdlib>
using namespace std;

int main()
{
   //Start your code here


    return 0;

}

 

In this task, you are required to write a code that converts an Octal number into its equivalent Decimal value or vice versa. The user first selects the conversion
choice by inserting 1 or 2.
• Choice 1 is followed by inserting an Octal integer and getting its Decimal equivalent value as an output.
• Choice 2 requires inserting a Decimal integer and prints out its Octal equivalent.
The Octal numeral system, is the base-8 number system, and uses the digits 0 to 7, that is to say 10 octal represents 8 Decimal and 100 octal represents 64
Decimal.
Convertion from an Octal integer into Decimal
In the Decimal system, each number is the digit multiplied by 10 to the power of its location (starting from 0). For example:
• 74 decimal = 7 x 10^1 + 4 x 10^0
• 1252 decimal = 1 x 10^3 + 2 x 10^2 + 5 x 10^1 + 2 x 10^0
each number is the digit multiplied by 8 to the power of its location (starting from 0). For example:
• 112 octal = 1 x 8^2 + 1 x 8^1 + 2x8^0
Converting an Octal integer into Decimal can be done by performing the last calculation. Hence, 112 in Octal is equal to 64 + 8 + 2 = 74 in Decimal.
Conversion from a Decimal integer into Octal
On the other hand, to convert a Decimal integer into Octal, follow the follwoing steps:
●
1. Divide the number by 8, you get a quotient and a remainder.
●
2. Take note of the remainder. It can be any number between 0 to 7. This number will be the last digit of the octal number, i.e., the rightmost digit.
3. Use the quotient from step 1 as your new initial number.
4. Repeat steps 1-3, and keep concatenating the remainder to the left of the previously obtained digits. Stop when the quaotient is zero.
Transcribed Image Text:In this task, you are required to write a code that converts an Octal number into its equivalent Decimal value or vice versa. The user first selects the conversion choice by inserting 1 or 2. • Choice 1 is followed by inserting an Octal integer and getting its Decimal equivalent value as an output. • Choice 2 requires inserting a Decimal integer and prints out its Octal equivalent. The Octal numeral system, is the base-8 number system, and uses the digits 0 to 7, that is to say 10 octal represents 8 Decimal and 100 octal represents 64 Decimal. Convertion from an Octal integer into Decimal In the Decimal system, each number is the digit multiplied by 10 to the power of its location (starting from 0). For example: • 74 decimal = 7 x 10^1 + 4 x 10^0 • 1252 decimal = 1 x 10^3 + 2 x 10^2 + 5 x 10^1 + 2 x 10^0 each number is the digit multiplied by 8 to the power of its location (starting from 0). For example: • 112 octal = 1 x 8^2 + 1 x 8^1 + 2x8^0 Converting an Octal integer into Decimal can be done by performing the last calculation. Hence, 112 in Octal is equal to 64 + 8 + 2 = 74 in Decimal. Conversion from a Decimal integer into Octal On the other hand, to convert a Decimal integer into Octal, follow the follwoing steps: ● 1. Divide the number by 8, you get a quotient and a remainder. ● 2. Take note of the remainder. It can be any number between 0 to 7. This number will be the last digit of the octal number, i.e., the rightmost digit. 3. Use the quotient from step 1 as your new initial number. 4. Repeat steps 1-3, and keep concatenating the remainder to the left of the previously obtained digits. Stop when the quaotient is zero.
Example: convert Decimal number 6521 to octal representation:
1. Divide by 8, i.e., 6521/8 = 815, remainder is 1.
2. Now, we will use the quotient from step 1, i.e., 815 as the new number, and repeat step 1.
3. We will continue repeating the above steps until we get 0 as the quotient.
System Message: WARNING/2 (<string>, line 35)
Block quote ends without a blank line; unexpected unindent.
4. Reading the remainders in reverse order, the number 14571 is the Octal value for 6521 in Decimal
Important Notes:
• If the inserted choice is wrong, the output will be "Invalid".
• If the inserted Octal or Decimal number is a negative value, the output will be " Negative".
• If the inserted Octal number has at least one digit which is 8 or 9, the output will be "Invalid".
• You are not allowed to add any additional headers/libraries to the code
1/0
Program Input:
• Conversion choice (1 or 2)
• An integer number to be converted based on the previous choice
Program Output:
• A single line that represents the converted value
Transcribed Image Text:Example: convert Decimal number 6521 to octal representation: 1. Divide by 8, i.e., 6521/8 = 815, remainder is 1. 2. Now, we will use the quotient from step 1, i.e., 815 as the new number, and repeat step 1. 3. We will continue repeating the above steps until we get 0 as the quotient. System Message: WARNING/2 (<string>, line 35) Block quote ends without a blank line; unexpected unindent. 4. Reading the remainders in reverse order, the number 14571 is the Octal value for 6521 in Decimal Important Notes: • If the inserted choice is wrong, the output will be "Invalid". • If the inserted Octal or Decimal number is a negative value, the output will be " Negative". • If the inserted Octal number has at least one digit which is 8 or 9, the output will be "Invalid". • You are not allowed to add any additional headers/libraries to the code 1/0 Program Input: • Conversion choice (1 or 2) • An integer number to be converted based on the previous choice Program Output: • A single line that represents the converted value
Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
ASCII Codes
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education