Day 5 Python

 Day 5 Python


How to be successful in python?

To practice and practice.


Programming using variables


What is variable?

Something that represents some value, but value can be changed.


<syntax o declare variables>

<variablename> = <value>

Example 1:

a = 10

b = 90123.098132

x = "Rad"


Types of values 

1. Numerical value 

Any number that doesn't have decimal and fractional part is called numerical value.

Example of numerical value:

-10 

-20 

3089013289312

-921831


Float 

A number which ahs fractional and decimal part is floating value. Example of floating value:

-1.21

-3.11

939.11

0839012.391028

1000.1


String values

Collection of characters which encloses with the double quotes or single quotes in python. Example of string value:

"SAM"

"CAN)))!@(((*"

"POIU"

" " - this is known as empty string and still considered a string due to it being enclosed with double quotes.


Program 1 - write python program to store person name 


1. Design with O/P 

-------------------

| name ="whatever name you put here"

|

|print(name)


2. Program


name="any name"

print(name)

o/p

----

any name 


Program 2 - Write a python program to store person name and age


1. Design with O/P

-------------------

| name = "name"

| age = "age"

| print(name)

|print(age)


Step 2 - Program 

name = "name"

age = "age"

print(name)

print(age)

------------

Out/Put

----------

name 

age


3. Write a python program to store a employee information employee number, name, and salary into 3 vars, eno ename, and esal. 


Step 1 Design with the O/P

----------------

| eno = "9876543210"

|ename = "name"

| esal = "1234567890"

|print("Employee number is:",eno)

|print("Employee name is:",ename)

|print("Employee salary is:",esal)


Step 2 -> Program

| eno = "9876543210"

|ename = "name"

| esal = "1234567890"

|print("Employee number is:",eno)

|print("Employee name is:",ename)

|print("Employee salary is:",esal)


Homework - Write python program to store 3 subject marks, 80, 90, 100 into three variables that are M1, M2, M3. Calculate the total marks. Store into one variable called totmarks and calculate average marks store into another variable into another variable called avgmarks. Print the totalmarks and avgmarks with the help of message and variable.

To view or add a comment, sign in

More articles by Sam Bhusal

  • AWS Questions - 10/6/2021

    What is Cloud computing ? Cloud computing is the distribution of computing services like storages, databases, software,…

  • Python Day 2

    Python Continued..

  • Day 3 of Flutter

    Dart pad debug console and terminal instead of just writing print Life is beautiful 3 times like this print("Life is…

  • Day 14 of flutter class

    1)What is statelesswidget ? A stateless widget in flutter is is defined as any widget which changes its state within…

  • JSON and API, etc …

    What is API and how to create own API? The set of functions and procedures allowing the creation of applications that…

  • Day 1 of AWS 10/12/2020

    What is Cloud computing ? Cloud computing is the distribution of many distinct services. How AWS cloud is different…

  • Day 1 Intro to Python

    Day 1 Session 1 Before beginning Python we should first address some questions that generally arouse in first time…

  • Intro to Linux/Unix 3/21/2021 Overview

    Chapter 1 The Standard Boot process for PC Power to Computer The Basic Input/output system (BIOS) is read from a chip…

Explore content categories