Viết chương trình nhập số n, in các số từ 1 đến n ra màn hình.
Thiên Bình print(*list([i for i in range(1,int(input('nhap n: '))+1) if i%2!=0])) Củ Tỏi Hằng Nguyễn program B1; 3 trả lời Cho số 10x để điền vào x (Tin học - Lớp 8) 3 trả lời Nhập vào một dãy gồm n số thực (Tin học - Lớp 7) 1 trả lời IF=(AVERAGE(30,40,50)=35),40,50)= (Tin học - Lớp 11) 1 trả lời bài 1: uses crt;var n,i,j:longint;begin clrscr; write(‘Nhap n:’); readln(n); write(‘so chan tu 1->n la:’); for i:=1 to n do if i mod 2=0 then write(i,’ ‘); writeln; write(‘so le tu 1->n la:’); for j:=1 to n do if j mod 2<>0 then write(j,’ ‘); readln; end. bài 2: uses crt;var n,i,j,s,s1:longint;begin clrscr; write(‘Nhap n:’); readln(n); s1:=1; s:=0; write(‘tong cac so tu 1->n la:’); for i:=1 to n do s:=s+i; write(s); writeln; write(‘tich cac so tu 1->n la:’); for j:=1 to n do s1:=s1*j; write(s1); readln; end. bài 3: uses crt;var n,i,j,s,s1:longint;begin clrscr; write(‘Nhap n:’); readln(n); s1:=0; s:=0; for i:=1 to n do if i mod 2<>0 then s:=s+i; write(‘tong cac so le tu 1->n la:’,s); writeln; for j:=1 to n do if j mod 2<>0 then inc(s1); write(‘co tat ca ‘,s1,’ so le’); readln; end. bài 4: uses crt;var n,i,j,s,s1:longint;begin clrscr; write(‘Nhap n:’); readln(n); s1:=0; s:=1; for i:=1 to n do if i mod 2=0 then s:=s*i; write(‘tich cac so chan tu 1->n la:’,s); writeln; for j:=1 to n do if j mod 2=0 then inc(s1); write(‘co tat ca ‘,s1,’ so chan’); readln; end. |