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.
- 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.
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
do by c++
0
Output:Invalid
1
847
Output:Invalid
Input
1
77
Output:
63
Input
2
(-54)
Output:
Negative
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.](https://content.bartleby.com/qna-images/question/19b5c724-fa8b-4b21-89fa-8bce6085f76e/7ec2c41d-e0ef-4123-88e9-48f580771d2c/syy8tow_thumbnail.jpeg)
![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](https://content.bartleby.com/qna-images/question/19b5c724-fa8b-4b21-89fa-8bce6085f76e/7ec2c41d-e0ef-4123-88e9-48f580771d2c/4lusqmr_thumbnail.jpeg)
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)