This week, we would be learning a few basics in python. Python programs are very similar to text files; they can be written with something as simple as a basic text editor.
In this project we will be creating a simple quiz, that asks users a series of short questions, the scanrio im using is a simple set of questions asked to any typical college student. Like many projects, there are often more than one way to achieve this. For example, you may choose to do this on CentOS 7, or RHEL. For this excersie I chose RHEL (I personally think they are very small differences between the two, however, you must pay attention to the slight changes in the use of commands).
In this project, we will work with a Linux distro, RHEL to get a Python 3 environment setup . In addition, we will Activate that virtual environment and confirm the environment is up and run Vim.
1. A Linux RHEL8 environment
2. Python 3 version
Install and run RHEL 8
In this step we will install and run a package on Red Hat Linux enetrprise Linux 8. If you haven’t already, downaload and install RHEL 8.
Login into your RHEL terminal.
Next, you will enter these commands in sequence to ensure that your system files are upto date ( See screenshots below for guidance )
sudo yum -y update
sudo yum -y install yum-utils
sudo yum -y install
sudo yum -y install python36
Python doesn’t come preinstalled, therefore as a RHEL user, you need to specify which version of python you want, for this exercise we would be installing Python 3.
We must install python36-devel to complete this section. This will enable us to make use of the files for the libraries we will need in order to fully use for , Python3. To do so, enter this command.
sudo yum -y install python36-devel
Set Up VIM Editor for Python
Vim is a customizable programmable text editor.
On RHEL, you can install VIM from the official package repository of RHEL. To do this input this line of code vim test.py
Now press ‘i’ and VIM should go to “INSERT” mode.
to proceed to enter your list of questions. I forgot to take screenshots of this section however to do this, enter this command as follows.
myfirstname=input (“What is your first name?”)mylastname=input (“What is your last name?”)mycity=input (“What city are you from?”)courseofstudy=input (“What is your course of study”)
Now enter :wq! and press to save the file and exit VIM.
Now let’s test to see if this works